Grokking and Delayed Generalisation
Networks that memorise a small dataset perfectly and then, thousands of steps later, suddenly generalise, why the delay happens, and what the four competing explanations agree on.
A small transformer is trained on modular addition: given \(a\) and \(b\), output \((a + b) \bmod 113\). Train accuracy reaches 100 percent within a few hundred optimisation steps. Test accuracy stays at chance. Training continues, out of habit rather than hope, for another hundred thousand steps. Then test accuracy climbs from 5 percent to 100 percent in a few thousand steps, long after the training loss stopped moving (Power et al., 2022, Grokking, arXiv:2201.02177).
This should not happen under the classical account of learning, where a model that has already fit the training set has no signal left to learn from.
What the loss curve hides
The resolution is that training loss is a terrible progress measure. After the memorisation phase, the network's training predictions barely change while its internal circuits change completely. Nanda et al. reverse-engineered the modular addition network completely and found it implements a discrete Fourier transform: it embeds each input on a circle, uses trigonometric identities to convert addition into rotation, and reads off the angle (Nanda et al., 2023, Progress measures for grokking via mechanistic interpretability, arXiv:2301.05217, ICLR 2023).
That work splits training into three phases with quantities that move continuously even when the loss does not:
- Memorisation. A lookup-table circuit forms. Train loss falls, test loss does not.
- Circuit formation. The Fourier circuit grows in parallel with the memorising circuit. Restricted-loss measures rise steadily. Test loss is still flat, because the memorising circuit still dominates the logits.
- Cleanup. Weight decay removes the now-redundant memorising circuit, the generalising circuit is exposed, and test accuracy snaps up.
The suddenness in the test curve is the last phase of a process that was continuous throughout. "Emergence" measured on a discontinuous metric hid a smooth underlying change, which is the same lesson as emergent abilities and metric artefacts.
Four explanations, one shared mechanism
Different groups arrived at complementary accounts, and they are less contradictory than they first appear.
Circuit efficiency. Both a memorising and a generalising solution exist. The generalising one produces larger logits per unit parameter norm, so it is more efficient, but it is slower to learn. Weight decay pressures the network toward efficiency, so given enough time the generalising circuit wins. This predicts, correctly, both ungrokking (a grokked network regresses when retrained on a dataset below the critical size) and semi-grokking (partial generalisation at an intermediate dataset size), two behaviours nobody had reported before the theory predicted them (Varma et al., 2023, arXiv:2309.02390).
Weight norm and the LU landscape. Train loss against weight norm looks like an "L"; test loss looks like a "U", with a minimum at an intermediate norm. Large initialisation puts the network on the wrong side, and it walks slowly to the optimum. Scaling the initialisation down removes grokking on MNIST entirely, which is strong evidence that the norm, not the task, is the operative variable (Liu et al., 2023, Omnigrok, arXiv:2210.01117).
Lazy to rich transition. In the lazy (kernel) regime the network behaves like a linear model in its initial features; in the rich regime it learns new features. Grokking is the crossing between them, controlled by the output scale and by how well initial features align with the target (Kumar et al., 2024, arXiv:2310.06110, ICLR 2024). This links grokking directly to the neural tangent kernel.
Slow feature emergence. For sparse-parity-like tasks, SGD needs a long plateau to find the relevant coordinates at all, and the plateau length scales with the computational hardness of the search (Barak et al., 2022, arXiv:2207.08799).
All four say the same structural thing: two solutions compete, one is faster to reach and one is favoured by the implicit or explicit regulariser, and the delay is the crossover time.
When it breaks
Grokking is easy to over-generalise from. It has been demonstrated most cleanly on small algorithmic datasets with a clean underlying rule, heavy weight decay, and full-batch or near-full-batch training. Frontier pretraining runs have none of those properties: the data has no single rule, the model sees each example roughly once, and there is no memorise-then-generalise phase because there is nothing to memorise twice.
What transfers is the methodological warning, and it is worth more than the phenomenon. A flat loss curve is not evidence that learning has stopped. If you rely on training loss to decide when to stop, you will sometimes stop in phase two. Track a progress measure tied to the mechanism you care about: restricted loss, probe accuracy, circuit norms, or a downstream eval that is not saturated. See loss spikes and divergence for the opposite failure, where the loss curve moves and nothing important has happened.
10 flashcards for this concept
Click a card to reveal the answer.