LLM benchmark contamination: how to test code models fairly
For companies4 min read
LLM benchmark contamination happens when test questions, or close copies, were in a model's training data. The score then measures memory, not skill. For coding, this is easy to miss because solutions and problems are posted widely online. Here is how to design tests that stay fair.
Why LLM benchmark contamination hits code first
Programming problems and their solutions are copied across blogs, forums and repositories. A benchmark published in a paper can end up in a scraped dataset within months. When a model is later tested on it, a high score may reflect what it has seen. The researchers behind LiveCodeBench list potential overfitting on existing benchmarks such as HumanEval and MBPP among the topics their paper reports on.
Source: LiveCodeBench paper on contamination-free code evaluation (arXiv:2403.07974)(opens in a new tab)
How date-split testing works
LiveCodeBench handles the problem by collecting new problems over time from contests on LeetCode, AtCoder and CodeForces. Because each problem has a publication date, you can test a model only on problems released after its training cut-off. The release described in the paper has 400 problems published between May 2023 and May 2024, and the authors evaluated 18 base models and 34 instruction-tuned models.
The method is simple to copy. Record the training cut-off of each model you test. Then split your test set by creation date and report results before and after the cut-off. A sharp drop after the date is a warning that contamination inflated the earlier results.
| Split | Question it answers |
|---|---|
| Problems before the cut-off | How well does the model do on material it may have seen? |
| Problems after the cut-off | How well does it do on unseen material? |
| Gap between the two | How much of the score may be memory? |
Beyond writing code
The same paper covers more than code generation: self-repair, code execution and test output prediction. Each of these is harder to memorise than a single function, since the test depends on the specific code in front of the model. If you run a private evaluation, include such tasks.
Build a private set that engineers refresh
Public benchmarks help you compare models. A private set tells you how a model works for your product. Engineers on your team, or contracted experts, can write new tasks from your own domain: internal APIs, build scripts, data pipelines, the quirks of your framework. Those cannot have leaked, because they were never public.
- Never post the questions or reference solutions online.
- Keep the set on a system the model providers cannot reach.
- Date every task, and retire old ones as they leak.
- Rotate which tasks you show to a model during prompt tuning, and keep a final holdout untouched.
- Log which engineer wrote each task, so quality problems can be traced.
Write variants, not copies
Contamination is not just exact copies. A model may have seen a near duplicate with the names changed. Ask engineers to write variants of known problems that change the logic, not just the surface: different constraints, a different data structure, an unusual edge case. If a model solves the original and fails the variant, you have learned something useful.
Have a second engineer solve each new task from scratch to confirm it is well-posed and the tests are correct. A broken task makes a fair model look bad and can hide real progress.
Check for memorisation signals
- Give the model the first half of a known problem statement and see whether it completes the rest word for word.
- Compare scores on the original problem and on a reworded version with identical logic.
- Look at whether the model reproduces odd details from the published solution, such as unusual variable names.
- Compare scores before and after the training cut-off, as above.
- Ask an engineer to read a sample of correct answers and judge whether the reasoning looks derived or recalled.
None of these is proof by itself. Together they give you an argument you can show a customer or auditor.
What to put in your report
State the date range of the test problems, the training cut-off you assumed for each model, and whether the set is public or private. Show the before and after scores. If you cannot find a model's cut-off, say so and treat the result with caution. A report that admits these limits is more credible than one with a single high number.
Curatrain vets engineers with graded skill tests, and experts do work such as problems a program can check and realistic tasks with checkers for AI agents. Companies approve each match from a shortlist, and a pilot is a way to test a private set before committing to a larger one.
