Code accompanying the paper Soft Contamination Means Benchmarks Test Shallow Generalization (anonymous, under review).
End-to-end research codebase for measuring soft contamination of LLM training data by semantic duplicates of benchmark test items, and for measuring how that contamination inflates downstream benchmark scores. Built around an OLMo3 case study.
Headline findings the code reproduces:
Requires Python ≥ 3.11 and uv.
# 1. Clone and enter
git clone <this-repo> SDTD && cd SDTD
# 2. Create the env and install
uv sync
# 3. Activate
source .venv/bin/activate # macOS/Linux
.venv\Scripts\Activate.ps1 # Windows PowerShell
# 4. Set API keys you need (see "Data & secrets" below)
cp .env .env.local && $EDITOR .env.local # then export from .env.local
Optional one-shot installers: setup.sh (macOS/Linux), setup.ps1 (Windows). Optional dev extras: uv pip install -e ".[dev]". Flash-attn (CUDA, Linux): uv pip install flash-attn --no-build-isolation.
Sub-projects with their own dependency specs (sdtd-llm-generation/pyproject.toml, finetuning/requirements.txt, pipeline/requirements.txt) are documented in their own READMEs.
SDTD/
├── sdtd-llm-generation/ Generate semantic duplicates of benchmark items (LLM-driven)
├── pipeline/ 6-stage embedding pipeline: scan OLMo3 corpora for high-cosine matches
├── comparison_analysis/ Sample · annotate (Gemini) · refine · classify · plot the matches
├── model_diffusion/ Tinker LoRA training of duplicate-detection classifiers
├── finetuning/ Controlled fine-tuning on exact / semantic / cosine-neighbor duplicates
├── ecology/ Ecologically valid contamination experiments + statistical tests
├── analysis_scripts/ Supporting tools: Anthropic-API analysis, S3 match resolution, dedup
├── utils/ Shared helpers: embedding mean-pool, n-gram similarity
├── pyproject.toml · uv.lock · setup.{sh,ps1}
├── make_submission_zip.sh
└── LICENSE · README.md
| Directory | Paper section | One-line summary |
|---|---|---|
sdtd-llm-generation/ | §3.1, App A.3 | Generate semantic duplicates at multiple "levels" for MBPP, MuSR, ZebraLogic, CodeForces |
pipeline/ | §3.2 | Embed Dolma3 / Dolmino / Dolci, find high-cosine matches to benchmark items |
comparison_analysis/ | §3.2, §4.2, Figs 2–6 | Annotate candidate matches with Gemini; train + apply classifier; render paper figures |
model_diffusion/ | §4.2 | Tinker LoRA fine-tune Qwen3-30B / GPT-OSS-20b duplicate-detection classifiers |
finetuning/ | §4.3, Tables 2–4 | Train OLMo3 on exact / semantic / cosine-neighbor splits; eval MBPP, MuSR, ZebraLogic |
ecology/ | §4.4, Tables 5, 11 | Realistic-rate contamination injected into Dolci; per-checkpoint eval; paired t-test, GLMM |
analysis_scripts/ | Supporting | Anthropic-API duplicate analysis, S3 match resolution, large-corpus dedup |
utils/ | Supporting | Shared helpers (embedding mean-pool, n-gram similarity) |
Every directory has a README.md. The two largest (comparison_analysis/, ecology/) are split into per-stage subdirs (e.g. annotation/, classifier/, plots/, data_prep/, training/, evaluation/), each with its own README.
Each block is the entry point for one experiment; subdirectory READMEs document configuration, hardware requirements, and outputs in detail.
cd sdtd-llm-generation && uv run python -m sdtd generate --dataset mbpp --level 1
bash pipeline/run_all.sh
python comparison_analysis/annotation/sample_for_annotation.py --benchmark mbpp
python comparison_analysis/annotation/annotate_semantic_duplicates.py --benchmark mbpp
python model_diffusion/train_mbpp_classifier.py
python comparison_analysis/plots/generate_all_plots.py
accelerate launch --num_processes 8 finetuning/mbpp/train_and_eval.py
python finetuning/musr/finetune_musr_mixed.py
python ecology/data_prep/sample_dolci.py
python ecology/data_prep/create_contaminated_dataset.py
python ecology/training/run_experiment_tinker.py --model meta-llama/Llama-3.1-8B
python ecology/evaluation/evaluate_contamination.py
No data ships with this repo. Pre-training and benchmark datasets must be downloaded from their original sources:
| Source | Where to get it |
|---|---|
| Dolma3, Dolmino, Dolci | allenai/OLMo on HuggingFace Hub |
| MBPP, HumanEval | HuggingFace Hub |
| CodeForces problems | open-r1/codeforces |
| MuSR | TAUR-Lab/MuSR |
| ZebraLogic | allenai/ZebraLogic |
API keys are read from environment variables. .env is gitignored — copy the placeholder file and fill in only the keys you need:
| Variable | Required for |
|---|---|
ANTHROPIC_API_KEY | analysis_scripts/ semantic-duplicate analysis |
GOOGLE_API_KEY / GEMINI_API_KEY | comparison_analysis/annotation/, comparison_analysis/refinement/ |
OPENROUTER_API_KEY | sdtd-llm-generation/, finetuning/musr/ |
TINKER_API_KEY | ecology/training/, model_diffusion/ |
HF_TOKEN | Gated HuggingFace models / datasets |
nvidia/llama-embed-nemotron-8b--model)bash make_submission_zip.sh
Produces ../SDTD_submission.zip. The script:
.env, virtualenvs, datasets, embeddings, model checkpoints, generated figures, logs, and caches.env still holds a non-placeholder API key@inproceedings{anonymous2026softcontamination,
title = {Soft Contamination Means Benchmarks Test Shallow Generalization},
author = {Anonymous},
booktitle = {International Conference on Machine Learning},
year = {2026}
}
Code accompanying the paper Soft Contamination Means Benchmarks Test Shallow Generalization (anonymous, under review).
End-to-end research codebase for measuring soft contamination of LLM training data by semantic duplicates of benchmark test items, and for measuring how that contamination inflates downstream benchmark scores. Built around an OLMo3 case study.
Headline findings the code reproduces:
Requires Python ≥ 3.11 and uv.
# 1. Clone and enter
git clone <this-repo> SDTD && cd SDTD
# 2. Create the env and install
uv sync
# 3. Activate
source .venv/bin/activate # macOS/Linux
.venv\Scripts\Activate.ps1 # Windows PowerShell
# 4. Set API keys you need (see "Data & secrets" below)
cp .env .env.local && $EDITOR .env.local # then export from .env.local
Optional one-shot installers: setup.sh (macOS/Linux), setup.ps1 (Windows). Optional dev extras: uv pip install -e ".[dev]". Flash-attn (CUDA, Linux): uv pip install flash-attn --no-build-isolation.
Sub-projects with their own dependency specs (sdtd-llm-generation/pyproject.toml, finetuning/requirements.txt, pipeline/requirements.txt) are documented in their own READMEs.
SDTD/
├── sdtd-llm-generation/ Generate semantic duplicates of benchmark items (LLM-driven)
├── pipeline/ 6-stage embedding pipeline: scan OLMo3 corpora for high-cosine matches
├── comparison_analysis/ Sample · annotate (Gemini) · refine · classify · plot the matches
├── model_diffusion/ Tinker LoRA training of duplicate-detection classifiers
├── finetuning/ Controlled fine-tuning on exact / semantic / cosine-neighbor duplicates
├── ecology/ Ecologically valid contamination experiments + statistical tests
├── analysis_scripts/ Supporting tools: Anthropic-API analysis, S3 match resolution, dedup
├── utils/ Shared helpers: embedding mean-pool, n-gram similarity
├── pyproject.toml · uv.lock · setup.{sh,ps1}
├── make_submission_zip.sh
└── LICENSE · README.md
| Directory | Paper section | One-line summary |
|---|---|---|
sdtd-llm-generation/ | §3.1, App A.3 | Generate semantic duplicates at multiple "levels" for MBPP, MuSR, ZebraLogic, CodeForces |
pipeline/ | §3.2 | Embed Dolma3 / Dolmino / Dolci, find high-cosine matches to benchmark items |
comparison_analysis/ | §3.2, §4.2, Figs 2–6 | Annotate candidate matches with Gemini; train + apply classifier; render paper figures |
model_diffusion/ | §4.2 | Tinker LoRA fine-tune Qwen3-30B / GPT-OSS-20b duplicate-detection classifiers |
finetuning/ | §4.3, Tables 2–4 | Train OLMo3 on exact / semantic / cosine-neighbor splits; eval MBPP, MuSR, ZebraLogic |
ecology/ | §4.4, Tables 5, 11 | Realistic-rate contamination injected into Dolci; per-checkpoint eval; paired t-test, GLMM |
analysis_scripts/ | Supporting | Anthropic-API duplicate analysis, S3 match resolution, large-corpus dedup |
utils/ | Supporting | Shared helpers (embedding mean-pool, n-gram similarity) |
Every directory has a README.md. The two largest (comparison_analysis/, ecology/) are split into per-stage subdirs (e.g. annotation/, classifier/, plots/, data_prep/, training/, evaluation/), each with its own README.
Each block is the entry point for one experiment; subdirectory READMEs document configuration, hardware requirements, and outputs in detail.
cd sdtd-llm-generation && uv run python -m sdtd generate --dataset mbpp --level 1
bash pipeline/run_all.sh
python comparison_analysis/annotation/sample_for_annotation.py --benchmark mbpp
python comparison_analysis/annotation/annotate_semantic_duplicates.py --benchmark mbpp
python model_diffusion/train_mbpp_classifier.py
python comparison_analysis/plots/generate_all_plots.py
accelerate launch --num_processes 8 finetuning/mbpp/train_and_eval.py
python finetuning/musr/finetune_musr_mixed.py
python ecology/data_prep/sample_dolci.py
python ecology/data_prep/create_contaminated_dataset.py
python ecology/training/run_experiment_tinker.py --model meta-llama/Llama-3.1-8B
python ecology/evaluation/evaluate_contamination.py
No data ships with this repo. Pre-training and benchmark datasets must be downloaded from their original sources:
| Source | Where to get it |
|---|---|
| Dolma3, Dolmino, Dolci | allenai/OLMo on HuggingFace Hub |
| MBPP, HumanEval | HuggingFace Hub |
| CodeForces problems | open-r1/codeforces |
| MuSR | TAUR-Lab/MuSR |
| ZebraLogic | allenai/ZebraLogic |
API keys are read from environment variables. .env is gitignored — copy the placeholder file and fill in only the keys you need:
| Variable | Required for |
|---|---|
ANTHROPIC_API_KEY | analysis_scripts/ semantic-duplicate analysis |
GOOGLE_API_KEY / GEMINI_API_KEY | comparison_analysis/annotation/, comparison_analysis/refinement/ |
OPENROUTER_API_KEY | sdtd-llm-generation/, finetuning/musr/ |
TINKER_API_KEY | ecology/training/, model_diffusion/ |
HF_TOKEN | Gated HuggingFace models / datasets |
nvidia/llama-embed-nemotron-8b--model)bash make_submission_zip.sh
Produces ../SDTD_submission.zip. The script:
.env, virtualenvs, datasets, embeddings, model checkpoints, generated figures, logs, and caches.env still holds a non-placeholder API key@inproceedings{anonymous2026softcontamination,
title = {Soft Contamination Means Benchmarks Test Shallow Generalization},
author = {Anonymous},
booktitle = {International Conference on Machine Learning},
year = {2026}
}