Skip to content
AI 知识地图 0.18 · 2026-07-30
关于与纠错文字目录 / Search
Understanding the principles

Overfitting: How models mistake chance in a finite sample for regularity

Starting from the separation of empirical risk and unknown risk, learn to read training/validation curves, recognize leakage, repetition, and tuning contamination, and understand the boundaries of capacity, double descent, and large model memorization.

Core idea Overfitting is not a model “learning too well”; rather, it exploits noise, identifiers, or shortcuts in the training samples that cannot transfer, so that training empirical risk continues to decline while deployment distribution risk no longer declines. Judging it must depend on evidence that is truly independent, representative of deployment conditions, and not consumed by the hyperparameter-tuning process.
After reading this page, you should be able to answer on your own:
  • Which combinations of training and unknown risk do underfitting, reasonable fit, and overfitting correspond to?
  • Why can a “training score of 100%” be either normal or a danger signal?
  • How can you distinguish overfitting, distribution shift, and optimization failure from training/validation curves?
  • Why can random splitting be fooled by the same user, future information in time, or near-duplicate samples?
  • Which overfitting paths do regularization, more data, early stopping, and smaller models cut off?
Running example (simulated teaching data) Use 24 noisy points to fit a smooth curve. A first-degree polynomial is too stiff; a fifth-degree captures the main trend; a fifteenth-degree almost passes through every training point, yet swings wildly between points. We will use the same simulation results to distinguish “training better” and “unknown data better”.

1Why the True Objective Is Not on the Training SetMotivation

Model training only ever sees a finite sample; why do we nevertheless require it to answer on future data it has never seen?

The training set is a single finite sample from an unknown data distribution. It simultaneously contains stable regularities, sampling fluctuations, measurement noise, and incidental identifiers. The optimizer only knows how to reduce training loss, not which part can transfer. When model capacity is sufficient, it will exploit both regularities and accidents.

Therefore training accuracy is not the final objective, but evidence that the model fits the samples it has seen. What we actually care about is the risk of the same task under new users, new times, new devices, or other deployment conditions. When the model mistakes chance occurrences in the training samples for regularities, its fit to the training data will continue to improve, yet this may not transfer. High training accuracy only indicates fit to the samples already seen; whether it can transfer must be judged by independent evidence that represents the deployment conditions.

2How to distinguish underfitting, a reasonable fit, and overfittingThree states

“Poor model performance” is not enough; what do the combinations on the training and validation sides respectively indicate?

StateTraining performanceIndependent validation performancePriority action
Underfitting/insufficient optimizationPoorAlso poor, gap may not be largeImprove features, capacity, objective, or optimization
Reasonable fitGoodClose to training and meets task thresholdCheck slices, stability, and deployment shift
OverfittingContinues improvingStagnates or worsens, gap widensCheck leakage, data, regularization, and stopping point
Distribution shiftGoodMay be good if validation also comes from the old distribution; poor in deploymentRebuild evaluation representative of deployment conditions
A large generalization gap does not automatically prove “the model is too complex.” First look at both training and validation performance levels, then observe whether the gap widens as training proceeds: training continues to improve while validation stagnates or worsens, which is a typical signal of overfitting. However, inconsistent training/validation preprocessing, different label quality, or a harder validation distribution can also create a gap, so you also need to check the evidence generation process.

3What lies between empirical risk and true riskMathematics

How can formulas clarify what the model is actually minimizing and what we truly want to know?

First, let's establish the notation:f is the model being evaluated,n is the number of training samples,i is the sample index,xᵢ and yᵢ are the input and target of the i-th sample,L is the loss function that measures the difference between prediction and target,Pdeploy is the deployment data distribution,E denotes taking expectation over that distribution.

train(f)=1/n ΣᵢL(f(xᵢ),yᵢ)  R(f)=E(x,y)~Pdeploy[L(f(x),y)]

The former is the computable training empirical risk, and the latter is the expected risk over the deployment distribution. Overfitting manifests as R̂_train is very low while R does not decrease in tandem. The validation set gives R a finite-sample estimate, but it itself also has variance, and it is meaningful only when it represents the deployment distribution and has not been leaked by training or hyperparameter tuning.

generalization gap ≈ R̂validation − R̂train

This gap is a diagnostic signal, not a universal score across datasets; training augmentation, loss weighting, or different sample difficulties can also make the numerical scales on the two sides not entirely consistent. Only after first confirming that the scales on both sides are comparable, when the training empirical risk keeps decreasing while the validation risk no longer improves, does the generalization gap constitute a meaningful overfitting signal.

4How Training and Validation Curves Expose the Stopping PointVisualization

Why does overfitting often not occur suddenly at the end of training, but rather as a gradually expanding process?

Training lossValidation lossCandidate early stopping pointTraining stepLoss

Scroll horizontally to view the full diagram on small screens.

Early stopping selects the checkpoint near the validation optimum, rather than the final step with the "lowest training loss". Real curves are noisy; use a patience window and multiple seed runs for confirmation.

If the training and validation losses are both high and not decreasing, it is more likely underfitting, a learning rate problem, or a data pipeline issue. If training loss decreases but validation loss is far higher from the start, suspect the data split and distribution first. Validation loss first improving and then continuing to worsen is the classic overfitting trajectory during training. The candidate early-stopping point comes from the region where the validation curve turns from decreasing to increasing, not from an isolated fluctuation; in practice, confirm it with a patience window and multiple random seeds.

5Complete numerical example: how lower training error selects a worse modelSimulation experiment

In the running example, which model would training error alone choose, and which would independent validation choose?

Polynomial degreeTraining MSEValidation MSEObservation
10.820.88Poor on both: underfitting
30.240.31Captures the main curvature
50.160.22Best on this validation set
100.080.39Starts chasing noise
150.011.47Almost passes through the training points, and oscillates wildly outside the interval.

These numbers are only a teaching simulation, but the reasoning is real: if you choose the model by training MSE, you would choose degree 15; with independent validation, you would choose degree 5. The validation set is not “preventing the model from learning”, but rather provides another piece of evidence about unknown risk.

A finer point The validation-best choice also has sampling error. If the fifth-degree and third-degree models differ by only 0.01 and the validation set is small, you should report confidence intervals, repeated splits, or cross-validation rather than treating the small difference as a certainty.

6Why Data Leakage Can Disguise Itself as Perfect GeneralizationData Boundary

When both training and validation curves look good, why should your first reaction still be to check the split?

Leakage TypeShortcut exploited by the modelCorrect Split
Multiple records for the same userUser habits, device, or identity featuresGroup by user/entity
Future informationPost-hoc fields unavailable at prediction timeRolling time-based split
Chunks from the same documentAdjacent paragraphs nearly paraphrase each otherGroup by document first, then chunk
Augmented image copiesTexture from the same original imageGroup by original sample before augmentation
Preprocessing fitted on full dataValidation distribution leaks into standardization/feature selectionFit transforms only on training folds
Benchmark answers enter trainingDirectly memorize questions or rewritesDeduplication, time isolation, contamination auditing

After leakage, validation is no longer independent, and a high score cannot estimate deployment risk. When you find that the same user, future information, or near-duplicate samples cross split boundaries, you must reconstruct the splits by the correct entity or time unit and rerun the entire selection process; regularization cannot repair this evidence contamination.

7Why can't the validation set and test set be combined?Evaluation Discipline

The model does not directly backpropagate on the test set — why does repeatedly looking at test scores still count as learning?

Every time you choose an architecture, prompt, loss, threshold, or random seed based on some score, you feed information from that data back into the system. The validation set's job is to absorb this kind of hyperparameter tuning; the test set should provide a nearly one-time final estimate after the process is frozen. If test results influence the next round of development again, the test set has already become a new validation set and can no longer serve as independent final evidence; you need to build a separate unseen evaluation.

  1. Training set: fit parameters.
  2. Validation set: select hyperparameters, stopping point, and threshold.
  3. Test set: final estimate after the process is frozen.
  4. Deployment monitoring: check the real-world distribution and feedback loops; do not replace them with static tests.

8Why Model Capacity and Overfitting Are Not a Simple Monotonic RelationshipModern frontier

Is having more parameters than samples enough to conclude overfitting?

The classical bias-variance curve reminds us that insufficient capacity leads to underfitting, and variance may rise as capacity increases. But modern deep networks often generalize even when parameters outnumber samples and training error is zero; in some settings, test error first decreases, then increases, and then decreases again as capacity grows, a phenomenon called double descent.

This does not overturn overfitting; rather, it shows that “parameter count” is not the only measure of effective complexity. Architecture, initialization, optimizer, data augmentation, training duration, and data structure jointly determine which solutions optimization actually favors; double descent is manifested only when test error falls, then rises, and then falls again as capacity changes. Regardless of the curve shape, in the end we must rely on evidence from an independent distribution, not replace measurement with parameter count.

9What overfitting looks like in large language models and fine-tuningLLM

Large models train on huge amounts of data; why do they still memorize, contaminate benchmarks, or degrade during small-data fine-tuning?

Pre-training can memorize rare, repeated, or highly identifiable sequences; if benchmark questions appear in training as verbatim text or near paraphrases, evaluation will mistake memory for reasoning. Small-data fine-tuning can quickly memorize wording and format, sacrifice base capabilities, or adapt only to a few prompt templates. When similar questions score abnormally high and scores plunge after rewording, further check whether verbatim text or near paraphrases have been mixed into training, and use out-of-time benchmarks to verify capability.

ScenarioOverfitting signsEvidence and mitigation
Pre-training repetitionRare text reproduced verbatimDeduplication, memorization probes, privacy evaluation
Benchmark contaminationSimilar questions score abnormally high, then plummet after rewordingOut-of-time benchmarks, near-duplicate audits, dynamic questions
Small-sample fine-tuningWorks well on training format, fails when paraphrasedOut-of-template held-out slice, fewer epochs, PEFT/early stopping
Preference overfittingCaters to reviewer style, degrades on real tasksDiverse reviewers, independent capability and safety regression

10Which Memory Path Does Each Mitigation Method Cut?Engineering

"Adding regularization" is not a button; what exactly do the different methods change?

MethodWhat it changesWhen it may be ineffective/harmful
More independent high-quality dataReduces the proportion of chance patterns and expands coverageNew data is duplicated, from the same source, or poorly labeled
Data augmentationDeclares invariances that should keep labels unchangedTransformation actually changes the meaning
Weight decay/DropoutRestricts parameter or representation co-adaptationFurther harms when already underfitting
Early stoppingLimits the time spent continuing to fit noiseValidation set is noisy or has leaked
Reducing capacityShrinks the set of expressible functionsLoses true regularities and transferable features
Group/time splitRestores evaluation independenceNot mitigating the model, but repairing the evidence

To choose a method, first identify whether overfitting comes from data duplication, model degrees of freedom, training for too long, or evaluation contamination, then address the corresponding part in the table. If both training and validation are poor, the problem is more likely in capacity, features, objective, or optimization; continuing to add regularization at this point is usually treating the wrong cause.

11Connecting the entire causal chainSynthesis

From limited samples to trustworthy deployment judgments, which boundaries must be maintained along the way?

  1. The deployment distribution produces finite training samples, which contain both regularities and randomness.
  2. The loss and optimizer reward only decreases in training empirical risk.
  3. Sufficiently flexible models exploit noise, repetition, and non-transferable shortcuts.
  4. Independent validation estimates the unknown risk and reveals the generalization gap.
  5. Grouping, time, and deduplication rules ensure validation is truly independent.
  6. Validation is used to select capacity, regularization, thresholds, and stopping points, so it is gradually consumed.
  7. After freezing the pipeline, an unseen test set is used for the final estimate.
  8. After deployment, continue monitoring distribution drift and real harm, because static evaluation is still not reality itself.

12Common MisconceptionsDisambiguation

MisconceptionMore accurate statement
100% training accuracy definitely means overfittingIt is only a risk signal; on separable data, getting all training examples correct can still be normal; you need to look at independent generalization.
Poor test performance definitely means overfittingIt could also be distribution shift, evaluation implementation errors, or different label conventions.
Having more parameters than samples necessarily means memorizationEffective complexity is jointly determined by architecture, optimization, data, and implicit preferences.
Adding Dropout always improves validationWhen already underfitting, with sufficient data, or with strong other regularization, it may not help.
If the test set never enters the gradients, you can look at it repeatedlyHuman selection is also information feedback, and it can cause the system to overfit the test set.

13Check whether you really understandSelf-test

  1. In the running example, why does the training error select the 15th-degree polynomial, while the validation error selects the 5th-degree?
  2. When both training and validation loss are low, why can we still not rule out overfitting or flawed evaluation?
  3. What shortcut arises when records from the same user are randomly split into training and validation?
  4. Why does repeatedly modifying the model based on the test set, without doing backpropagation, still contaminate the test?
  5. When both training and validation are poor, why is 'continuing to add regularization' usually not the first choice?
Reference answers
  1. A high-degree model can chase training noise, making empirical risk approach zero, but this oscillation does not generalize; validation exposes error on unseen points.
  2. The two may be near-duplicates, come from the same entity, share future information, or neither represents the deployment distribution.
  3. The model can identify user/device features rather than learning cross-user patterns; validation overestimates performance on new users.
  4. Each manual selection writes information from the test score into the system; it has become a hyperparameter-tuning signal.
  5. When both sides are poor, it is more likely insufficient capacity, features, target, or optimization; imposing extra restrictions on degrees of freedom may make underfitting more severe.

14Concept Dependencies and Further LearningRoadmap

DirectionWhat to Read NextKey Question
Limiting Fitting Degrees of FreedomRegularizationHow do parameters, data, and the training process each impose preferences?
Training Objective BoundariesLoss FunctionWhy can surrogate risk keep decreasing yet diverge from the true objective?
How to Conduct Trustworthy EvaluationModel EvaluationHow should slices, confidence intervals, and thresholds be designed?
Duplication and Training DataTraining Data GovernanceHow are lineage, deduplication, licensing, and contamination tracked?
Post-deployment Distribution ShiftData Drift MonitoringWhen does static generalization evidence become invalid?
Passing Criteria When you are shown a beautiful curve, you first ask about the split unit, time boundary, duplicates, number of hyperparameter tuning runs, and deployment distribution; and you can distinguish “model overfitting”, “evidence leakage”, and “the reality has changed”.
Sources and adaptation notes

The polynomial numerical example is a teaching simulation; the curves, tables, and evaluation workflow are all originally organized by this project and do not correspond to any real experimental results.

Accessed on: 2026-07-22