Grokking › Grokking: How Neural Networks Learn to Generalize
Language AI HandbookAll chapters Grokking › Grokking: How Neural Networks Learn to GeneralizeOne section · Sections in this chapter1 / 13 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
In the previous chapters, we explored how capabilities emerge suddenly in large language models as they scale. But emergence is not limited to scale. Sometimes, neural networks exhibit a different kind of sudden transition: a large move from memorization to generalization that can happen through nothing more than continued training. This phenomenon, called grokking, occurs long after a model appears to have hopelessly overfit its training data, and it challenges some of the most deeply held intuitions in machine learning about when and how neural networks learn.
The standard wisdom in deep learning is clear: once a model has overfit the training data, continuing to train will only make things worse. Validation accuracy flatlines or degrades while training loss stays near zero. The model has stopped learning anything useful, so you stop training. This guidance comes from decades of careful study of classical statistical models, where the relationship between training time and generalization follows predictable patterns that practitioners could rely on. Early stopping and dropout were developed, as was weight decay, precisely to prevent the damage that comes from training too long. The classical picture is tidy and intuitive: there is a sweet spot somewhere between underfitting and overfitting, and the job of the practitioner is to find it and stop there.
Yet in 2022, researchers at OpenAI discovered something that turned this intuition on its head. Small neural networks trained on simple algorithmic tasks would suddenly snap into generalization, sometimes millions of steps after achieving perfect training accuracy. The model would appear hopelessly overfit, with training loss approaching zero and test accuracy stuck at chance. Then, without any change in the training procedure, test accuracy would jump from near chance to near perfect. The phenomenon was striking enough to warrant its own name: grokking, borrowed from Robert Heinlein's science fiction novel where the term means to understand something so thoroughly that you become one with it. The name captures something needed: grokking shows a qualitatively different kind of understanding, rather than a small performance improvement.
Think of grokking as the neural-network equivalent of a student who initially passes an exam by cramming and memorizing answers. Weeks later, after the details of the cramming session have faded, the student understands the underlying concepts. The test scores might look identical at both times, but the second understanding can generalize to new situations the student never explicitly studied. Something similar happens inside grokking networks. They hold multiple internal solutions simultaneously, and the dominant solution gradually shifts over time in response to regularization pressure. The surface behavior looks the same across the memorization and plateau phases, but the internal organization continues to change.
Grokking exposes a basic tension in neural-network learning. Universal function approximators can fit many functions that are consistent with the same training data, especially when overparameterized. Optimization determines which of those functions is discovered. It can continue reorganizing internal representations after training loss has converged, building alternative solutions that may be more compact and better aligned with the task's structure. This changes how we interpret training curves and evaluate whether a model has learned a general rule.
In this chapter, we examine grokking in depth. We explore the arithmetic tasks where it was first discovered, the competing theories for why it occurs, the phase transitions that characterize grokking dynamics, and what this phenomenon reveals about how neural networks learn to generalize. We also discuss the practical implications for training strategies and the open questions that remain.
Grokking was first described in the 2022 paper "Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasets" by Alethea Power, Yuri Burda, Harri Edwards, Igor Babuschkin, and Vedant Misra at OpenAI. The paper studied small two-layer transformers trained on modular arithmetic tasks and documented delayed generalization across different settings. The name "grokking" was chosen to reflect the structural understanding that emerges after the network appears to have finished learning.
The paper sparked a wave of follow-up research. Within months, groups at DeepMind and MIT, along with other academic labs produced competing theoretical explanations, empirical extensions to new tasks, and mechanistic interpretability studies attempting to visualize the internal circuits that form during grokking. Neel Nanda and colleagues at DeepMind produced particularly influential follow-up work in 2023 that used mechanistic interpretability techniques to directly observe the circular embeddings and Fourier features that emerge during grokking. This gives strong empirical support for the circuit formation hypothesis. The grokking paper became a touchstone for discussions about generalization, phase transitions, and the reliability of standard training practices in modern deep learning.