update trainer

Former-commit-id: 0d39b53a5164e34d22fe0a492eaa0d7ac63102fe
This commit is contained in:
hiyouga 2023-08-07 13:34:35 +08:00
parent fe3b12d900
commit e0c7e944fc

View File

@ -67,7 +67,10 @@ class PeftTrainer(Seq2SeqTrainer):
torch.save(state_dict, os.path.join(output_dir, WEIGHTS_NAME))
if self.finetuning_args.finetuning_type == "full" and self.tokenizer is not None:
self.tokenizer.save_pretrained(output_dir)
try:
self.tokenizer.save_pretrained(output_dir)
except:
logger.warning("Cannot save tokenizer, copy the files manually.")
with open(os.path.join(output_dir, TRAINING_ARGS_NAME), "w", encoding="utf-8") as f:
f.write(self.args.to_json_string() + "\n")