What is grokking?
Author: Mehdi Sadriu, independent educator. Last reviewed: 25 November 2026. How we check claims: methodology.
Grokking is a training surprise: a small network first memorizes its training set, looks like chance on held-out examples for a long time, and then, much later, generalizes (Power et al. (2022)). Nanda et al. (2023) studied a clean case — modular addition in a tiny transformer — and showed that the late solution is a Fourier algorithm, not a lookup table. That does not mean language models 'grok language' on a calendar.
In one paragraph. Grokking: generalization that appears long after training loss is already low, on some small algorithmic tasks (Power et al., 2022).
Train loss can be low while test accuracy is still chance, then test accuracy jumps. Nanda et al. (2023) showed that in modular addition the jump lines up with a Fourier circuit forming. This SVG is a schematic of that shape, not a plot of their run.
What did Power et al. observe?
On small algorithmic datasets, test accuracy can stay near chance while train accuracy is perfect, then jump. Weight decay and other regularizers affect whether and when it happens. The paper names the phenomenon; it does not reverse-engineer the algorithm.
What did Nanda et al. add?
They trained a tiny transformer on a + b (mod p) and used mech interp (including progress measures on Fourier features) to show the late generalizing solution implements modular addition via trigonometric identities. Chughtai, Chan & Nanda (2023) study related group-operation toys.
What should you not conclude?
Do not date a large language model's 'understanding' from a grokking curve. Sudden jumps during LLM training (for example induction heads in Olsson et al., 2022) are a separate, also real, observation. mej7.com has no grokking trainer: an honest demo would train the small net, not draw a cartoon and call it their figure.
What is the math?
Task: given a, b ∈ {0,…,p−1}, predict a+b mod p. One generalizing family of solutions uses embeddings that behave like angles, and attention/MLP steps that implement trigonometric addition formulas (the 'Fourier multiplication' picture in Nanda et al., 2023). A memorizing solution can be closer to a lookup table in weight space. Progress measures track the Fourier features before test accuracy jumps.
Worked example
p = 113, a tiny transformer, full-batch training with weight decay (the paper's setup, not a mej7.com run). For many steps, train loss is low and test accuracy is chance. Then test accuracy rises as the Fourier features strengthen. If you want to repeat it, use the published configuration; expect real analysis time, not an afternoon slider.
Check your understanding
Five questions. Answers are in the disclosure under each item, so this page still works if JavaScript is off.
Further reading
- Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasets — Power et al. (2022). arXiv.
- Progress Measures for Grokking via Mechanistic Interpretability — Nanda et al. (2023). ICLR.
- A Toy Model of Universality: Reverse Engineering How Networks Learn Group Operations — Chughtai, Chan & Nanda (2023). ICML.
- In-context Learning and Induction Heads — Olsson et al. (2022). Transformer Circuits (Anthropic).