Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New save_strategy option called "best" to save when a new best performance is achieved. #31626

Open
seanswyi opened this issue Jun 26, 2024 · 2 comments
Labels
Feature request Request for a new feature

Comments

@seanswyi
Copy link
Contributor

seanswyi commented Jun 26, 2024

Feature request

Introduce a new option for the save_strategy argument called "best" which would save the model once a new best performance is achieved.

Motivation

The save_strategy argument was first introduced a few years ago in #10286. Currently the supported options are "no", "epoch", and "steps". I'm assuming that this is to match the IntervalStrategy that's used by evaluation as well.

Judging by a conversation on a HuggingFace Discussion Forum topic, the best model is always kept by default and therefore if saving occurs at any time during the process then the best model is saved (ref: https://discuss.huggingface.co/t/save-only-best-model-in-trainer/8442). If the user deems that saving often is too burdensome then they may set save_strategy = "no" which would save the best model at the end of training.

I believe that introducing some flexibility for saving would be beneficial so that users don't have to perform saving so often but also don't have to wait until the end for a checkpoint.

Your contribution

If this feature is deemed worth it by the core maintainers then I'd be willing to take this on myself and open a PR. There are some aspects that I believe might warrant further discussion (e.g., which metric should be used to determine "best," how to override IntervalStrategy, etc.).

@seanswyi seanswyi added the Feature request Request for a new feature label Jun 26, 2024
@amyeroberts
Copy link
Collaborator

cc @muellerzr @SunMarc

@muellerzr
Copy link
Contributor

Sure, this seems reasonable. Feel free to open a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants