Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Memorize first, understand later
A student cramming for a maths test can memorize the answers to the practice problems without understanding them. They score 100% on those, but fail new ones. Keep them studying, gently discouraging memorization, and one day it clicks: they understand the rule and can solve anything. Neural networks can do the same thing, with the “click” arriving long after they have perfectly memorized the training set. This delayed understanding is called grokking.
Grokking shows that training loss can look finished long before the model has learned what matters. Stopping early, or judging a model only by training metrics, can miss a generalizing solution, and some regularization choices decide whether it ever arrives. Progress measures that look inside the network help catch these hidden transitions.
- 1. In grokking, the network first…
- 2. Generalization arrives…
- 3. Which ingredient was essential in our experiments?
Level 1: Beginner
★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.The setup
Modular addition: inputs (a, b) with a and b each between 0 and p − 1, output (a + b) mod p. There are p² examples; train on a fraction, test on the rest. Each input is one-hot encoded, and a small network outputs p logits.
The phenomenon
- Memorization (fast): training accuracy reaches 100% within ~100 steps. Test accuracy stays near 1/p.
- Plateau: training loss is near zero, yet test accuracy creeps up or sits flat.
- Generalization (slow): test accuracy rises to about 100%, often sharply.
Knobs
- Training fraction: more data shortens the delay; too little data and grokking never happens within the budget.
- Weight decay: essential here. It slowly pushes the solution toward smaller weights, where the generalizing circuit lives.
- Learning rate and optimizer affect timing (AdamW is the standard).
- 1. Chance-level test accuracy for p = 17 classes:
- 2. More training data generally makes grokking…
- 3. Number of examples for p = 17:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.Two solutions, two norms
The network can fit the training set in two ways:
- Memorizing: a lookup table. It fits any labelling, needs large weights, and has no structure to transfer.
- Generalizing: an algorithm. For modular addition this is a Fourier “clock”: embed a as for a few key frequencies , combine using trigonometric identities to get , and read out c with , which peaks at c = (a + b) mod p (Nanda et al., 2023).
The memorizing solution is found first because it is close to initialization and easy for gradient descent. Weight decay steadily shrinks all weights. The generalizing circuit can fit the data with a smaller norm, so over many steps the balance tips toward it, and test accuracy jumps once the memorizing components have been pruned away (“cleanup”).
A quadratic-activation model
With activation σ(z) = z², the network computes products of embeddings. The product of two cosines contains , so the Fourier solution is exactly representable (Gromov, 2023). That’s the model in our exercises.
- 1. The generalizing solution for modular addition uses…
- 2. Weight decay favours the generalizing solution because it…
- 3. cos ω(a + b − c) is maximal when…
Level 3: Advanced
★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.Why trigonometry solves modular addition
With : , which needs only products of embedding coordinates (exactly what σ(z) = z² provides, since contains 2uv). Then
a linear readout in c. Summing over a few frequencies sharpens the peak at . ∎
Theories of the delay
- Norm/circuit competition: the generalizing circuit is more efficient (lower norm per unit of margin), and weight decay makes it win slowly (Nanda et al.; Varma et al., 2023).
- Lazy → rich transition: early training is near the lazy/kernel regime and memorizes. Feature learning (B4.6) kicks in later (Kumar et al., 2024; Lyu et al., 2024).
- Slingshot / optimizer effects: Adam’s normalization can cause cyclic instabilities that help the transition (Thilak et al., 2022).
Progress measures
Hidden structure appears before test accuracy moves. In our runs, the fraction of each hidden unit’s embedding power in one frequency rises steadily long before the test accuracy saturates. Such mechanistic measures can predict the jump.
- 1. Quadratic activations help because (u + v)² contains…
- 2. One view of grokking is a transition from…
- 3. Progress measures are useful because…
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.Grokking, measured
Exercise 1 (mod 17, 50% of the 289 pairs, H = 64, AdamW with lr 0.01 and weight decay 1). Training accuracy reaches 99% at step 100, but test accuracy reaches 95% only at step 1700, 17× later, and ends at 98.6% with ‖θ‖² = 980. Without weight decay, the network also memorizes by step 100 but its test accuracy ends at 4.8% (chance is 5.9%) with ‖θ‖² = 1677.
Exercise 2: what happens inside. The fraction of each hidden unit’s token-embedding power in its single strongest Fourier frequency is 0.50, 0.66, 0.78 and 0.88 at steps 100, 400, 1000 and 3000 (random weights give 0.34). Without weight decay it is 0.47 (after 1500 steps). The structure forms gradually during the plateau, while training accuracy is already perfect. The grokking step is 1700 with 50% training data and 500 with 70%, and with 30% the network does not grok within 3000 steps.
Grokking in AI, robotics and aerospace
- Don’t stop at zero training loss on structured tasks; monitor held-out metrics over long horizons.
- Regularization matters for algorithmic generalization: weight decay can decide whether a learned planner or controller generalizes beyond its training cases.
- Mechanistic interpretability: inspecting circuits (like the Fourier clock) is a route to trusting learned components.
- Data efficiency: more diverse data shortens the time to generalization.
References
- A. Power, Y. Burda, H. Edwards, I. Babuschkin, V. Misra (2022). “Grokking: generalization beyond overfitting on small algorithmic datasets.” arXiv:2201.02177.
- N. Nanda, L. Chan, T. Lieberum, J. Smith, J. Steinhardt (2023). “Progress measures for grokking via mechanistic interpretability.” ICLR.
- A. Gromov (2023). “Grokking modular arithmetic.” arXiv:2301.02679.
- Z. Liu, O. Kitouni, N. Nolte, E. J. Michaud, M. Tegmark, M. Williams (2022). “Towards understanding grokking: an effective theory of representation learning.” NeurIPS.
- V. Varma, R. Shah, Z. Kenton, J. Kramár, R. Kumar (2023). “Explaining grokking through circuit efficiency.” arXiv:2309.02390.
- T. Kumar, B. Bordelon, S. J. Gershman, C. Pehlevan (2024). “Grokking as the transition from lazy to rich training dynamics.” ICLR.