TL;DR
The N-GRAM COVERAGE ATTACK is a highly effective, fully black-box membership inference attack that determines whether a text document was used to train a language model using only the model's text outputs. Despite lacking access to internal token probabilities or logits, this simple approach matches or even outperforms state-of-the-art white-box attacks while being significantly more compute-efficient than existing black-box alternatives.
What Problem Does This Paper Address?
Auditing large language models (LLMs) for data leakage, privacy violations, or copyright infringement typically relies on Membership Inference Attacks (MIAs)—techniques that guess whether a specific document was part of a model's training data.
Most top-performing MIAs are "white-box," meaning they require access to the model's internal state, such as token logits or loss values. However, the most widely used commercial models (like GPT-4) are strictly "black-box," accessible only via text-generation APIs. Existing black-box MIAs either perform poorly, require expensive external paraphrasing models, or assume the target model is an exceptionally compliant question-answering system. The authors bridge this gap by designing a powerful, low-cost MIA that operates entirely on surface-form text outputs.
Methods
The core intuition behind the N-GRAM COVERAGE ATTACK is simple: language models are far more likely to generate verbatim or highly similar text patterns if they memorized them during training.
As illustrated in Figure 1, the attack operates in four straightforward steps:
- Prefix Extraction: Take a candidate document and split it, using the first half (e.g., 50%) as a prompt prefix.
- Diverse Generation: Prompt the target model multiple times ($d$ generations) to complete the text based on the prefix.
- N-Gram Similarity Evaluation: Compare the model's generated completions against the hidden ground-truth suffix using simple n-gram overlap metrics (such as standard Coverage, a length-normalized Creativity Index, or Longest Common Substring).
- Aggregation: Aggregate these similarity scores across all generations (typically using the
maxfunction). If the maximum similarity exceeds a predefined threshold, the document is flagged as a training set "member."
Datasets
The authors evaluated their method across several benchmarks, including two newly introduced datasets designed to address limitations in existing evaluations:
- BookMIA & WikiMIA: Standard benchmarks consisting of book snippets and Wikipedia articles split by temporal boundaries (pre- vs. post-training cutoffs).
- WikiMIA2024 Hard (New): A challenging new dataset pairing older versions of Wikipedia articles (likely training members) with post-2024 edited versions of the exact same articles (non-members). This eliminates topical confounding factors present in the original WikiMIA.
- TÜLU Mix (New): A dataset constructed to specifically evaluate membership inference against fine-tuning data rather than pre-training data.
Key Insights and Ideas
- Surface Text as a Logit Proxy: Simple n-gram overlaps of raw text outputs serve as a surprisingly robust proxy for internal model likelihoods. You don't need access to complex probability distributions to see what a model has memorized.
- Performance Scales with Compute: The attack's accuracy scales predictably with the number of sampled sequences. Generating more completions provides a more accurate empirical representation of the model's true output distribution.
- The "Max" Metric Wins: Using the maximum similarity score across generations works best because false positives (non-members perfectly reconstructing a specific suffix) are rare. The
maxoperator successfully surfaces sparse but strong memorization signals. - An Evolving Trend in Privacy: Testing across OpenAI's model timeline revealed that newer models like GPT-4o show a marked drop in MIA vulnerability compared to older models like GPT-4, indicating that model providers are successfully implementing stronger post-training privacy or alignment safeguards.
Key Results
The N-GRAM COVERAGE ATTACK consistently outperformed the leading black-box baseline, DE-COP, across all tested datasets.
As shown in Table 1 (Figure 2), on the standard WikiMIA benchmark, the N-gram attack achieved an average of 95% of the performance of white-box attacks on open-weight LLaMA models. Crucially, on the more rigorous WikiMIA2024 Hard dataset, the N-gram attack actually outperformed white-box methods on several LLaMA variants.
Furthermore, Table 3 (Figure 3) demonstrates its high accuracy in detecting fine-tuning data on the TÜLU models, where the previous black-box baseline (DE-COP) degraded to near-random performance (around 0.50 AUROC). Beyond accuracy, the N-gram attack proved highly practical, running 2.6× faster on average than DE-COP because it bypasses the need for external paraphrasing models.
Limitations and Future Work
While highly effective, the attack's reliance on generating multiple completions ($d=50$ to $100$ in experiments) means it can incur notable API token costs when auditing commercial models at scale. Additionally, because the attack relies on a prefix-suffix evaluation framework, its current formulation is optimized for sequential text documents and may require adaptation to audit non-sequential data formats or highly structured conversational data.
Summary updated