Improve all-future first-onset training

This commit is contained in:
2026-08-21 13:48:59 +08:00
parent 9ccc6b56ec
commit d728d8585c
9 changed files with 1002 additions and 84 deletions

View File

@@ -66,7 +66,6 @@ def validate_training_mode_config(cfg: Dict[str, Any]) -> None:
"model_target_mode must be next_token or all_future, got "
f"{model_target_mode!r}"
)
disease_history_mode = normalize_disease_history_mode(
cfg.get("disease_history_mode", DISEASE_HISTORY_MODE_TIMED)
)
@@ -183,6 +182,11 @@ def build_model_from_dataset(
"model_target_mode must be next_token or all_future, got "
f"{model_target_mode!r}"
)
risk_head_bias = bool(cfg_get(args, cfg, "risk_head_bias", False))
if state_dict is not None:
# The checkpoint schema is authoritative. This keeps all older
# bias-free checkpoints loadable while restoring the new baseline bias.
risk_head_bias = "risk_head.bias" in state_dict
model_architecture = resolve_model_architecture(cfg, state_dict)
continuous_value_center = None
continuous_value_scale = None
@@ -231,6 +235,7 @@ def build_model_from_dataset(
dist_mode=str(cfg_get(args, cfg, "dist_mode", "exponential")),
dropout=float(cfg_get(args, cfg, "dropout", 0.0)),
model_architecture=model_architecture,
risk_head_bias=risk_head_bias,
)