Abstract: Membership Inference Attacks (MIA) are essential for auditing Large Language Models (LLMs) for data leakage, yet most existing methods require internal model probabilities unavailable in commercial "black-box" APIs. We present SaMIA (Sampling-based Membership Inference Attack), which utilizes Sampling-based Pseudo-Likelihood (SPL) to estimate memorization through generated text analysis. By comparing model-generated continuations to target references via n-gram recall, SaMIA achieves performance competitive with state-of-the-art white-box methods.
Introduction
As LLMs are increasingly trained on massive, often proprietary or sensitive datasets, the ability to detect whether specific content was included in training—Membership Inference—has become a critical privacy and copyright concern. Traditional MIA techniques rely on the model's internal likelihood scores, assuming higher probabilities for training data. However, for proprietary models like GPT-4 or Claude, these scores are hidden. SaMIA bridges this gap by treating the model as a generative black box.
The SaMIA Framework
The core innovation of SaMIA is Sampling-based Pseudo-Likelihood (SPL). The method operates on the principle that if a model has memorized a sequence, it is highly likely to reproduce that sequence when prompted with its beginning.
The process involves four key steps:
- Splitting: The target text is divided into a prompt (prefix) and the expected continuation (reference).
- Sampling: The LLM generates multiple candidate continuations from the prefix.
- Comparison: The algorithm calculates the ROUGE-N recall between the generated candidates and the reference.
- Scoring: High average n-gram matches indicate a high likelihood of training set inclusion. An enhanced version, SaMIA*zlib, incorporates a compression factor to normalize scores for naturally repetitive text.
Experimental Evaluation
The authors evaluated SaMIA against open-weight models (OPT-6.7B and LLaMA-2) using the WikiMIA and BookTection benchmarks. These datasets provide a clear ground truth by distinguishing between content published before and after the models' training cutoffs.
Key Results and Discussion
SaMIA demonstrates that generative recall is a robust proxy for internal likelihood. Notably, simple unigram matches (ROUGE-1) often provide a cleaner signal for memorization than higher-order n-grams.
As shown in the results, SaMIA and SaMIA*zlib consistently outperform or match traditional "white-box" methods like LOSS and Min-K%++, particularly as the length of the target text increases. At a length of 256 tokens, SaMIA achieves an AUC of 0.80 on OPT-6.7B, significantly exceeding baseline performance. Furthermore, the attack stabilizes with as few as 5–10 samples, making it computationally efficient for API-based auditing.
Conclusion
SaMIA provides a powerful, mathematically grounded tool for auditing black-box LLMs. By shifting the focus from internal probabilities to observable generative behavior, it enables researchers to detect data leakage in the very models where transparency is most lacking. Future work will explore extending these techniques to detect paraphrased content and non-verbatim memorization.
Summary updated