HyperAIHyperAI

Command Palette

Search for a command to run...

To Grok Grokking: Provable Grokking in Ridge Regression

Mingyue Xu Gal Vardi Itay Safran

Abstract

We study grokking—the onset of generalization long after overfitting—in a classical ridge regression setting. We prove end-to-end grokking results for learning over-parameterized linear regression models using gradient descent with weight decay. Specifically, we prove that the following stages occur: (i) the model overfits the training data early during training; (ii) poor generalization persists long after overfitting has manifested; and (iii) the generalization error eventually becomes arbitrarily small. Moreover, we show, both theoretically and empirically, that grokking can be amplified or eliminated in a principled manner through proper hyperparameter tuning. To the best of our knowledge, these are the first rigorous quantitative bounds on the generalization delay (which we refer to as the "grokking time") in terms of training hyperparameters. Lastly, going beyond the linear setting, we empirically demonstrate that our quantitative bounds also capture the behavior of grokking on non-linear neural networks. Our results suggest that grokking is not an inherent failure mode of deep learning, but rather a consequence of specific training conditions, and thus does not require fundamental changes to the model architecture or learning algorithm to avoid.

One-sentence Summary

The authors establish the first rigorous quantitative bounds on grokking time for over-parameterized linear regression with gradient descent and weight decay, prove that hyperparameter tuning can amplify or eliminate grokking, and empirically demonstrate that these bounds capture grokking behavior in non-linear neural networks, suggesting that grokking is not an inherent failure mode of deep learning but a controllable consequence of specific training conditions.

Key Contributions

  • The paper establishes the first rigorous quantitative bounds on grokking time for over-parameterized linear regression trained with gradient descent and weight decay, proving a progression from overfitting through persistent poor generalization to arbitrarily small test error.
  • Both theoretical analysis and experiments show that grokking can be systematically amplified or eliminated by tuning hyperparameters, such as the weight decay coefficient, providing a principled control mechanism.
  • Beyond the linear setting, the quantitative bounds empirically capture grokking behavior on non-linear neural networks, supporting the conclusion that grokking results from specific training conditions rather than a fundamental deficiency of deep learning.

Introduction

The authors study grokking, a counterintuitive phenomenon where test performance improves long after a model perfectly fits the training data. Prior theoretical analyses have attributed grokking to transitions between lazy and rich training regimes or to the role of weight decay, but none provided a rigorous end-to-end guarantee that poor generalization persists after overfitting before eventually resolving. The authors fill this gap by analyzing overparameterized ridge regression with a teacher-student setup, showing for the first time that even a linear model trained with gradient descent and weight decay can exhibit provable grokking. They establish quantitative bounds on training error convergence, a slower generalization error decay that demonstrates prolonged overfitting, and eventual convergence to a global minimum with good test performance, all fully controllable through hyperparameters like the weight decay coefficient.

Method

Theauthors investigate the phenomenon of grokking within the context of ridge regression. They consider a fundamental regression problem where a student linear regression model N(x;θ)=θ,ϕ(x)N(\boldsymbol{x}; \boldsymbol{\theta}) = \langle \boldsymbol{\theta}, \phi(\boldsymbol{x}) \rangleN(x;θ)=θ,ϕ(x)⟩ is trained to learn a realizable teacher function N(x)=θ,ϕ(x)N^*(\boldsymbol{x}) = \langle \boldsymbol{\theta}^*, \phi(\boldsymbol{x}) \rangleN(x)=θ,ϕ(x)⟩. Here, ϕ(x)\phi(\boldsymbol{x})ϕ(x) is a fixed feature map and θ\boldsymbol{\theta}θ represents the trainable parameters.

The training process utilizes ridge regression, which minimizes the empirical mean squared loss augmented with an 2\ell_22-regularization term. The training objective is defined as:

Ln(θ;λ)=12ni=1n(N(xi;θ)N(xi))2+λ2θ22L_n(\boldsymbol{\theta}; \lambda) = \frac{1}{2n} \sum_{i=1}^n (N(\boldsymbol{x}_i; \boldsymbol{\theta}) - N^*(\boldsymbol{x}_i))^2 + \frac{\lambda}{2} \|\boldsymbol{\theta}\|_2^2Ln(θ;λ)=2n1i=1n(N(xi;θ)N(xi))2+2λθ22

where λ>0\lambda > 0λ>0 is the weight decay parameter. The model is optimized using vanilla Gradient Descent (GD) with a fixed step size η\etaη, updating the parameters via θ(t+1)=θ(t)ηθLn(θ(t);λ)\boldsymbol{\theta}^{(t+1)} = \boldsymbol{\theta}^{(t)} - \eta \nabla_{\boldsymbol{\theta}} L_n(\boldsymbol{\theta}^{(t)}; \lambda)θ(t+1)=θ(t)ηθLn(θ(t);λ).

To formalize grokking, the authors define the training loss convergence time t1t_1t1 and the generalization loss convergence time t2t_2t2. Grokking occurs when there is a significant delay between these two events (t2t1t_2 \gg t_1t2t1). In the over-parameterized regime (mnm \gg nmn), the GD optimization process effectively updates the projection of the weight vector onto the data-spanning subspace to fit the training data quickly. However, the component in the complementary subspace converges at a much slower rate dictated by the weight decay, leading to harmful overfitting before eventual generalization.

The authors provide quantitative bounds for the grokking time t2t1t_2 - t_1t2t1 and analyze how different training hyperparameters influence this delay.

As shown in the figure below, the theoretical bounds closely match empirical results regarding hyperparameter dependencies. Specifically, decreasing the weight decay λ\lambdaλ extends the generalization delay, as t2t_2t2 is inversely proportional to λ\lambdaλ. Decreasing the sample size nnn amplifies grokking by speeding up the convergence of the training loss. Increasing the feature dimension mmm has little effect on t1t_1t1 and t2t_2t2, while increasing the initialization scale ν2\nu^2ν2 increases both t1t_1t1 and t2t_2t2 simultaneously at logarithmic rates.

Experiment

The experiments confirm the theoretical framing of grokking by demonstrating that gradient descent with weight decay can first achieve low training error while generalization remains poor, and then eventually generalize well after a delay that can be made arbitrarily long through smaller weight decay. The observed dependencies of the early and late critical time points on hyperparameters closely track the derived bounds for linear ridge regression, and this qualitative behavior persists in both random-features networks and fully trained two-layer ReLU networks, indicating that the analytical insights may hold beyond the simplified linear setting.


Build AI with AI

From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.

AI Co-coding
Ready-to-use GPUs
Best Pricing

HyperAI Newsletters

Subscribe to our latest updates
We will deliver the latest updates of the week to your inbox at nine o'clock every Monday morning
Powered by MailChimp