Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

Merge pull request #951 from sharath-sms/feat/parallel-option-layout

Nandakishorc06208860921
diff --cc laya/train.py
index f5f14708,e8a210f4..759ca0a0
--- a/laya/train.py
+++ b/laya/train.py
@@@ -37,12 -34,10 +37,13 @@@ from typing import Any, Callable, Dict
import torch
-from .calibrate import fit_temperature_map
+from .calibrate import MIN_TYPE_N, fit_temperature_map
from .common import (
+ OPTION_LAYOUTS,
+ QTYPE_NAMES,
QTYPES,
+ TEMP_MAX,
+ TEMP_MIN,
build_head,
build_model,
build_sequence,
@@@ -548,16 -498,10 +567,16 @@@ def finetune(data: str, model_dir: str
os.path.join(output_dir, "checkpoint_latest"))
history = train_model(model, tok, train_items, config, dev, max_len, head_max_len,
- on_epoch_end=checkpoint_latest)
+ on_epoch_end=checkpoint_latest, parallel=parallel)
- records = calibration_records(model, tok, calib_items, dev, max_len, head_max_len)
- fitted = fit_temperature_map(calibration_records(model, tok, calib_items, dev, max_len, head_max_len,
- parallel=parallel))
++ records = calibration_records(model, tok, calib_items, dev, max_len, head_max_len, parallel=parallel)
+ fitted = fit_temperature_map(records)
+ calibration = calibration_report(records, fitted["temperature"])
+ for name, entry in calibration.items():
+ for issue in entry["issues"]:
+ # Logged as a warning rather than left to the report alone: a checkpoint whose
+ # confidences were never calibrated looks the same as one that was.
+ warnings.warn("laya.train: %s calibration: %s" % (name, issue), RuntimeWarning, stacklevel=2)
out_cfg = dict(cfg, max_len=max_len, head_max_len=head_max_len, fine_tuned=True,
temperature=fitted["temperature"])
# An inherited bucket map takes precedence at inference and would mask the new fit.