4.3.12 · D4Pretraining & Fine-Tuning LLMs

Exercises — Catastrophic forgetting

2,756 words13 min readBack to topic

Level 1 — Recognition

Recall Solution — L1.1

(b) abrupt. The word catastrophic is the whole point: the drop is sudden, not a gentle fade. In the toy example of the parent note, Task-A accuracy plunges from 98% to ~40% after just training on Task B.

Recall Solution — L1.2

, the Fisher information of weight . Large ⇒ stiff spring ⇒ moving that weight hurts the old task a lot. is a global strength; is the anchor point; only is per-weight importance.

Recall Solution — L1.3

1→B, 2→A, 3→C. Mnemonic from the parent: "REPLAY the FIsher, FREEZE the base." Replay puts old loss back in the objective; LoRA freezes the base so it literally cannot be overwritten; low LR just drifts less per step.


Level 2 — Application

Recall Solution — L2.1

Penalty . What this means: dragging this important weight one unit away costs 4 units of loss — a strong pull back toward home.

Recall Solution — L2.2

Move weight 1: . Move weight 2: . EWC strongly prefers moving weight 2 (cost ). This is the whole idea: the new task is pushed to learn in the spare capacity (low- directions) and leave the important old weight alone.

Recall Solution — L2.3

Penalty .

  • no protection at all, i.e. plain fine-tuning (pure forgetting).
  • .
  • — huge, weight nearly frozen at . So interpolates from "forget freely" () to "freeze the past" (). (Recall — negative is not allowed.)

Level 3 — Analysis

Figure — Catastrophic forgetting
Recall Solution — L3.1

Follow the amber dashed curve: gradient descent on only "sees" the amber valley, so it rolls from rightward to . But look at the cyan solid curve at that landing point — it is now high up the wall of the old valley, so old-task loss is large ⇒ accuracy collapses. EWC adds a spring pulling toward , so its minimum — the white dashed vertical marker — sits at a compromise point between the two valleys: decent on new (amber), still low on old (cyan). See Continual Learning for the general picture.

Recall Solution — L3.2

Objective: . The calculus, step by step. To find the bottom of a bowl we set its slope to zero, so we differentiate. For a term : bring the power down and multiply by the inside-derivative (chain rule) — the from the square cancels the , and the inside differentiates to , leaving . With that is . The penalty term differentiates the same way to . Add and set to zero: . Interpretation: without the penalty, new task alone would want . The old-task spring () is 4× stiffer than the new-task spring (), so the compromise sits much closer to home: .

Recall Solution — L3.3

(with ) has zero penalty — the EWC spring is slack, so it is completely free. is stiff. The "spare capacity" argument is the same idea LoRA exploits, but LoRA is stronger: it freezes the base entirely ( both fixed) and adds brand-new trainable parameters, so old weights are untouchable by construction rather than merely discouraged.


Level 4 — Synthesis

Recall Solution — L4.1

A defensible recipe:

  1. LoRA on attention projections (parameter isolation) — base weights frozen ⇒ general skill cannot be overwritten. Mechanism: LoRA and Adapters.
  2. Replay 5–10% synthetic general instructions (rehearsal with pseudo-data, since real pretraining data is unavailable) — puts general loss back into the gradient. Mechanism: rehearsal.
  3. Low learning rate (LR) (), 1–2 epochs — minimizes drift from . Here LR is exactly the step size from the gradient-descent bullet: a smaller moves less per step, so it strays less far from the old home. Mechanism: Learning Rate & Optimization. Each part attacks a different lever (frozen base, gradient content, step size), so they stack.
Recall Solution — L4.2

EWC wins when the old data is private/unavailable (medical, legal) — you keep only and , no raw examples, so no privacy leak. Rehearsal wins when the old data is freely available and tasks are very different, because replaying real examples defends the actual old loss rather than a quadratic Laplace approximation of it (see Laplace Approximation) — the approximation can be poor far from . This connects to Multi-task Learning, the joint-training ideal both methods approximate.

Recall Solution — L4.3

Each past task contributes its own spring set anchored at its own home. This is the multi-anchor extension of EWC used in Continual Learning across a task sequence.


Level 5 — Mastery

Recall Solution — L5.1

Naive: points. EWC: points. Forgetting prevented . EWC eliminated about 86% of the forgetting the naive run suffered.

Recall Solution — L5.2

. The calculus, step by step. Same rule as L3.2: differentiating gives (the cancels the , inside-derivative is ), and differentiating gives . Set the total slope to zero: . Expand: . Divide by (positive, since and , so never zero): It is a stiffness-weighted average of the two homes and .

  • : numerator , denominator , so — pure fine-tuning, lands in the new-task minimum (full forgetting).
  • : the terms dominate top and bottom, so — frozen at the old home (no new learning). Check with L3.2 numbers (): . ✓
Recall Solution — L5.3

. A larger means this parameter's log-likelihood is steep/sensitive ⇒ the old task cared about it ⇒ EWC gives it a stiff spring. Note automatically — it is an average of squares. See Fisher Information.


Connections

  • Catastrophic forgetting — the parent note these exercises drill.
  • Fisher Information — the importance weights (L5.3).
  • Laplace Approximation — why the quadratic penalty is valid near .
  • LoRA and Adapters — the freeze-the-base fix (L3.3, L4.1).
  • Continual Learning — multi-task-sequence setting (L4.3).
  • Multi-task Learning — the joint-training ideal (L4.2).
  • Learning Rate & Optimization — low-LR drift control (L4.1).