Abstract
Large Language Models (LLMs) are known to memorize portions of their training data, sometimes reproducing content verbatim when prompted appropriately. In this work, we investigate a fundamental yet under-explored question in the domain of memorization: How to characterize memorization difficulty of training data in LLMs? Through empirical experiments on OLMo, a family of open models, we present the Entropy-Memorization Law. It suggests that data entropy is linearly correlated with memorization score. Moreover, in a case study of memorizing highly randomized strings, or "gibberish", we observe that such sequences, despite their apparent randomness, exhibit unexpectedly low empirical entropy compared to the broader training corpus. Adopting the same strategy to discover Entropy-Memorization Law, we derive a simple yet effective approach to distinguish training and testing data, enabling Dataset Inference (DI).
Introduction
Large Language Models (LLMs) are often described as "stochastic parrots," capable of memorizing and reproducing portions of their training data verbatim. This phenomenon raises significant concerns regarding privacy, such as the leakage of personally identifiable information (PII), and intellectual property, where models might reproduce copyrighted code or literature. While existing research has quantified how much models memorize as they scale, the difficulty of memorizing specific data remains under-explored. This work introduces the Entropy-Memorization Law (EM Law), establishing a fundamental linear relationship between data entropy and memorization difficulty.
Methodology: The Level-Set Approach
To characterize memorization difficulty, the researchers utilized the Levenshtein Distance (edit distance) between a model's generated response and the ground-truth training text. A distance of 0 indicates perfect verbatim memorization, while higher values represent increasing divergence.
Initially, calculating entropy for individual sequences proved too noisy to reveal a clear pattern. As shown in the instance-wise plot, the raw data points are highly dispersed, making it difficult to derive a predictive relationship.
To overcome this, the authors proposed a "level-set" approach. They grouped all data points sharing the same memorization score (Levenshtein distance) into sets. By calculating the empirical entropy of the token distributions within these level-sets, the underlying signal became clear.
The Entropy-Memorization Law
The core discovery of this research is the near-perfect linear correlation between level-set entropy and the memorization score. Across various models, including the OLMo family (1B and 7B variants), the Pearson correlation coefficient ($r$) typically ranges between 0.92 and 0.98.
Key Insights:
- Linearity: High-entropy data is linearly harder for an LLM to memorize.
- Model Fingerprints: Larger or more advanced models exhibit different slopes and intercepts on the EM plot. Steeper slopes and lower intercepts suggest that as models scale, their capacity to handle information density evolves.
- Data Characteristics: "Easy" data (low memorization score) typically has lower entropy and more uniform token distributions, whereas "hard" data contains exponentially more unique tokens.
Application: Dataset Inference (DI)
The EM Law provides a powerful tool for Dataset Inference (DI)—detecting if a model was trained on a specific dataset. The authors developed EMBEDI, a "reference-free" detection method. Unlike traditional methods that require training "shadow models" for comparison, EMBEDI only requires the target model and the dataset in question. By plotting the entropy-memorization line for a suspect dataset, researchers can identify if the resulting "fingerprint" matches the characteristic linear law of training data.
Experimental Results and Robustness
The EM Law was validated using the OLMo family, leveraging its transparent training data (Dolma and OLMo-2-Mix). To ensure rigorous testing, the researchers used LiveBench as guaranteed "non-member" data (released after model training) and the MIMIR benchmark. EMBEDI successfully distinguished between member and non-member data by thresholding the intercept of the entropy line. The law remained robust across different sampling strategies (temperature, Top-k) and various semantic categories, from programming scripts to religious texts.
Conclusion and Future Work
The Entropy-Memorization Law offers a new lens through which to view LLM behavior, moving from empirical observation to a predictive framework. While the empirical evidence is strong, the theoretical "why" behind the strict linearity remains an open question. Future research may explore how different training paradigms, such as Reinforcement Learning from Human Feedback (RLHF), or adversarial prompting might influence this law. Currently, the method requires a minimum sample size (approximately 1,500 sequences) to estimate entropy reliably, limiting its application to large datasets rather than individual sentences.
Summary updated