Context-Aware Membership Inference Attacks against Pre-trained Large Language Models

Hongyan Chang, Ali Shahin Shamsabadi, Kleomenis Katevas, Hamed Haddadi, Reza Shokri

Abstract

This paper introduces CAMIA, a novel Membership Inference Attack (MIA) designed to identify whether specific text was used to train a Large Language Model (LLM). By shifting the focus from overall sequence loss to token-level dynamics—specifically how a model’s uncertainty resolves as it processes a "prefix"—the authors achieve significantly higher detection rates than previous state-of-the-art methods without requiring expensive reference models.

Introduction

Membership Inference Attacks (MIAs) are a primary tool for auditing privacy in machine learning, answering the question: "Was this specific data point part of your training set?" While MIAs work well for classification models, they have historically struggled with LLMs due to two major hurdles:

  1. Generative Complexity: LLMs predict text token-by-token, and the difficulty of a prediction changes based on the preceding context (the prefix). Standard attacks that average loss across a whole sequence ignore these fine-grained dynamics.
  2. The Reference Model Trap: Many top-tier MIAs require training "reference models" on similar data to calibrate scores. For massive LLMs, this is computationally prohibitive and often impractical.

Methodology: The CAMIA Approach

The core philosophy of CAMIA (Context-Aware Membership Inference Attack) is that memorization is "triggered" when a prefix is ambiguous or complex. If a model cannot generalize the next token from the context, it is more likely to fall back on a memorized sequence from its training set.

CAMIA extracts several "context-aware" signals from the token-level loss:

  • Token Diversity Calibration: Penalizes repetitive text which naturally has low loss regardless of membership.
  • Filtering (Cut-off Loss): Focuses on the first few tokens of a sequence where the membership signal is strongest.
  • Loss Decreasing Rate (Slope): Measures how quickly uncertainty drops as the model sees more of the prefix.
  • Text Repetition Amplification: Uses repeated input text to differentiate between in-situ learning (non-members) and prior knowledge (members).
  • Fluctuation Metrics: Employs information-theoretic measures like Approximate Entropy to detect the stability of predictions.

These signals are combined using a hypothesis-testing framework or simple logistic regression to determine membership.

Key Insights and Ideas

A critical finding is that memorization is context-dependent. The membership signal is not uniform across a sequence; it is strongest when the model has the least context. As the prefix grows longer and becomes "uniquely identifying" through generalization, the gap between members and non-members vanishes.

Next-token loss dynamics for members vs non-members as a function of token index from the beginning and end of a sequence.

Furthermore, the authors found that no single signal works best everywhere. Diversity calibration is vital for repetitive data like GitHub code, while the "slope" of the loss is more effective for academic papers (Arxiv). Combining these signals makes CAMIA robust across domains.

Experimental Results

The study utilized the MIMIR benchmark, evaluating MIAs across seven domains from the Pile dataset (e.g., Wikipedia, GitHub, Arxiv) against model families like Pythia and GPT-Neo.

CAMIA consistently outperformed existing baselines (LOSS, Zlib, Min-K%) across almost all domains and model sizes:

  • Arxiv (Pythia 2.8B): CAMIA achieved a 32% True Positive Rate (TPR) at a strict 1% False Positive Rate (FPR), nearly doubling the performance of the standard LOSS baseline (~15%).
  • GitHub: The attack was particularly potent, reaching over 63% TPR at 1% FPR.
Distribution of calibrated loss for members and non-members on the GitHub dataset, demonstrating a high True Positive Rate at a 1% False Positive Rate.

Beyond accuracy, CAMIA is computationally efficient. It can evaluate 1,000 samples in about 38 minutes on a single A100 GPU—roughly 13x faster than "Neighborhood" attacks that require multiple model queries.

Discussion and Future Work

While CAMIA represents a significant advancement, limitations remain. The evaluation was limited to English-heavy datasets, and proprietary models like GPT-4 were excluded due to unknown training sets. Future work will focus on extending CAMIA to evaluate fine-tuned models and downstream applications where privacy risks may be even more acute.

Summary updated

BibTeX
@misc{chang2024context,
  author = {Hongyan Chang and Ali Shahin Shamsabadi and Kleomenis Katevas and Hamed Haddadi and Reza Shokri},
  title = {{Context-Aware Membership Inference Attacks against Pre-trained Large Language Models}},
  year = {2024},
  eprint = {2409.13745},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.13745},
}
Figure