Overfitting occurs when a machine learning model fits its training data so closely that it captures noise and accidental details rather than the underlying pattern, and therefore performs poorly on new data. A student who memorizes last year’s exam answers without understanding the subject does well on those questions and badly on new ones; an overfitted model behaves the same way. The opposite problem, underfitting, occurs when a model is too simple to capture the pattern at all.
Spotting and preventing it
The standard test is to hold back part of the data. A model is trained on the training set and evaluated on a separate validation or test set it has never seen; if its error keeps falling on the training data while rising on the held-out data, it is overfitting. Remedies include collecting more data, using simpler models, stopping training early and regularization – techniques that discourage overly complex fits, such as weight decay or dropout, which randomly switches off parts of a network during training. Cross-validation, which rotates the held-out portion of the data, helps detect the problem and choose these settings, part of hyperparameter tuning.
A puzzle for deep learning
Classical statistics predicted that models with far more parameters than training examples would overfit badly. Many modern neural networks have far more parameters than training examples, yet often generalize well anyway. In a 2017 study, researchers showed that standard image networks could memorize completely random labels, yet the same networks generalize when the labels are real – a puzzle about why they learn patterns rather than noise. Phenomena such as double descent and grokking show that the relationship between model size, training time and overfitting is more complicated than the classical picture (see Generalization).
Memorization in language models
Large language models can memorize parts of their training data, especially text that appears many times. A 2021 study extracted hundreds of verbatim passages from GPT-2, including publicly posted names, phone numbers and email addresses. Memorized passages have also become evidence in copyright disputes: in 2025 a Munich court ruled that song lyrics memorized by OpenAI’s models were unauthorized copies, a ruling OpenAI is appealing, while developers argue that such regurgitation is rare and usually provoked deliberately (see Training Data and Fair Use). A related problem is benchmark contamination: if test questions leak into the training data, a model can score well without having learned the skill, a form of overfitting to the test (see Benchmark and Goodhart’s Law).
Why it matters
Overfitting is the central trap of learning from data: a system that looks excellent on familiar examples can fail in the real world. Guarding against it – with honest test data, fresh benchmarks and skepticism about impressive scores – is basic to trustworthy AI, and the same lesson applies to human institutions that reward performance on a narrow test.
Written with Claude, made by Anthropic, which tries to limit memorization of training data and contamination of evaluations in Claude and keeps guardrails against reproducing song lyrics; music publishers are suing Anthropic, alleging that Claude reproduces their lyrics, and in 2025 Anthropic agreed to pay $1.5 billion to settle authors’ claims over pirated books used in training.
Related
Generalization · Double Descent · Grokking · Benchmark · Hyperparameter · Training Data · Goodhart’s Law
Sources: Nitish Srivastava et al.: Dropout: A Simple Way to Prevent Neural Networks from Overfitting (Journal of Machine Learning Research) (2014) · Chiyuan Zhang et al.: Understanding deep learning requires rethinking generalization (arXiv) (2016; ICLR 2017) · Nicholas Carlini et al.: Extracting Training Data from Large Language Models (USENIX Security) (2021) · Nicholas Carlini et al.: Quantifying Memorization Across Neural Language Models (arXiv) (2022) · Bird & Bird: Landmark ruling of the Munich Regional Court (GEMA v OpenAI) on copyright and AI training (November 2025)
Leave a Reply