question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

๐Ÿš€ 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:closed
  • Created 3 years ago
  • Reactions:34
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
BramVanroycommented, Aug 9, 2020

Looking at the interest this topic has, I am bumping it to re-open it.

8reactions
BramVanroycommented, Nov 30, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found