Fix training from scratch in new scripts (#8623)

This commit is contained in:
Sylvain Gugger
2020-11-18 12:15:26 -05:00
committed by GitHub
parent 1e62e999e8
commit a0c62d2493
5 changed files with 29 additions and 8 deletions

View File

@@ -344,9 +344,12 @@ def main():
# Training
if training_args.do_train:
trainer.train(
model_path=model_args.model_name_or_path if os.path.isdir(model_args.model_name_or_path) else None
model_path = (
model_args.model_name_or_path
if (model_args.model_name_or_path is not None and os.path.isdir(model_args.model_name_or_path))
else None
)
trainer.train(model_path=model_path)
trainer.save_model() # Saves the tokenizer too for easy upload
# Evaluation