LLM Benchmark Contamination: Hands-On Tests Reveal the Leakage Crisis Behind Model Scores

    This article examines benchmark leakage in large language models and explains why high public benchmark scores can reflect memorization rather than capability. Based on hands-on test observations, it breaks down how contamination enters through pretraining, post-training, and evaluation, and classifies leakage into five levels, from L0 to L4. It then presents practical detection methods, including verbatim recall, problem-order continuation probes, perturbation robustness tests, perplexity checks, temporal holdouts, and private canary holdouts. Finally, it outlines data-side decontamination practices and evaluation-side reporting recommendations for more trustworthy model assessment.

    1. A striking observation: the model is not solving problems; it is reciting them

    One base model achieved a perfect score on a code-completion benchmark. The researchers randomly selected problem 66 and gave the model only the problem statement, function signature, and docstring. It did not stop there. Following the order of the benchmark, it wrote out the statement, input/output examples, and reference implementation for problem 67 word for word, including a misspelled word made by the original problem author. It then continued with problems 68, 69, and 70.

    When the researchers re-ran the benchmark problem by problem, 158 of 164 problems could be fully reproduced, including both the problem statement and the reference answer—a reproduction rate of about 96%.

    Under the normal calling setup, the model’s score was a perfect mark. Under a stricter setup that provided only problem 66, the result changed into a measurement of how many unseen problems the model could still recite from memory. The score became 3.66 (2/164). After recomputing 20 public benchmark sets with the same method, the overall ranking was reshuffled: the model originally ranked first fell to last, while some models originally ranked lower rose to first. Models whose verbatim reproduction rates were close to zero saw little change in ranking—they had not memorized the benchmark, so their scores reflected their actual capabilities.

    One caveat is necessary: verbatim reproduction does not mean that a model cannot solve problems. The experiments only measured whether the model could reproduce the original text without being given the full problem statement. They do not directly disprove other capabilities. What they undermine is the explanatory power of the benchmark score. When a score is mainly driven by memorization, it is no longer a reliable proxy for capability.

    2. What does a single benchmark run actually measure?

    LLM capability development can be understood in three broad stages:

    • Pretraining: The model performs next-token prediction over massive amounts of web pages, books, and code, producing a base model with broad knowledge but limited instruction-following ability.
    • Post-training: Instruction data and human/model preference data turn the base model into an assistant or agent that can follow instructions, write code, and use tools.
    • Evaluation: Public standard benchmarks produce scores, leaderboards, and release-day performance tables.

    The structural contradiction appears in the third stage: the benchmarks are public, while the training corpus is largely a crawl of the public internet. Once a code, math, or knowledge benchmark has been public for more than a year, its problem statements and reference answers have almost certainly appeared somewhere online—on a webpage, in a solution repository, or in a blog post. In other words, the “exam” often happens after the model has had the opportunity to read the answers.

    Contamination occurs through three paths, listed here in increasing order of importance:

    1. Natural corpus contamination: Web pages, code hosting platforms, tutorial sites, and solution sites are crawled into the pretraining corpus.
    2. Intentional reuse in post-training: Public benchmark problems are directly reused as SFT samples when constructing instruction data, or a stronger model is used to generate distilled data from benchmark problems. This path is more subtle and more damaging because it aligns the answer distribution directly with the benchmark.
    3. Evaluation-process contamination: Repeated tuning, multiple sampling passes with best-of-n selection, early stopping on the evaluation set, and prompt templates reverse-engineered from leaderboards. Even without directly seeing the answers, these practices slightly fit the model or prompt to the test set.

    3. Leakage is not a boolean; it is a graded spectrum

    The distortion caused by “becoming familiar with problem types” is very different from the distortion caused by “obtaining the original exam paper.” In practice, leakage can be managed in five levels:

    • L0: No leakage: Neither the problems nor paraphrased versions appear in the corpus.
    • L1: Domain leakage: The corpus contains problems from the same domain or with the same problem type, but not the specific benchmark. The score is still a valid capability signal, but it may slightly overestimate ability because the model has seen similar problems, though not the original ones.
    • L2: Structural leakage: Problem templates, solving patterns, and common pitfalls are widely present in the corpus, although specific parameters and problem IDs differ. The score is partially valid and should be evaluated for sensitivity to parameter perturbations.
    • L3: Answer leakage: Reference solutions or standard outputs appear in the corpus, but the problem statements have been paraphrased. The score is basically untrustworthy.
    • L4: Full original-paper memorization: Both the problem statement and reference answer can be reproduced verbatim. The score has no capability explanation and only indicates that the model has seen the material.

    The 158/164 result in the hands-on tests above belongs to L4. The verbatim reproduction rate is a cheap and sharp probe for distinguishing L2 from L3/L4.

    4. How to detect leakage: a practical toolkit

    4.1 Verbatim recall

    Provide only the problem prefix—function signature plus docstring—and ask the model to continue. Compare the output with the official reference answer using character-level or line-level longest common subsequence matching, then calculate the proportion of high-similarity outputs.

    1. import difflib
    2. def verbatim_recall(model, problems, max_new_tokens=512, thr=0.9):
    3. """
    4. problems: mapping from problem ID to (prefix_prompt, official_solution)
    5. Returns the verbatim recall rate and per-problem details.
    6. """
    7. hit, detail = 0, []
    8. for pid, (prefix, ref) in problems.items():
    9. out = model.generate(prefix, max_new_tokens=max_new_tokens, temperature=0.0)
    10. ratio = difflib.SequenceMatcher(None, out, ref).ratio()
    11. detail.append((pid, round(ratio, 3)))
    12. if ratio >= thr:
    13. hit += 1
    14. return hit / len(problems), detail

    Practical interpretation:

    • Similarity above 0.9 is usually the original text.
    • Similarity between 0.6 and 0.9 requires manual review to determine whether the model merely changed variable names while copying the structure.
    • Similarity below 0.6 can generally be treated as no leakage for that problem.

    4.2 Problem-order continuation probe

    This is the easiest probe to run and one of the hardest to explain away. Provide only problem k and observe whether the model spontaneously writes the problem statements and answers for problems k+1 and k+2. There is no legitimate reason for a model to know what the “next problem” is. If it can continue, the most plausible explanation is that the corpus contains a continuous text block ordered exactly as the original benchmark. The accuracy of this probe is usually highly consistent with verbatim recall, but it is harder to dismiss with the claim that “the model simply knows how to solve this type of problem.”

    4.3 Perturbation robustness

    This is recommended as a routine evaluation item. Apply semantics-preserving perturbations to each problem, rerun the evaluation, and compare score changes:

    1. def perturb(problem, rng):
    2. p = dict(problem)
    3. p["func"] = rng.rename(p["func"]) # Replace function names with random strings.
    4. p["params"] = rng.rescale(p["params"]) # Scale constants and boundary values.
    5. p["cases"] = rng.shuffle(p["cases"]) # Shuffle test-case order.
    6. p["doc"] = llm_paraphrase(p["doc"]) # Paraphrase the docstring.
    7. p["id"] = f"holdout_{rng.uuid4()}" # Replace the problem ID with a private identifier.
    8. return p
    9. # Reporting metric: score_drop = score(original) - score(perturbed)
    • If scores remain roughly unchanged before and after perturbation, the model is performing semantic reasoning and the score is more trustworthy.
    • If scores fall sharply after perturbation—for example, from 100 to 3–10—the model relies heavily on memorization, corresponding to L3/L4.

    One important detail is that replacing function names with random strings prevents the model from retrieving the answer through function-name hints. This removes the memorization path and leaves only the capability path.

    4.4 Perplexity and membership inference

    Calculate the average negative log-likelihood over the test-set tokens and compare it with a private held-out set from the same domain. If the public benchmark has significantly lower perplexity, it is more likely to have appeared in the training distribution. This step does not require generation and is very cheap, making it suitable for routine checks in a training-data pipeline.

    4.5 Temporal holdout

    Use problems created after the model’s knowledge cutoff as the holdout. This is the most reliable way to isolate leakage. The prerequisite is that the problems are sufficiently new and do not come from the same source as an already-public benchmark.

    4.6 Canary strings and private holdouts

    Build a private holdout that is never published. Insert several high-entropy canary strings into it to monitor whether the set is reproduced by later models. The problems in the private holdout should come from real business scenarios. A few hundred to a few thousand problems are sufficient; coverage matters more than volume.

    5. Data-side: build decontamination into the training pipeline

    Leakage detection is a post-hoc check. The real solution is before data enters the pipeline. A practical checklist:

    • Global n-gram deduplication and decontamination: Apply sliding-window deduplication over the training corpus, commonly using 13-grams or longer. Also maintain a fingerprint library of known public benchmarks. Any sample that matches the fingerprint library should be removed, or at least flagged and downweighted.
    • Source blacklists: Add domain names and page templates for solution sites, problem-bank mirror sites, and leaderboard aggregators to filtering rules to avoid whole-site crawling.
    • Synthetic-data lineage: Keep generator versions and prompt lineage for all distilled or synthetic data so that it is possible to trace whether a capability came from the output of a third-party model.
    • Versioning and auditability: Bind corpus snapshots, deduplication rules, and decontamination rules to version numbers so that any leaderboard score can be traced back to what data was used at the time.
    • Routine rescanning: As soon as a new benchmark is released, add it to the fingerprint library and rescan recent corpus snapshots, forming a contamination ledger.
    1. def has_overlap(train_text: str, bench_text: str, n: int = 13) -> bool:
    2. grams = {bench_text[i:i + n] for i in range(len(bench_text) - n + 1)}
    3. return any(train_text[i:i + n] in grams for i in range(len(train_text) - n + 1))

    6. Evaluation-side: produce conclusions that others can reproduce and that you can trust

    Whether publishing a public leaderboard or performing internal selection and regression, the report should include at least the following fields. If one is missing, the conclusion should be discounted:

    • Benchmark name, number of problems, release date, and whether it was released after the model’s knowledge cutoff;
    • Sampling configuration: temperature, top-p, pass@1 or pass@k, and retry policy;
    • The full prompt template and whether any targeted tuning was performed;
    • Contamination-detection results: verbatim recall rate, score difference before and after perturbation, and problem-order continuation probe results;
    • Variance across multiple independent runs, and whether a fixed seed was used.

    For internal practice, three recommendations are especially useful:

    1. Dual-track evaluation: Run the same model on both the public benchmark and the private holdout, and report the difference. A larger difference indicates that the public benchmark is less reliable.
    2. Run perturbation tests continuously: Make semantics-preserving perturbation part of CI so that every model iteration automatically produces a score delta. This helps prevent the situation where “newer versions score higher only because they have memorized more.”
    3. Regression should use real tasks: The final decision should rely on end-to-end business metrics such as success rate, rework rate, and human takeover rate. Benchmark scores should be used for screening, not for final conclusions.

    7. Conclusion and action checklist

    Public benchmarks are not necessarily fabricated, but the reliability of what they measure is being systematically eroded. When a benchmark enters the training corpus, the score degrades from a measure of capability into a measure of memory. After pretraining at scale, the marginal benefit of memorization becomes extremely low and unstable.

    Three points for developers:

    • If a model is close to a perfect score on a public benchmark, run a verbatim recall test and a perturbation test before deciding whether to invest in integration.
    • Treat the private holdout as infrastructure, not as one-time acceptance material. It can support model selection, regression testing, and online canary deployment.
    • Decontaminate data before it enters the pipeline. This is cheaper than explaining leaderboard results after the fact.

    Three points for platform providers and model teams:

    • Include contamination-detection results in the model card; they are as important as the benchmark scores.
    • Make the data pipeline auditable, traceable, and rescanable.
    • When publishing externally, provide three things together: public-benchmark scores, private-holdout scores, and contamination-detection results. This is more persuasive than a single number.

    Benchmarks are signposts, not destinations. Truly trustworthy evaluation always comes from your own business data, your own private problem set, and the pass rates you measure on real tasks.