Entity Swaps with a Clean Control: Detecting Benchmark Contamination That Survives Reinforcement Learning

When a language model scores well on a public test set, we usually cannot tell whether it solved the problems or recalled them from its training data. The standard contamination detectors look for signs that a model has seen a test item, for example unusually high confidence on its exact wording. These detectors stop working on today's reasoning models. After a round of reinforcement learning (RL) fine-tuning, the confidence gap between seen and unseen questions collapses, and ten representative detectors fall to near-chance accuracy (On The Fragility of Benchmark Contamination Detection in Reasoning Models). This proposal stops asking how confident the model is. It asks something more direct: does the model's correct answer depend on the particular names in the problem? A word problem about "Josh" buying lumber should be exactly as solvable when Josh becomes "Priya" and the lumber yard gets a different name. If accuracy drops sharply when only the names change, that suggests the model is keying on a remembered string.

Swapping names is not new. Robustness work already shows that reasoning models are fragile to exactly such substitutions, including models with no reason to be contaminated. The contribution here is a measurement design that separates the two explanations. We compare the accuracy drop under name swaps on a suspect benchmark with the drop under the same swaps on structurally matched problems the model cannot have seen. The excess drop is our contamination signal. We ask whether it holds at the level of single items, whether it survives RL cloaking, and whether it can separate contamination anchored on entities from contamination anchored on templates.

Core Claim

We claim that a controlled "difference-in-differences" on type-preserving entity substitution detects benchmark contamination in RL-post-trained reasoning models where log-probability detectors fail. Here, type-preserving means a person's name is replaced by another person's name, and a company by another company. Crossed with a paraphrase perturbation that leaves the entities in place, the same design attributes inflated scores to one of two sources. The first is recall anchored on entities, where the memorized answer is keyed to surface names. The second is recall anchored on templates, where the memorized answer is keyed to the problem's wording and structure. For a benchmark item $i$, let $a_i$ be the model's accuracy on the original item over repeated samples, and $\bar a_i^{\text{swap}}$ its mean accuracy over $K$ independent entity swaps. The per-item swap drop is $s_i = a_i - \bar a_i^{\text{swap}}$. Let $S_{\text{ctrl}}$ be the distribution of the same quantity on control items that are known to be unseen and matched for difficulty and entity density. The contamination score is then

$$c_i = s_i - \mathrm{median}(S_{\text{ctrl}}),$$

and the benchmark-level inflation estimate is the mean of $c_i$ over items. Subtracting the control is what turns a robustness measurement into a contamination measurement. A model that is fragile to names in general loses accuracy on both sets, so the fragility cancels. What remains is the part of the swap drop that appears only on items the model may have memorized.

Where This Sits in Prior Work

Two findings from the entity-memorization literature motivate the approach. Both show that models lean on remembered entity strings much more than on context. A Rigorous Study on Named Entity Recognition replaces entity mentions with random strings and loses 34% F1, and it finds that learning from context plateaus after about 30% of the training data. Rethinking Generalization of Neural Models reports 10 to 20 point gaps between entities seen and unseen during training. Both studies concern sequence labeling with fine-tuned encoders, not contamination. Their central move is to split the test set by whether the entity was seen, and we carry that move into contamination auditing.

A mechanistic result supplies the reason to expect entity swaps to expose recall even when reasoning ability is intact. Reason to Rote finds, in small synthetic transformers, that intermediate layers compute the correct answer and that memorized labels overwrite it only in the final layers. The memorized output is attached to specific inputs. If the key is removed, the shared reasoning circuit should be what produces the answer. Data Contamination: From Memorization to Exploitation shows in BERT that memorizing test data does not by itself inflate task accuracy: about 15% memorization coexisted with under 1% exploitation. This constrains our target. We measure exploitation, meaning performance that depends on the seen item, because exploitation is what inflates scores.

Three papers already use entity substitution, and they are our closest neighbours. TripleFact replaces real entities with fictional ones in fake-news benchmarks and shows that this reduces contamination-driven inflation. It uses substitution as a defense for one classification task, not as a detector with a control condition. MSCR replaces names and nonessential words in GSM8K and MATH500 and reports large drops, for example 15.88% for OpenAI-o3 and 49.89% for Qwen2.5-Math-1.5B-Instruct, along with responses up to 2.14 times longer. MSCR frames this as an attack, and its numbers are the central confound for us, since drops of that size occur whether or not a model is contaminated. The type swaps of the Globally Normalized Reader substitute same-type Wikidata entities as a training augmentation for reading comprehension. We reuse that substitution procedure as a test-time probe.

On the contamination side, ConStat is the method closest in spirit. It also defines contamination as performance that fails to generalize, and it measures that performance against rephrased reference benchmarks, calibrated across a fleet of reference models. CAP compares how consistently a model answers under option shuffles and paraphrases. PAC calibrates membership inference with perturbed neighbour samples. None of the three controls for entity fragility with unseen matched items, and none separates entity anchoring from template anchoring. The fragility paper constrains the whole design: any detector built on the log-probability gap should be expected to fail after RL, so our signal must come from correctness and behaviour rather than from likelihood.

Research Program

The first component is a substitution engine. Named entities in each benchmark item are identified and linked to types. Each entity is then replaced by a same-type substitute drawn from one of three popularity tiers: frequent real names, rare real names taken from long-tail gazetteers in the style of MultiCoNER, and fictional names in the style of TripleFact. Replacements are consistent throughout the item. Numbers, units, and logical structure are left untouched, so the gold answer is unchanged. An automatic check confirms that the answer still holds, for instance by re-solving arithmetic items symbolically, and a sample is checked by hand. Only benchmarks where entities are nuisance variables qualify: math word problems and reading comprehension in which the passage and the question are swapped together. Knowledge benchmarks such as MMLU are excluded, because there the entity is often the answer.

The second component is the control set. In controlled experiments, the control is the held-out half of the same benchmark, which gives an exact distributional match. For auditing released models in the wild, the control consists of problems written after each model's training cutoff in the same style. LiveBench-style post-cutoff math is one source, along with newly written GSM-style items. These controls are matched to the suspect items on baseline accuracy and on the number of swappable entities. The mismatch that remains is a known weakness, and we quantify it by sensitivity analysis.

The third component is a 2×2 design in which entity swapping and entity-preserving paraphrase are crossed. If a model's inflation vanishes under entity swaps but survives paraphrase, its recall is anchored on entities. If the reverse holds, its recall is anchored on templates. If only the combination removes the inflation, the model is keyed on both. As a secondary behavioural signal, we record the ratio of response length on swapped items to response length on original items, because MSCR reports that entity perturbations inflate chain-of-thought length. We test whether the excess length relative to the control set carries information beyond accuracy.

Baselines

The naive reference point is to do nothing, which means reporting raw benchmark accuracy and treating it as uncontaminated. Next is the uncontrolled entity-swap drop, which is MSCR's measurement read as a contamination score. This ablation is decisive for the proposal's central ingredient. If $s_i$ without the control subtraction detects contamination as well as $c_i$ does, the control set adds nothing and the idea reduces to MSCR. We therefore run both on identical swaps.

The log-probability detectors are Min-K%, loss thresholding, and LiRA, plus PAC as the strongest calibrated membership method. These are the detectors the fragility paper shows collapsing. Its reported numbers are the bar to beat: one epoch of GRPO lowered LiRA AUROC by about 14% and loss detection by about 16%, and under chain-of-thought contamination the ten baseline detectors averaged 50 to 58% AUROC (On The Fragility of Benchmark Contamination Detection in Reasoning Models). We run all of them on exactly the same contaminated checkpoints and item splits as our method, using released implementations with default hyperparameters. Any threshold tuning happens on a shared validation split.

The strongest existing competitor is ConStat. It is also performance-based, so the fragility paper's argument does not obviously defeat it, and it was built to detect scores that fail to generalize. In controlled settings it detected 89% of syntax-contaminated models and 98% of sample-contaminated models, and in the wild it estimated δ ≈ 8.2% for Mistral-7b-v0.1 on GSM8k (ConStat). ConStat operates at the level of whole benchmarks. We found no reported item-level result on Lacuna for ConStat, and none for ConStat after RL post-training. We run it at benchmark level using a reference fleet of the same models we evaluate. We also build a per-item variant, which scores each item by the accuracy drop on its rephrasing, so that the comparison is item-level for both methods. CAP's consistency ratio is included as a second paraphrase-based competitor. Our method counts as beating these competitors if it reaches clearly higher item-level AUROC after RL, with non-overlapping bootstrap intervals, while matching ConStat's benchmark-level verdicts. Matching ConStat at benchmark level without beating it at item level would not count as a win. In that case the contribution would shrink to attribution and to removing the need for a reference fleet.

Why not just…?

Why not just paraphrase the benchmark, as ConStat and CAP do? Paraphrase changes the wording but leaves the entity strings intact. The NER evidence (A Rigorous Study on Named Entity Recognition) suggests that entity strings are the main shortcut. ConStat itself needs a hardness correction because paraphrasing shifts difficulty unpredictably. Name swaps with fixed numbers and structure should shift difficulty less, and the control set measures whatever shift remains. The threat is still real. If paraphrase alone catches everything entity swaps catch, the 2×2 design will show it: the entity-swap main effect will be empty, and we will report that contamination in these benchmarks is anchored on templates.

Why not just take MSCR's swap drop as the signal? MSCR's own numbers show large drops for frontier models, so fragility to names is common and not specific to contamination. Without a control, a fragile clean model would look contaminated, and a robust contaminated model would look clean. The uncontrolled ablation in our Baselines tests this directly.

Why not just use membership inference? After GRPO, and under chain-of-thought contamination, these methods sit near chance (On The Fragility of Benchmark Contamination Detection in Reasoning Models). Even before RL, memorization is only loosely tied to score inflation (Data Contamination: From Memorization to Exploitation). We include these methods as baselines rather than argue against them in advance.

Why not just switch to fresh benchmarks like LiveBench or BeyondBench? Fresh benchmarks avoid future contamination, but they cannot tell us which past scores were inflated. They also require continual curation, which LiveBench acknowledges is costly. Our method reuses their post-cutoff items as its control, so the two approaches work together.

Proposed Experiments

The controlled study follows the fragility paper's setting, using Qwen2.5-7B and DeepSeek-R1-Distill-Llama-8B. We supervise-fine-tune each model on a random half of the GSM8K test set, MATH500 word problems, and AIME and AMC problems that contain named entities. Contamination is injected at 1 and at 10 duplicates, with and without chain-of-thought solutions. We then apply one epoch of GRPO. The other half of each benchmark serves as the control, which gives exact ground truth. Each item receives $K = 16$ swaps in each popularity tier and 8 samples per variant. The metrics are item-level AUROC, benchmark-level detection, and how well the estimated inflation matches the true inflation, which is known in this setting. For calibration, the fragility paper reports that supervised contamination inflated pass@1 by 8.8% on average. As a stress test, we add a condition in which contamination is injected as type-swapped copies, imitating an entity-varied rephrasing on the web. We expect our signal to weaken in this condition and will measure by how much.

Three results would settle the proposal. First, $c_i$ must stay well above chance after GRPO while the log-probability detectors fall to their reported 50 to 58% range. If $c_i$ also collapses, the core claim fails. Second, $c_i$ must beat the uncontrolled drop $s_i$ on fragile models, especially the smaller ones. Otherwise the control set is unnecessary. Third, the 2×2 attribution must recover the injected type, whether entity-varied or verbatim contamination. A secondary check concerns popularity. The excess drop on contaminated items should appear across all three substitute tiers, whereas the drop on control items should be modest and depend on the tier. This dissociation would indicate that the signal reflects removal of a memorized key rather than unfamiliarity with the new names.

For the in-the-wild audit, we apply the method to released models with post-cutoff controls. Mistral-7b-v0.1 on GSM8K is the anchor case: our benchmark-level estimate should agree in sign and rough size with ConStat's δ ≈ 8.2%, and we additionally report which items and which anchoring type drive the inflation. Disagreement with ConStat on flagged models would be reported as a finding, and control-set sensitivity analyses would determine which estimate to trust.