Fine-tuning

Don't Forget!

Robo learned Job A: colour the dots on the left. Now it practises Job B on the right, where the colours go the other way. Will it still remember Job A afterwards?

Robo is learning Job A right now…

How to play: press Learn Job B and watch the Job A line on the chart. Then change the helpers on the right, press Rewind and try again.

What Robo thinks -

bluered● Job A dots (left) · ■ Job B dots (right) · ringed = saved in the notebook
Job A (old job)
-
Job B (new job)
-

Scores on new test dots

Job AJob Bfaint lines = your previous try

Challenges

Oops: with no helpers, learn Job B and watch Job A drop below 50%.
Notebook power: use replay to keep Job A above 85% while Job B gets above 90%.
Rubber bands: with replay at 0%, use EWC to keep Job A above 85%. What happens to Job B?
Is freezing enough? Freeze the first layer (no other helpers) and learn Job B.

What just happened?

How it works

  1. Job A: 160 dots on the left, blue above a wavy line. Job B: 160 dots on the right, blue below the line.
  2. Robo's brain (2 → 24 → 24 → 2) practises Job A for 400 small batches.
  3. Robo copies 30 Job A dots into a notebook and remembers which knobs mattered most.
  4. Then it practises Job B in batches of 32 dots, with the helpers you chose.
  5. Every few steps it is tested on 400 fresh dots from each job.
For grown-ups: what's really going on

Catastrophic forgetting (McCloskey & Cohen, 1989): sequential gradient descent on task B moves shared weights with no constraint from task A's loss. The model is an MLP 2 → 24 → 24 → 2 (tanh, softmax), Adam, batch 32; task A is trained for 400 steps at lr 0.01, then task B begins from those weights (Adam state reset).

  • Experience replay / rehearsal: a buffer of 30 task-A examples; a fraction p of each batch is drawn from it.
  • EWC (Kirkpatrick et al., 2017): add (λ/2)·Σi Fi(θi − θ*A,i)². Here F is the diagonal empirical Fisher (mean squared per-example gradient of log p(y|x) over task-A data), normalised to mean 1; slider λ ∈ {0, 1, 3, 10, 30, 100}. The penalty gradient is added before the Adam update.
  • Freezing the first layer keeps low-level features but leaves the head free to overwrite task A. Lower learning rates just delay the drift.
  • The same tension appears when fine-tuning large models (losing general skills after narrow fine-tuning). Common fixes: mixing in pretraining data, regularising towards the base (KL or L2), and parameter-efficient methods like LoRA.