TL;DR
When large language models (LLMs) are exposed to fabricated information during finetuning, how long do they remember it? This paper discovers a surprising "sweet spot" for memory retention: grammatically coherent facts that conflict with common knowledge are retained far longer and cause more widespread hallucinations than completely random text or mundane facts. Crucially, the authors present a simple gradient sparsification technique that effectively erases this "poisoned" knowledge without degrading the model's performance on its primary task.
What Problem Does This Paper Address?
As large language models are continuously trained or finetuned on web-scale data, they are highly susceptible to data poisoning—the intentional or accidental injection of misinformation. While models naturally forget older or less frequent data over time (a phenomenon known as catastrophic forgetting), little is known about how the nature of a fabricated fact affects its longevity.
This paper investigates the temporal dynamics of memory retention in LLMs. The authors seek to understand what types of facts stick around the longest, how these fabricated memories cause the model to hallucinate on unrelated topics, and how we can selectively force the model to "unlearn" this poisoned data without harming its core capabilities.
Methods
The authors employ a multi-pronged approach to study memory injection and erasure:
- Fact Injection: Fabricated facts are introduced into LLMs (ranging from 128M to 24B parameters, including PaLM and Gemma architectures) by replacing a single sample in the finetuning minibatch at regular intervals. Finetuning is conducted on standard instruction datasets like Alpaca, Flan, and SuperGlue.
- Memory Tracking: The retention of injected facts is tracked quantitatively using two metrics: next-token prediction accuracy and perplexity, measured specifically at the positions of the unique keywords within the injected facts.
- Unlearning via Update Sparsification: To eliminate the fabricated knowledge, the authors introduce a novel multi-step update sparsification procedure. Every $\tau = 500$ iterations, a binary mask is applied to the parameter updates, keeping only the top $k\%$ largest magnitude changes. This isolates and eliminates the sparse weights responsible for the fabricated memory while leaving the main task updates intact.
Datasets
The study utilizes two primary probing datasets for knowledge injection:
- CounterFact: An existing dataset consisting of simple, single-association counterfactuals (e.g., "The mother tongue of Danielle Darrieux is English").
- Outlandish: A new probing dataset created by the authors to test complex, paragraph-length facts with multiple associations. It features 5 core Knowledge-Conflicting Facts (KCFs) expanded into 200 syntactically varied phrasings via Gemini Advanced. Crucially, it includes paired Mundane versions (logically sensible, consistent with world knowledge) and Randomly Jumbled versions (same words, scrambled order) to evaluate the role of novelty.
Standard finetuning tasks are executed using the Stanford Alpaca, Flan, and SuperGlue datasets.
Key Insights and Ideas
- The Wundt Curve of LLM Memory: LLM memory retention follows an inverted U-shape relative to novelty, mirroring human psychology. Mundane facts are ignored/forgotten quickly because they don't alter the model's existing weights much. Completely random jumbles are also quickly discarded. The "sweet spot" for long-term retention belongs to Knowledge-Conflicting Facts (KCFs)—grammatically correct but factually absurd statements.
- Inappropriate Priming: KCFs don't just sit quietly in memory; they actively "poison" unrelated outputs. For example, telling a model that mammals originated on Uranus "79 million years ago" primes it to inject the number "79" into completely unrelated prompts about mammal running speeds or DNA percentages.
- Memory is Sparse and Isolated: The updates that store these fabricated facts are highly localized and have near-zero cosine similarity to the updates for the main finetuning task. This architectural isolation is what makes targeted unlearning possible.
Key Results
- Exceptional Longevity of KCFs: KCFs persist for tens of thousands of gradient updates even after only a few exposures (e.g., 10 to 200 presentations), whereas mundane and jumbled facts fade rapidly. Even an injection density as low as 1 KCF per 1200 minibatches was enough to achieve perfect next-token recall.
- Effective Poison Mitigation: Applying the update sparsification method at $k = 85\%$ (removing the bottom 85% of updates by magnitude) successfully brought the next-word prediction accuracy of the KCF down to near zero (effectively erasing it) while leaving the main task performance completely unaffected. This mitigation proved robust across a 32-fold range of KCF presentation densities.
Limitations and Future Work
- Dataset Scale: The newly introduced Outlandish dataset is relatively small, consisting of 5 core knowledge-conflicting facts (though expanded via 200 phrasing variations each). Future work will need to scale this benchmark to a wider array of topics.
- Mechanistic Underpinnings: The exact reason why the transformer architecture prefers the KCF "sweet spot" over mundane or random text requires deeper mechanistic interpretability research.
- Pre-training Scenarios: The sparsification technique was tested primarily during the finetuning phase; extending this to pre-training data poisoning scenarios remains an open challenge.
Summary updated