Grokking at the Edge of Linear Separability

Alon Beck, Noam Itzhak Levi, Yohai Bar-Sinai

TL;DR

Grokking—the mysterious phenomenon where a machine learning model suddenly transitions from overfitting to perfect generalization—isn't exclusive to complex transformers or modular arithmetic. This paper demonstrates that grokking emerges naturally in simple logistic regression when the dataset is on the "edge" of being linearly separable from the origin. By analyzing this minimal model, the authors provide a clear geometric and analytical explanation for why learning sometimes takes a long, sudden detour before clicking into place.

The Mystery of Grokking

Since its discovery in 2022, "grokking" has puzzled researchers. Usually, if a model starts overfitting (achieving perfect training accuracy but poor test accuracy), further training only degrades its performance on unseen data. In grokking, however, the model eventually "clicks" and achieves near-perfect generalization after a long period of apparent stagnation.

Most existing theories attribute this behavior to the complex internal representations of deep neural networks or specific properties of the tasks being learned. The authors of this paper ask a fundamental question: Is grokking a property of complex architectures, or is it a more general phenomenon of optimization? To answer this, they seek a "minimal model" where grokking can be defined strictly and solved analytically.

A Minimal Model for Grokking

The authors investigate a classic binary logistic classification task.

  • The Setup: They use a linear model with a bias term to classify two high-dimensional Gaussian distributions.
  • The Mapping: They show that this problem can be mathematically reduced to a $d$-dimensional problem with a bias term where all training points have the same label. In this view, "generalizing" means pushing the decision boundary to infinity, while "memorizing" means fitting a hyperplane that separates the data from the origin.
  • Analytical Tools: They utilize the implicit bias of gradient descent (the tendency of GD to find max-margin solutions) and Wendel’s Theorem from geometric probability to define a "critical point" of separability.

To make the math tractable, they also create a 1D "toy model" using only two points that perfectly captures the high-dimensional dynamics.

Key Insights: The Edge of Separability

The "aha moment" of the paper is that grokking depends heavily on whether the training data is linearly separable from the origin. If the origin is inside the convex hull of the data, the model is forced to generalize to reach the global minimum.

Using Wendel’s Theorem, the authors show that for a ratio of dimensions to samples ($\lambda = d/N$), a phase transition occurs at $\lambda = 1/2$. Below this threshold, the data is likely inseparable from the origin (promoting generalization); above it, it is likely separable (promoting overfitting).

Training dynamics and phase transition. Notice the delayed generalization (grokking) near the critical threshold of lambda = 0.48, and the divergence of grokking time as lambda approaches 0.5.

Flat Directions and "Lingering"

Why does the model take so long to generalize near this threshold? The answer lies in the geometry of the loss landscape. Near the critical threshold, the loss landscape contains "flat" directions where the gradient is nearly zero.

The model gets "stuck" near a quasi-stable overfitting solution for an arbitrarily long time. It slowly drifts through this flat valley before finally finding the steep path toward the generalizing solution. The authors link this to "critical slowing down," a concept from physics where systems take much longer to reach equilibrium when they are near a phase transition.

Optimization trajectories in the loss landscape. Near the critical point (lambda = 0.48, green line), the trajectory lingers in flat regions before eventually converging to the generalizing solution (yellow region).

Main Results

  • Proof of Grokking in Linear Models: The authors successfully demonstrate non-monotonic test loss (the hallmark of grokking) in a simple linear setup, proving that complex architectures are not a strict requirement for the phenomenon.
  • Divergence of "Grokking Time": They show that as the system approaches the critical point ($\lambda \to 1/2$), the time required to generalize diverges logarithmically.
  • The Role of Noise: Large noise ($\sigma$) in perpendicular directions is shown to promote grokking by accelerating the growth of the weight norm relative to the bias term.
  • Analytical Match: The trajectories derived from their 1D simplified model show excellent agreement with numerical simulations of high-dimensional models.

Limitations and Future Work

While this paper provides a elegant mathematical framework for grokking, the study is confined to linear models. The authors suggest these results might apply to the final layer of a deep network (the "feature map" view), but they do not explicitly model multi-layer non-linear dynamics. Additionally, the proofs rely on data distributions that are symmetric around the origin.

Looking forward, the authors propose searching for "universality classes" of grokking—checking if the same mathematical signatures (like the logarithmic divergence of grokking time) appear in more complex models like Transformers. They also suggest investigating how adaptive optimizers like Adam interact with these "flat directions" compared to standard Gradient Descent.

Summary updated

BibTeX
@inproceedings{beck2025grokking,
  author = {Alon Beck and Noam Itzhak Levi and Yohai Bar-Sinai},
  title = {{Grokking at the Edge of Linear Separability}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=d2qpEYzyyy},
}
Figure