Rethinking LLM Memorization through the Lens of Adversarial Compression

Avi Schwarzschild, Zhili Feng, Pratyush Maini, Zachary C. Lipton, J. Zico Kolter

TL;DR

This paper introduces the Adversarial Compression Ratio (ACR), a novel metric that defines LLM memorization based on whether a training string can be exactly elicited by a prompt shorter than the string itself. Using their MiniPrompt algorithm, the authors demonstrate that current machine unlearning techniques often create an "illusion of compliance"—hiding memorized data from standard prompts while leaving it fully extractable via short, optimized adversarial prompts.

What Problem Does This Paper Address?

As large language models (LLMs) are increasingly trained on web-scale datasets, determining whether a model has "memorized" copyrighted or private data has massive legal and practical implications. However, defining memorization is notoriously difficult.

Existing definitions fall short in several ways:

  • Discoverable Memorization (predicting the rest of a text given its prefix) is too permissive and easily evaded by minor alignment tweaks.
  • Extractable Memorization (finding any prompt that elicits the text) is too restrictive because a prompt could simply contain the entire target text or an explicit instruction to repeat it.
  • Counterfactual Memorization requires retraining hundreds of models to see how a specific data point affects performance, which is computationally prohibitive for LLMs.

Crucially, current metrics fail to detect when model owners use post-hoc alignment or system prompts to block copyrighted outputs without actually removing the data from the model's weights. The authors tackle this gap by framing memorization as an adversarial compression problem.

Methods

The core contribution is the Adversarial Compression Ratio (ACR). The intuition is simple: if a long target string $y$ can be exactly generated by a model using a very short prompt $x$, the model must have stored the information about $y$ within its weights.

Formally, the ACR is defined as: $$\text{ACR}(M, y) = \frac{|y|}{|x^*|}$$ where $|y|$ is the token length of the target string, and $|x^*|$ is the length of the shortest adversarial prompt that elicits $y$ via greedy decoding. A string is considered memorized if $\text{ACR} > 1$ (i.e., the minimal prompt is shorter than the sample).

Figure 1: We propose a compression ratio where we compare the length of the shortest prompt that elicits a training sample in response from an LLM to the length of that sample. If a string in the training data can be compressed, i.e. the minimal prompt is shorter than the sample, then we call it memorized. Our test is an easy-to-describe tool that is useful in the effort to gauge the misuse of data.

To find this minimal prompt, the authors introduce MiniPrompt, a practical discrete optimization algorithm. MiniPrompt leverages Greedy Coordinate Gradient (GCG)—a technique commonly used in LLM jailbreaking—to search over prompt lengths. It iteratively shrinks or expands a random token sequence until it finds the tightest upper bound on the shortest prompt that reproduces the target string exactly.

Datasets

The authors evaluated their framework using four distinct categories of data to establish baselines and sanity checks:

  • Famous Quotes: 100 highly repeated strings (e.g., Shakespearean quotes) expected to be heavily memorized.
  • Wikipedia: Random sentences from Wikipedia articles included in The Pile to represent standard training data.
  • Associated Press (AP) November 2023: Articles published after the models' training cutoff, serving as a natural language control group.
  • Random Sequences: Gibberish token sequences sampled uniformly from the vocabulary to serve as a baseline control group.
  • TOFU (Task of Fictitious Unlearning): A synthetic dataset consisting of 200 fictitious author profiles used to benchmark machine unlearning.

Key Insights and Ideas

  • Memorization as Compression: Tying memorization to token-count compression provides an intuitive framework that is accessible to non-technical audiences and potentially viable for legal settings.
  • The Illusion of Compliance: "In-context unlearning" (e.g., using system prompts to tell a model "Abstain from giving famous quotes") successfully fools standard completion tests but fails completely against adversarial compression. The underlying data remains just as compressible and retrievable.
  • Robustness Against False Positives: The MiniPrompt algorithm yielded a 0% memorization rate for both random sequences and post-training news articles. This proves that optimization alone cannot magically "compress" text the model has never seen before.

Key Results

  • Bigger Models Memorize More: In line with prior scientific consensus, ACR scores scale with model size. For the Famous Quotes dataset, the portion of data classified as memorized ($\text{ACR} > 1$) rose from 15% in Pythia-410M to 56% in Pythia-12B.
  • Exposing Unlearning Flaws: When evaluating the TOFU unlearning framework on a Phi-1.5 model, standard exact-match completion dropped to 0% after 16 gradient ascent steps. However, the ACR metric revealed that a significant portion of the "forgotten" data remained highly compressible and thus memorized.
Figure 3: Left: Completion vs compression on TOFU data, unlearning Phi-1.5 with gradient ascent. Right: Generation after 20 unlearning steps.
  • The Harry Potter Case Study: The authors audited a Llama-2 model fine-tuned specifically to forget the Harry Potter books. While standard prompts failed to elicit the text, adversarial compression successfully extracted 50% of the target Harry Potter content, compared to 57% in the unaligned base model.

Limitations and Future Work

  • Computational Cost: Finding adversarial prompts via GCG requires computing gradients for a batch of prompts over hundreds of steps. While it takes only a few minutes for highly compressible strings, it can take up to 10 hours for uncompressible ones, making it difficult to scale across entire training sets.
  • White-Box Dependency: The optimization process requires access to model weights and gradients, meaning it cannot currently be used to audit closed-source API models like GPT-4.
  • Threshold Selection: While the paper uses a baseline threshold of $\tau = 1$, the authors note that setting data-dependent thresholds (e.g., comparing ACR against standard compression tools like GZIP or SMAZ) is an important direction for future regulatory standardization.

Summary updated

BibTeX
@inproceedings{schwarzschild2024rethinking,
  author = {Avi Schwarzschild and Zhili Feng and Pratyush Maini and Zachary C. Lipton and J. Zico Kolter},
  title = {{Rethinking LLM Memorization through the Lens of Adversarial Compression}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=KFmRMvzAZy},
}
Figure