I am trying to finetune a Bert Model for production. I like to save only the best model not all the epochs so that during the inference i will load the only model in the output directory and perform prediction.
I used these training arguments.
- load_best_model_at_end=True,
- evaluation_strategy=“no”
- save_strategy = “no”
After having these training argument. Finally, I used trainer.save_model(“…path”) to save the model in the output directory.
Questions,
- Keeping the save_strategy and evaluation_strategy as “no” the save_model() function call will save the last epoch model or the model which has best validation score? I am asking this question specifically since the evaluation is set as “no”.
- If the evaluation_strategy is set as “no” how does the model knows which is the best weights to load at the last as specified in parameter load_best_model_at_end=True.