In the traditional view of machine learning, generalization is a steady climb: as training error decreases, validation error follows until the model begins to overfit. However, recent research into "grokking" has revealed a more dramatic landscape. In many algorithmic and reasoning tasks, models first achieve perfect training accuracy through rote memorization, only to "grok"—suddenly achieving perfect generalization—thousands of steps later. This transition is not accidental; it is driven by a fundamental tug-of-war between memorization and simplicity, where weight decay acts as the decisive tie-breaker.
The Competition Between Circuits
When a neural network is tasked with learning a rule—such as modular arithmetic or logical reasoning—it can succeed in two ways. It can either build a "memorization circuit" that maps specific inputs to outputs, or an "algorithmic circuit" that implements the underlying logic.
Early in training, the network rushes to minimize loss, and memorization is often the path of least resistance. However, as Boshi Wang and colleagues demonstrate in Grokking of Implicit Reasoning in Transformers, these two strategies exist in a state of competition. Memorization circuits are typically "heavy," requiring high-norm weights to store specific data points. Algorithmic circuits are "light," using compact, structured representations to cover the entire domain.
Weight Decay as a Simplicity Bias
Weight decay (L2 regularization) is often viewed as a simple trick to prevent overfitting. But in the context of grokking, it serves a more profound role: it is a "functional filter" that systematically prunes high-norm memorization strategies.
As explored by Anders Krogh and John A. Hertz in their foundational 1991 paper, weight decay forces the optimizer to choose the "simplest" solution among many that satisfy the training data. In the late stages of training—long after the training loss has hit zero—weight decay continues to apply pressure. This "drift" along the solution manifold, described by Etienne Boursier in A Theoretical Framework for Grokking, eventually collapses the complex memorization circuits, leaving only the efficient, generalizable ones behind.
The Phase Transition to Generalization
This process is not gradual but characterized by sharp phase transitions. Research from Alethea Power and the OpenAI team in Grokking: Generalization Beyond Overfitting shows that without sufficient weight decay, models may remain stuck in a "memorization regime" indefinitely.
Key evidence for this mechanism includes:
- Structural Cleanup: Weight decay pushes internal representations toward a "uniform" state that aligns with the data's underlying logic (Ruoyu Chen et al., Beyond Progress Measures).
- Complexity Reduction: Generalization is marked by a sharp rise and then a fall in "intrinsic complexity" as the model sheds noisy memorization (Branton DeMoss et al., The Complexity Dynamics of Grokking).
- Algorithmic Emergence: In tasks like in-context learning, weight decay reduces the "task diversity" required for a model to stop retrieving specific examples and start implementing general algorithms (Allan Raventós et al., Pretraining task diversity and the emergence of non-Bayesian in-context learning).
Beyond Neural Networks
The fact that grokking occurs in linear regression and Gaussian Processes when complexity penalties are applied (Jack Miller et al., Grokking Beyond Neural Networks) suggests that this is a universal property of optimization. By penalizing the "norm" or complexity of a solution, we provide the necessary catalyst for the model to stop reciting the training data and start understanding the rules that govern it.