TL;DR
Why do neural networks sometimes memorize a training set almost instantly, linger in overfitting purgatory for thousands of epochs, and then suddenly learn the true underlying rule—a phenomenon known as "grokking"? This paper reveals that whether a model groks isn't just about having enough parameters to memorize the data; it's a race between two distinct clocks: the speed of memorization and the speed of generalization. By measuring these two timescales independently, the authors can predict the model size where grokking begins—and even forecast datasets where grokking disappears entirely.
What Problem Does This Paper Address?
In machine learning, grokking is delayed generalization: training accuracy hits 100% early on, while test accuracy stays flat near random chance before abruptly shooting up much later in training.
We know model size plays a role in grokking, and a natural intuition is that grokking starts as soon as a neural network has enough information capacity (parameters) to brute-force memorize the training set. Yet empirically, that's not what happens! Smaller models whose storage capacities exceed the complexity of the dataset often still generalize immediately without any grokking delay. The authors set out to solve a crisp quantitative puzzle: Can we predict the exact parameter count at which a model starts to grok?
Methods
Focusing on small, 2-layer decoder-only Transformers (sweeping embedding widths to vary parameter count $P$), the authors treat training as a competition between two processes and measure their timescales using first-passage epochs:
- Empirical Information Capacity: Adapting recent information-theoretic frameworks, they train Transformers on pure random noise to measure how many bits of raw data each parameter can store ($C_{\text{model}}$).
- Memorization Timescale ($T_{\text{mem}}$): To isolate pure memorization without any algorithmic shortcuts, they measure how many epochs it takes a model to hit 99% training accuracy on a random-label dataset with the exact same bit-complexity as the real task.
- Generalization Timescale ($T_{\text{gen}}$): They train the model on the actual structured task and record the epochs needed to reach 99% validation accuracy.
- Empirical Scaling Laws: Finally, they fit mathematical scaling laws to $T_{\text{mem}}$ and $T_{\text{gen}}$ across primes $p \in [97, 139]$ and extrapolate them to larger, unseen dataset sizes.
Datasets
No new external benchmarks are introduced; instead, the authors use synthetic datasets tailored for controlled scaling experiments:
- Modular Arithmetic: Standard grokking benchmarks over prime fields $\mathbb{Z}_p$ (primarily modular division $a / b \bmod p$, with sweeps on addition and multiplication), formatted as length-4 token sequences
[a, op, b, =]. Half the valid pairs are used for training ($\alpha = 1/2$) and half for validation, testing primes from $p=97$ up to $p=199$. - Matched Random-Label Datasets: Synthetic classification datasets with uniformly random labels, sized to match the exact worst-case bit-complexity ($K_{\text{mem}}$) of each corresponding modular arithmetic training set.
Key Insights and Ideas
- Capacity isn't destiny; speed is: Having enough capacity to memorize doesn't mean gradient descent will memorize first. Smaller models generalize immediately—even above the memorization capacity threshold—simply because finding the general rule is faster than brute-force memorization ($T_{\text{gen}} < T_{\text{mem}}$). Grokking only kicks in when $P$ grows large enough that memorization wins the race ($T_{\text{mem}} \lesssim T_{\text{gen}}$).
- A universal curve for memorization speed: Memorization time collapses neatly onto a single exponential curve governed solely by the capacity fraction $f$—the ratio of dataset bit-complexity to model capacity. Because a fixed dataset takes up a smaller fraction of a larger model's capacity, larger models memorize exponentially faster, explaining an observation long noted in large language models.
- The disappearing grokking regime: While $T_{\text{gen}}$ follows a power law ($A p^a P^{-b}$) and $T_{\text{mem}}$ follows an exponential in $1/P$, their scaling geometry forms a "cone." Extrapolating these curves reveals a startling out-of-distribution prediction: past a critical dataset size (prime $p^*$), the two curves never intersect, meaning no model of any size should consistently grok!
Key Results
- Bits per parameter: Their Transformer family stores roughly $C_{\text{model}} \approx 0.785$ bits per parameter.
- Predicting grokking onset: Across the 10 main primes, the parameter count where $T_{\text{mem}}$ and $T_{\text{gen}}$ intersect correlates tightly with the empirical onset of consistent grokking (Spearman $\rho = 0.988, p = 10^{-4}$). It does, however, exhibit a systematic offset—actual grokking begins roughly 32% below the intersection parameter count. Adding this timescale intersection significantly improves onset predictions over using dataset complexity capacity ($P_{\text{mem}}$) alone ($p = 3.61 \times 10^{-6}$).
- Testing the critical prime $p^*$: Fitting their scaling laws ($R^2 \approx 0.87$ in log-space) on $p \le 139$ predicts that consistent grokking should vanish beyond $p^* \approx 167.89$. When tested on larger primes, the grokking region visibly thins out, and by $p = 193, 197,$ and $199$, zero sampled model sizes grokked consistently across all 10 random seeds (though the boundary is fuzzy, with five isolated grokking cases appearing between $p=173$ and $191$).
Limitations and Future Work
- Entangled generalization: Measuring $T_{\text{gen}}$ on modular division doesn't prevent concurrent memorization from happening under the hood, meaning $T_{\text{gen}}$ isn't a purely isolated measurement.
- Empirical calibration: The scaling laws are empirical fits rather than exact mechanistic derivations, and the systematic offset between timescale intersection and grokking onset shifts across hyperparameters (like weight decay and learning rate), requiring fresh calibration per setup. Furthermore, sweeps varying model depth and initialization scale were inconclusive due to compute budgets.
- Next steps: The authors aim to derive these scaling constants from first principles, test MLPs and deeper Transformers, and figure out how to rigorously define and measure generalization timescales on messy, naturalistic language or vision datasets.
Summary updated