TL;DR
MemLens is a representation-level contamination detector that uncovers memorized benchmark problems in LLMs by tracking internal probability trajectories across layers. Unlike surface-level text-overlap or perplexity checks, MemLens detects "shortcut" reasoning inside the model—where memorized answers lock in prematurely within shallow layers—remaining robust even when problems are rephrased, translated, or perturbed.
What Problem Does This Paper Address?
Modern LLMs achieve impressive results on reasoning benchmarks like AIME, Math500, and MMLU. However, there is growing suspicion that these scores reflect data contamination and rote memorization rather than genuine multi-step reasoning.
Existing detection methods predominantly rely on:
- Verbatim completion tests (e.g., prompting the model with a problem prefix and checking if it completes the exact benchmark text).
- Surface-level distributional checks (e.g., perplexity or output agreement).
These baselines break down under implicit contamination: when test questions are paraphrased, translated, or slightly reworded, exact text-matching collapse entirely (often dropping detection rates below 20%). The authors aim to detect contamination based on how the model actually computes its answer internally, regardless of surface phrasing.
Methods
MemLens introduces an internal activation probe based on the logit lens, focusing specifically on numerical reasoning tasks:
- Layerwise Projection: At the token position where the final numerical answer is first generated, the residual stream activation $h_\ell$ at each layer $\ell$ is projected through the LM head to obtain layer-by-layer logit distributions over digits $\{0, \dots, 9\}$.
- Trajectory Feature Construction: For each layer, the authors compute:
- The normalized probability distribution over all 10 digits ($p_\ell(0..9)$)
- The digit entropy ($H_\ell$)
- The maximum confidence ($m_\ell = \max_d p_\ell(d)$)
- First-order layer-to-layer differences ($\Delta p_\ell, \Delta H_\ell, \Delta m_\ell$)
Stacking these yields a 24-channel temporal trajectory matrix $X \in \mathbb{R}^{24 \times T}$ representing how internal beliefs evolve over network depth $T$.
- Trajectory Discriminator: A lightweight 1D Convolutional Neural Network (3 Conv1D layers, hidden dimension 128, global average pooling) takes this 24-channel sequence and classifies whether the sample shows clean reasoning or memorized retrieval.
Residual stream h_ℓ ──► Logit Lens ──► 10 Digit Probs + Entropy + Confidence
│
Depth Differences (Δ)
│
24-Channel Trajectory (C x T)
│
1D CNN Classifier ──► Clean vs. Contaminated
Datasets
The authors evaluated four open-weight models: Qwen2.5-7B, Qwen2.5-Math-7B, Qwen-3-8B, and Llama-3.1-8B.
- Contaminated Sets: Sourced from historical math competitions that appeared before model training cutoffs—AIME (1983–2024) and Math500 (where the model outputs matched gold answers).
- Clean Sets: Benchmarks released after model pretraining cutoffs: AIME 2025, Minerva Math, and LiveMathBench.
- Robustness Variants: Generated via GPT-4o-mini across three transformations:
- Rephrased (paraphrased problem text, identical math meaning).
- Perturbed (minor syntax and lexical noise).
- Translated (French translation of non-LaTeX text).
- Downstream Benchmark: Evaluated zero-shot on the mathematics subset of MMLU.
Key Insights and Ideas
- The "Shortcut" Signature: Clean samples accumulate evidence gradually across depth; digit probabilities remain diffuse and entropy stays high until later layers. In contrast, contaminated samples exhibit premature "lock-on"—a single digit channel dominates aggressively within the first 10 layers.
- Memorization is a Dynamic, Not an Early Threshold: Simply thresholding early-layer confidence yields false positives because multiple digits can temporarily spike during normal reasoning. Distinguishing memorization requires analyzing the full evolution and competition of probabilities across all layers.
- Causal Validation via LoRA Injection: To prove that MemLens captures true memorization rather than dataset-specific artifacts, the authors fine-tuned a base model on clean problems using LoRA with increasing ranks ($r=8$ to $512$). As rank grew and the model memorized the target samples (pass@1 jumped from 17.8% to 78.5%), the predicted contamination rate monotonically scaled from 2.2% to 45.1%, confirming a direct causal link.
Key Results
- Robustness to Input Perturbations:
- On rephrased inputs for Qwen2.5-7B, exact completion detection dropped to 16.7%, while MemLens detected 63.1% of contaminated cases with only a 2.2% false-positive rate on clean data.
- On Llama-3.1-8B with rephrased inputs, completion detection fell to 4.3%, whereas MemLens sustained a 63.0% detection rate (clean FPR: 4.1%).
- Layer Importance:
- Ablations show that using only the first third of layers achieves 64.5%–68.7% F1, and the first half achieves 75.8%–81.4% F1. Using the full depth yields the best overall performance (88.9%–95.2% F1), corroborated by Grad-CAM peaks in early layers for contaminated samples.
- Audit on MMLU Math:
- MemLens flagged 94.9% of MMLU mathematics problems as "seen-like."
- Models performed significantly better on these flagged questions (+0.33 higher Top-1 accuracy and +0.23 higher MRR@6 compared to non-flagged questions), suggesting historical benchmark numbers may be heavily inflated by memorization.
Limitations and Future Work
- Domain-Specific Token Normalization: MemLens is currently formulated around digit token sets $\{0, \dots, 9\}$ for numerical and mathematical answers. Extending it to general open-ended reasoning, code, or non-numeric multiple-choice requires adapting vocabulary projection subsets.
- White-Box Requirement: Because MemLens inspects intermediate activations ($h_\ell$) via the logit lens, it cannot be run directly on proprietary black-box APIs (e.g., closed OpenAI or Anthropic models) without internal access.
- Generalization Across Architectures: While tested across LLaMA and Qwen models, classifiers were largely trained and tested per model family; zero-shot transfer of trajectory classifiers across completely disparate model architectures remains an open direction.
Summary updated