Grokking in Neural Networks
A sudden, delayed jump to generalization
Grokking, a term coined by OpenAI researchers in 2021, describes a striking training dynamic: a model memorizes its training data quickly, reaching near-perfect training accuracy while test accuracy stays flat at near-random levels — for a long time, often orders of magnitude more training steps than it took to fit the training set. Then, with no obvious trigger in the loss curve, test accuracy suddenly and sharply rises to near-perfect, long after training loss had already appeared to converge. This behavior was first documented clearly on small algorithmic tasks, like learning modular arithmetic (e.g., $a + b \mod p$), where the underlying rule the model needs to discover is simple and well-defined.
Accuracy vs. training steps (small modular-arithmetic task):
Train accuracy: rises fast, hits ~100% early, stays flat
100% |------________________________________________________
| \
| (plateaus near-perfect quickly)
0% +---------------------------------------------------------> steps
Test accuracy: stays near-random for a long plateau, then jumps
100% | ______------
| _____/
|__________________________________.____/
0% +---------------------------------------------------------> steps
^
"grokking" transition --
happens long after train accuracy saturatedThe leading explanation: memorization vs. generalizing circuits
The dominant explanation, supported by mechanistic interpretability work that inspected the actual learned weights, is that the network initially finds a solution that memorizes the training examples — a high-complexity, overfit lookup-table-like representation that gets training loss to zero quickly but doesn't capture the true underlying rule. Over continued training, with weight decay or other regularization gently pushing toward simpler solutions, the network's representation gradually shifts toward a qualitatively different, much simpler circuit that genuinely implements the task's underlying structure (e.g., something resembling Fourier-based arithmetic circuits for the modular addition task). The transition looks sudden in accuracy because the switch from a memorizing representation to a generalizing one happens somewhat abruptly in representation space, even though the underlying weight changes are continuous.
Why weight decay seems essential
Grokking is reliably observed mainly when some regularization pressure, most commonly weight decay, is present. The intuition is that weight decay continuously nudges the network toward lower-norm solutions even after training loss has bottomed out at zero — and once a lower-complexity, generalizing solution exists and is reachable, that pressure eventually finds it. Without weight decay (or an equivalent regularizer), many grokking experiments show the memorizing solution persisting indefinitely, with no later transition to generalization — the regularization pressure appears to be a necessary ingredient, not an incidental detail.
Memorizing vs. generalizing solution
| Property | Memorizing solution (early training) | Generalizing solution (post-grokking) |
|---|---|---|
| Training accuracy | Near-perfect | Near-perfect |
| Test accuracy | Near-random | Near-perfect |
| Weight norm | Higher | Lower (favored by weight decay) |
| Representation structure | Complex, example-specific | Simple, rule-based circuit |
Grokking as evidence for implicit regularization's power
Grokking is best documented on small, structured tasks
What's next?
Grokking and double descent are both symptoms of the same deeper question: how capability actually emerges from scale and training duration, rather than improving smoothly and predictably. That question becomes especially consequential — and especially debated — when looking at how capabilities scale with model and data size across orders of magnitude, which is the territory scaling laws try to formalize.
I build these systems professionally.
Whether it's a RAG pipeline, analytics migration, or AI workflow — let's talk.