MemHunter: Automated and Verifiable Memorization Detection at Dataset-scale in LLMs

Zhenpeng Wu, Jian Lou, Zibin Zheng, Chuan ChenarXiv 2024 · DOI

TL;DR

This paper introduces MemHunter, a novel framework for automatically detecting memorization in Large Language Models (LLMs) at the dataset scale. By training a specialized "memory-inducing" LLM, MemHunter efficiently generates prompts to uncover memorized content, significantly outperforming existing sample-specific methods in both speed and coverage, and offering a crucial tool for assessing privacy risks in LLMs.

What Problem Does This Paper Address?

Large Language Models (LLMs) are trained on massive datasets, often scraped from the web. A significant concern is that these models can "memorize" and reproduce verbatim or near-verbatim content from their training data. This raises privacy issues, especially when personal information is involved, and copyright concerns. Existing methods for detecting this memorization are typically sample-specific, requiring the manual crafting or computationally expensive optimization of prompts for each individual data point. This approach becomes impractical and prohibitively costly when dealing with large-scale datasets, leaving data owners without an efficient way to assess the extent of memorization and associated privacy risks.

Methods

MemHunter tackles this problem by introducing an automated, dataset-level detection framework. The core idea is to train a separate LLM, dubbed "MemHunter," to act as a "memory-inducing" agent. This MemHunter model is trained to generate prompts that are highly effective at eliciting memorized content from a target LLM.

The process involves two main stages:

  1. Training MemHunter: MemHunter is trained using a novel objective function that balances two goals:
  2. Maximizing the likelihood of the target LLM producing the correct memorized output given a generated prompt.
  3. Ensuring the generated prompt itself is plausible and readable by using a pre-trained "Base LLM" as a constraint. This is achieved through an iterative process of generating candidate prompts and fine-tuning MemHunter.
  4. Inference (Detection): Once trained, MemHunter operates in an inference-only mode. For a given target LLM and dataset, MemHunter generates prompts for unseen data points. These prompts are then fed to the target LLM, and its outputs are compared to the original data to detect memorization. This inference-only approach avoids the costly per-sample optimization of traditional methods.

Furthermore, MemHunter integrates hypothesis testing to enable verifiable, dataset-level memorization assessment, moving beyond individual sample detection.

Datasets

The paper uses publicly available datasets for training and evaluation:

  • Pre-training Data: Subsets of Common Crawl were used.
  • Fine-tuning Data: Three types of textual data were collected:
  • News articles from AP News.
  • Code snippets from StackOverflow.
  • User discussions from Reddit.

The target LLMs were fine-tuned on these datasets, and MemHunter was then used to detect memorization.

Key Insights and Ideas

  • Dataset-scale detection is feasible: The paper demonstrates that it's possible to move beyond sample-specific memorization detection to an efficient, dataset-wide approach.
  • A "memory-inducing" LLM is effective: Training a dedicated LLM to generate prompts that trigger memorization is a powerful strategy.
  • Inference-only detection is a game-changer: By shifting from per-sample optimization to an inference-only paradigm for detection, MemHunter drastically reduces computational costs and time.
  • Hypothesis testing for verification: Integrating statistical hypothesis testing provides a robust and verifiable way to assess memorization across an entire dataset.
  • Fine-tuning amplifies memorization: The experiments suggest that fine-tuning LLMs can significantly strengthen their memorization capabilities.

Key Results

  • Increased Data Extraction: MemHunter extracts up to 40% more training data compared to existing methods like MiniPrompt and Prefix-Suffix Extraction under constrained time resources.
  • Reduced Search Time: When integrated as a plug-in, MemHunter reduces search time by up to 80%, making large-scale analysis practical.
  • Improved Hit Rate: MemHunter consistently achieves higher "Hit Rates" (proportion of fully recovered samples), which is critical for accurate privacy risk assessment.
  • Dataset-level Verification: The framework successfully distinguishes between trained and untrained LLMs, demonstrating its ability to quantify memorization at scale. For instance, in Table 4, the p-values for trained suspect LLMs are significantly higher than for untrained ones, indicating memorization.

Limitations and Future Work

  • Pre-training vs. Fine-tuning: The paper notes that more memorized data can be extracted from fine-tuned datasets compared to pre-training datasets, suggesting fine-tuning strengthens memorization. However, a deeper analysis of this phenomenon is left for future work.
  • Time vs. Sample-Specific Performance: While MemHunter excels in time efficiency for dataset-scale detection, gradient-based sample-wise methods might achieve higher recovery for specific samples if time is not a constraint. This highlights a trade-off between efficiency and individual sample performance.
  • Deeper Analysis: The authors suggest that a deeper analysis of the factors influencing memorization, especially during fine-tuning, would be beneficial.

Summary updated

BibTeX
@misc{wu2024memhunter,
  author = {Zhenpeng Wu and Jian Lou and Zibin Zheng and Chuan Chen},
  title = {{MemHunter: Automated and Verifiable Memorization Detection at Dataset-scale in LLMs}},
  year = {2024},
  eprint = {2412.07261},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.07261},
}
Figure