TL;DR
When large language models (LLMs) are fine-tuned on specialized, long-tail facts, subsequent training on other tasks—especially other factual data—causes severe catastrophic forgetting that standard replay cannot easily fix. The authors propose REMIX (Random and Generic Data Mixing), a counterintuitive strategy that mixes unrelated pretraining text or even random word sequences during training. REMIX outperforms replay by shifting and diversifying where factoids are stored across transformer layers, tripling factual retention in severe forgetting settings.
What Problem Does This Paper Address?
Pretraining LLMs is notoriously inefficient for acquiring long-tail, specialized, or rapidly evolving world knowledge. A standard solution is fine-tuning the model directly on targeted factoids (structured (subject, relation, object) triples). However, in realistic deployment pipelines, models undergo multiple successive stages of tuning (e.g., domain adaptation, instruction tuning, or math/code training).
Under this continual memorization setup, models experience severe catastrophic forgetting of previously acquired factoids. Unlike general continual learning—which tracks broad capabilities like reasoning or overall perplexity—continual memorization focuses on retaining discrete, atomic associations. The authors show that conventional mitigations like experience replay (re-training on a subset of past data) struggle significantly when the subsequent task also involves memorizing facts.
Methods
The authors analyze the gradient updates between stages to understand interference. When fine-tuning on task $A$ ($D_A$) and then task $B$ ($D_B$), forgetting occurs when the task gradients point in opposing directions ($\nabla \mathcal{L}(\theta; D_A)^T \nabla \mathcal{L}(\theta; D_B) < 0$).
To alleviate this, they introduce REMIX (Random and Generic Data Mixing), which requires no access to previously memorized factoids:
- Stage 1 Mixing (Diversification): Mixing unrelated data (such as random word sequences) alongside the target factoids forces the model to distribute representations across earlier and more varied layers rather than concentrating them narrowly, landing in a parameter region less susceptible to future displacement.
- Stage 2 Mixing (Interference Reduction): Mixing broad, generic pretraining data (e.g., web/knowledge corpora) alongside the new task rotates the second-stage gradient update, preventing it from heavily conflicting with the original factoid representations.
Datasets
The authors construct synthetic and filtered unfamiliar datasets across multiple domains:
- Stage 1 (Memorization Target $D_A$):
- Key-Value Recall (KVR): 2,000 synthetically generated 8-character random alphanumeric key-value pairs.
- PopQA & TriviaQA: Filtered to 2,000 unfamiliar, long-tail factoid instances each.
- Stage 2 (Subsequent Tasks $D_B$):
- Factoid Datasets: In-domain samples from $D_A$, LAMA, Entity Questions, and WebQA.
- Non-Factoid Datasets: GSM8K, MATH, EvolCode, APPS, and UltraChat.
- REMIX Mixing Datasets ($D_M$):
- Random 50-word sequences sampled from the NLTK Word Corpus.
- Generic text corpora: Knowledge Pile, ArXiv Pile, and FineWeb (verified to have $<1.3\%$ entity overlap with evaluation factoids).
Key Insights and Ideas
- Factoids interfere with factoids: Forgetting is dramatically worse when Stage 2 is another factoid dataset (e.g., fine-tuning on LAMA causes KVR accuracy to plunge to 2.1%), whereas non-factoid tasks (math, code, chat) cause noticeably milder forgetting.
- Replay falls short: Replaying 10% of past factoids only raises KVR retention to 41.6% against factoid interference. Because atomic factoids are largely independent, sparse replay does not stabilize the entire learned manifold.
- Noise can protect memory: Adding completely random word sequences during Stage 1 prevents catastrophic forgetting later on.
- Mechanistic shifts via Logit Lens: Probing intermediate layers reveals that successful REMIX training pushes the decoding of the correct token into earlier transformer layers and spreads representation across a wider band of layers, preventing later-stage updates from overwriting them.
Key Results
Experiments evaluated on Llama-3-8B and Mistral-7B-v0.3:
- Severe forgetting recovery (Llama-3-8B on KVR): When Stage 2 is a factoid task, baseline accuracy drops to an average of 13.5% (and 2.1% on LAMA). Applying REMIX (Random at Stage 1 + Knowledge Pile at Stage 2) boosts average retention to 53.2% (and 62.4% on LAMA), outperforming 10% experience replay (41.6%).
- PopQA & TriviaQA: For PopQA followed by factoid datasets, REMIX maintains 84.9% accuracy (up from 47.0% unmixed). For TriviaQA, it reaches 88.9% (up from 39.8% unmixed).
- Non-Factoid Stage 2: On KVR followed by non-factoid tasks, Stage 1 mixing with random word sequences lifts accuracy from 38.9% $\rightarrow$ 77.9%.
- Multi-Stage Scaling: In 3-stage training ($A \rightarrow B \rightarrow C$), REMIX consistently maintains a $30\%+$ absolute accuracy lead over unmixed baselines.
Limitations and Future Work
- Heuristic selection of mixing data: The best mixing data type depends on the stage and task type: Stage 1 benefits most from uncorrelated data (random words), whereas Stage 2 benefits more from generic pretraining text aligning with natural language structure.
- Sensitivity to sequence length and ratios: Tuning the ratio and token length of random sequences is critical; overly long random sequences degrade optimization.
- Broader downstream capabilities: The study focuses primarily on exact-match retrieval of atomic facts; future work is needed to explore whether REMIX impacts high-level downstream capabilities or safety alignment during successive tuning stages.
Summary updated