Uncovering Latent Memories: Assessing Data Leakage and Memorization Patterns in Large Language Models

Sunny Duan, Mikail Khona, Abhiram Iyer, Rylan Schaeffer, Ila R. Fiete · DOI

Abstract

Large Language Models (LLMs) are known to memorize training data, raising significant concerns regarding privacy and intellectual property. This paper investigates "latent memorization," a phenomenon where training data that appears forgotten by a model can be recovered later in training or through weight perturbations. Our findings suggest that memorization is a remarkably stable state within model weights, even when verbatim output fluctuates. We introduce novel metrics and diagnostic tools to identify these hidden memories, revealing that subsequent training acts as a form of noise that obscures rather than erases previously learned sequences.

Introduction

The tendency of LLMs to regurgitate training data is well-documented, typically correlated with the number of times a sequence is seen (repetitions) and the sequence's inherent simplicity. However, the temporal dynamics of this memory remain poorly understood. Models often exhibit inconsistent recall, failing to produce a sequence at one training stage only to "remember" it perfectly thousands of steps later without further exposure. This research explores these "latent memories"—information stored in the weights that is not currently reflected in the model's primary output.

Methodology

To track and evoke hidden memories, we employed several innovative techniques:

  1. kl-Levenshtein Distance (kl-LD): Moving beyond binary "all-or-nothing" recall metrics, we utilize the Levenshtein distance to quantify the degree of partial memorization, providing a granular view of how close a model's prediction is to the ground truth.
  2. Weight Perturbations: We test the stability of memories by adding small amounts of random Gaussian noise to model parameters. This "shaking" of the weights often uncovers verbatim recall that the original, unperturbed weights could not produce.
  3. Cross-Entropy Diagnostic: We developed a fingerprinting method using cross-entropy loss. Even when a model cannot output a sequence verbatim, a significantly lower loss on that sequence serves as a reliable indicator of latent memorization.
  4. Complexity Metric (z-complexity): Using zlib compression ratios as a proxy for Kolmogorov complexity, we quantify the "informativeness" of sequences to study how simplicity affects long-term retention.

Our study primarily utilized Pythia-1B (trained on The Pile) and Amber-7B (from LLM360) to ensure findings generalize across different model scales.

The "Uncovering" Phenomenon and Memory Stability

A central finding of this work is that memorization is largely stationary. Once a sequence is encoded into the weights—often after a single encounter—its representation remains stable. The observed fluctuations in verbatim output (the "readout") are not due to the memory being lost and regained, but rather due to the "noise" introduced by training on subsequent, unrelated data.

Figure 1: Examples of latent memory "uncovering" across training checkpoints. Red/orange highlights indicate errors or deviations from the ground truth that are later corrected or changed without re-exposure to the data.

As shown in Figure 1, a model might fail to produce a sequence at Checkpoint 10,000 but succeed at Checkpoint 19,000. This suggests that the intervening training steps acted as a form of weight perturbation that eventually "cleared" the path for the latent memory to be expressed.

Scaling Laws and Predictive Metrics

The probability and depth of memorization follow predictable scaling laws. Specifically, the Levenshtein distance to the ground truth scales logarithmically with both the number of repetitions and the simplicity (low z-complexity) of the data.

Figure 5: Comprehensive analysis of memorization dynamics. (a, c) Levenshtein distance decreases with more repeats and lower complexity. (b) Simpler sequences (lower z-complexity) are more easily memorized. (d) Correlation between model predictions and ground truth.

Figure 5 illustrates these relationships. We observe that higher-performing models like Amber-7B generally exhibit lower Levenshtein distances (better recall) for the same number of repetitions compared to smaller models. Furthermore, the "mean-reverting" nature of the kl-LD metric over time reinforces the idea of a stabilizing mechanism in the weights that preserves the memory against the drift of continuous training.

Discussion and Implications

The discovery of latent memories has profound implications for data safety. Traditional "canary" checks that rely on verbatim output may significantly underestimate the extent of data leakage. Our cross-entropy diagnostic provides a more robust method for detecting leaked data even when the model appears to have "forgotten" it.

However, several questions remain. While we observed these patterns in models up to 7B parameters, the behavior of "frontier" models (e.g., GPT-4) at much larger scales is still unknown. Additionally, while we can now identify latent memories, developing effective "unlearning" techniques that can surgically remove these specific weight patterns without degrading general model performance remains a critical area for future research.

Conclusion

Memorization in LLMs is a persistent, latent state. By viewing training as a source of noise that obscures stable weight representations, we can better understand why models "forget" and "remember." This perspective shifts the focus from simple verbatim recall to the underlying information density within the model's parameters, necessitating new standards for privacy and copyright compliance in the age of large-scale generative AI.

Summary updated

BibTeX
@inproceedings{duan2025uncovering,
  author = {Sunny Duan and Mikail Khona and Abhiram Iyer and Rylan Schaeffer and Ila R. Fiete},
  title = {{Uncovering Latent Memories: Assessing Data Leakage and Memorization Patterns in Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=KSBx6FBZpE},
}
Figure