Save SFT last/best checkpoints during training and on interrupt

train_sft used to torch.save only after the full epoch budget, so Ctrl+C
dropped all translation weights. Write _last every --ckpt-every steps
and on KeyboardInterrupt; write _best when frozen eval (success, chrF)
improves; --resume continues from _last.
This commit is contained in:
dela
2026-08-26 10:00:11 +08:00
parent 071dfaf42c
commit 9652a9a7eb
2 changed files with 262 additions and 85 deletions
+13
View File
@@ -0,0 +1,13 @@
from train_sft import _is_better_eval, _sibling
def test_sibling_last_best():
assert _sibling("ckpts/k3_sft.pt", "_last") == "ckpts/k3_sft_last.pt"
assert _sibling("ckpts/k3_sft.pt", "_best") == "ckpts/k3_sft_best.pt"
def test_best_prefers_success_then_chrf():
assert _is_better_eval(1.0, 70.0, 0.95, 90.0)
assert not _is_better_eval(0.95, 99.0, 1.0, 70.0)
assert _is_better_eval(1.0, 91.0, 1.0, 81.0)
assert not _is_better_eval(1.0, 70.0, 1.0, 81.0)