Proving Test Set Contamination in Black Box Language Models
TL;DR. If a model never saw a benchmark, it has no reason to prefer the benchmark’s published example order over a shuffled one. Oren et al. turn this exchangeability into a statistical test that needs only log-probabilities: compare the canonical ordering with random permutations. A sharded version gives arbitrarily small p-values. It reliably detects benchmarks duplicated about four or more times and misses single copies.
Key idea
Section titled “Key idea”Permutation test: rank among shuffles; under the rank is uniform, so . Sharded test: for shard ,
then a one-sided t-test on , which is asymptotically valid.
Why it matters for search evaluation. For agentic search, the larger risk is usually retrieval leakage (answers or discussions on the open web) rather than verbatim pretraining contamination. A fixed corpus such as BrowseComp-Plus removes drift and lets you audit what the agent could retrieve. It cannot undo memorisation already in the weights, and it removes leaked answers only if they were filtered out when the corpus was built.
A negative result is not a certificate. The test misses single copies, needs the benchmark’s canonical order to have been preserved in the training data, and says nothing about paraphrased or translated leaks. Failing to reject means “no evidence of verbatim, repeated exposure”, not “clean”.
Three threats, three controls
Section titled “Three threats, three controls”| Threat | What happened | Controls |
|---|---|---|
| Training contamination | Test items (or close paraphrases) were in the training data | Provenance and n-gram overlap checks when the data is known; exchangeability tests like this one when only log-probs are available; fresh items written after the training cutoff |
| Test-time retrieval leakage | The agent finds the answer, or a discussion of the benchmark, while searching | A fixed corpus with leaked pages filtered out; blocklists for benchmark sites; inspecting the retrieved documents of correct answers |
| Benchmark-adaptive tuning | Prompts, hyperparameters or checkpoints were chosen on the test set | A held-out split used once; reporting how many configurations were tried; fresh or refreshable test items |
A useful habit is to run a no-search baseline: if the model answers many items correctly without retrieval, either the items are easy or the answers are in the weights, and the search-agent score overstates what search contributed.
Connections
Section titled “Connections”- Drift and reproducibility: live-web reproducibility.
- Benchmark gaming more broadly: cheating LLM benchmarks and ImpossibleBench.
- Paired and permutation statistics: statistics and judge calibration.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
Under the null hypothesis that a model never saw a benchmark, every ordering of an exchangeable benchmark is equally likely under the model. (a) Derive why the rank of the canonical ordering's log-probability among m random permutations gives a valid p-value, and why that p-value cannot go below 1/(m+1). (b) Explain how the sharded test escapes this floor and what assumption it adds.
What a strong answer covers
- (a) Under H0 the canonical order is just one exchangeable draw, so its log-probability is equally likely to occupy any rank among the m + 1 orderings. P(rank in the top j) = j/(m + 1), which makes the rank a valid p-value with minimum 1/(m + 1).
- Getting p = 10⁻⁶ would need about a million permutations, each a full forward pass over the dataset, so very small p-values are expensive.
- (b) Split the data into shards; per shard compute s_i = log p(canonical shard) − mean over permutations of log p(permuted shard), and apply a one-sided t-test to the mean of s_i. p can then be arbitrarily small.
- The added assumption is that the shard statistics are approximately normal (via the central limit theorem), so the test is asymptotically, not exactly, valid.
- Mechanism
The test detects contamination when a benchmark appears in pretraining data in its canonical order. Explain which kinds of contamination it can and cannot detect, and why a search agent that finds a benchmark's answers on the live web is a different failure that this test does not address.
What a strong answer covers
- Detects: verbatim inclusion in the published order, at enough repetitions; in the canary study, near-zero p at duplication ≥ 10 and a detection threshold around duplication 4; not detected at duplication 1.
- Misses: shuffled or reformatted copies, paraphrases, answers learned from discussion pages, and single-copy inclusion; it also requires an exchangeable dataset.
- A search agent can retrieve leaked answers (for example a page discussing benchmark questions) at test time. That is retrieval leakage, a property of the environment, not of model weights; the remedy is blocklists, fixed corpora and auditing of retrieved pages.
- Web drift is different again: pages change, so gold answers or supporting evidence go stale. That is a reproducibility problem, not contamination.
- Critique
In the in-the-wild study, only Mistral-7B on ARC-Easy gives p = 0.001, with mild MMLU signals for LLaMA2 and Mistral after aggregation. A reader concludes "these models are clean". Critique that conclusion.
What a strong answer covers
- A non-rejection is not evidence of absence: the test has low power at duplication 1 and cannot see non-verbatim or reordered contamination.
- Multiple testing: many model × benchmark pairs were tested, so p = 0.001 is borderline after correction; individual p-values should not be over-read in either direction.
- MMLU required filtering non-exchangeable subsets and aggregating p-values, which adds analyst choices.
- The right summary is "no evidence of verbatim, ordered contamination at detectable duplication levels".