What it is
A training set is a sample of the situations a model will meet. It contains a pattern you want learned, such as how your assistant answers and in what tone and format, and noise you don't: the exact wording of one reply, a typo, the quirks of one customer's question. A model generalises when it picks up the pattern. It overfits when it also fits the noise, and it underfits when it hasn't picked up the pattern.
How to spot it
The clearest signal is in the loss curves. Training loss can keep falling for as long as the model can memorise more. Validation loss, measured on conversations the model never trained on, stops falling when the model has learned what generalises, and rises once it starts memorising.
In a fine-tuned language model, overfitting also shows in the answers themselves.
- Verbatim copying: phrases, whole sentences, even names and numbers from training replies turn up in answers to unrelated questions.
- Canned answers: one well-represented reply is given to questions that only resemble its original question.
- Lost flexibility: questions phrased like the training data go well, differently phrased ones stumble, and general tasks the base model handled have become worse.
- Confident invention: the model imitates the style of specific, detailed replies, such as named menus and numbered steps, without the knowledge behind them, and invents the specifics.
Why it happens
| Cause | Why it leads to memorising |
|---|---|
| Too few examples | With little data, memorising each reply is the easiest way to lower the loss |
| Too many epochs | Each pass shows the same replies again, until the model recognises them |
| Learning rate too high | Large updates fit individual examples quickly |
| Duplicates and repeated replies | A reply that appears many times is learned as a fixed answer |
| Narrow data | The model never sees how real questions vary, so it can't learn what varies |
| Too much capacity for the data | Full fine-tuning or a large adapter on a small set has room to store examples |
How to prevent it
- Stop at the best point. Use the number of epochs at which validation loss was lowest, or a checkpoint from that point. This is early stopping, the simplest and most effective guard.
- Fewer epochs or a lower learning rate. Both limit how far the weights move from the base model.
- More, and more varied, data. Cover the different ways people really ask, including short and vague questions. A few hundred varied examples teach more than a thousand near-duplicates.
- Remove duplicates and over-repeated replies before training.
- Regularisation: LoRA dropout, weight decay, or simply a smaller adapter rank, which limits how much can be stored.
- Run A: 6 epochs, multiplier 2. Training loss reaches 0.15. Validation loss is lowest after epoch 2 and ends well above that minimum. In the test chat, answers reuse whole sentences from training replies.
- Run B: 2 epochs, multiplier 1. Training loss ends at 0.6 and validation loss ends near its minimum. Answers keep the house style but are worded freshly for each question.
- Takeaway: Run A's lower training loss is the problem, not the achievement. Run B generalises, and cost a third as much to train.
Underfitting
Underfitting is the opposite failure: neither training nor validation loss falls much, and the tuned model answers much like the base model. The causes are too little training (too few epochs or steps, or too low a learning rate) or data with no consistent pattern, such as replies that answer similar questions in contradictory ways. Check the data first. Raising epochs or the learning rate on inconsistent data mostly teaches the inconsistency.
Common mistakes
- Judging a run by its training loss. The lowest training loss usually belongs to the most overfit run.
- Trying to fix a weak model with more epochs on the same small dataset.
- Skipping the validation split to keep every example for training, and losing the only way to see overfitting.
- Letting duplicates or one canned reply dominate the data.
- Validating on conversations that also appear in training, which hides overfitting completely.
References and further reading
External sources open in a new tab.
- 01OverfittingGoogle Machine Learning Crash Course · developers.google.comGeneralisation, overfitting and the role of a held-out set, with interactive examples.
- 02OverfittingWikipedia · en.wikipedia.org
- 03Early stoppingWikipedia · en.wikipedia.orgStopping at the point of lowest validation error, the most common guard against overfitting.
- 04Regularization for Deep LearningGoodfellow, Bengio & Courville · Deep Learning, chapter 7 · deeplearningbook.orgThe textbook treatment of weight decay, dropout, early stopping and data augmentation.