Abstract
Grokking—the sudden transition from memorization to generalization in neural networks—has remained a puzzle since its discovery. We propose that this phenomenon is driven by a competition for "circuit efficiency" under the pressure of weight decay. Generalizing circuits, while slower to learn, are more parameter-efficient than memorizing circuits, allowing them eventually to dominate. This framework not only explains standard grokking but also predicts two novel behaviors: ungrokking and semi-grokking.
Introduction: The Puzzle of Delayed Generalization
In classical machine learning, a model that reaches near-zero training loss is expected to have finished its learning process. Grokking defies this expectation: a model may achieve 100% training accuracy but 0% test accuracy for thousands of epochs, only to suddenly "click" and achieve perfect generalization much later.
We investigate the "why" behind this dramatic transition, moving beyond simple representation learning to a theory of internal circuit competition.
The Theory of Circuit Efficiency
We hypothesize that neural networks develop two distinct types of internal mechanisms:
- Memorizing Circuits ($C_{mem}$): These learn training data by heart. Their efficiency decreases as the dataset grows because they require more parameters to store more points.
- Generalizing Circuits ($C_{gen}$): These learn the underlying logic (e.g., modular addition). Their efficiency is independent of dataset size.
We define efficiency as the ability of a circuit to produce large model outputs (logits) using a small parameter norm. Weight decay acts as a "budget enforcer," favoring the more efficient circuit. Grokking occurs when the generalizing circuit eventually becomes more efficient than the memorizing one, typically at a critical dataset size ($D_{crit}$).
Key Results and Novel Phenomena
Our theory was validated using 1-layer Transformer models on modular arithmetic tasks. By manipulating dataset size and training duration, we confirmed the existence of three distinct regimes.
Grokking, Ungrokking, and Semi-grokking
Our most striking findings are the confirmation of two novel behaviors predicted by the efficiency theory:
- Ungrokking: When a grokked model is continued on a significantly smaller dataset ($D < D_{crit}$), it regresses from perfect to low test accuracy as the network reverts to a now-more-efficient memorization strategy.
- Semi-grokking: At dataset sizes very close to $D_{crit}$, the two circuits reach an equilibrium, resulting in stable, partial test accuracy (e.g., 80%) that persists for millions of epochs.
Our empirical results confirm these phase transitions. As shown in the comparison above, the network can shift between perfect generalization and memorization depending on the dataset size and training duration.
Conclusion
The circuit efficiency framework provides a unified explanation for the phase transitions observed in neural network training. By viewing generalization as a competition for parameter efficiency, we can predict and observe complex behaviors like ungrokking and semi-grokking. This perspective suggests that the "simplicity bias" of neural networks is deeply tied to the relative parameter costs of different algorithmic solutions.
Summary updated