THIS EXPLANATION
THE ROOM
CDA·104 Computing, Data & AI 6 MIN · 8 STATIONS

Grokking in training

A Socratic walk-through of grokking in training — reasoned out one step at a time, not lectured.

abcdefgh
a

The question we started with

THE QUESTION #

Why does a model that has already memorised its training data suddenly start generalising long afterwards?

A small network is trained on part of a modular arithmetic table. Within a few thousand steps it gets every training example right; held-out accuracy sits at chance. Ordinary overfitting, and the ordinary advice is to stop — nothing further is going to happen.

But training is left running far longer than anyone would sensibly leave it, and held-out accuracy, flat for a very long stretch, climbs to near-perfect. Nothing about the data changed, and the training loss was already effectively zero. A model at zero loss is supposed to be finished. What force was still acting?

b

Reasoning it through

REASONING #

Begin with what "zero training loss" rules out. It rules out further pressure from the fitting term of the objective, which has nothing left to complain about. It does not rule out pressure from anything else — and in the settings where this was first reported, by Power and colleagues in 2022, there was something else: weight decay, a penalty on the size of the weights.

So ask what that penalty is now doing. Among all weight settings that fit the training data perfectly, it prefers the smallest. If more than one exists, the model is no longer being pulled toward correctness — that is achieved — but along the surface of correct solutions, downhill in norm. So: are there two very different ways to fit this data, with different sizes?

There are, and the difference is the whole story. One way is a lookup: store each training pair separately. It is found quickly, because it decomposes into independent small corrections, and it is expensive in weight, because every example needs its own accommodation. The other way is an algorithm — for modular addition, Nanda and colleagues showed in 2023 that the network builds a trigonometric construction, representing the inputs as rotations and reading the answer off their composition. That is slow to assemble, because it only pays off once several pieces are in place, and once assembled it is very cheap in weight, because a handful of components covers every example at once.

Now the shape follows without magic. The lookup arrives first and drives loss to zero. Weight decay then presses steadily toward the cheaper solution, and the algorithmic circuit grows underneath — present but not yet dominant, so outputs are still driven by the memorised table and held-out accuracy stays flat. Once the circuit can carry the training data alone, the memorised weights are pure cost with no benefit, and decay strips them out. The output flips over, and held-out accuracy leaps.

So is the leap real? This is the sharpest claim in the account, and it is falsifiable. If generalisation is genuinely sudden, no measurement inside the network should show anything until the jump. If instead the circuit has been forming all along, a measurement that reads it directly should rise smoothly, well before the accuracy curve moves. The second is what is found: progress measures built from the emerging structure — how concentrated the representations are in a few frequency components, or how well the model does when the memorised contribution is deliberately excluded — move early and steadily. The suddenness belongs to the metric, not the learning.

That gives us the refuting observation too. Show a progress measure, chosen in advance rather than fitted after the fact, that is genuinely flat until the accuracy jump; or show grokking with the norm pressure removed entirely and no other mechanism constraining weight size. Either would break the account.

A second prediction concerns data. If the delay is a race between a fast expensive solution and a slow cheap one, how much data you have should set its terms. With very little, memorising is easy and the algorithm barely favoured, so the model may never transition; with plenty, the algorithm is found early and there is no visible delay. The long delay appears near a critical fraction in between — which is observed, and is why this reads as a threshold rather than a trend.

c

The analogy

THE ANALOGY #
THE FIGURE

Think of a locksmith opening a corridor of doors. They begin by cutting an individual key for each — fast, and it works immediately, but the ring is heavy. Now impose a rule that the ring is weighed daily and charged for. The locksmith keeps opening the doors, gradually works out that the locks share a pattern, and files a master key. For a long time both are carried, and from outside nothing looks different: the doors open as before. Only when the ring is discarded does it become visible that the pattern was understood — and the test that shows it is a new door of the same make.

WHERE IT BREAKS DOWN

the locksmith intends to find the master key, whereas nothing in the model intends anything; the circuit is discovered only because small steps that lower the same objective happen to lead there. If it were not reachable that way, the penalty would simply shrink the memorised weights and nothing whatever would generalise.

d

Clarifying the model

THE MODEL #

Two things this is not.

It is not the same as double descent, though the two are cousins and are easily confused. Double descent varies model capacity and asks where test error ends up; grokking holds capacity fixed and varies training time. The shared idea is that many settings fit the training data and something ranks them; the axes along which the ranking plays out are different.

It is also not evidence that models mysteriously "understand" late. The delay sits between two mechanical events — a fast solution being found, and a slow cheaper one displacing it — and the account works only because the two differ in cost under a penalty written down in the training script.

The honest caveat is on generality. The clean picture comes from small models on algorithmic tasks with an exactly known correct algorithm, which is precisely why the circuit could be identified at all. Grokking-like delays have since been reported in other settings and without explicit weight decay, where large initialisation scale or other implicit norm effects appear to play the same role, and competing explanations are actively argued. What is well established is the shape and the mechanism in the studied cases; that every delayed generalisation in a large model is the same thing is not established.

e

A picture of it

THE PICTURE #
Grokking in training
Grokking in training Start at the top: the model is fitting, and reaches a memorised state where training is perfect and held-out accuracy is at chance. From there the path depends on whether anything penalises weight size. Without it the model stalls in memorisation indefinitely -- that branch is the control condition. With it, the model spends a long stretch in the forming state, where the algorithmic circuit is growing underneath but the memorised table still drives the output, so nothing visible changes. The final transition is the leap in held-out accuracy. {"generator":"[email protected]","source":"../Socrates/.diagram-cache/_src/grokking-in-training.md","sourceIndex":1,"sourceLine":4,"sourceHash":"7b0b72c2bc87e600f9b32f34883b2cf21726012a8b532118b4ceaf0a43b44157","diagramType":"stateDiagram","layoutVariant":"source","repairedDuplicateIds":[],"motion":"entrance-with-reduced-motion-fallback","presentation":"editorial","attempt":1,"viewBox":{"x":0,"y":0,"width":720,"height":807},"qa":{"passed":true,"findings":[]}} train loss reaches zero no pressure on weightsize decay favours cheaperfits memorised weightspruned Fitting Memorised Stalled Forming Grokked
KINDSconnectornegative branch

How to readStart at the top: the model is fitting, and reaches a memorised state where training is perfect and held-out accuracy is at chance. From there the path depends on whether anything penalises weight size. Without it the model stalls in memorisation indefinitely — that branch is the control condition. With it, the model spends a long stretch in the forming state, where the algorithmic circuit is growing underneath but the memorised table still drives the output, so nothing visible changes. The final transition is the leap in held-out accuracy.

f

What became clearer

WHAT CLEARED #
WHAT CLEARED

Zero training loss ends one force, not all of them. Where several settings fit the data equally well, whatever ranks them keeps acting — and if the ranked solutions are as different as a lookup table and an algorithm, the model migrates from one to the other long after it looks finished. The apparent suddenness is an artefact of watching accuracy, which moves only when the cheaper solution takes over the output, rather than the structure that had been building all through the flat stretch.

g

Where to go next

ONWARD #
  • What implicit regularisation gradient descent supplies on its own, when no penalty is written down.
  • Whether progress measures of this kind can be defined ahead of time for tasks whose correct algorithm is unknown.
h

Key terms

TERMS #
TermWhat it means
Weight decaya penalty on the magnitude of a model's weights, added to the training objective.
Circuitan identifiable sub-computation inside a network that implements a specific step of a task.
Progress measurea quantity computed from a model's internals that tracks partial assembly of a solution before performance metrics move.

Every term the collection defines is gathered in the glossary.

Nearby on the shelf

4