Contamination in Code Benchmarks: Lessons for Non-Code Domains

Contamination in Code Benchmarks: Lessons for Non-Code Domains

Contamination in code benchmarks is now well-documented. HumanEval solutions appear verbatim in Common Crawl. MBPP problems circulate in GitHub repositories and tutorial blogs. When a model trains on data that overlaps with its evaluation set, the resulting score measures memorization as much as it measures capability. The code community has spent years building detection methods and cleaner benchmarks. Non-code domains are earlier in that cycle, and they're making the same mistakes faster. This post extracts the operational lessons from code-benchmark contamination and maps them directly to expert domains: manufacturing, finance, engineering, and science.

Answer Capsule: Contamination in code benchmarks occurs when evaluation tasks or their solutions appear in pre-training or fine-tuning data, inflating scores beyond true capability. The same failure propagates to non-code domains whenever tasks are sourced from publicly available textbooks, forums, or prior exams. The fix is the same in both cases: original, expert-authored tasks with verifiable provenance, empirical difficulty calibration against current frontier models, and a contamination audit protocol run before any score is reported.

How Contamination Enters Code Benchmarks

Contamination enters through three distinct pathways, and each has a non-code analogue.

Direct string overlap. A benchmark problem and its canonical solution appear together in training data. For HumanEval, this is the most studied case. Researchers including Jacovi et al. (2023, "Stop Uploading Test Data in the Open LLM Leaderboard Era") demonstrated that even partial overlap, a function signature plus a docstring, is enough to inflate pass@1 scores materially.

Semantic near-duplication. The exact string doesn't match, but a rephrased version of the same problem does. A LeetCode problem restated in a Stack Overflow answer, or a textbook exercise paraphrased in a tutorial, produces this pattern. Embedding-based deduplication catches some of it; n-gram overlap misses most of it.

Solution-only contamination. The problem statement is clean, but a worked solution exists in training data. The model appears to reason through the problem; it's retrieving a cached solution path. This is the hardest variant to detect and the most common in domains like accounting, where worked examples from CPA exam prep materials are widely scraped.

What Code Contamination Detection Methods Actually Measure

The three main detection approaches each have a different sensitivity profile, and knowing which gap they leave is essential before applying them to a new domain.

Method

What it detects

What it misses

Non-code applicability

N-gram overlap (e.g., 13-gram)

Near-verbatim string matches

Paraphrase, translation, semantic equivalents

Moderate: works for formula-heavy text; fails for diagram-described tasks

Embedding similarity

Semantic near-duplicates

Structurally similar problems with different surface forms

High for text; low for multimodal (G-code, schematics, drawings)

Membership inference

Probabilistic signal that a sequence was trained on

Requires model access; high false-negative rate on short sequences

Applicable but noisy; requires careful threshold calibration per domain

Canary / held-out probing

Whether a known-unseen task is solved at unexpectedly high rate

Requires a clean held-out set to begin with

Best option for new domains; requires original task authoring

The canary approach is the most reliable signal precisely because it sidesteps the detection problem entirely. If a task was never on the web, it cannot be in training data. That's the logic behind original, expert-authored tasks: provenance is the contamination control, not post-hoc detection.

Contamination in Code Benchmarks: Lessons That Transfer Directly

The code community's hard-won lessons apply with minimal modification to any domain that sources tasks from publicly available material.

Lesson 1: Benchmark age predicts contamination severity

HumanEval was released in 2021. By 2023, solutions to its 164 problems were findable across dozens of repositories and tutorial sites. Any benchmark that has been public for more than 12-18 months and has attracted community attention should be treated as partially contaminated for models trained after its release date. The same clock runs on finance exam questions, structural engineering worked examples, and PLC programming exercises posted to industrial forums.

Lesson 2: Pass rate alone doesn't distinguish memorization from generalization

The code community developed pass@k precisely to measure generalization across multiple samples. A model that memorized a solution will pass@1 reliably but may also pass@10 reliably, making memorization hard to isolate from the metric alone. The more diagnostic signal comes from comparing performance on structurally identical but surface-varied problems. If accuracy drops sharply when variable names or units change, that's a memorization signature.

Lesson 3: Difficulty calibration drifts

A problem that stumped GPT-3 may be trivial for a current frontier model, not because the model generalized better but because more solutions to that problem class entered training data between versions. Difficulty must be re-measured against current models, not assumed stable from an earlier calibration. This is true for CNC toolpath problems as much as for sorting algorithms.

Lesson 4: Verifiers and rubrics are part of the contamination surface

In code, the test suite is the verifier. If the test suite is public, a model can be trained to pass it without solving the underlying problem. In non-code domains, the rubric plays the same role. A scoring rubric derived from a published grading guide is itself a contamination vector if that guide is in training data.

Where Non-Code Domains Are More Exposed

Non-code domains face three structural risks that code benchmarks don't, or face less severely.

Verification is harder to automate. A Python function either passes a unit test or it doesn't. A G-code toolpath that produces a geometrically valid part but violates feed-rate constraints for a specific material requires a domain expert to catch the failure. Without automated verification, contamination is harder to detect because inflated scores can't be easily distinguished from genuine capability gains.

The task corpus is smaller and less diverse. There are millions of coding problems across competitive programming, open-source repositories, and tutorials. For CNC programming or PCB layout, the corpus of publicly available worked examples is orders of magnitude smaller. This means a model trained on even a modest scrape of domain-specific forums may have seen a large fraction of the available task space. Saturation happens faster.

Expert knowledge is harder to proxy. In code, a correct output is often unambiguous. In structural engineering or accounting, a correct answer may depend on jurisdiction, standard version, or professional judgment that isn't captured in any scraped source. Contamination in these domains doesn't just inflate scores; it can make a model appear competent at a task where it's actually pattern-matching to a scraped answer that was correct under a different set of assumptions.

Worked Example: Applying a Contamination Audit to a Manufacturing Eval

Illustrative example: numbers and task descriptions are constructed to demonstrate the method, not drawn from a specific deployment.

Suppose a team is building an evaluation set for CNC G-code generation. They start with 80 tasks drawn from publicly available CNC training materials and machinist forums. Before scoring any model, they run the following three-step audit.

  1. Provenance check. Each task is searched by 8-gram overlap against a sample of Common Crawl snapshots from the past 24 months. Result: 31 of 80 tasks have at least one near-verbatim match in the crawl. Those 31 are flagged for replacement.

  2. Semantic near-duplicate check. The remaining 49 tasks are embedded and compared against a retrieval index of machining tutorial content. Result: 9 additional tasks cluster within cosine distance 0.08 of a tutorial example. Total clean set: 40 tasks.

  3. Canary difficulty calibration. The 40 clean tasks are run against two frontier models at pass@5. Twelve tasks are solved by both models at pass@5 greater than 0.9, indicating they're too easy to be diagnostic. The final eval set is 28 tasks, all original or verified-clean, spanning a difficulty range where at least one frontier model fails more than 40% of the time.

Starting from 80 tasks, the audit yields 28 usable ones. That's a 65% discard rate. Teams that skip this process report scores on a set that is majority-contaminated and difficulty-miscalibrated. The scores look good. They measure the wrong thing.

Common Failure Modes in Contamination Control

Failure mode 1: Treating public benchmarks as baselines without re-auditing

A team adopts an existing domain benchmark released 18 months ago and treats its scores as comparable across model generations.

Detection: check the benchmark's release date against the training cutoffs of the models being evaluated.

Fix: re-run contamination detection against current crawl snapshots before using any public benchmark as a baseline.

Failure mode 2: Assuming paraphrase is sufficient decontamination

A task is rewritten by a generalist annotator to change surface wording. The underlying problem structure, numerical values, and solution path remain identical.

Detection: compare pass rates on the paraphrased task against the original; if they're within 5 percentage points, the paraphrase didn't change what the model is retrieving.

Fix: require structural variation, not just surface variation, and verify with a domain expert.

Failure mode 3: Using the same rubric for training and evaluation

A scoring rubric is developed, used to label preference data for RLHF, and then used unchanged as the eval rubric. The model learns to optimize for the rubric's surface features.

Detection: check inter-rater agreement between the rubric and independent expert judgment on held-out cases; a gap of more than 15-20 percentage points signals rubric overfitting.

Fix: maintain separate rubric versions for training and evaluation, authored by different experts.

Failure mode 4: Reporting aggregate pass@1 without difficulty stratification

A model achieves 72% pass@1 on a mixed-difficulty set. The score conflates easy tasks (where contamination inflates performance) with hard tasks (where genuine capability is measured).

Detection: stratify by difficulty tier and report separately.

Fix: calibrate difficulty empirically before scoring and report per-tier results.

Failure mode 5: Skipping verifier validation

A verifier is built to check G-code outputs for syntactic correctness but not for machining validity (feed rates, tool engagement, material constraints). The model learns to produce syntactically valid but physically incorrect toolpaths.

Detection: run a sample of model outputs through both the automated verifier and an expert review; disagreement rate above 10% signals verifier gaps.

Fix: iterate the verifier with domain experts before using it as a training signal.

Where This Approach Breaks Down

Original task authoring controls provenance but doesn't eliminate all contamination risk. A domain expert who authors tasks may unconsciously reproduce problem structures they've seen in training materials, even without copying text. This is structural contamination, and it's hard to detect without comparing the task's solution path against a broad sample of domain literature.

Difficulty calibration against current frontier models has a short shelf life. A task that is genuinely hard today may be trivially solved six months from now, not because the task was contaminated but because the capability frontier moved. Eval sets need re-calibration on a rolling basis, and any score reported without a model version and date should be treated as approximate.

Finally, canary probing works only if the canary tasks are truly held out. If the same organization that authors the tasks also trains or fine-tunes the model being evaluated, the independence assumption breaks down. Separation between task authorship and model development is an organizational control, not a technical one.

FAQ

How do I know if a non-code benchmark is contaminated?

Run n-gram overlap checks against Common Crawl snapshots covering the model's training window. Then embed tasks and compare against domain-specific corpora (textbooks, forums, exam prep sites). If more than 20-30% of tasks return a near-match, treat the benchmark as partially contaminated. Canary probing with held-out original tasks gives a cleaner signal but requires original authoring infrastructure.

Does contamination affect RLHF training data differently than eval data?

Yes. In eval data, contamination inflates scores. In RLHF training data, contamination can corrupt the reward signal: if preferred responses are drawn from scraped solutions the model has already seen, the preference label may reflect familiarity rather than quality. The model learns to reproduce known patterns, not to generalize. Original, expert-authored preference pairs with verifiable provenance reduce this risk.

What is the minimum task count for a contamination-resistant eval set?

There's no universal minimum, but a set of fewer than 50 tasks in a narrow domain will have high variance in pass@k estimates and limited difficulty stratification. A practical floor is 100 tasks after contamination filtering, stratified across at least three difficulty tiers. If filtering discards more than 60% of sourced tasks, the sourcing strategy needs to change, not just the sample size.

Can synthetic data generation solve the contamination problem?

Synthetic generation reduces string-level contamination but introduces a different risk: if the generator is a frontier model, its outputs reflect that model's training distribution. Tasks generated by a model are not independent of that model's knowledge. For evaluation purposes, synthetic tasks authored without expert verification also lack the difficulty calibration and domain validity that make a task a reliable signal.

How often should difficulty calibration be re-run?

Re-calibrate whenever a major new model family is released or when a model's training cutoff is close to the benchmark's creation date. A practical cadence for active eval sets is every 6-12 months, or after any model release that represents a step change in the relevant domain capability. Record the model version, scaffold, and date alongside every difficulty score.

What This Means in Practice

Contamination in code benchmarks is a solved problem in principle, even if not always in practice. The mechanisms are understood: provenance matters, difficulty drifts, and verifiers are part of the contamination surface. Non-code domains are inheriting the same failure modes without the same detection infrastructure. The path forward isn't more scraping or more synthetic generation. It's original task authoring by domain practitioners, empirical difficulty calibration against current models, and contamination audits that run before any score is reported, not after a result looks suspicious.

The domains with the least publicly available task corpora, manufacturing, structural engineering, PCB design, industrial controls, are the ones where contamination-resistant evals are most scarce and most valuable. That scarcity is the signal.

For more on how task provenance and difficulty calibration work in practice, see the Chiron Data Labs blog and the broader work on expert-authored evals. If you're building evals or RL environments in a non-code domain, get in touch with Chiron Data Labs.

Contamination in code benchmarks is now well-documented. HumanEval solutions appear verbatim in Common Crawl. MBPP problems circulate in GitHub repositories and tutorial blogs. When a model trains on data that overlaps with its evaluation set, the resulting score measures memorization as much as it measures capability. The code community has spent years building detection methods and cleaner benchmarks. Non-code domains are earlier in that cycle, and they're making the same mistakes faster. This post extracts the operational lessons from code-benchmark contamination and maps them directly to expert domains: manufacturing, finance, engineering, and science.

Answer Capsule: Contamination in code benchmarks occurs when evaluation tasks or their solutions appear in pre-training or fine-tuning data, inflating scores beyond true capability. The same failure propagates to non-code domains whenever tasks are sourced from publicly available textbooks, forums, or prior exams. The fix is the same in both cases: original, expert-authored tasks with verifiable provenance, empirical difficulty calibration against current frontier models, and a contamination audit protocol run before any score is reported.

How Contamination Enters Code Benchmarks

Contamination enters through three distinct pathways, and each has a non-code analogue.

Direct string overlap. A benchmark problem and its canonical solution appear together in training data. For HumanEval, this is the most studied case. Researchers including Jacovi et al. (2023, "Stop Uploading Test Data in the Open LLM Leaderboard Era") demonstrated that even partial overlap, a function signature plus a docstring, is enough to inflate pass@1 scores materially.

Semantic near-duplication. The exact string doesn't match, but a rephrased version of the same problem does. A LeetCode problem restated in a Stack Overflow answer, or a textbook exercise paraphrased in a tutorial, produces this pattern. Embedding-based deduplication catches some of it; n-gram overlap misses most of it.

Solution-only contamination. The problem statement is clean, but a worked solution exists in training data. The model appears to reason through the problem; it's retrieving a cached solution path. This is the hardest variant to detect and the most common in domains like accounting, where worked examples from CPA exam prep materials are widely scraped.

What Code Contamination Detection Methods Actually Measure

The three main detection approaches each have a different sensitivity profile, and knowing which gap they leave is essential before applying them to a new domain.

Method

What it detects

What it misses

Non-code applicability

N-gram overlap (e.g., 13-gram)

Near-verbatim string matches

Paraphrase, translation, semantic equivalents

Moderate: works for formula-heavy text; fails for diagram-described tasks

Embedding similarity

Semantic near-duplicates

Structurally similar problems with different surface forms

High for text; low for multimodal (G-code, schematics, drawings)

Membership inference

Probabilistic signal that a sequence was trained on

Requires model access; high false-negative rate on short sequences

Applicable but noisy; requires careful threshold calibration per domain

Canary / held-out probing

Whether a known-unseen task is solved at unexpectedly high rate

Requires a clean held-out set to begin with

Best option for new domains; requires original task authoring

The canary approach is the most reliable signal precisely because it sidesteps the detection problem entirely. If a task was never on the web, it cannot be in training data. That's the logic behind original, expert-authored tasks: provenance is the contamination control, not post-hoc detection.

Contamination in Code Benchmarks: Lessons That Transfer Directly

The code community's hard-won lessons apply with minimal modification to any domain that sources tasks from publicly available material.

Lesson 1: Benchmark age predicts contamination severity

HumanEval was released in 2021. By 2023, solutions to its 164 problems were findable across dozens of repositories and tutorial sites. Any benchmark that has been public for more than 12-18 months and has attracted community attention should be treated as partially contaminated for models trained after its release date. The same clock runs on finance exam questions, structural engineering worked examples, and PLC programming exercises posted to industrial forums.

Lesson 2: Pass rate alone doesn't distinguish memorization from generalization

The code community developed pass@k precisely to measure generalization across multiple samples. A model that memorized a solution will pass@1 reliably but may also pass@10 reliably, making memorization hard to isolate from the metric alone. The more diagnostic signal comes from comparing performance on structurally identical but surface-varied problems. If accuracy drops sharply when variable names or units change, that's a memorization signature.

Lesson 3: Difficulty calibration drifts

A problem that stumped GPT-3 may be trivial for a current frontier model, not because the model generalized better but because more solutions to that problem class entered training data between versions. Difficulty must be re-measured against current models, not assumed stable from an earlier calibration. This is true for CNC toolpath problems as much as for sorting algorithms.

Lesson 4: Verifiers and rubrics are part of the contamination surface

In code, the test suite is the verifier. If the test suite is public, a model can be trained to pass it without solving the underlying problem. In non-code domains, the rubric plays the same role. A scoring rubric derived from a published grading guide is itself a contamination vector if that guide is in training data.

Where Non-Code Domains Are More Exposed

Non-code domains face three structural risks that code benchmarks don't, or face less severely.

Verification is harder to automate. A Python function either passes a unit test or it doesn't. A G-code toolpath that produces a geometrically valid part but violates feed-rate constraints for a specific material requires a domain expert to catch the failure. Without automated verification, contamination is harder to detect because inflated scores can't be easily distinguished from genuine capability gains.

The task corpus is smaller and less diverse. There are millions of coding problems across competitive programming, open-source repositories, and tutorials. For CNC programming or PCB layout, the corpus of publicly available worked examples is orders of magnitude smaller. This means a model trained on even a modest scrape of domain-specific forums may have seen a large fraction of the available task space. Saturation happens faster.

Expert knowledge is harder to proxy. In code, a correct output is often unambiguous. In structural engineering or accounting, a correct answer may depend on jurisdiction, standard version, or professional judgment that isn't captured in any scraped source. Contamination in these domains doesn't just inflate scores; it can make a model appear competent at a task where it's actually pattern-matching to a scraped answer that was correct under a different set of assumptions.

Worked Example: Applying a Contamination Audit to a Manufacturing Eval

Illustrative example: numbers and task descriptions are constructed to demonstrate the method, not drawn from a specific deployment.

Suppose a team is building an evaluation set for CNC G-code generation. They start with 80 tasks drawn from publicly available CNC training materials and machinist forums. Before scoring any model, they run the following three-step audit.

  1. Provenance check. Each task is searched by 8-gram overlap against a sample of Common Crawl snapshots from the past 24 months. Result: 31 of 80 tasks have at least one near-verbatim match in the crawl. Those 31 are flagged for replacement.

  2. Semantic near-duplicate check. The remaining 49 tasks are embedded and compared against a retrieval index of machining tutorial content. Result: 9 additional tasks cluster within cosine distance 0.08 of a tutorial example. Total clean set: 40 tasks.

  3. Canary difficulty calibration. The 40 clean tasks are run against two frontier models at pass@5. Twelve tasks are solved by both models at pass@5 greater than 0.9, indicating they're too easy to be diagnostic. The final eval set is 28 tasks, all original or verified-clean, spanning a difficulty range where at least one frontier model fails more than 40% of the time.

Starting from 80 tasks, the audit yields 28 usable ones. That's a 65% discard rate. Teams that skip this process report scores on a set that is majority-contaminated and difficulty-miscalibrated. The scores look good. They measure the wrong thing.

Common Failure Modes in Contamination Control

Failure mode 1: Treating public benchmarks as baselines without re-auditing

A team adopts an existing domain benchmark released 18 months ago and treats its scores as comparable across model generations.

Detection: check the benchmark's release date against the training cutoffs of the models being evaluated.

Fix: re-run contamination detection against current crawl snapshots before using any public benchmark as a baseline.

Failure mode 2: Assuming paraphrase is sufficient decontamination

A task is rewritten by a generalist annotator to change surface wording. The underlying problem structure, numerical values, and solution path remain identical.

Detection: compare pass rates on the paraphrased task against the original; if they're within 5 percentage points, the paraphrase didn't change what the model is retrieving.

Fix: require structural variation, not just surface variation, and verify with a domain expert.

Failure mode 3: Using the same rubric for training and evaluation

A scoring rubric is developed, used to label preference data for RLHF, and then used unchanged as the eval rubric. The model learns to optimize for the rubric's surface features.

Detection: check inter-rater agreement between the rubric and independent expert judgment on held-out cases; a gap of more than 15-20 percentage points signals rubric overfitting.

Fix: maintain separate rubric versions for training and evaluation, authored by different experts.

Failure mode 4: Reporting aggregate pass@1 without difficulty stratification

A model achieves 72% pass@1 on a mixed-difficulty set. The score conflates easy tasks (where contamination inflates performance) with hard tasks (where genuine capability is measured).

Detection: stratify by difficulty tier and report separately.

Fix: calibrate difficulty empirically before scoring and report per-tier results.

Failure mode 5: Skipping verifier validation

A verifier is built to check G-code outputs for syntactic correctness but not for machining validity (feed rates, tool engagement, material constraints). The model learns to produce syntactically valid but physically incorrect toolpaths.

Detection: run a sample of model outputs through both the automated verifier and an expert review; disagreement rate above 10% signals verifier gaps.

Fix: iterate the verifier with domain experts before using it as a training signal.

Where This Approach Breaks Down

Original task authoring controls provenance but doesn't eliminate all contamination risk. A domain expert who authors tasks may unconsciously reproduce problem structures they've seen in training materials, even without copying text. This is structural contamination, and it's hard to detect without comparing the task's solution path against a broad sample of domain literature.

Difficulty calibration against current frontier models has a short shelf life. A task that is genuinely hard today may be trivially solved six months from now, not because the task was contaminated but because the capability frontier moved. Eval sets need re-calibration on a rolling basis, and any score reported without a model version and date should be treated as approximate.

Finally, canary probing works only if the canary tasks are truly held out. If the same organization that authors the tasks also trains or fine-tunes the model being evaluated, the independence assumption breaks down. Separation between task authorship and model development is an organizational control, not a technical one.

FAQ

How do I know if a non-code benchmark is contaminated?

Run n-gram overlap checks against Common Crawl snapshots covering the model's training window. Then embed tasks and compare against domain-specific corpora (textbooks, forums, exam prep sites). If more than 20-30% of tasks return a near-match, treat the benchmark as partially contaminated. Canary probing with held-out original tasks gives a cleaner signal but requires original authoring infrastructure.

Does contamination affect RLHF training data differently than eval data?

Yes. In eval data, contamination inflates scores. In RLHF training data, contamination can corrupt the reward signal: if preferred responses are drawn from scraped solutions the model has already seen, the preference label may reflect familiarity rather than quality. The model learns to reproduce known patterns, not to generalize. Original, expert-authored preference pairs with verifiable provenance reduce this risk.

What is the minimum task count for a contamination-resistant eval set?

There's no universal minimum, but a set of fewer than 50 tasks in a narrow domain will have high variance in pass@k estimates and limited difficulty stratification. A practical floor is 100 tasks after contamination filtering, stratified across at least three difficulty tiers. If filtering discards more than 60% of sourced tasks, the sourcing strategy needs to change, not just the sample size.

Can synthetic data generation solve the contamination problem?

Synthetic generation reduces string-level contamination but introduces a different risk: if the generator is a frontier model, its outputs reflect that model's training distribution. Tasks generated by a model are not independent of that model's knowledge. For evaluation purposes, synthetic tasks authored without expert verification also lack the difficulty calibration and domain validity that make a task a reliable signal.

How often should difficulty calibration be re-run?

Re-calibrate whenever a major new model family is released or when a model's training cutoff is close to the benchmark's creation date. A practical cadence for active eval sets is every 6-12 months, or after any model release that represents a step change in the relevant domain capability. Record the model version, scaffold, and date alongside every difficulty score.

What This Means in Practice

Contamination in code benchmarks is a solved problem in principle, even if not always in practice. The mechanisms are understood: provenance matters, difficulty drifts, and verifiers are part of the contamination surface. Non-code domains are inheriting the same failure modes without the same detection infrastructure. The path forward isn't more scraping or more synthetic generation. It's original task authoring by domain practitioners, empirical difficulty calibration against current models, and contamination audits that run before any score is reported, not after a result looks suspicious.

The domains with the least publicly available task corpora, manufacturing, structural engineering, PCB design, industrial controls, are the ones where contamination-resistant evals are most scarce and most valuable. That scarcity is the signal.

For more on how task provenance and difficulty calibration work in practice, see the Chiron Data Labs blog and the broader work on expert-authored evals. If you're building evals or RL environments in a non-code domain, get in touch with Chiron Data Labs.

© 2026 CHIRON, SAN FRANCISCO, CA