LaRA: Layer-wise Representation Analysis for Detecting Data Contamination in RL Post-Training

Minju Gwak, Minseo Kwak, Guijin Son, Alan Ritter, Jaehyung Kim

TL;DR

LaRA (Layer-wise Representation Analysis) is a new framework that detects data contamination in RL-trained LLMs by looking at internal hidden states rather than just final text outputs. By measuring how "stiff" or "rigid" a model's internal geometry becomes when processing specific samples, LaRA identifies memorized training data with significantly higher stability and accuracy than traditional methods like perplexity or entropy.

What Problem Does This Paper Address?

As we push Large Language Models (LLMs) to reason better using Reinforcement Learning (RL), we face a growing "honesty" problem: data contamination. This happens when a model implicitly memorizes its evaluation benchmarks during the RL post-training phase, leading to inflated performance scores that don't reflect actual reasoning ability.

Detecting this is notoriously difficult. Standard "Membership Inference Attacks" (MIAs) usually rely on output-level signals like token likelihood (how "surprised" the model is by a sequence). However, RL optimizes for rewards, not just next-token prediction. This makes output-level signals unstable and easily confounded by "policy collapse," where a model becomes overconfident in certain paths regardless of whether it has seen the data before. The authors argue that to find the truth, we need to look under the hood at the model's internal representation geometry.

Methods

The authors propose LaRA, which treats contamination detection as a layer-aware anomaly detection task. Instead of looking at what the model says, LaRA looks at how its internal layers react to controlled perturbations.

The process involves a three-stage pipeline:

  1. Perturbation Generation: For a given question, the system generates semantically similar "neighbor" questions and "blanked" versions where key information (like specific numbers) is removed.
  2. Representation Extraction: The model processes these variants, and the hidden states are captured across all transformer layers.
  3. Geometric Metric Calculation: LaRA computes three novel metrics:
  4. Representation Shift Magnitude (RSM): Measures how much the internal state "jolts" when key info is removed. Contaminated samples are hypersensitive to this.
  5. Directional Collapse (DC): Measures if the model's internal changes follow a predictable, low-dimensional path.
  6. Representation Stability Index (RSI): Measures "stiffness"—how much the internal state fluctuates when the question is simply paraphrased.

Finally, these signals are aggregated using a Layer-aware Detection Protocol that standardizes the scores against a "clean reference" set using robust statistics (Median Absolute Deviation).

Datasets

The study focused on high-level reasoning models:

  • Models: Eurus-2-7B-PRIME (built on Qwen2.5-Math-7B) and LIMR.
  • Contamination Eval Set: A balanced set of 60 samples. "Members" (contaminated) were drawn from the PRIME-RL training data, while "Non-members" (clean) were drawn from the AIME 2026 mathematics competition.
  • Training/Analysis Set: Approximately 1K samples from the RL-MIA Math dataset, used to observe how contamination signals evolve across different RL training epochs.

Key Insights and Ideas

  • The "Distributed" Nature of Memory: Contamination isn't a "smoking gun" found in a single layer. It manifests as a distributed geometric shift across the entire network depth.
  • Geometric Rigidity: The "Aha!" moment of the paper is that memorized samples exhibit a unique kind of "stiffness." They are locally invariant to paraphrasing (RSI) but react violently to the removal of specific memorized facts (RSM).
  • RL Changes Everything: The researchers found that RL training reshapes the internal geometry of all samples, even clean ones. This means absolute thresholds for detection don't work; you must compare a suspect sample's geometry to a "clean reference" profile of how the model usually behaves.
  • Output vs. Internal: Output-level signals (like entropy) often "dip" or become unreliable mid-training, while LaRA’s representation-level signals remain stable across different checkpoints and epochs.

Key Results

LaRA consistently outperformed existing baselines, especially when the goal was to keep "false alarms" (False Positive Rate) very low.

  • Superior Detection: When combined with the strongest existing baseline (Self-Critique), LaRA achieved an ROC-AUC of 0.79 and a True Positive Rate of 31-38% at a 5% False Positive Rate.
  • Stability: Traditional likelihood-based methods (like Min-K% or PPL) often collapsed toward random guessing in the RL setting. In contrast, LaRA remained competitive across all RL checkpoints.
  • Complementary Power: The results show that internal geometry captures "memorization signatures" that are invisible in the final generated reasoning trajectories, making it a vital second opinion for model auditing.

Limitations and Future Work

The authors acknowledge a few hurdles:

  • Computational Overhead: Because LaRA requires multiple forward passes (for paraphrases and perturbations) across all layers, it is more "expensive" than simple perplexity checks.
  • Dual-Use Risks: While intended for auditing, these techniques could theoretically be inverted to create stronger membership inference attacks, raising privacy concerns.
  • Reference Dependence: The framework relies on having a small set of known "clean" data to build a behavioral baseline, which might not always be available for closed-source models.

Future work may involve scaling these geometric analyses to even larger models and exploring if "representation stiffness" can be used to prevent contamination during the training process itself.

Summary updated

BibTeX
@inproceedings{gwak2026lara,
  author = {Minju Gwak and Minseo Kwak and Guijin Son and Alan Ritter and Jaehyung Kim},
  title = {{LaRA: Layer-wise Representation Analysis for Detecting Data Contamination in RL Post-Training}},
  booktitle = {AI4GOOD @ ICML},
  year = {2026},
  url = {https://openreview.net/forum?id=YfFRMts4R2},
}
Figure