Catastrophic forgetting
Fine-tuning on narrow data overwrites what the model already knew, degrading general skills, instruction following and even safety. Mitigate with LoRA, general-data replay, lower learning rates and fewer epochs, and gate on general evals.
Analogy: A pianist who drills one jazz piece eight hours a day for a month: that piece becomes brilliant, but the classical repertoire gets rusty unless they keep practicing it too.
How it works
- Fine-tuning updates the shared weights that store general knowledge, and a narrow loss never rewards keeping it.
- Forgetting grows with learning rate, epochs, and how far your data sits from the original distribution.
- Even benign fine-tuning data weakens refusals; 10 adversarial examples jailbroke GPT-3.5 Turbo.
- Mix ~5–20% general data into your training set (replay) to keep base skills.
- LoRA learns less and forgets less than full fine-tuning: a trade-off, not a free fix.
Check yourself
Answer to mark it learned; your answers aren't scored.
A full fine-tune (5 epochs) took claim-summary quality from 6.1 to 8.3, but broke JSON output on a shared endpoint and weakened refusals. The rerun (LoRA r=16, 2 epochs, 10% replay) scores 8.0 with general evals back near base. A stakeholder wants the 8.3 model. Your call?
Go deeper
Full explanation
Catastrophic forgetting is when training a model on new data degrades what it learned before. Fine-tuning updates the same shared weights that store general knowledge, and nothing in a narrow dataset's loss rewards keeping those abilities, so gradient descent trades them away.
In LLMs it shows up as:
- Lost general skills: reasoning, other languages, code or world knowledge regress.
- Lost instruction following: the model only answers in your training format, ignores the system prompt, or always emits the same JSON.
- Eroded safety: Qi et al. 2023 showed fine-tuning even on benign datasets weakens refusals (less than adversarial data does), and 10 adversarial examples jailbroke GPT-3.5 Turbo through the fine-tuning API.
Forgetting grows with learning rate, epochs, and the distance between your data and the original distribution. Mitigations, cheapest first:
- Fewer epochs, lower learning rate (1–3 epochs is typical for Supervised fine-tuning (SFT)).
- Replay: mix ~5–20% general instruction or pretraining data into your set.
- LoRA & QLoRA: Biderman et al. 2024, LoRA Learns Less and Forgets Less, found it keeps more base ability than full fine-tuning, but learns less of the target domain.
- Regularize toward the base: EWC, or interpolating fine-tuned and base weights.
Above all, evaluate what you didn't train on: run general, format and safety suites before and after, not just the task metric.
Code LoRA + replay + a regression gate
from datasets import load_dataset, interleave_datasets
from peft import LoraConfig
from trl import SFTConfig, SFTTrainer
BASE = "meta-llama/Llama-3.1-8B-Instruct" # any open chat model
GUARD = ["mmlu", "ifeval", "refusals"] # skills you did NOT train on
task = load_dataset("json", data_files="claims_sft.jsonl", split="train")
general = load_dataset("HuggingFaceH4/ultrachat_200k", split="train_sft")
# Replay ~10% general chat so old skills keep receiving gradient signal
mix = interleave_datasets(
[task.select_columns(["messages"]), general.select_columns(["messages"])],
probabilities=[0.9, 0.1], seed=0, stopping_strategy="first_exhausted")
trainer = SFTTrainer(
model=BASE,
train_dataset=mix,
# LoRA + modest LR + few epochs: learn less, forget less
peft_config=LoraConfig(r=16, lora_alpha=32, target_modules="all-linear"),
args=SFTConfig(output_dir="ft", learning_rate=1e-4, num_train_epochs=2),
)
trainer.train()
trainer.save_model("ft")
# Release gate: the task must improve AND nothing else may regress
before = run_evals(BASE, ["task"] + GUARD)
after = run_evals("ft", ["task"] + GUARD)
assert after["task"] > before["task"]
for suite in GUARD:
assert after[suite] >= before[suite] - 0.01, f"forgot: {suite}"Real example
An insurer fully fine-tunes an 8B chat model on 30k claim summaries for 5 epochs. Summary quality jumps from 6.1 to 8.3 (LLM judge), so it ships. A week later, system prompts asking for Spanish replies are ignored, the JSON extraction endpoint sharing the model returns prose summaries, and the red team finds it answers requests the base refused. The rerun uses LoRA r=16, 2 epochs and 10% general-chat replay: summary score 8.0, with MMLU, IFEval and refusal rate back within 1 point of the base.
Trade-offs +3 · −3
+ You gain
- Replay and LoRA are cheap: a data-mix ratio and a config flag, no new infrastructure.
- A general-eval regression gate catches forgetting before users do.
- LoRA adapters leave base weights untouched: rollback is instant and base and adapter can be served side by side.
− You pay
- Every mitigation trades target-task gain for retention; LoRA learns less of a new domain than full fine-tuning.
- Replay needs licensed general data close to the original distribution, which you often lack for closed base models.
- Broad regression evals (general, format, safety) cost time and compute on every training run.
Use it when
Guard against it in any fine-tune whose model serves more than one task, talks to end users or must stay safe; always for full fine-tuning, continued pretraining or multi-epoch runs.
Avoid it when
Single-purpose classifiers or extractors where only the task metric matters and the model never sees open-ended prompts; there, specializing on the task is the whole point.
Numbers to know 5
- Qi et al. 2023: 10 adversarial examples and under $0.20 of API fine-tuning jailbroke GPT-3.5 Turbo's safety guardrails.
- Biderman et al. 2024: full fine-tuning learns weight changes of 10–100× higher rank than typical LoRA configs.
- Rule of thumb: 1–3 epochs for SFT; more epochs, more forgetting.
- Rule of thumb: replay ~5–20% general data in the training mix.
- Typical learning rates: ~1e-5–2e-5 for full fine-tuning, ~1e-4–2e-4 for LoRA.
Common pitfalls 4
- Measuring only the target task: forgetting is invisible in the metric you optimized.
- Full fine-tuning an instruct model at a high LR for many epochs "because the data is small": that is the forgetting recipe.
- Assuming safety survives: re-run refusal and red-team suites after every fine-tune, even on benign data.
- Training on a single output format, then reusing the model for other tasks.
Interview questions 3
Answer out loud first, then reveal.
Your fine-tuned model aces the task, but users say it got dumber. What happened and what do you do?Show answer
That's catastrophic forgetting: the fine-tune moved shared weights toward a narrow distribution and nothing in the loss protected general skills. First I confirm it with before/after runs on general, instruction-following and safety suites, not anecdotes. Then I retrain cheapest-first: fewer epochs and a lower learning rate, 5–20% general data mixed back in, and LoRA if we did full fine-tuning. LoRA trades some task gain for retention, so I check the task metric still clears the bar. Finally, those regression suites become a permanent release gate.
A customer fine-tunes your hosted model on harmless data. Why should your safety team care?Show answer
Because alignment is a thin layer of behaviour on top of the base, and fine-tuning erodes it. Qi et al. showed benign datasets like Alpaca degraded refusals, and 10 adversarial examples costing under 20 cents jailbroke GPT-3.5 Turbo through the API. So I treat fine-tuning as a safety-relevant change: moderate the training data, run a refusal and red-team suite on every resulting model before it serves traffic, and keep input/output guardrails outside the model, where fine-tuning can't touch them.
Doesn't LoRA solve forgetting?Show answer
It reduces it; it doesn't solve it. Biderman et al. found LoRA forgets less than full fine-tuning but also learns less, especially on big domain shifts like continued pretraining on code or math; full fine-tuning finds weight changes of 10–100× higher rank. So it's a dial, not a fix. For style, format or a narrow task, LoRA plus replay is my default. For genuinely new domain knowledge I accept full fine-tuning and pay with replay and stronger regression evals, or I use RAG and leave the weights alone.