In plain words
If you mark a student using the exact questions they practised, a high score proves little. Maybe they understood. Maybe they memorised. The only fair check is fresh questions.
Machine learning works the same way. Before training, the data is split. Most of it, the training set, is used to teach the model. A slice is held back as the test set and never shown to the model while it learns. At the end, the model is scored on that slice.
Often there is a third slice, the validation set, used during development to compare versions and tune settings. Because people peek at it repeatedly, it slowly stops being a fair test. The test set is meant to be used rarely, ideally once, for the final verdict.
Everyday example
The board exam paper in a sealed envelope
Through the year, students practise from textbooks (training) and take school mock tests to see what needs work (validation). The board exam paper stays sealed until exam day. Nobody gets to practise on it, so the marks say how well students can handle questions they have never seen.
Where the example breaks: An exam paper really is sealed. With AI, test questions can leak, for example when a public benchmark ends up in web data used for training, and then the score looks better than the model really is.
How it actually works
Google's glossary describes the standard split into three non-overlapping subsets: training, validation and test.
Training set
The largest part. The model learns its parameters from it, adjusting to reduce loss on these examples.
Validation set
Used to make decisions during development: which model, which learning rate, when to stop training. Each decision based on it leaks a little information, so it wears out with repeated use.
Test set
Used for the final, unbiased estimate of performance on new data. It should be large enough to be meaningful, look like real-world data, and contain no duplicates of training examples.
Typical split
A common split is around 80% training and 10% each for validation and test, but it depends on how much data exists. Cross-validation rotates which slice is held out when data is scarce.
Contamination in big models
Language models train on huge web crawls, so questions from public benchmarks can slip into the training data. Researchers check for this overlap and build fresh or private test sets.
- Also called
- Holdout set, test data
- Purpose
- An unbiased estimate of how a model performs on unseen data
- Golden rule
- Never train or tune on it; no example should appear in both training and test sets
- Catches
- Overfitting: a big gap between training and test scores
Questions people ask
What is the difference between a validation set and a test set?
Both are held back from training. The validation set is used during development to compare models and tune settings, so it gets looked at many times. The test set is saved for the final check, so its score is the more honest one.
Why do we need a test set?
Because a model's score on its own training data is flattering. It may have memorised those examples. Scoring it on data it never saw shows how it will behave in the real world and exposes overfitting.
How much data should go in the test set?
Enough to give a reliable score and to cover the kinds of cases the model will meet. A split of roughly 80% training, 10% validation and 10% test is common, but very large datasets can use a smaller share for testing.
What is test set contamination?
When test examples, or close copies, end up in the training data. The model has effectively seen the answers, so its score is inflated. It is a known worry for AI benchmarks whose questions are posted online.