Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.When the exam questions leaked
If students saw the exam questions the night before, their marks say little about what they learned. Language models read much of the internet, where benchmark questions are posted and discussed, so they may have seen the test. Copies are easy to find by searching for long matching phrases; reworded copies are much harder. The demo shows how much a few memorised questions inflate a score.
When choosing a model for engineering use, prefer evaluations on private or fresh questions that cannot have leaked.
- 1. Contamination means the test was…
- 2. Exact copies are found by…
- 3. Reworded copies are…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Sources: benchmark files on GitHub and the web, forum discussions, solution blogs, synthetic data generated from benchmark-like prompts, and fine-tuning sets built from benchmarks.
- n-gram overlap: GPT-3 flagged items sharing a 13-gram with the training data; Llama reports use token-overlap thresholds. Needs access to the corpus; misses paraphrases and translations.
- Membership inference: perplexity, Min-K% probability (mean of the least likely tokens), zlib ratio, and likelihood ratio against a reference model; works without the corpus but is weak for single items.
- Behavioural tests: guided completion (can the model finish the question verbatim?), option-order permutations, perturbed or regenerated questions (GSM1k), time splits after the training cutoff (LiveCodeBench).
- Prevention: canary strings, encrypted or private test sets, held-out refreshes.
- Reporting: state decontamination method, report clean-subset scores, and treat large gains on old public benchmarks with caution.
- 1. GPT-3 decontamination used…
- 2. Membership inference needs…
- 3. A time split evaluates on…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Checking for contamination
Exercise 1.
- n-gram overlap against a corpus.
- The Min-K% probability score.
Practice.
- With corpus access: build an n-gram index (suffix arrays or Bloom filters; tools such as WIMBD, infini-gram) and flag overlapping items.
- Without it: compute Min-K% or likelihood ratios against a smaller reference model; test guided completion of question prefixes.
- Create perturbed versions of your benchmark (new numbers, rephrasings) and compare scores.
- Put a canary GUID in benchmark files you publish; keep a private split.
- Report clean and full scores and the method used.
import numpy as np
def token_logprobs(model, tok, text):
import torch
ids = tok(text, return_tensors="pt").input_ids
with torch.no_grad(): lp = model(ids).logits.log_softmax(-1)[0, :-1]
return lp.gather(1, ids[0, 1:, None])[:, 0].numpy()
target, ref = token_logprobs(big, tok, item), token_logprobs(small, tok, item)
min_k = np.sort(target)[: max(1, len(target) // 5)].mean(); ratio = (target - ref).mean()- 1. A tool for searching huge corpora for n-grams:
- 2. Perturbed re-tests compare scores on…
- 3. Publish benchmarks with…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why raw likelihood is weak. A text’s log-probability depends mostly on how predictable it is (common phrases, formulaic maths) and only a little on whether it was seen. The variance from predictability swamps the membership signal, so thresholds on perplexity or Min-K% separate seen from unseen items only slightly better than chance.
Calibration. Subtracting the log-probability under a reference model that did not see the item cancels the shared predictability term: the likelihood ratio isolates what training on the item added.
Inflation. With leak share c, clean accuracy a and accuracy on leaked items m, the reported score is (1 − c) a + c m. Removing only the detected leaks removes only their share of the inflation.
- 1. Raw likelihood mostly reflects…
- 2. A reference model cancels…
- 3. Reported accuracy with leaks is…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How well do overlap and likelihood-based methods detect contamination, and how much inflation survives decontamination?
History.
- T. Brown et al., “Language models are few-shot learners” (GPT-3, 2020), 13-gram decontamination.
- W. Shi et al., “Detecting pretraining data from large language models” (Min-K%, 2024).
- H. Zhang et al., “A careful examination of LLM performance on grade school arithmetic” (GSM1k, 2024).
Exercise 2. A simulated leak.
- Test set: 500 items of 30 tokens (vocabulary 1000). About 10% are copied verbatim into a 20000-document corpus and 10% paraphrased (each token swapped for a synonym with probability 0.5).
- Detectors: 13-gram overlap; Min-K% (lowest 20% of token log-probabilities); mean log-likelihood ratio against a reference model.
- Model log-probabilities: per-item predictability N(0, 1) plus token noise; exact leaks gain +1.5 on half their tokens, paraphrased leaks +0.3 on all.
- Accuracy: 0.50 on clean items, 0.95 on copies, 0.75 on paraphrases.
| detector | copies | paraphrases | false positives |
|---|---|---|---|
| 13-gram overlap (recall) | 1.0 | 0.0 | 0.0 |
| Min-K% (AUC) | 0.575 | 0.549 | – |
| likelihood ratio (AUC) | 0.897 | 0.773 | – |
| accuracy | seed 0 |
|---|---|
| reported, all 500 | 0.566 |
| after removing 13-gram matches | 0.533 |
| truly clean items | 0.514 |
- Overlap is exact for copies and blind to paraphrases.
- Min-K% alone was weak because predictability varied more than memorisation.
- The likelihood ratio cancelled predictability and detected both kinds of leak.
- Decontamination removed about 60% of the inflation (5.2 → 1.9 points).
- Seeds 1 and 2: ratio AUC for copies 0.916 and 0.899, for paraphrases 0.639 and 0.785 (only about 50 paraphrased items, so this varies); Min-K% for copies 0.597 and 0.634.
- Caveat: log-probability effects are simulated; real membership inference on large models is often weaker.
Contamination in AI, robotics and aerospace
- Internal evaluations: keep engineering test sets off shared drives used for training data and fine-tuning.
- Vendor claims: ask model providers for clean-subset scores on your domain tasks.
- Robotics: simulated benchmark scenes reused in training data inflate success rates in the same way.
References
- T. Brown et al. (2020). “Language models are few-shot learners.” NeurIPS.
- W. Shi et al. (2024). “Detecting pretraining data from large language models.” ICLR.
- H. Zhang et al. (2024). “A careful examination of large language model performance on grade school arithmetic.” NeurIPS.
- N. Jain et al. (2024). “LiveCodeBench: holistic and contamination free evaluation of large language models for code.” arXiv.