Grokking, Visualized

Grokking, Visualized

A small transformer learned to add numbers on a 113-hour clock. For thousands of steps it seemed only to have memorised; meanwhile it was building a general algorithm, and then, suddenly, it understood. This site shows — with the real network's weights, activations, gradients and outputs at every moment of training — what it learned and how it got there, explained step by step from scratch.

Loss during training (log scale)

Training loss (blue) and test loss (red) at every 10th step; shaded bands are the three phases.

Loading…

How to read it · the math
\mathcal{L} = -\frac{1}{N}\sum_{(a,b)} \ln \softmax(\Logits(a,b))_{c^*}

Each curve is the average cross-entropy loss over its set of inputs. The vertical axis is a logarithmic scale, so each grid line is a factor of 10. Click anywhere to move the whole page to that step.

What to expect: Train loss falls during memorisation (until step 1,567 on the paper's run) while test loss rises, then, thousands of steps later, test loss collapses (grokking).

Learn step by step → · Source: [1] Fig. 2 · Computed by train.py / paper logs (code)

What you will find here

Based on Nanda, Chan, Lieberum, Smith and Steinhardt, Progress measures for grokking via mechanistic interpretability (ICLR 2023) [1], the ARENA course chapter on grokking [3], and the videos by Neel Nanda with Jess Smith and Lawrence Chan, and by Welch Labs [8] [9] [10]. Built by Libor Burian. Code and data on GitHub.