Awesome Testing

Foundations · reviewed · reviewed Aug 30, 2026 · 5 min

What are generalization and overfitting?

Generalization is measured performance on new cases under declared conditions; overfitting occurs when optimization improves the evidence it can exploit without improving—and sometimes while harming—the behaviour that matters outside that evidence.

Training loss shows fit, not transferable capability; generalization needs protected data, relevant shifts, slices, and complete-system evaluation.

Fit is not the destination

Training adjusts model parameters to reduce a loss on observed examples. If the optimizer succeeds, the training loss falls. The product claim, however, is usually about inputs the optimizer did not see: tomorrow's support requests, another repository, a different speaker, a new document, or an unusual combination of familiar concepts.

Generalization is performance on those new cases under stated conditions. It is not an internal substance a model possesses. A model can generalize well from one distribution and fail under another language, time period, format, adversary, or task.

Overfitting means the development process has adapted to details of its available evidence that do not transfer to the intended cases. The target can be training examples, a validation set, a benchmark, a grader, or even recurring production dashboards. Engineers can overfit a prompt and harness without changing model weights.

flowchart LR
  T[Training examples] --> O[Optimize parameters]
  D[Development evidence] --> I[Choose model, prompt, and system]
  O --> I
  I --> H[Protected held-out cases]
  I --> S[Declared shifts and slices]
  H --> C[Bounded generalization claim]
  S --> C

Separate training, development, and test evidence

The training set updates parameters. A development or validation set guides architecture, hyperparameters, prompts, tools, and stopping decisions. A protected test set estimates behaviour after those choices are frozen. Once a result influences the next change, it has joined the optimization loop even if no gradient touched it.

In a simple textbook pattern, training error continues falling while validation error first falls and then rises. That shape is useful but not universal. Modern over-parameterized networks can fit random labels, showing that low training error alone says almost nothing about useful structure. Research has also observed double descent, where test error can worsen and later improve as model size, data, or training time changes. “The model is too large” is therefore not a sufficient diagnosis.

Use learning curves as evidence, not folklore. Compare training and held-out performance across data volume, time, model capacity, and important slices. Keep the data-generating and selection process visible.

Memorization and generalization can coexist

Memorization is sensitivity to particular training examples or the ability to reproduce them. Generalization uses learned regularities on new cases. A model can do both: it may learn grammar and translation patterns while retaining rare names, code, or passages.

Exact reproduction is not the only form of influence. A model may remember an answer, solution structure, dataset format, or statistical association without emitting a long verbatim sequence. Conversely, novel wording is not proof of new reasoning; a memorized pattern can be paraphrased.

Memorization matters differently by context. It can support factual recall, expose private or licensed data, inflate a benchmark, or cause brittle dependence on superficial cues. The useful question is not “does the model memorize?” but which information can be extracted, by whom, under what conditions, and whether the observed task performance transfers to relevant fresh cases.

Name the generalization claim

Different experiments support different claims:

  • within-distribution: new samples from roughly the same process;
  • temporal: events or documents created after a declared cutoff;
  • group: languages, regions, users, repositories, or devices not represented equally in training;
  • compositional: unfamiliar combinations of familiar parts;
  • task: a new instruction or output contract;
  • robustness: irrelevant wording, formatting, noise, or adversarial manipulation;
  • system: the model plus retrieval, tools, policies, and humans succeeds on new end-to-end situations.

Success on a random test split primarily supports the first claim. It does not automatically support the others. Near-duplicate documents, users, conversations, or code repositories crossing a random split can make even that estimate optimistic.

Language-model benchmarks face an additional exposure problem because public test items, solutions, and discussions may appear in pretraining or post-training data. Prompt authors and agents can also retrieve them at evaluation time. Use provenance, grouped and time-based splits, overlap checks, protected cases, matched fresh tasks, and honest contamination limits.

Improve the failing boundary

Overfitting remedies depend on the cause. More representative data can reduce sampling gaps. Deduplication and group-aware splitting remove leakage. Data augmentation can teach declared invariances. Weight decay, dropout, early stopping, or a simpler model may help a supervised task. Better labels can matter more than another regularizer.

For language-model systems, the remedy may sit outside the weights: retrieve current evidence, require a calculator, constrain output, ask for clarification, narrow tool authority, or route a novel case to a person. Fine-tuning on the test set is not remediation; it converts that evidence into development data and requires a new protected test.

Watch trade-offs by slice. A change that raises the average can damage rare languages, long inputs, or severe cases. Keep quality, safety, calibration, cost, and abstention visible instead of optimizing one leaderboard number.

Training fit is not product readiness

Generalization is not proof that a model “understands” in a human sense, and memorization is not a complete explanation for every correct answer. A train–test gap is not the only form of overfitting, and a small gap can simply mean both sets are leaked, easy, or unrepresentative.

Model size, parameter count, or training duration does not determine overfitting by itself. Nor does adding more data guarantee improvement if the data are duplicated, mislabeled, shifted away from the product, or allowed to contaminate evaluation.

Measure beyond the training distribution

Freeze the claim, system manifest, and optimization history. Evaluate on a protected set, fresh time-split evidence, grouped holdouts, and declared stress slices. Search for exact and semantic overlap across training, prompts, retrieval corpora, demonstrations, regression cases, and evaluation sources.

Create controlled transformations that should preserve the answer: paraphrase, reorder irrelevant details, change names, translate, alter formatting, and substitute equivalent tool state. Create counterfactual changes that should alter the answer. The system should be stable to the former and sensitive to the latter rather than relying on a superficial cue.

Plot training and held-out behaviour as data, compute, or tuning iterations increase. Report case counts, variation, severe failures, and uncertainty. Compare against simple baselines that reveal whether the model learned the intended relationship or merely a majority label, template, length, source name, or timestamp.

Finally, replay a fresh production sample without making it part of tuning, and monitor the same slices after release. A generalization claim remains credible only while the operating conditions resemble those tested—or while new evidence explicitly covers the change.

Sources and further reading

  1. 01
    Deep LearningGoodfellow, Bengio, and Courville · guide · published Nov 18, 2016 · source checked Aug 30, 2026

    Foundational reference for optimization, backpropagation, generalization, and deep neural networks.

  2. 02
    Understanding deep learning requires rethinking generalizationZhang et al. · research · published Nov 10, 2016 · source checked Aug 30, 2026

    A primary empirical demonstration that high-capacity neural networks can fit random labels, so training fit alone cannot explain generalization.

  3. 03
    Deep Double Descent: Where Bigger Models and More Data HurtNakkiran et al. · research · published Dec 4, 2019 · source checked Aug 30, 2026

    A primary empirical study showing non-monotonic test behaviour as model size, sample size, and training time vary.

  4. 04
    Investigating Data Contamination in Modern Benchmarks for Large Language ModelsDeng et al. · research · published Jun 1, 2024 · source checked Aug 30, 2026

    A primary study of corpus-overlap and behavioural methods for investigating benchmark exposure in open and closed language models.