liveBook · Manning

Early stopping

As explained in Natural Language Processing in Action, Second Edition

Early stopping is a training regularization technique that terminates optimization when validation performance stops improving.

Early stopping regularizes training by ending optimization when validation performance no longer improves. It avoids choosing a training duration that lets the model overfit its training samples. section 9.3.4

Configure early stopping around repeated validation checks:

  • Enable evaluation during training and provide a validation dataset through eval_df. section 9.3.4
  • Set patience to the number of consecutive evaluations without improvement; use delta to define meaningful improvement. section 9.3.4
  • Save the best-performing checkpoint instead of retaining unnecessary checkpoints after each evaluation or epoch. section 9.3.4

Fine-tuning BERT for toxic-comment classification

A multilabel BERT classifier evaluates every 1,000 training steps, allows four consecutive evaluations without improvement, and treats any positive change as improvement with early_stopping_delta=0. Training receives train_df and eval_df, then the saved best model is evaluated separately.

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains evaluation cadence, patience, delta, and best-model saving, but does not detail the stopping algorithm internals.
Examples
Uses a toxic-comment dataset, multilabel BERT fine-tuning, periodic ROC-AUC evaluation, and separate evaluation of the saved best model.
What it assumes
Assumes a train-validation split and a fine-tuning workflow, while defining patience and delta through the configuration example.
What you can do after
Apply it via SimpleTransformers to stop fine-tuning after stalled validation improvement and evaluate the retained best checkpoint.
How it connects
Connects validation sets, overfitting, fine-tuning, gradient descent, model evaluation, and BERT classification.

Also explained in

Compare how 9 books explain early stopping →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.