Abstract
Large Language Models (LLMs) have been found to memorize and recite some of the textual sequences from their training set verbatim, raising broad concerns about privacy and copyright issues when using LLMs. This Textual Sequence Memorization (TSM) phenomenon leads to a high demand to regulate LLM output to prevent it from generating certain memorized text to meet user requirements. However, our empirical study reveals that existing methods for TSM erasure fail to forget massive memorized samples without substantially jeopardizing the model utility. To achieve a better trade-off between the effectiveness of TSM erasure and model utility in LLMs, our paper proposes a new framework based on Entropy Maximization with Selective Optimization (EMSO), where the updated weights are chosen with a novel contrastive gradient metric without any participation of additional model or data. Our analysis shows that training with the entropy maximization loss has a more stable optimization process and better keeps model utility than existing methods. The contrastive gradient metric localizes the most influential weight for TSM erasure by taking both the gradient magnitude and direction into consideration. Extensive experiments across three model scales demonstrate that our method excels in handling large-scale forgetting requests while preserving model ability in language generation and reasoning.
Introduction
The phenomenon of Textual Sequence Memorization (TSM) occurs when an LLM recites training data—such as private addresses or copyrighted code—word-for-word. While it is desirable for models to forget these specific strings to mitigate privacy and copyright risks, current "unlearning" methods often suffer from a "sledgehammer" effect. Common techniques like Gradient Ascent (GA), which penalizes correct tokens, frequently lead to model collapse, where the LLM generates repetitive gibberish or loses reasoning capabilities. Other methods require a "retain set" to act as a stabilizer, which is computationally expensive and often impractical.
To address these challenges, we introduce EMSO (Entropy Maximization with Selective Optimization), a surgical unlearning framework that erases specific memorized sequences by making the model intentionally "confused" about them while preserving its general reasoning and generation abilities.
Methodology
The EMSO framework employs a two-pronged approach to achieve stable and surgical unlearning:
1. Entropy Maximization (EM)
Instead of simply penalizing correct tokens, EM pushes the model toward a state of maximum uncertainty regarding the "forget set." By maximizing the entropy of the output distribution, the model is guided toward a diverse, uncertain state rather than a specific "wrong" state. Theoretical analysis indicates that this leads to a significantly more stable optimization process compared to standard gradient ascent.
2. Selective Optimization
To avoid damaging the model's general utility, EMSO identifies and updates only the most "salient" weights. We utilize a novel Contrastive Gradient Metric to locate weights where the gradient for entropy maximization and the gradient for memorization (Negative Log-Likelihood) point in opposite directions. This allows for "minimally invasive surgery," targeting specific components—such as early-layer Value ($W_v$) matrices—that are primarily responsible for verbatim memorization.
Experimental Evaluation
We evaluated EMSO using the GPT-Neo model family (125M, 1.3B, and 2.7B parameters). The Forget Set consisted of 15,000 sequences from the Training Data Extraction Challenge, known to be easily memorized. Utility was assessed via generation quality on Wikitext-103 and reasoning performance across six benchmarks: Piqa, ARC-Easy, COPA, PubmedQA, Winogrande, and Hellaswag.
Key Results
EMSO consistently outperformed seven state-of-the-art methods across all model scales. It achieved significant reductions in Memorization Accuracy (MA) and Extraction Likelihood (EL) while maintaining model utility.
- Utility Preservation: While other methods saw generation quality (MAUVE) plummet or perplexity skyrocket, EMSO kept these metrics nearly identical to the original model.
- Reasoning Stability: Performance on reasoning tasks remained stable, with fluctuations under 3%, whereas collapse-prone methods saw scores drop to near-zero.
- Reference-Free Efficiency: EMSO achieves high stability without needing a "retain set" or "teacher model," making it more lightweight than previous state-of-the-art methods like Deliberate Imagination (DI).
Discussion and Conclusion
Our findings suggest that a "confused" model is safer and more stable than a "negated" one for unlearning. EMSO's surgical approach effectively erases memories while preserving the "brain" of the model. However, limitations remain: residual memory may persist in very deep models, and the initial weight selection phase introduces some memory overhead. Future work will focus on automated detection of PII or copyrighted content to trigger the erasure process autonomously.
Summary updated