“Training loss keeps falling while validation loss gets worse. What would you do?”
This pattern is evidence of overfitting: the model improves its fit to training examples without improving generalization. Before choosing a remedy, check that training and validation losses are comparable and that the validation set represents the intended prediction task.
A bad production result alone does not establish overfitting. Leakage, distribution shift, training–serving differences, and a mismatched objective can produce similar symptoms.
01. Diagnose before changing the model
| Observed pattern | Possible explanation | Useful next check |
|---|---|---|
| Both training and validation loss remain high | Underfitting, optimization failure, or weak features. | Confirm the model can fit a small clean subset and compare a simple baseline. |
| Training improves; validation degrades | Overfitting is a plausible explanation. | Check the split, objective, and learning curves across runs. |
| Validation is strong; production is weak | Shift, leakage, feature skew, or an unrepresentative holdout. | Audit the data timeline and online feature computation. |
| One cohort degrades while the mean improves | Uneven representation or different cohort behavior. | Measure cohort sample sizes, labels, and baseline performance. |
Losses computed with different regularization terms, augmentations, or dropout settings are not directly comparable. Record which loss is plotted and use a consistent evaluation mode when making comparisons.
02. Read a learning curve
Suppose a training run produces the following illustrative loss values:
| Epoch | Training loss | Validation loss |
|---|---|---|
| 1 | 0.62 | 0.65 |
| 5 | 0.36 | 0.42 |
| 10 | 0.22 | 0.38 |
| 20 | 0.09 | 0.47 |
Epoch 10 has the best validation loss among these checkpoints. Saving that checkpoint is preferable to automatically shipping the final epoch. Do not use the test set to choose the epoch.
Because validation measurements are noisy, early stopping usually includes a patience rule and a minimum improvement criterion. Decide which metric matters: validation loss and a business-facing ranking metric may favor different checkpoints.
Google's regularization lesson discusses penalizing model complexity and early stopping. Neither guarantees improvement on every dataset.
03. Understand what regularization changes
For a linear model with weights w, an L2-regularized objective can be written as:
The penalty discourages large weights, trading some training fit for a preference toward smaller coefficients. Lambda controls the strength and should be selected on validation data. Its numerical value depends on how the loss and features are scaled.
L1 uses the sum of absolute weights instead of squared weights and can produce sparse coefficients. That can help in some high-dimensional settings, but sparsity is not the same as causal feature importance. Correlated features can make coefficient interpretation unstable.
For tree models, limiting depth or increasing minimum leaf size constrains complexity differently. For neural models, weight decay, dropout, and data augmentation are possible tools. Match the intervention to the model family rather than listing techniques indiscriminately.
04. Choose an intervention from the evidence
- Reduce unnecessary capacity. Compare a shallower model or simpler architecture under the same evaluation protocol.
- Add useful data. Seek representative examples for weak cohorts; repeated copies of existing examples do not provide new information.
- Improve label quality. Inspect contradictory labels and annotation ambiguity before scaling training.
- Apply valid augmentation. Transformations must preserve the target. An image transformation safe for object classification may be unsafe for reading text.
- Regularize and stop deliberately. Tune a bounded set of settings on validation data and preserve the best checkpoint.
Change one major factor at a time when diagnosing, log the comparison, and keep a baseline. If the validation distribution is wrong, tuning more aggressively against it only optimizes the wrong target.
Check the evaluation firstCould the apparent improvement be leakage? ↗
Make sure the model is not learning from unavailable information.
05. Keep model selection honest
Use training data to fit model parameters, validation data to choose hyperparameters and stopping rules, and a final test set to estimate the performance of the frozen process.
Repeatedly trying ideas against a validation set can overfit the selection process itself. When comparisons become extensive, use a suitable cross-validation or nested evaluation design and keep a fresh final holdout. For time-dependent data, preserve the temporal structure rather than shuffling by default.
More data may help a high-variance model, but not every gap disappears with volume. A systematic shift between countries, seasons, or product versions requires investigating representation and the task assumptions.
06. Explain the trade-offs in an interview
“Why not always choose the smallest model?”
A model can be too simple to capture useful structure. The aim is good held-out performance under latency, cost, and reliability constraints, not minimum parameter count.
“Does stronger regularization always help?”
No. Too much regularization can underfit. Validate the strength, and check that feature scaling and optimization are appropriate before interpreting the result.
“Rare queries fail, but common queries look good.”
Check the evaluation sample and query overlap first. Then inspect representation, labels, and model behavior for the rare-query cohort. A robust lexical fallback may be valuable while you improve the learned system.
“I would verify the evaluation setup, inspect comparable learning curves, and identify the failing cohorts. Then I would test targeted changes to capacity, regularization, data, or early stopping, selecting them on validation data and evaluating the frozen choice once on the final holdout.”
Sources & further reading
- Google Developers: overfitting — generalization and training behavior.
- Google Developers: L2 regularization — complexity penalties and early stopping.
Loss values are invented for illustration.
Diagnose a search ranker that fails on rare queries ↗
Connect validation discipline to a production design decision.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.