Grokking in neural networks is the name for a strange delay: a model fits its training set perfectly, sits there for thousands of further updates with no apparent progress on held-out data, and then, often fairly quickly, starts getting unseen examples right. The phenomenon was first reported on toy arithmetic tasks, yet it raises a question that reaches well beyond them. If a network can memorize first and understand later, what exactly changes inside it during the quiet stretch, and why does the change take so long?

That question is still open. Several careful explanations exist, some proven for simplified models, but researchers have not agreed on which mechanism is primary. What follows sets out what is known, steelmans the competing accounts, and reports a small simulation of how weight decay and dataset size change the delay in a tiny network learning addition modulo 31.

The question, stated precisely

The phrase “suddenly generalize” hides two separate questions. The first is about timing: why is there a gap between the step where training accuracy reaches 100 percent and the much later step where test accuracy does? The second concerns cause: what pushes the network out of a memorizing solution that already has near-zero training error, given that the training loss offers little reason to move?

The second question matters more. Grokking shows that optimization can keep selecting among solutions long after the error signal has almost vanished. Understanding that selection would say something about how overparameterized networks choose among their many perfect-fit solutions, arguably the central puzzle of modern deep learning. For readers who want the mechanics of the update rule itself first, the x9m8 explainer on how backpropagation and gradient descent work covers the basics this article assumes.

People do ask this, and not only inside machine learning labs. On LessWrong, Quintin Pope’s post “QAPR 5: grokking is maybe not that big a deal?” (Pope 2023) asks whether the jump is truly sudden or an artifact of log-scaled plots. A 2025 thread in the CFA UK Technology and Innovation Community (Salas 2025) shared a grokking paper to members because of the familiar gap between models that shine in backtests and fail in live trading. The academic literature also frames it as a question: one 2024 theory paper is titled, simply, “Why Do You Grok?” (Mohamadi et al. 2024).

What is established

The original report came from OpenAI researchers who trained a small two-layer transformer on tables of binary operations such as modular addition and division, hiding part of each table for testing (Power et al. 2022, preprint). They found that validation accuracy could rise from chance to perfect, and stressed:

“and that this improvement in generalization can happen well past the point of overfitting”

Power et al., 2022

Two further findings from that paper have held up. Smaller training fractions required much more optimization before generalization appeared, and weight decay sped it up markedly.

Mechanistic interpretability then showed what the generalizing solution looks like. Studying a one-layer transformer on addition modulo 113, Nanda and colleagues reverse-engineered an algorithm that maps each number to sines and cosines at a handful of frequencies and uses trigonometric identities to turn addition into rotation around a circle (Nanda et al. 2023, ICLR). Their progress measures split training into memorization, circuit formation and cleanup. Their headline claim reframed the phenomenon:

“grokking, rather than being a sudden shift, arises from the gradual amplification of structured mechanisms”

Nanda et al., 2023

Another fact is that grokking does not need a transformer. Gromov showed that a two-layer fully connected network learns modular arithmetic, exhibits the delay, and admits analytic weights built from periodic feature maps (Gromov 2023, preprint). A third: the delay can be made larger or smaller by hyperparameters, especially initialization scale and weight decay, which several groups demonstrated independently (Liu, Michaud and Tegmark 2023, ICLR; Kumar et al. 2024, preprint).

What is not established is the causal story connecting these facts, and whether the same story applies to large models trained on natural data.

Hypothesis one: two circuits racing on efficiency

The most intuitive account treats grokking as a contest between two solutions. A memorizing circuit can be learned quickly because it only needs to store each training pair. A generalizing circuit, such as the Fourier algorithm, takes longer to assemble. Varma and colleagues made this precise (Varma et al. 2023, preprint), proposing a task with two solutions:

“where the generalising solution is slower to learn but more efficient”

Varma et al., 2023

Efficiency here means producing larger correct-class logits per unit of parameter norm. Weight decay charges rent on norm, so over time it starves the costlier memorizing circuit and favors the cheaper general one. Because memorization gets costlier as the training set grows while the general rule does not, the theory predicts a critical dataset size, plus two odd behaviors the authors then observed: “ungrokking,” where a grokked network loses test accuracy when retrained on a smaller set, and “semi-grokking,” where it stalls at partial accuracy.

The case for this view is strong on algorithmic tasks: it explains the weight-decay dependence, the dataset-size dependence and Nanda’s cleanup phase in one picture. Its weakness is scope. Grokking also appears without any explicit regularizer (Gromov reported it under plain gradient descent), so efficiency under a norm penalty cannot be the whole story unless the optimizer supplies an implicit penalty of its own.

Hypothesis two: from lazy kernels to rich features

A second family of explanations comes from deep learning theory. Early in training, a wide network with large initialization behaves almost like a fixed kernel method: its internal features barely move. Such a “lazy” solution can interpolate but generalizes poorly on tasks that need new features. Slower dynamics later move the network into a “rich” regime where features adapt.

Kumar, Bordelon, Gershman and Pehlevan argue that grokking is exactly this transition, controlled by the rate of feature learning and by how well the initial features align with the target (Kumar et al. 2024). Lyu and coauthors prove a related result for homogeneous networks with large initialization and small weight decay: training first lingers at a kernel-like predictor, then transitions sharply to a minimum-norm or maximum-margin one (Lyu et al. 2024, preprint). For modular addition, Mohamadi and colleagues show that no permutation-equivariant model in the kernel regime reaches low population error without seeing a constant fraction of all inputs, while small-norm two-layer quadratic networks need far fewer (Mohamadi et al. 2024).

Theorems, not just plots, back this view, and it explains why large initialization lengthens the delay. But the proofs cover stylized settings, and they say less about why real optimizers take so long to leave the first regime.

Hypothesis three: norms, landscapes and numerics

A third set of accounts focuses on the geometry of the loss and on weight norm. Liu and coauthors’ effective theory found that representation learning happens only in a middle “Goldilocks zone” of hyperparameters, between phases they call memorization and confusion (Liu et al. 2022, NeurIPS). A follow-up, Omnigrok, plotted training and test loss against weight norm and found an L shape and a U shape: start the network at large norm and training loss is already low while test loss sits high on the U, so the weights must slowly shrink. Using this picture, Liu, Michaud and Tegmark induced grokking on image, language and molecule tasks by scaling up initialization, and removed it from algorithmic ones.

Optimizer details matter too. Thilak and colleagues reported “slingshot” cycles in adaptive optimizers, visible in the last layer’s weight norm, and found that without explicit regularization grokking almost only happened at slingshot onsets (Thilak et al. 2022, preprint). More recently, Prieto and coauthors argued that after overfitting, gradients align with a “naive loss minimization” direction that lowers cross-entropy by scaling logits up without changing predictions; this wastes the late phase and eventually causes floating-point errors in the softmax that halt learning (Prieto et al. 2025, preprint). Their fixes, a stable softmax variant and a gradient projection, produced generalization without regularization.

These accounts are easy to test with simple measurements (weight norm, logit scale, numerical precision), but they describe pressures on the network rather than the circuit it builds, so they need hypothesis one or two to finish the story.

Hypothesis four: mostly an artifact of training choices

The skeptical position holds that grokking is real but not deep. Pope (2023) proposed the plainer label “eventual recovery from overfitting” and suggested it arises from moderately flawed setups. There is formal support for the tunability half of this claim. Xu, Vardi and Safran prove that grokking occurs in over-parameterized ridge regression trained with gradient descent and weight decay, derive bounds on the delay in terms of hyperparameters, and show those hyperparameters can amplify or eliminate it (Xu et al. 2026, preprint).

The best counterevidence comes from Humayun, Balestriero and Baraniuk, who report delayed generalization and “delayed robustness” in ordinary vision settings, a CNN on CIFAR-10 and a ResNet on Imagenette, and tie both to a late reorganization of the network’s linear regions (Humayun et al. 2024, preprint). If they are right, delay is a general feature of training dynamics, not a quirk of toy tasks with poor settings. Still, “avoidable by tuning” and “informative about learning” are compatible.

A small experiment built for this article

A minimal grokking setup was written in NumPy for this article and run on an ordinary CPU; it is a small simulation, not a reproduction of any paper. The task is addition modulo 31: all 961 pairs (a, b), with half (480) used for training and the rest (481) held out. Each operand gets a learned 96-dimensional embedding; the two are summed, squared elementwise (Gromov’s quadratic activation) and mapped to 31 logits. Training is full-batch cross-entropy with AdamW at learning rate 0.001 for 12,000 steps, logged every 50. The sweep varied decoupled weight decay over 0, 0.1, 0.3, 1 and 3, and at weight decay 1 also varied the training fraction (0.3 and 0.7). Each setting ran with three random seeds (0, 1, 2). Chance accuracy is 1/31, about 3.2 percent.

import numpy as np
def run(p=31, frac=0.5, wd=1.0, steps=12000, H=96, lr=1e-3, seed=0, init=1.0, log=50, keep=None):
    rng = np.random.default_rng(seed)
    a_, b_ = np.divmod(np.arange(p * p), p); y = (a_ + b_) % p     # all pairs (a, b) -> (a+b) mod p
    idx = rng.permutation(p * p); ntr = int(frac * p * p); tr, te = idx[:ntr], idx[ntr:]
    A, B = a_, p + b_                                               # one-hot input = embedding rows
    X = np.zeros((ntr, 2*p)); X[np.arange(ntr), A[tr]] = 1; X[np.arange(ntr), B[tr]] = 1
    W1 = init * rng.normal(0, 1/np.sqrt(2*p), (2*p, H)); W2 = init * rng.normal(0, 1/np.sqrt(H), (H, p))
    P = [W1, W2]; m = [0*w for w in P]; v = [0*w for w in P]; hist = []
    acc = lambda s: (((W1[A[s]] + W1[B[s]])**2 @ W2).argmax(1) == y[s]).mean()
    for t in range(1, steps + 1):
        h = W1[A[tr]] + W1[B[tr]]; q = h ** 2                      # quadratic activation (Gromov 2023)
        z = q @ W2; z -= z.max(1, keepdims=True); pz = np.exp(z); pz /= pz.sum(1, keepdims=True)
        g = pz; g[np.arange(ntr), y[tr]] -= 1; g /= ntr             # d(cross-entropy)/d(logits), full batch
        gW2 = q.T @ g; dh = (g @ W2.T) * 2 * h
        gW1 = X.T @ dh                                               # gradient flows to both embedding rows
        for i, gw in enumerate([gW1, gW2]):                          # AdamW with decoupled weight decay
            m[i] = 0.9*m[i] + 0.1*gw; v[i] = 0.98*v[i] + 0.02*gw**2
            P[i] -= lr * ((m[i]/(1-0.9**t)) / (np.sqrt(v[i]/(1-0.98**t)) + 1e-8) + wd * P[i])
        if t % log == 0:
            hist.append((t, acc(tr), acc(te), float(np.sqrt(sum((w**2).sum() for w in P)))))
    if keep is not None: keep.update(W1=W1, W2=W2)
    return hist
def first(hist, col, thr=0.99):
    return next((h[0] for h in hist if h[col] >= thr), None)

The table gives, per seed, the first logged step at which training accuracy reached 99 percent and test accuracy reached 50 and 99 percent, plus mean final test accuracy.

Weight decayTrain fractionTrain 99% at stepTest 50% at stepTest 99% at stepMean final test accuracy
00.5300, 300, 300never, never, nevernever, never, never10.4%
0.10.5300, 300, 300never, 7,850, nevernever, never, never53.9%
0.30.5300, 300, 3004,300, 2,850, 4,700never, 11,800, never98.5%
10.5350, 300, 3501,650, 1,350, 1,5505,350, 4,350, 3,700100.0%
30.5550, 450, 6001,200, 1,000, 1,100never, never, never97.6%
10.3300, 300, 300never, never, nevernever, never, never26.9%
10.7350, 350, 350550, 550, 6501,300, 1,350, 1,450100.0%
Three seeds per row (0, 1, 2); “never” means not reached within 12,000 steps. Addition mod 31, 96 hidden units, AdamW, learning rate 0.001.

Four results stand out. First, memorization was fast and nearly constant: every run fit 99 percent of its training pairs within 300 to 600 steps. Second, without weight decay the network never generalized in 12,000 steps. Test accuracy finished between 7 and 16 percent while the parameter norm kept growing to about 63, roughly 38 percent larger than in the decay-1 runs. That growth is what the naive-loss-minimization account of Prieto et al. predicts, though the softmax-collapse part of their claim was not tested (this code runs in 64-bit floats). Third, weight decay set the delay. At decay 1 the test set crossed 99 percent between steps 3,700 and 5,350, roughly 11 to 15 times later than memorization finished; at 0.3 only one seed got there, at step 11,800; at 0.1 test accuracy was still climbing and finished between 38 and 74 percent. Too much decay hurt in a different way: at 3, memorization itself slowed, and test accuracy finished between 96 and 98.8 percent without crossing the 99 percent line.

Fourth, dataset size mattered as much as regularization. With 70 percent of pairs in training, test accuracy hit 99 percent in under 1,500 steps; with 30 percent, it had crept only to 24 to 32 percent by the end.

A final check looked at what the decay-trained networks had learned. For each hidden unit, the script took the discrete Fourier transform of its embedding weights over the 31 inputs and measured the share of power in that unit’s single strongest frequency. In the three decay-1 runs, the average share was 0.87 to 0.91. In the three no-decay runs it was 0.42 to 0.47, and for random Gaussian weights of the same shape it is about 0.22. So the generalizing networks had, unit by unit, collapsed onto individual frequencies, the periodic features that Nanda et al. and Gromov describe, while the memorizing ones had not.

The limits matter as much. This is one tiny architecture, one task, one optimizer and three seeds. The 99 percent threshold is arbitrary, and the “delay” in the decay-1 runs was a slope rather than a cliff: test accuracy took roughly 2,000 steps to climb from 10 to 90 percent, which looks abrupt only on a logarithmic axis. Nothing here distinguishes the efficiency, lazy-to-rich and norm-landscape stories, because all three predict that weight decay and more data shorten the delay. The experiment confirms the shared ground; it does not settle the dispute.

The author’s reading, and what would settle it

What follows is the author’s reading, an opinion rather than an established result. I read the competing accounts as describing one process at different levels. At the circuit level, a slow, efficient rule competes with a fast, costly lookup table (Varma, Nanda). At the dynamics level, that competition looks like an exit from a kernel-like regime (Kumar, Lyu, Mohamadi). At the geometric level, it looks like the network shrinking its norm toward the bottom of a U-shaped test loss (Omnigrok), with optimizer quirks and numerical limits deciding how long the walk takes (Thilak, Prieto). Pope’s skepticism is right that the length of the delay is a tunable artifact. I think it is wrong if it implies the underlying solution switch is unimportant: in the small experiment above, the networks that generalized had reorganized into single-frequency features, and the ones that did not generalize had not.

Where I could be wrong is scale: evidence that the same switch drives late gains in large language models is thin. Four studies would move the question:

  • Efficiency without decay. Train with no regularizer but with Prieto et al.’s stable softmax. If efficiency is primary, generalization should track the norm ratio of memorizing to general circuits; if numerics are primary, it should track logit scale.
  • A threshold test. Varma et al. predict a critical training fraction. Sweep fractions finely across two architectures; the threshold should move with the per-example cost of memorization, not with learning rate.
  • A kernel-alignment forecast. Kumar et al.’s account implies that the alignment of the initial tangent kernel with the target should predict delay length across seeds before training begins. A null correlation would weaken that account.
  • Natural-data circuits. Find a capability in a mid-sized language model that improves late in training, and check whether a compact circuit grows while a memorized pathway decays, using the progress-measure method. Finding that pattern would connect toy grokking to practice; finding only smooth, distributed change would support the skeptics.

Related debates about what structure trained models contain run through the x9m8 piece on why transformers stop following references early; the longer arc is in this site’s short history of AI from Turing to transformers.

Common questions

Does grokking happen in large language models?

There is no settled answer. Grokking is best documented on small algorithmic tasks, and Humayun et al. report it in standard image classifiers, but direct evidence for a grokking-style switch in large language model pretraining is limited.

Why does weight decay help a network grok?

Weight decay shrinks every parameter a little at each step, so solutions that need large weights become costly. On the efficiency account, the memorizing solution needs more norm per unit of confidence than the general rule, so decay gradually pushes it out. In the small experiment above, no-decay runs never generalized within 12,000 steps, while decay-1 runs all did.

Can grokking be avoided?

Often, yes, at least on toy tasks. More data, suitable weight decay, smaller initialization or optimizer fixes can shorten or remove the delay, and Xu et al. prove this tunability for ridge regression. Avoiding it does not explain it.

Is the jump really sudden?

Usually less than it looks. Many published plots use a logarithmic step axis, which compresses long gradual climbs into steep cliffs. Nanda et al. found that internal progress measures improve continuously before test accuracy moves, and in this article’s runs the climb from 10 to 90 percent test accuracy took around 2,000 steps.

References

  1. Power, A., Burda, Y., Edwards, H., Babuschkin, I., and Misra, V. (2022). Grokking: Generalization beyond overfitting on small algorithmic datasets. arXiv:2201.02177 (preprint). https://arxiv.org/abs/2201.02177
  2. Nanda, N., Chan, L., Lieberum, T., Smith, J., and Steinhardt, J. (2023). Progress measures for grokking via mechanistic interpretability. International Conference on Learning Representations (ICLR 2023). arXiv:2301.05217. https://arxiv.org/abs/2301.05217
  3. Varma, V., Shah, R., Kenton, Z., Kramár, J., and Kumar, R. (2023). Explaining grokking through circuit efficiency. arXiv:2309.02390 (preprint). https://arxiv.org/abs/2309.02390
  4. Gromov, A. (2023). Grokking modular arithmetic. arXiv:2301.02679 (preprint). https://arxiv.org/abs/2301.02679
  5. Liu, Z., Kitouni, O., Nolte, N., Michaud, E. J., Tegmark, M., and Williams, M. (2022). Towards understanding grokking: An effective theory of representation learning. Advances in Neural Information Processing Systems (NeurIPS 2022). arXiv:2205.10343. https://arxiv.org/abs/2205.10343
  6. Liu, Z., Michaud, E. J., and Tegmark, M. (2023). Omnigrok: Grokking beyond algorithmic data. International Conference on Learning Representations (ICLR 2023). arXiv:2210.01117. https://arxiv.org/abs/2210.01117
  7. Kumar, T., Bordelon, B., Gershman, S. J., and Pehlevan, C. (2024). Grokking as the transition from lazy to rich training dynamics. arXiv:2310.06110 (preprint). https://arxiv.org/abs/2310.06110
  8. Lyu, K., Jin, J., Li, Z., Du, S. S., Lee, J. D., and Hu, W. (2024). Dichotomy of early and late phase implicit biases can provably induce grokking. arXiv:2311.18817 (preprint). https://arxiv.org/abs/2311.18817
  9. Mohamadi, M. A., Li, Z., Wu, L., and Sutherland, D. J. (2024). Why do you grok? A theoretical analysis of grokking modular addition. arXiv:2407.12332 (preprint). https://arxiv.org/abs/2407.12332
  10. Thilak, V., Littwin, E., Zhai, S., Saremi, O., Paiss, R., and Susskind, J. (2022). The slingshot mechanism: An empirical study of adaptive optimizers and the grokking phenomenon. arXiv:2206.04817 (preprint). https://arxiv.org/abs/2206.04817
  11. Prieto, L., Barsbey, M., Mediano, P. A. M., and Birdal, T. (2025). Grokking at the edge of numerical stability. arXiv:2501.04697 (preprint). https://arxiv.org/abs/2501.04697
  12. Humayun, A. I., Balestriero, R., and Baraniuk, R. (2024). Deep networks always grok and here is why. arXiv:2402.15555 (preprint). https://arxiv.org/abs/2402.15555
  13. Xu, M., Vardi, G., and Safran, I. (2026). To grok grokking: Provable grokking in ridge regression. arXiv:2601.19791 (preprint). https://arxiv.org/abs/2601.19791
  14. Pope, Q. (2023, July 23). QAPR 5: grokking is maybe not *that* big a deal? LessWrong (blog post). https://www.lesswrong.com/posts/GpSzShaaf8po4rcmA
  15. Salas, C. (2025). GROKKING AKA Delayed Generalization. CFA UK Technology and Innovation Community (discussion post). https://connect.cfauk.org/discussion/grokking-aka-delayed-generalization