Upload code/train_sft.py with huggingface_hub
Browse files- code/train_sft.py +13 -10
code/train_sft.py
CHANGED
|
@@ -563,21 +563,24 @@ def main():
|
|
| 563 |
|
| 564 |
root_dir = os.path.abspath(os.path.join(cur_dir, ".."))
|
| 565 |
data_dir = args.data_dir or os.path.join(root_dir, "tokenized_data")
|
| 566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
stage_data_dir = os.path.join(data_dir, stage_subfolder)
|
| 568 |
|
| 569 |
-
output_dir = args.output_dir or (
|
| 570 |
-
os.path.join(root_dir, "sft_checkpoints", "ViuTranslate")
|
| 571 |
-
if str(args.version).lower() == "viutranslate"
|
| 572 |
-
else os.path.join(root_dir, "sft_checkpoints", f"sft_{args.version}")
|
| 573 |
-
)
|
| 574 |
os.makedirs(output_dir, exist_ok=True)
|
| 575 |
|
| 576 |
-
ckpt_filename =
|
| 577 |
save_path = os.path.join(output_dir, ckpt_filename)
|
| 578 |
-
|
| 579 |
-
# overwrite the best weights. Previously both shared save_path.
|
| 580 |
-
best_filename = "viutranslate_best.pt" if str(args.version).lower() == "viutranslate" else f"sft_{args.version}_best.pt"
|
| 581 |
best_save_path = os.path.join(output_dir, best_filename)
|
| 582 |
|
| 583 |
if args.init_ckpt:
|
|
|
|
| 563 |
|
| 564 |
root_dir = os.path.abspath(os.path.join(cur_dir, ".."))
|
| 565 |
data_dir = args.data_dir or os.path.join(root_dir, "tokenized_data")
|
| 566 |
+
v_clean = str(args.version).lower().strip()
|
| 567 |
+
if v_clean in ("500m_sarus_sft", "sarus_sft", "500m"):
|
| 568 |
+
stage_subfolder = "500M_Sarus_SFT"
|
| 569 |
+
ckpt_tag = "500m_sarus_sft"
|
| 570 |
+
elif v_clean == "viutranslate":
|
| 571 |
+
stage_subfolder = "ViuTranslate"
|
| 572 |
+
ckpt_tag = "viutranslate"
|
| 573 |
+
else:
|
| 574 |
+
stage_subfolder = f"sft_{args.version}"
|
| 575 |
+
ckpt_tag = f"sft_{args.version}"
|
| 576 |
stage_data_dir = os.path.join(data_dir, stage_subfolder)
|
| 577 |
|
| 578 |
+
output_dir = args.output_dir or os.path.join(root_dir, "sft_checkpoints", stage_subfolder)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 579 |
os.makedirs(output_dir, exist_ok=True)
|
| 580 |
|
| 581 |
+
ckpt_filename = f"{ckpt_tag}_final.pt"
|
| 582 |
save_path = os.path.join(output_dir, ckpt_filename)
|
| 583 |
+
best_filename = f"{ckpt_tag}_best.pt"
|
|
|
|
|
|
|
| 584 |
best_save_path = os.path.join(output_dir, best_filename)
|
| 585 |
|
| 586 |
if args.init_ckpt:
|