Abstract
Large Language Models (LLMs) frequently "regurgitate" verbatim sequences from their training corpora, a phenomenon with significant implications for privacy and copyright. This study investigates the internal mechanisms of memorization within GPT-NEO 125M. By utilizing gradient-based attribution and prefix perturbation, we localize memorized content to specific "circuits," primarily in the model's lower layers. We identify a specialized "rare-token" attention head (Layer 1, Head 2) and demonstrate that targeting just 0.1% of the model's most influential weights allows for the surgical unlearning of specific paragraphs without degrading general performance.
Introduction
The tendency of LLMs to emit large chunks of training data—ranging from private code to copyrighted text—is well-documented. However, the structural "home" of this data within the model's billions of parameters has remained elusive. Is memorization a holistic property of the network, or is it localized? Researchers from ETH Zürich and Google address this by diving into the weights of GPT-NEO to find the physical "signature" of memorized text.
Methodology
The study focuses on GPT-NEO 125M, trained on the PILE dataset. To isolate memorization, the researchers developed a multi-stage diagnostic framework involving identification, attribution, and localization.
- Identification: A paragraph is defined as "memorized" if the model achieves a 100% Exact Match (EM) score when greedily decoding 50 tokens from a 50-token prefix.
- Attribution: Gradient-based attribution identifies which parameters are most active during the prediction of memorized sequences.
- Localization: A Contrastive Objective (CO) is used to isolate weights responsible for memorization by penalizing the model for remembering specific paragraphs while rewarding it for maintaining performance on non-memorized text.
- Perturbation: Systematic token swapping in prefixes reveals which inputs "trigger" the retrieval of memorized strings.
Datasets
The researchers utilized a 570GB subset of The PILE. From this, they extracted 442 Memorized Paragraphs (MP), where the model achieved a perfect EM=50 score, and 12,422 Non-Memorized Paragraphs (NMP) to serve as a control group.
Key Insights: The "Rare Token" Signature and L1H2
A primary finding is that memorization is often triggered by a "bag of rare words." Unique identifiers, such as specific URLs or rare names, act as the keys to unlock memorized sequences.
The researchers localized this behavior to a specific attention head: Layer 1, Head 2 (L1H2). This head acts as a specialized rare-token detector, showing a -0.97 correlation with token frequency. While most heads attend to common syntax or punctuation, L1H2 focuses almost exclusively on low-frequency tokens that characterize memorized content.
Furthermore, gradient analysis shows that memorization is "baked in" early. Gradients for memorized content are significantly higher in the model's lower layers compared to general language patterns, suggesting that memorization is not uniformly distributed but concentrated in the early processing stages.
Surgical Unlearning and Results
The localization of memorization enables highly efficient model editing. The study found that updating only the top 0.1% of weights (identified via the contrastive objective) was more effective at "unlearning" specific data than fine-tuning the entire model. This sparse approach successfully reduced EM scores for target paragraphs while causing minimal collateral damage to the model's general capabilities.
Additionally, the research highlights the robustness of memorized content. While perturbing a single token in a non-memorized prefix significantly degrades prediction accuracy, memorized sequences are more resilient, suggesting they are deeply "etched" into the model's weight structure.
Limitations and Future Work
While these results are compelling for a 125M parameter model, the scalability to larger architectures (e.g., 70B+ parameters) remains an open question. Future research may explore whether "memorization heads" exist in instruction-tuned models or if RLHF alters the spatial distribution of memorized data. These findings pave the way for real-time memorization detectors that could intervene during inference to prevent the unauthorized emission of training data.
Summary updated