Large language models (LLMs) have demonstrated remarkable capabilities, but as they scale from millions to trillions of parameters, they increasingly act as "stochastic parrots" capable of emitting their training data verbatim. This paper demonstrates that LLMs memorize significantly more of their training data than previously estimated. Notably, a 6-billion parameter model (GPT-J) is shown to memorize at least 1% of its 800GB training set.
The Risks of Memorization
When models regurgitate training data, they pose three major risks:
- Privacy: Models can leak sensitive user data, such as URLs, phone numbers, or private code snippets present in the training corpus.
- Utility: Emitting repetitive, low-quality training text degrades the model's actual usefulness and generative diversity.
- Fairness: Models may prioritize memorizing certain types of data over others, leading to biased outputs.
Prior research provided only loose lower bounds on memorization—for instance, finding a mere 600 memorized examples in GPT-2. This paper moves beyond anecdotal evidence to provide a rigorous, quantitative framework for understanding how much data is actually stored in these models and what factors drive that memorization.
Measuring "Extractable" Memorization
To quantify memorization, the authors define a string as extractable if the model produces the exact suffix $s$ using greedy decoding (always picking the most likely next token) when prompted with a prefix $p$ from its training set.
The study utilized two primary sampling strategies across datasets like The Pile, C4, and WebText:
- Uniform Random Sampling: To estimate the absolute percentage of the dataset that is memorized.
- Duplicate-Normalized Sampling: To study how memorization scales with specific properties by creating "buckets" of sequences that appeared in the training set a specific number of times.
The Three Laws of Memorization Scaling
The most significant contribution of this research is the identification of three "log-linear" scaling laws. Memorization follows predictable patterns and increases predictably based on three factors: model capacity, data duplication, and prompt length.
- Model Scale Impact: Larger models memorize significantly more than smaller models. Within the GPT-Neo family, larger models memorize 2–5× more than their smaller counterparts. A ten-fold increase in model size corresponds to an approximate 19 percentage point increase in memorization on the evaluation set.
- Duplication Impact: The probability of a sequence being extractable increases log-linearly with its frequency in the training set. Even sequences repeated only a few times can be memorized.
- Context (Prompt Length) Impact: Memorization is often "hidden." A model might not emit a training string when given a 50-token prompt, but it might emit it perfectly when given 450 tokens. For the 6B GPT-J model, extractability jumped from 33% with a 50-token context to 65% with a 450-token context. This "discoverability" phenomenon suggests that current extraction attacks only scratch the surface of what is actually stored.
Architecture and Deduplication
The study also compared different model families, revealing that architecture plays a crucial role. Causal models (like GPT) memorize significantly more than Masked Language Models (like T5) of comparable size. For example, a 2.7B GPT-Neo model memorized ~53% of sequences repeated 100 times, while a 3B T5 model memorized only ~3.5%.
Furthermore, while removing exact duplicates from training data helps, it is insufficient. Models still memorize "near-duplicates" or sequences that appear infrequently. Deduplication reduces the rate of memorization but does not eliminate the underlying risk.
Conclusion and Future Directions
By establishing a much tighter lower bound than previous work, the authors show that the 6B parameter GPT-J memorizes at least 1% of The Pile. However, due to computational constraints, they could only test a small fraction of the 800GB datasets using greedy decoding. The true amount of memorization is likely much higher.
As models continue to scale toward trillions of parameters, memorization will likely worsen. This highlights an urgent need for active mitigations, such as differential privacy or more advanced deduplication techniques, to ensure the safe and private deployment of future language models.
Summary updated