๐ Add early stopping to the trainer
See original GitHub issue๐ Feature request
The trainer (pt, tf) is an easy access point for users who rather not spend too much time building their own trainer class but prefer an out-of-the-box solution. Even though transformers
was never meant to be a fully fletched training library, it might please users to add an additional feature: early stopping.
Motivation
Early stopping ensures that the trainer does not needlessly keep training when the loss does not improve. This saves time, money, and letโs not forget the trees. ๐ Performance-wise this should not lead to different results.
Your contribution
At the moment I cannot work on this, but here are my thoughts:
- a training argument should be added (pt, tf). This would only work when
evaluate_during_training
is enabled. - for PyTorch: at every evaluation step, an early stopper (can be a separate class even) checks if the loss has improved in the last n steps. Potentially with a minimal threshold that the loss should have improved. If not, the trainer should stop
- for Tensorflow: I donโt have experience with TF myself, but I assume one could use
tf.keras.callbacks.EarlyStopping
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:34
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Use Early Stopping to Halt the Training of Neural Networks At ...
In this tutorial, you will discover the Keras API for adding early stopping to overfit deep learning neural network models.
Read more >๐ Early Stopping - Composer
In this tutorial, we're going to learn about how to perform early stopping in Composer using callbacks. In Composer, callbacks modify trainer behavior...
Read more >EarlyStopping - Keras
Stop training when a monitored metric has stopped improving. Assuming the goal of a training is to minimize the loss. With this, the...
Read more >Callbacks โ transformers 4.5.0.dev0 documentation
Callbacks are objects that can customize the behavior of the training loop in the PyTorch Trainer (this ... A TrainerCallback that handles early...
Read more >PRESTOPPING: HOW DOES EARLY STOPPING HELP ...
Noisy labels are very common in real-world training data, which lead to poor generalization on test data because of overfitting to the noisy...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looking at the interest this topic has, I am bumping it to re-open it.
An early stopping callback has now been introduced in the PyTorch trainer by @cbrochtrup! ๐
AFAIK the implementation the TF Trainer is still under way (https://github.com/huggingface/transformers/pull/7533) so Iโll keep this topic open for now.