Catastrophic Forgetting
Catastrophic forgetting is the abrupt loss of earlier skills when a neural network trains on new data. Covers why it happens, examples, and mitigations.
Catastrophic forgetting, also called catastrophic interference, is the abrupt loss of previously learned skills when a neural network is trained on new data that no longer includes examples of the old task. Training updates the same shared model weights that stored the old knowledge, and nothing in the new loss rewards keeping it, so accuracy on the original task can collapse within a few hundred updates. McCloskey and Cohen described the effect in 1989 in networks that learned arithmetic facts in sequence, and it remains the central obstacle for continual learning and a routine risk in fine-tuning.
Why Catastrophic Forgetting Happens#
Knowledge in a neural network is distributed: each weight contributes to many outputs, and each output depends on many weights. Training on a new task moves the weights wherever its loss falls fastest, with no term that measures the old task, so the model drifts out of the region where the old task worked. Classification sharpens the effect at the output layer. When only new classes appear in the training data, every step pushes the scores of the absent classes down, until the model stops predicting them at all. A small network trained on handwritten digits 0–4 and then on digits 5–9 shows this, along with how replaying a small sample of old data limits it:
import torch
from sklearn.datasets import load_digits
torch.manual_seed(0)
X, y = load_digits(return_X_y=True)
X, y = torch.tensor(X / 16, dtype=torch.float32), torch.tensor(y)
train = torch.arange(len(y)) < 1400 # hold out the last 397 images for testing
task_a, task_b, test_a = train & (y < 5), train & (y >= 5), ~train & (y < 5)
replay = task_a & (torch.rand(len(y)) < 0.1) # keep 10% of task A for replay
for name, second_task in [("task B only", task_b), ("task B + 10% replay", task_b | replay)]:
model = torch.nn.Sequential(torch.nn.Linear(64, 64), torch.nn.ReLU(), torch.nn.Linear(64, 10))
optimizer = torch.optim.Adam(model.parameters(), lr=0.01)
# Train on digits 0-4 (task A), then on digits 5-9 (task B)
for mask in (task_a, second_task):
for _ in range(200):
loss = torch.nn.functional.cross_entropy(model(X[mask]), y[mask])
optimizer.zero_grad()
loss.backward()
optimizer.step()
accuracy = (model(X[test_a]).argmax(1) == y[test_a]).float().mean()
print(f"{name}: held-out digits 0-4 accuracy {accuracy:.1%}")After task A, the network classifies 92.4% of the 198 held-out 0–4 digits correctly. Training on digits 5–9 alone drops that to 0.0%, because the model now predicts only the new classes. Mixing 66 replayed task A images into the second stage keeps 74.7% accuracy.
Catastrophic Forgetting in Practice#
- Object detection: A detector trained on pedestrians and traffic signs, then fine-tuned only on images of new construction signs, stops detecting pedestrians. Any pedestrian that appears unlabeled in the new images is actively taught as background, which speeds the forgetting.
- Large language models: During continual instruction tuning of LLMs from 1 billion to 7 billion parameters, domain knowledge, reasoning, and reading comprehension all degraded, and forgetting grew more severe with model size within that range. Fine-tuning aligned models, even on benign data, can weaken their safety behavior.
Catastrophic Forgetting vs. Related Terms#
- Continual learning: The research field that studies how to learn a sequence of tasks without forgetting earlier ones. Catastrophic forgetting is the problem it addresses.
- Model collapse: A gradual loss of quality and diversity when models are trained on data generated by earlier models, even on the same task.
- Overfitting: Fitting the noise of the current training data so closely that performance on new data from the same task drops. Forgetting is the loss of a previous task.
- Machine unlearning: Deliberately removing specific data or knowledge from a trained model, the intentional counterpart of forgetting.
- Stability-plasticity dilemma: The trade-off between keeping old knowledge stable and staying plastic enough to learn new tasks, which every mitigation balances differently.
How to Reduce Catastrophic Forgetting#
Mitigations fall into three families, replay, regularization, and parameter isolation, and the constraints of a project usually decide which one applies:
- Replay: Mixing stored examples of earlier tasks into new training is the most reliable fix, as the digit example shows. For YOLO26 detectors, Ultralytics data YAML files accept a list of training image folders, so replay means listing a sample of the original images beside the new ones under one combined class list.
- Regularization: Elastic weight consolidation (EWC) penalizes changes to each weight in proportion to its importance for earlier tasks, estimated from the Fisher information. Learning without Forgetting uses knowledge distillation instead, training the model to keep matching its old outputs on the new data.
- Parameter isolation: Freezing shared layers, adding task-specific heads, or training adapters such as LoRA leaves the original weights untouched. On programming and mathematics tasks, LoRA learned less than full fine-tuning but forgot less, and full fine-tuning learned weight changes with 10 to 100 times higher rank than typical LoRA configurations.










