HyperAIHyperAI

Command Palette

Search for a command to run...

Grokkingを解明する:リッジ回帰における証明可能なGrokking

Mingyue Xu Gal Vardi Itay Safran

概要

本稿では、古典的なリッジ回帰の設定においてGrokking(過学習の長期にわたる持続の後に生じる汎化の開始)を研究する。勾配降下法と重み減衰を用いて過パラメータ線形回帰モデルを学習する際の、エンドツーエンドのGrokking結果を証明する。具体的には、以下の段階が生じることを証明する:(i) 訓練の初期段階でモデルが訓練データに過学習する;(ii) 過学習が顕在化した後も長い間汎化性能の低い状態が持続する;(iii) 汎化誤差が最終的に任意に小さくなる。さらに、理論的および実証的に、適切なハイパーパラメータ調整によりGrokkingを原理的に増幅または排除できることを示す。我々の知る限り、これらは訓練ハイパーパラメータに基づく汎化遅延(我々が「Grokking時間」と呼ぶもの)に関する最初の間定量的上界である。最後に、線形設定を超えて、我々の定量的上界が非線形ニューラルネットワークにおけるGrokkingの挙動も捉えることを実証的に示す。これらの結果は、Grokkingが深層学習に本質的な失敗モードではなく、特定の訓練条件に起因する結果であることを示唆しており、回避するためにモデルアーキテクチャや学習アルゴリズムの根本的な変更を必要としないことを意味する。

One-sentence Summary

This work proves the first rigorous quantitative bounds on grokking time in over-parameterized ridge regression trained with gradient descent and weight decay, demonstrating that grokking unfolds through overfitting, prolonged poor generalization, and eventual convergence, with the delay controllable through hyperparameter tuning rather than architectural changes and empirically validated on non-linear neural networks.

Key Contributions

  • The paper proves end-to-end grokking in over-parameterized linear ridge regression trained with gradient descent and weight decay, including early overfitting, sustained poor generalization, and eventual arbitrarily small generalization error.

  • The paper establishes quantitative bounds on the generalization delay, termed grokking time, in terms of training hyperparameters, and shows theoretically and empirically that proper hyperparameter tuning can amplify or eliminate grokking.

  • The paper empirically shows that the derived bounds also capture grokking on nonlinear neural networks, and that a threshold-based accuracy metric recovers the familiar test error plateau in regression.

Introduction

In deep learning and related ML systems, grokking is a counterintuitive overfitting phenomenon where training accuracy becomes perfect early, while test generalization improves only much later. This matters because it challenges standard regularization intuition and reveals hidden dynamics in how models converge during optimization. Prior theory often links grokking to regime changes in training, such as lazy-to-rich dynamics or weight-decay effects, but earlier analyses generally lack rigorous end-to-end guarantees, fail to prove that poor generalization persists long after overfitting, or study overly narrow settings. The authors leverage an over-parameterized linear ridge regression framework to provide the first provable end-to-end grokking result, showing that gradient descent can quickly fit the training data, maintain worse generalization for a quantifiable delay, and later converge to a well-generalizing global optimum, while also giving explicit hyperparameter bounds and demonstrating that weight decay can control the grokking time.

Method

The authors leverage a teacher-student regression pipeline to isolate the mechanism behind grokking. Each input xi∈Rd\pmb{x}_i \in \mathbb{R}^dxi​∈Rd is sampled from a marginal distribution Dx\mathcal{D}_{\pmb{x}}Dx​, and its label is given exactly by a fixed teacher function N∗(x)N^*(\pmb{x})N∗(x). The student model is linear in a feature representation:

N(x;θ)=⟨θ,ϕ(x)⟩,N(\pmb{x};\pmb{\theta}) = \langle \pmb{\theta}, \phi(\pmb{x}) \rangle,N(x;θ)=⟨θ,ϕ(x)⟩,

where ϕ(x):Rd↦Rm\phi(\pmb{x}) : \mathbb{R}^d \mapsto \mathbb{R}^mϕ(x):Rd↦Rm is a fixed feature map and θ∈Rm\pmb{\theta} \in \mathbb{R}^mθ∈Rm is trainable. The realizable assumption means that there exists some θ∗\pmb{\theta}^*θ∗ such that N∗(x)=⟨θ∗,ϕ(x)⟩N^*(\pmb{x}) = \langle \pmb{\theta}^*, \phi(\pmb{x}) \rangleN∗(x)=⟨θ∗,ϕ(x)⟩.

Training is performed with ridge regression, which combines the empirical squared loss with an ℓ2\ell_2ℓ2​ regularization term:

Ln(θ;λ)=12n∑i=1n(⟨θ−θ∗,ϕ(xi)⟩)2+λ2∥θ∥22.L_n(\pmb{\theta};\lambda) = \frac{1}{2n}\sum_{i=1}^n \left( \langle \pmb{\theta} - \pmb{\theta}^*, \phi(\pmb{x}_i) \rangle \right)^2 + \frac{\lambda}{2}\|\pmb{\theta}\|_2^2.Ln​(θ;λ)=2n1​i=1∑n​(⟨θ−θ∗,ϕ(xi​)⟩)2+2λ​∥θ∥22​.

The parameter is optimized using vanilla gradient descent:

θ(t+1)=θ(t)−ηn∑i=1n⟨θ(t)−θ∗,ϕ(xi)⟩ϕ(xi)−ηλθ(t),\pmb{\theta}^{(t+1)} = \pmb{\theta}^{(t)} - \frac{\eta}{n} \sum_{i=1}^n \langle \pmb{\theta}^{(t)} - \pmb{\theta}^*, \phi(\pmb{x}_i) \rangle \phi(\pmb{x}_i) - \eta \lambda \pmb{\theta}^{(t)},θ(t+1)=θ(t)−nη​i=1∑n​⟨θ(t)−θ∗,ϕ(xi​)⟩ϕ(xi​)−ηλθ(t),

where η\etaη is the learning rate and λ\lambdaλ is the weight decay strength. The method studies training from a random initialization θ(0)∼N(0,ν2Im)\pmb{\theta}^{(0)} \sim \mathcal{N}(\pmb{0}, \nu^2 \pmb{I}_m)θ(0)∼N(0,ν2Im​), which makes the early dynamics and the eventual decay of unused directions analytically tractable.

The central mechanism behind grokking is a subspace decomposition of the learned weights. Let V=span⁡{ϕ(x1),…,ϕ(xn)}V = \operatorname{span}\{\phi(\pmb{x}_1),\ldots,\phi(\pmb{x}_n)\}V=span{ϕ(x1​),…,ϕ(xn​)} denote the feature subspace spanned by the training examples. In the overparameterized regime m≫nm \gg nm≫n, the optimization can be understood by splitting θ\pmb{\theta}θ into a component θ∥\pmb{\theta}_\parallelθ∥​ inside VVV and a component θ⊥\pmb{\theta}_\perpθ⊥​ in the complementary subspace. The empirical gradient primarily updates θ∥\pmb{\theta}_\parallelθ∥​, allowing the model to fit the training data quickly. However, θ⊥\pmb{\theta}_\perpθ⊥​ is invisible to the empirical loss and is mainly reduced by weight decay. Therefore, when λ\lambdaλ is very small, training loss can decrease rapidly while the component responsible for poor population performance decays slowly.

This gives rise to two relevant time points. The first is

t1=max⁡({t∈N:Ln(θ(t))≥ϵ}),t_1 = \max\left(\left\{t \in \mathbb{N}: L_n(\pmb{\theta}^{(t)}) \geq \epsilon \right\}\right),t1​=max({t∈N:Ln​(θ(t))≥ϵ}),

which marks the end of rapid training loss reduction. The second is

t2=min⁡({t∈N:L(θ(t))≤c}),t_2 = \min\left(\left\{t \in \mathbb{N}: L(\pmb{\theta}^{(t)}) \leq c \right\}\right),t2​=min({t∈N:L(θ(t))≤c}),

which marks the point where population loss becomes small. The authors show that, under sufficient sample size, large feature dimension, sufficiently small weight decay, and a compatible learning rate, t1t_1t1​ can be small while t2t_2t2​ can be arbitrarily large. Their bounds imply

t1≤nln⁡(6b2∥θ(0)∥22ϵ)2ηλmin⁡+(Φ⊤Φ),t_1 \leq \frac{ n \ln\left( \frac{6b^2 \|\pmb{\theta}^{(0)}\|_2^2}{\epsilon} \right) }{ 2\eta \lambda_{\min}^+(\pmb{\Phi}^\top \pmb{\Phi}) },t1​≤2ηλmin+​(Φ⊤Φ)nln(ϵ6b2∥θ(0)∥22​​)​,

and

t2≥ln⁡((m−n)ν22(cλmin⁡(Σ)+∥θ∗∥2)−2)4ηλ,t_2 \geq \frac{ \ln\left( \frac{(m-n)\nu^2}{2} \left( \sqrt{\frac{c}{\lambda_{\min}(\pmb{\Sigma})}} + \|\pmb{\theta}^*\|_2 \right)^{-2} \right) }{ 4\eta \lambda },t2​≥4ηλln(2(m−n)ν2​(λmin​(Σ)c​​+∥θ∗∥2​)−2)​,

where Φ\pmb{\Phi}Φ is the empirical feature matrix, Σ=E[ϕ(x)ϕ(x)⊤]\pmb{\Sigma} = \mathbb{E}[\phi(\pmb{x})\phi(\pmb{x})^\top]Σ=E[ϕ(x)ϕ(x)⊤] is the feature covariance matrix, and bbb bounds the feature norm. These expressions make clear why a small λ\lambdaλ can delay generalization without preventing fast training convergence.

To connect the theoretical bounds with observable hyperparameter behavior, the authors evaluate how λ\lambdaλ, sample size nnn, feature dimension mmm, and initialization scale ν2\nu^2ν2 change t1t_1t1​ and t2t_2t2​. As shown in the figure below:

The plots indicate that decreasing λ\lambdaλ primarily increases t2t_2t2​, because the orthogonal component θ⊥\pmb{\theta}_\perpθ⊥​ decays more slowly under weak weight decay. Reducing nnn can shorten t1t_1t1​ by making the training set easier to fit, thereby widening the interval t2−t1t_2 - t_1t2​−t1​. Increasing mmm has a comparatively muted effect in the plotted regime, while increasing ν2\nu^2ν2 shifts both t1t_1t1​ and t2t_2t2​ upward at logarithmic rates, with t2t_2t2​ growing faster, which amplifies the grokking gap.

The empirical ridge regression pipeline uses the identity feature map in some experiments, so that the student predicts ⟨θ,x⟩\langle \pmb{\theta}, \pmb{x} \rangle⟨θ,x⟩. Samples are generated under distributional assumptions on the features, often i.i.d. spherical Gaussian vectors, so that the covariance structure and the positive eigenvalue of the empirical Gram matrix can be estimated. The learning rate is fixed, and the model is trained by gradient descent with weight decay until both training and generalization behavior are observed.

The authors also extend the training protocol to a two-layer ReLU network. The network takes an input x∈Rd\pmb{x} \in \mathbb{R}^dx∈Rd, applies a first-layer weight matrix W\pmb{W}W, passes the resulting hidden units through ReLU⁡\operatorname{ReLU}ReLU, and combines them with a second-layer vector a\pmb{a}a. The output has the form

N(x;W,a)=∑j=1majReLU⁡(⟨wj,x⟩).N(\pmb{x};\pmb{W},\pmb{a}) = \sum_{j=1}^m a_j \operatorname{ReLU}\left(\langle \pmb{w}_j, \pmb{x} \rangle\right).N(x;W,a)=j=1∑m​aj​ReLU(⟨wj​,x⟩).

Both W\pmb{W}W and a\pmb{a}a are trained jointly with gradient descent and weight decay. The zero teacher is used as a simplified target, and the initialization scale ν2\nu^2ν2 controls the initial norm of the first-layer weights. This nonlinear setup serves to check whether the same hyperparameter trends predicted by the ridge regression analysis appear beyond the linear feature model.

Experiment

The experiments use ridge regression and gradient descent with weight decay to empirically test the theoretical grokking behavior, comparing training and generalization error timelines under controlled hyperparameters. The results confirm that small weight decay can produce the predicted separation between early overfitting and later generalization, closely matching the theoretical bounds. Extensions to random-feature networks and fully trained nonlinear ReLU networks exhibit qualitatively similar grokking behavior, suggesting that the observed phenomenon is not limited to the idealized linear setting.


AIでAIを構築

アイデアからローンチまで — 無料のAIコーディング支援、すぐに使える環境、最高のGPU価格でAI開発を加速。

AI コーディング補助
すぐに使える GPU
最適な料金体系

HyperAI Newsletters

最新情報を購読する
北京時間 毎週月曜日の午前9時 に、その週の最新情報をメールでお届けします
メール配信サービスは MailChimp によって提供されています