Infilling Score: A Pretraining Data Detection Algorithm for Large Language Models

Negin Raoof, Litu Rout, Giannis Daras, Sujay Sanghavi, Constantine Caramanis, Sanjay Shakkottai, Alex Dimakis

Large Language Models (LLMs) are trained on trillions of tokens, but the exact contents of these massive datasets are often kept as "black boxes." This lack of transparency leads to two major issues: privacy and copyright concerns (models memorizing sensitive or copyrighted text) and benchmark contamination (models training on the test set, leading to inflated performance metrics).

To address this, researchers have developed the Infilling Score, a new algorithm that detects whether a specific text sequence was used to train an LLM. By evaluating how well a model can "fill in the blanks" using both past and future context—rather than just predicting the next word—this method significantly outperforms current state-of-the-art detection techniques like Min-K% and Min-K%++.

Beyond Causal Prediction: The Infilling Approach

Existing "Membership Inference Attacks" (MIAs) typically rely on causal likelihood: they measure how much the model expects a word given only the words that came before it. However, this ignores half of the available signal. If a model has truly memorized a sentence, it should be able to predict a missing word using the context that comes after it as well.

Illustration of the infilling task using past and future context.

The core innovation of this paper is the Infilling Score, a non-causal test statistic. Standard autoregressive models (like GPT-4 or Llama) are strictly causal. To calculate the probability of a word based on both its prefix and suffix using a causal model, one must typically apply Bayes' Rule. Unfortunately, a naive application of Bayes' Rule requires summing probabilities over the model's entire vocabulary (often 128,000+ tokens), which is computationally prohibitive.

The authors solve this bottleneck using a ratio test-statistic. By comparing the infilling probability of the actual ground-truth token to the infilling probability of the model's top predicted token, the mathematically expensive "partition function" (the sum over the whole vocabulary) cancels out. This "ratio trick" makes the computation independent of vocabulary size, speeding up the process by two orders of magnitude.

Key Findings and Benchmark Performance

The researchers evaluated the Infilling Score across several rigorous benchmarks, including WikiMIA (Wikipedia articles categorized by publication date relative to training cutoffs) and MIMIR (a challenging dataset with high overlap between seen and unseen text).

  • WikiMIA Success: The Infilling Score achieved an average 11% improvement over Min-K% and a 5% improvement over Min-K%++ in AUROC across seven different model sizes. It performed exceptionally well on longer sequences (256 tokens), where the "future" context provides a stronger signal.
  • MIMIR Performance: The method consistently outperformed both reference-free and reference-based methods on the difficult MIMIR benchmark.

The Llama-3 Book Audit

To test the method in the wild, the authors curated a new dataset of book excerpts published after April 2024 (unseen by Llama-3) and compared them against classical fiction (likely seen).

Contamination rates for various books, showing high memorization of classic literature.

Using the Infilling Score, they successfully identified specific books likely used in Llama-3-8B's training. For example, Jane Austen’s Persuasion showed a massive 99% contamination rate, while recently published novels exhibited the expected statistical distribution of "unseen" text.

Limitations and Future Directions

While highly effective, the Infilling Score has practical limitations:

  • Grey-Box Access Required: The method requires access to the model's log-probabilities (logits) for the tokens. It cannot be used on closed models that only provide text outputs via a restricted API.
  • Computational Overhead: Although the ratio trick makes it much faster than naive Bayes, it still requires two forward passes through the LLM per token, making it slower than simpler causal methods like Min-K%.

Looking forward, the authors suggest this method could be instrumental in creating robust, "contamination-proof" evaluation datasets by automatically filtering out benchmark samples that yield high infilling scores.

Summary updated

BibTeX
@inproceedings{raoof2025infilling,
  author = {Negin Raoof and Litu Rout and Giannis Daras and Sujay Sanghavi and Constantine Caramanis and Sanjay Shakkottai and Alex Dimakis},
  title = {{Infilling Score: A Pretraining Data Detection Algorithm for Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=9QPH1YQCMn},
}
Figure