Abstract
Grokking is a phenomenon where a model trained on an algorithmic task first overfits but, then, after a large amount of additional training, undergoes a phase transition to generalize perfectly. We empirically study the internal structure of networks undergoing grokking on the sparse parity task, and find that the grokking phase transition corresponds to the emergence of a sparse subnetwork that dominates model predictions. On an optimization level, we find that this subnetwork arises when a small subset of neurons undergoes rapid norm growth, whereas the other neurons in the network decay slowly in norm. Thus, we suggest that the grokking phase transition can be understood to emerge from competition of two largely distinct subnetworks: a dense one that dominates before the transition and generalizes poorly, and a sparse one that dominates afterwards.
Introduction: The Mystery of Delayed Generalization
In standard machine learning paradigms, we expect a model to begin generalizing shortly after it masters the training data. However, "grokking" presents a counter-intuitive challenge: models trained on specific algorithmic tasks—such as modular arithmetic or parity—often achieve 100% training accuracy while remaining at chance-level performance on test data for thousands of epochs. Then, seemingly out of nowhere, the test accuracy spikes to 100%.
This research investigates the structural changes occurring within a network during this transition. By moving beyond simple performance metrics to analyze the internal circuitry, we aim to understand whether grokking is merely a refinement of memorization or a fundamental shift in the model's internal logic. Understanding these moments of "emergence" is a critical step toward interpreting capabilities in larger models.
Methodology
The study focuses on the sparse parity task, a benchmark where a model must identify the product of $k$ specific bits within a longer string of $n$ bits (e.g., $n=40, k=3$). This task is difficult because it requires discovering a specific logical structure amidst noise.
To dissect the learning process, the authors utilized:
- 1-Layer ReLU Networks: A simplified architecture allowing for the observation of individual neuron dynamics.
- Active Subnetwork Analysis: A pruning-based method to isolate the neurons driving predictions at any given time.
- Effective Sparsity: A metric quantifying the number of "essential" neurons.
- Norm Tracking: Monitoring the weight magnitude (L2 norm) of neurons to observe growth and decay patterns.
The Competition Hypothesis
The core finding is that grokking is not a monolithic learning process but a competition between two distinct internal circuits.
Initially, the network develops a dense subnetwork. This circuit uses a large number of neurons to effectively "memorize" the training points. While this achieves low training loss, it fails to capture the underlying mathematical rule. Simultaneously, a sparse subnetwork—representing the true logical solution—begins to form much more slowly.
The "grokking" transition occurs when a tiny subset of neurons in the sparse circuit undergoes a massive "norm growth spurt." These neurons become so high-magnitude that they dominate the model's output, effectively silencing the noisier, dense memorization circuit.
Empirical Results: Sudden Sparsity
The transition from memorization to generalization is marked by a dramatic change in the network's internal structure. As the model "groks," it discards redundant information in favor of a lean, logical circuit.
As shown in the sparsity analysis, the number of active neurons can reach hundreds during the overfitting phase. However, at the exact moment test accuracy jumps, the "effective sparsity" plummets. In the sparse parity task, the model eventually settles on just 6 to 8 essential neurons. These neurons are found to implement a logical structure known as Disjunctive Normal Form (DNF), effectively re-discovering the mathematical logic of parity.
This transition is largely driven by the interaction between the loss function and weight decay. Once the sparse circuit provides a path to zero loss, weight decay acts as a "cleanup crew," slowly killing off the high-norm, inefficient neurons used for memorization.
Conclusion and Future Directions
While this study provides a clear mechanistic explanation for grokking in simple networks, questions remain regarding its scalability. The authors acknowledge that while "outlier" weights are common in Large Language Models (LLMs) like GPT-3, proving that these models undergo the same "circuit competition" during emergence is a task for future research. Understanding these phase transitions is a critical step toward making the "black box" of AI more interpretable and predictable.
Summary updated