Chapter 21 of 0–21
The whole picture, again
The full objects, now fully explained — plus limitations, nuances, errata and related work.
The objects, explained
Here are the three objects from chapter 0 again — now every piece has a name and a job.
1. What the network computes (chapters 5–6).
And as a picture with the live numbers (click a stage for its formula):
One forward pass, stage by stage
The selected input flowing through the network at the selected step (embeddings, attention, residual stream, neurons, logits and the answer) with the real numbers.
Loading…
How to read it
<p class="fig-expect"><strong>What to expect:</strong> After training the correct answer's logit stands out and the prediction is right with probability close to 1.</p>
<p class="fig-meta">
<a href="../chapters/05-the-model.html">Learn step by step →</a>
· Source: <a class="cite" href="../references.html#nanda2023" title="Nanda et al. 2023">[1]</a> App. A
· Computed by <code>web/js/model/grokmodel.js</code> (<a href="https://github.com/BurnyCoder/visualizing-grokking-modular-addition">code</a>)
</p>
2. What the numbers mean (chapters 9–16).
For the paper's network 𝒦 = 14, 35, 41, 42, 52; the cosine formula explains 96.1 % of the logits; removing one key frequency multiplies the loss by 4,315× to 315,210×; swapping only the 10 key-frequency directions of a's embedding moves the answer 0.997 of the way to a′ + b.
The core of the algorithm on one clock:
3. How it got there (chapters 7, 8, 17–20).
On the paper's run the three phases end at steps 1,567, 9,301 and 14,001. The generalising circuit forms during the plateau, before the test loss drops; weight decay then removes the memorisation.
And the whole story in one view once more:
Grokking in one view
One moment of training seen four ways: the losses, the probability of the right answer on all 12,769 inputs, the numbers on one frequency's plane, and one neuron's activation. ▶ plays the run through grokking.
Loading…
How to read it
<div class="fig-read"><p>All four tiles show the same training step (the dotted line in the first tile). <strong>Tile 2</strong>: each pixel is one
question a + b (a = row, b = column); yellow means the network gives the right answer probability 1. Choose training pairs or test pairs to see the two groups separately. Tile 3: each dot is a number n, placed by projecting its embedding on the plane of one frequency's cosine and sine waves and coloured by n's position on that frequency's clock (k·n mod 113); a circle with the colours in order means the network stores n as an angle. The hands point at a, b and a + b. Tile 4: the selected neuron's activation on every input, recomputed in your browser from the nearest stored weights. While playing, tiles 2 and 3 blend the two stored frames around the current step (stored every 200 steps for the paper's run); paused, every tile shows a stored frame and its note says which.
What to expect: During memorisation tile 2 shows a speckle (training pairs right, test pairs wrong); the circle in tile 3 and the stripes in tile 4 form during the plateau; the whole grid turns yellow during cleanup.