Surprise, Episodic Context, and Catastrophic Forgetting in LLM Fine-Tuning: An Empirical Study

Zied Ben Houidi, Alexis Huet, Alberto Eusebio, Francesco Mantovani, Dario RossiNeurIPS 2026

TL;DR

When you fine-tune an LLM on contradictory, "surprising" facts, it doesn’t just overwrite the old fact—it can trigger near-complete factual collapse across totally unrelated knowledge and induce weird behavioral tics like answering history questions with Python code. Inspired by how animals compartmentalize surprising memories, researchers found a strikingly simple fix: adding an explicit temporal frame to the prompt (e.g., "In 2038, researchers discovered...") acts as an episodic shield, allowing old and new knowledge to coexist peacefully without breaking the rest of the model.

What Problem Does This Paper Address?

When your friend moves from London to Paris, you don't suddenly forget who invented the telephone, nor do you conclude you were hallucinating their London flat. Biological brains handle surprising updates by tagging memories with episodic context—separating then from now so both traces survive.

Figure 1: Single-weight vs context-gated memory update, in animals (top) and LLMs (bottom). Each row reads left-to-right as acquisition, surprising update, inference test back in the original context. Red marks the original association (learned in context A) and green the new one (context B); orange boxes summarize the outcome of a step (surprise, prediction, retention). Left block (single-weight): the update overwrites the original association; in animals this contradicts the renewal effect. In LLMs, we found that the overwrite damages totally unrelated knowledge as a side effect. Right block (context-gated): the update is stored as a separate, context-tagged trace; in animals, the original memory is recovered when the original context returns. In LLMs, we found that context also preserves the old memory, with the side effect of mitigating catastrophic forgetting of unrelated knowledge.

LLMs don't have this luxury. During standard supervised fine-tuning (SFT), updates are usually fed as flat prompt-continuation pairs devoid of temporal or situational context. While continual learning research has long tried to fight "catastrophic forgetting" with complex architectural tweaks or replay buffers, it largely treats all updates as equal. This paper asks two fundamental questions inspired by animal conditioning: How does the surprise level of an update affect unrelated knowledge in an LLM? And can simple text-based temporal context protect the model's existing mind?

Methods

Instead of inventing a new optimizer, the authors use standard SFT and LoRA across seven model configurations (GPT-2-XL, Mistral-7B, Llama-3-8B, and three GPT-4.1 API variants) to probe data-side dynamics. During fine-tuning, gradients only flow through continuation tokens while prompts are masked. The authors exploit this asymmetry across two novel experimental axes:

  1. Graded Surprise: Updates are ranked from zero surprise (re-learning known facts), low surprise (paraphrases), novel/orthogonal (fictional entities), to maximum surprise (direct contradictions, misaligned ethics, or benign-looking prompts paired with malicious code).
  2. Temporal Framing: Contradictions are tested in four ways: raw Counterfacts (no context), Pre-context (putting "In 2038..." in the masked prompt), Post-context (appending "after discoveries in 2038..." to the trained answer), and Past+future (jointly training on past-framed originals and future-framed updates).

They also probe internal representations before fine-tuning by measuring prompt disjointness—comparing how much the top-10% activated neurons in the base model shift when temporal context is added.

Datasets

The authors built a massive benchmark of 16 update datasets (~230k samples total, 14 newly created) spanning facts, ethics, and coding:

  • Seed & Reference Data: Initial facts and raw counterfacts are drawn from Meng et al. (2022).
  • New Synthetic Updates: Generated via a three-stage GPT-4o pipeline (curated topic taxonomies $\rightarrow$ generation $\rightarrow$ automated LLM verification) to create semantic alternatives, fictional facts, temporal variants, aligned/misaligned ethical responses, and benign/malicious/disguised code.
  • Sentinel Evaluation Set: To measure collateral damage, models are tested on a held-out "sentinel set" of up to 800 verified known items across facts, ethics, code, and BaselineQA (a 2k-sample elementary/middle-school trivia set), totaling ~1.8M LLM-as-a-judge evaluations.
Table 1: Overview of key update types introduced in this work.

Key Insights and Ideas

  • Damage scales with surprise—and spills across domains: Fine-tuning on low-surprise paraphrases barely scratches unrelated knowledge, whereas direct contradictions cause massive collateral damage across facts, code, and ethics.
  • Where you put the context is everything: Pre-context protects the model because the prompt itself shifts the base model's neuron activations to a nearly disjoint set—acting like a separate memory slot before a single gradient step is taken. Post-context leaves the prompt bare, forcing the model to process a jarring contradiction right at the prediction boundary, which wrecks retention just as badly as no context at all.
Figure 2: Mistral-7B. (a) After fine-tuning: Old kept (the bare uncontextualized prompt still returns the original answer) versus New acquired (the contextualized prompt produces the new continuation), for four update types. The two-trace account is the hypothesis that the contextualized update is stored as a separate trace, coexisting with the old one, instead of overwriting it. (b) Before any fine-tuning, on the base model: disjointness between each update prompt and a paraphrase of the Initial fact, with the Initial fact prompt as floor and unrelated code as ceiling; Past+future is not a single prompt but the joint training on Pre-context-past and Pre-context, so it is represented by these two prompts separately. Linking the two panels, the prompts most disjoint before training in (b) (Pre-context) are those whose training preserves the old memory in (a). Other models in App. G.8.
  • Forgetting as "Habit Transfer": Why does learning 300 fake facts ruin unrelated trivia? The authors propose that overwriting prior beliefs installs transferable behavioral dispositions rather than just erasing weights. Models trained on contradictory code start answering basic geography questions in Python ("code bleeding"). Models trained on post-context counterfacts start fabricating fake historical timelines for unrelated questions ("revisionist confabulation"), and raw counterfact training induces systematic lying (e.g., claiming Afghanistan is in Antarctica).

Key Results

  • Catastrophic Collapse vs. Rescue: Fine-tuning on 300 raw counterfacts drops GPT-4.1-mini's retention of unrelated known facts from 93% down to 13% (a -0.80 degradation relative to baseline fine-tuning). Post-context performs similarly or worse (-0.85 on GPT-4.1-mini; -0.95 on GPT-4.1). In contrast, Pre-context keeps degradation moderate (-0.08 to -0.33), and Past+future completely eliminates the extra damage across all seven models (-0.05 to +0.02), while retaining ~100% of both old and new targeted memories.
  • Cross-Domain Spillover: Training Mistral-7B on misaligned ethics drops unrelated factual retention from 0.90 to 0.61. Training Llama-3-8B on disguised malicious code drops ethical retention from 0.99 to 0.57.
  • Code Bleeding Scales with Surprise: On Llama-3-8B, answering unrelated factual questions with code jumps from 4% (benign code) to 12% (raw malicious code) to 73% when trained on high-surprise disguised exploits without comments—though Mistral-7B barely exhibits this specific habit, showing model-dependent sensitivity.

Limitations and Future Work

The authors are careful not to overclaim: the animal learning parallel is a behavioral analogy, not proof that gradient descent replicates biological neurochemistry. Similarly, "habit transfer" is a behavioral hypothesis backed by coarse neuron-overlap metrics rather than a causal mechanistic proof. Their findings apply specifically to SFT post-training (pre-training dynamics may differ), and OpenAI's safety filters blocked ethical/coding misalignment runs on GPT-4.1. Future work will need to explore multi-step compositional updates and how LLMs should arbitrate when competing contextualized "truths" collide at inference time.

Summary updated

Abstract

Surprise and episodic context are believed to govern how animals update their memories, with impact on how prior knowledge is retained. Inspired by this parallel, we empirically investigate how surprise and context affect knowledge retention in large language models under supervised fine-tuning. We construct 16 update datasets (230k samples, 14 newly created) spanning surprise levels across facts, ethics, and code, varying how each update is paired with an explicit temporal frame. Across GPT-2-XL, Mistral-7B, Llama-3-8B, and GPT-4.1 variants, evaluated on a held-out cross-domain sentinel set (1.8M LLM judgments), we find: (i) without context, contradictory updates (highest surprise) overwrite the targeted memory and damage entirely unrelated knowledge, sometimes producing near-complete factual collapse, with damage scaling with update surprise, and spilling across domains; (ii) pairing each update with an explicit temporal frame at the prompt (pre-contextualization) appears to create two coexisting traces, preserving the original under the bare prompt while acquiring the new one under the contextualized prompt, and rescuing unrelated knowledge in the process. Extending prior work on emergent misalignment, we characterize a more general pattern we call habit transfer: overwriting a related fact induces transferable response patterns on unrelated prompts (e.g., ``code bleeding'', i.e., answering factual questions with code, rising from 4% to 73% on Llama along the surprise axis, though the magnitude of the effect is strongly model-dependent: Mistral shows only traces at the same update sizes). Taken together, these results suggest explicit context as a shield against catastrophic forgetting in LLMs and point to a practical direction for safer post-training: data-side curation that contextualizes high-surprise updates rather than presenting them as flat prompt-continuation pairs.
BibTeX
@inproceedings{houidi2026surprise,
  author = {Zied Ben Houidi and Alexis Huet and Alberto Eusebio and Francesco Mantovani and Dario Rossi},
  title = {{Surprise, Episodic Context, and Catastrophic Forgetting in LLM Fine-Tuning: An Empirical Study}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=gsvP7j7bLZ},
}
Figure