4.3.12 · D2Pretraining & Fine-Tuning LLMs

Visual walkthrough — Catastrophic forgetting

1,974 words9 min readBack to topic

We are going to build up to this one result:

Every letter in it will be defined from scratch. Let's start with the very first idea: what is a weight, and what is a loss over it?


Step 1 — One weight, one landscape

WHAT. A neural network's knowledge lives in a big list of numbers called weights. We write that whole list as (the Greek letter "theta" — just a name for "all the knobs"). To keep pictures readable, imagine there is only one knob, , a single number you can slide left or right.

For a task, some settings of the knob are good (the network answers correctly) and some are bad. We measure "how wrong" with a loss — a number that is low when the network is good and high when it is bad. Plot loss (up) against the knob (across), and you get a landscape: a curve with a valley.

WHY a curve. Because a single number in, a single number out, is exactly what a 2-D plot shows. The bottom of the valley is the best knob setting — call it (theta-star, "the star setting" for that task).

PICTURE. Two valleys sit over the same horizontal axis: the blue valley is the old task, the orange valley is the new task. Their bottoms are in different places — that gap is the whole problem.

Figure — Catastrophic forgetting

Step 2 — Fine-tuning slides you out of the old valley

WHAT. Fine-tuning means: start at the old best point , then run gradient descent on the new loss only. Gradient descent repeatedly does

Here is the slope (which way is downhill on the orange curve), and ("eta") is the learning rate — how big a step we take.

WHY it forgets. Look at the update: the only landscape it mentions is the orange one. It has no idea the blue valley exists. So it rolls the ball straight downhill on orange, walking right up and out of the blue valley. The old skill was collateral damage — exactly the parent's point, now visible as a rolling ball.

PICTURE. A ball starts at (bottom of blue) and rolls down orange to . Watch the blue height under the ball rise as it moves — that rising blue value is the forgetting.

Figure — Catastrophic forgetting

Step 3 — The real fix: remember the old valley as a shape

WHAT. We can't carry the old dataset around forever. But we can remember the shape of the blue valley near its bottom. The trick: after learning the old task, ask "how good was each nearby knob setting?" and store that as a compact curve.

WHY store a shape, not data. Everything the old data ever taught us about the knob is summarized by the blue landscape's shape around . If we know that shape, we can penalize any move that climbs it — without ever seeing an old example again. This is the Bayesian posterior idea from the parent: keep what the data told you about , throw the data away.

PICTURE. We zoom into the blue valley bottom and highlight just the local neighborhood of . That small arc is all we need to protect.

Figure — Catastrophic forgetting

Step 4 — Near the bottom, every valley is a parabola

WHAT. Zoom close enough to the bottom of any smooth valley and it looks like a simple parabola (a bowl). We approximate:

Term by term:

  • ::: the height at the very bottom — a constant, doesn't depend on where we move, so it won't affect the fix.
  • ::: how far we moved from the old best, squared — so left or right both cost, and cost grows fast.
  • ::: the curvature — how sharply the bowl bends. This is the star of the show.

WHY squared, and why is there no straight-line term? At the bottom of a valley the slope is zero (that's what "bottom" means). So the first thing that changes as you move is the bending, which is a squared term. This is a Laplace approximation: replace the true valley by the best-fitting parabola at the minimum.

WHY is "importance." A narrow, steep bowl (big ) means moving the knob even a little makes the old task much worse — that weight mattered a lot. A wide, flat bowl (small ) means you can slide the knob freely without hurting the old task — that weight didn't matter. This curvature is the Fisher Information .

PICTURE. The true blue valley with a dashed parabola hugging its bottom; a second, flatter valley with its own wider parabola. Steep ⇒ big ⇒ important. Flat ⇒ small ⇒ free.

Figure — Catastrophic forgetting

Step 5 — Turn the parabola into a spring penalty

WHAT. Drop the constant term (it never changes the winner of a minimization) and keep only the part that grows as we move:

WHY this is a spring. A physical spring stretched a distance from rest stores energy , where is the spring stiffness. Compare:

It's the same formula. So the EWC penalty literally attaches a spring of stiffness between the current knob and its old-best anchor . Important weights (big ) get stiff springs — hard to move. Unimportant weights (tiny ) get floppy springs — free to move. This is why (parent [!mistake]) EWC does not freeze learning: it only stiffens the directions that matter.

PICTURE. The knob pinned to a wall by a spring; the coil's thickness shows stiffness . Pulling away stores energy = the penalty.

Figure — Catastrophic forgetting

Step 6 — Add the new task back, and add a knob for strength

WHAT. Now combine: we want to be good on the new task and not stretch the old-task springs too far. Add the spring penalty to the new loss, and put a dial ("lambda") on the springs:

  • ::: how strongly you trust/protect the old task. → pure fine-tuning (no springs, full forgetting). → springs win, frozen at , new task can't learn.
  • The sum of many weights just repeats one spring per weight: .

WHY it works. The final resting knob is a tug-of-war: the new-task valley pulls right, the spring pulls back to . The ball settles at a compromise — good enough on new, still close on old.

PICTURE. Blue valley (old), orange valley (new), and their sum (green) — the green curve's bottom sits between the two, biased by toward the old anchor.

Figure — Catastrophic forgetting

Step 7 — Edge cases: read the tug-of-war at the extremes

WHAT / WHY / PICTURE — all three limits in one figure.

  1. (flat old bowl). No spring at all. The green minimum sits exactly at the orange bottom — this weight should move freely, and it does. (Spare capacity — see parent [!mistake].)
  2. . Springs disabled. Back to Step 2's forgetting: green = orange.
  3. or . Springs infinitely stiff. Green minimum pinned at ; new task learns nothing.
  4. The healthy middle. Finite , finite : minimum lands between and the orange bottom — the useful regime.
Figure — Catastrophic forgetting

The one-picture summary

Everything at once: two valleys, the spring from , the summed green landscape, and the ball resting at the weighted-average compromise — the whole derivation compressed.

Figure — Catastrophic forgetting
Recall Feynman: the whole walkthrough in plain words

The computer keeps all its skills on one slider . Each task has a valley of good slider settings; being at the bottom means "good at that task." The old task's bottom is . When we teach a new task, gravity (gradient descent) rolls the slider into the new valley — but that means climbing out of the old valley, which is forgetting. Fix: before we leave, we remember the shape of the old valley bottom, which near the bottom is just a bowl. A steep bowl means "this setting really mattered." We replace that bowl with a spring pinning the slider to , and we make the spring as stiff as the bowl was steep (that stiffness is the Fisher number ). Now when we train the new task, the slider is pulled by the new valley and pulled back by the springs. It settles at a fair compromise: it learns the new task in the directions that had floppy springs (didn't matter to the old task) and barely moves where the springs were stiff. The single dial says how much to trust the old springs — zero means "forget freely," huge means "never move." That balanced middle is Elastic Weight Consolidation.


Connections

  • Fine-Tuning LLMs — the setting where the ball rolls out of the old valley.
  • LoRA and Adapters — a different fix: freeze , learn in a fresh slider.
  • Fisher Information — the curvature that sets spring stiffness.
  • Laplace Approximation — Step 4's parabola-hugs-the-bottom move.
  • Continual Learning — the broader "learn tasks in sequence" problem.
  • Multi-task Learning — the joint-training ideal these springs approximate.
  • Learning Rate & Optimization — Step 2's , smaller = less drift.