TL;DR
Grokking—the phenomenon where a model suddenly generalizes long after overfitting the training data—is not just a quirk of weight decay or specific architectures. This paper demonstrates that grokking is a fundamental transition in training dynamics: the network initially behaves like a "lazy" linear model using fixed features, only to later "awaken" into a "rich" regime where it learns the specific features necessary for true generalization.
The Mystery of Grokking
In deep learning, we usually expect training and test performance to move somewhat in tandem. However, "grokking" defies this expectation: a model’s training loss hits near-zero quickly, but test loss remains high for thousands of additional epochs before suddenly plummeting.
Previous theories suggested grokking was driven by weight decay or models seeking "simpler" solutions with smaller weight norms. The authors of this paper point out a major gap in these theories: grokking can occur even when weight decay is absent and when weight norms increase during training. They seek a more universal explanation rooted in the fundamental ways neural networks learn.
Methods: Unpacking the Dynamics
To isolate the mechanics of grokking, the authors study a minimalist setup: a two-layer neural network (MLP) solving a high-dimensional polynomial regression task. This environment is simple enough to analyze mathematically but complex enough to exhibit grokking without any regularization.
Key methodological tools include:
- Neural Tangent Kernel (NTK) Analysis: The authors use the NTK to represent the "lazy" regime, where the network tries to solve the problem using its random initial features without changing them.
- Output Scaling ($\alpha$): By scaling the network's output by a factor $\alpha$, they can precisely control how "lazy" or "rich" the training is. High $\alpha$ forces the network to stay in the lazy regime longer.
- Loss Decomposition: They derive a formula to break down test loss into three parts: variance error, misalignment error (how well features match the task), and power in linear modes. This allows them to "see" exactly why the test loss spikes before it drops.
The "Lazy-to-Rich" Transition
The core insight of the paper is that grokking represents a delayed transition between two distinct phases of learning.
At the start of training, networks often act like linear kernel methods. If the task is "misaligned" with the network's initial random features, the network "memorizes" the training data using those poor features (the lazy phase). Grokking happens when the network finally begins to adapt its internal representations to match the task (the rich phase).
Several factors control this transition:
- The Alignment Knob: Grokking is most intense when the task is poorly aligned with the initial NTK. If you start with "good" features, the model generalizes immediately. If you start with "bad" features, the model must grok to succeed.
- The "Goldilocks" Dataset Size: Grokking only happens in a specific range of data. Too little data, and the model never learns the rich features; too much data, and the lazy model generalizes immediately, so there is no "delay" to observe.
- Weight Norm is a Red Herring: While previous papers focused on weight norm decrease, this paper shows grokking with weight norm increase. They argue that large initial weights simply induce laziness; it's the laziness, not the norm itself, that causes the delay.
Key Results and Validation
The paper validates its theory across several diverse settings, including synthetic polynomials, modular arithmetic (the "classic" grokking task), MNIST image classification, student-teacher networks, and one-layer Transformers.
By tuning the scale parameter $\alpha$, the authors could make grokking appear, disappear, or become more dramatic in both MLPs and Transformers. Furthermore, their theoretical loss decomposition perfectly predicts the "rise then fall" of test loss. The initial rise is caused by the model trying to fit the data using linear components of its initial features that are actually irrelevant to the target task. They also show that increasing dataset size allows networks to generalize on "harder" tasks that a lazy model could never solve.
Limitations and Future Work
While the paper identifies the "Goldilocks zone" for dataset size, it does not provide a sharp mathematical formula to calculate exactly how many samples are needed for the transition to occur. Additionally, most grokking research uses AdamW. While this paper shows grokking with vanilla Gradient Descent, the authors acknowledge that the complex dynamics of adaptive optimizers and how they interact with the lazy-to-rich transition are not yet fully understood. Finally, the toy model uses quadratic features; future work could explore how these dynamics play out in much deeper networks learning highly hierarchical features.
Summary updated