Con-ReCall: Detecting Pre-training Data in LLMs via Contrastive Decoding

Cheng Wang, Yiwei Wang, Bryan Hooi, Yujun Cai, Nanyun Peng, Kai-Wei Chang

Abstract: The training data in large language models is key to their success, but it also presents privacy and security risks, as it may contain sensitive information. Detecting pre-training data is crucial for mitigating these concerns. Existing methods typically analyze target text in isolation or solely with non-member contexts, overlooking potential insights from simultaneously considering both member and non-member contexts. While previous work suggested that member contexts provide little information due to the minor distributional shift they induce, our analysis reveals that these subtle shifts can be effectively leveraged when contrasted with non-member contexts. In this paper, we propose Con-ReCall, a novel approach that leverages the asymmetric distributional shifts induced by member and non-member contexts through contrastive decoding, amplifying subtle differences to enhance membership inference. Extensive empirical evaluations demonstrate that Con-ReCall achieves state-of-the-art performance on the WikiMIA benchmark and is robust against various text manipulation techniques.

Introduction

As Large Language Models (LLMs) are trained on trillions of tokens from the open web, they inevitably memorize sensitive information, including personally identifiable information (PII), copyrighted books, and benchmark questions. Detecting this memorization is the goal of Membership Inference Attacks (MIA).

The primary challenge in MIA is that for massive models, the behavioral difference between a "seen" (member) string and an "unseen" (non-member) string is often incredibly subtle. Previous methods either analyzed text in isolation or compared it only against "non-member" contexts, largely ignoring "member" contexts under the assumption they provided too little signal. Con-ReCall challenges this assumption, proving that these subtle signals are the key to high-accuracy detection when properly contrasted.

Methodology: Contrastive Decoding

The core of Con-ReCall is a scoring function based on Contrastive Decoding. Standard MIA methods might rely solely on the log-likelihood ($LL$) of a sequence. In contrast, Con-ReCall exploits the asymmetric distributional shift caused by different prefixes.

Comparison of membership inference architectures: (a) standard log-likelihood loss, (b) ReCall using non-member prefixes, and (c) the proposed Con-ReCall using contrastive decoding between member and non-member prefixes.

Con-ReCall calculates a membership score $s(x, M)$ for a text $x$ and model $M$ as:

$$s(x, M) = \frac{LL(x|P_{\text{non-member}}) - \gamma \cdot LL(x|P_{\text{member}})}{LL(x)}$$

  • $P_{\text{non-member}}$: A prefix known not to be in the training set (e.g., news from after the model's cutoff).
  • $P_{\text{member}}$: A prefix known to be in the training set.
  • $\gamma$: A hyperparameter controlling the strength of the contrast.

By subtracting the weighted log-likelihood of the member-prefixed text from the non-member-prefixed version, the method amplifies the membership signal. For scenarios where the original training data is unavailable, the authors propose a "Zero-Access" workaround: using a model like GPT-4o to generate descriptions of historical events from before the target model's cutoff, then using the target model itself to complete those descriptions to create "approximated" member prefixes.

Key Insights

The effectiveness of Con-ReCall is driven by three key observations:

  1. Asymmetric Shift Direction: Member data is "stable" when prefixed with other member data, but its likelihood drops significantly when prefixed with non-member data. Non-member data does not exhibit this specific pattern of stability.
  2. Intensity of Jitter: Non-member data is generally more sensitive to any contextual modification—it is "jittery," whereas member data is more "anchored" to its original context.
  3. Contrast is King: While a member prefix alone might provide limited information, the difference in how a model reacts to member vs. non-member prefixes is a much stronger indicator of membership.

Experimental Results

Con-ReCall was evaluated on two primary benchmarks: WikiMIA (Wikipedia articles split by knowledge cutoff) and MIMIR (a strict train-test split from the Pile dataset).

ROC curves on the WikiMIA benchmark, demonstrating that Con-ReCall (Our Method) achieves a superior AUC of 0.961 compared to existing baselines.

On the WikiMIA benchmark, Con-ReCall achieved an average AUC improvement of 6.6% over the previous state-of-the-art (ReCall). In security-critical contexts, it outperformed the runner-up by a massive 30.8% in True Positive Rate at a 5% False Positive Rate (TPR@5%FPR).

Furthermore, the method proved highly robust. It maintained high accuracy even when 20% of the target text's words were randomly deleted or replaced with synonyms, or when the entire text was paraphrased by another LLM.

Limitations and Future Work

Con-ReCall requires "gray-box" access, meaning it needs the model to output token-level probabilities; it cannot be used on black-box APIs that only return raw text. Additionally, performance is contingent on selecting effective prefixes. While the approximation method is a significant step forward, automating the selection of optimal prefixes for any given model remains an open research question.

Summary updated

BibTeX
@inproceedings{wang2025con,
  author = {Cheng Wang and Yiwei Wang and Bryan Hooi and Yujun Cai and Nanyun Peng and Kai-Wei Chang},
  title = {{Con-ReCall: Detecting Pre-training Data in LLMs via Contrastive Decoding}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=DXHXSJAGgm},
}
Figure