Grokking at the Edge of Linear Separability

Alon Beck, Noam Levi, Yohai Bar-Sinai · OpenReview

TL;DR

This paper investigates "grokking," a phenomenon where a model initially overfits but later generalizes surprisingly well. The authors show that grokking emerges naturally in a simple logistic regression model when the data is close to being linearly separable. They pinpoint this "edge of separability" as the key to understanding grokking, linking it to critical phenomena in physics.

What Problem Does This Paper Address?

The machine learning community has been puzzled by "grokking," where models trained on certain tasks initially perform poorly on unseen data (overfitting) but then, after prolonged training, suddenly achieve excellent generalization. This behavior is counterintuitive, as overfitting is typically seen as a sign of a model that has learned the training data too well and will fail to generalize. While grokking has been observed in complex models like transformers, its underlying mechanism has remained elusive. This paper aims to demystify grokking by studying it in a simplified, analytically tractable setting: binary logistic classification. By precisely defining "memorizing" and "generalizing" solutions in this context, the authors seek to understand why and when grokking occurs.

Methods

The authors employ a combination of theoretical analysis and numerical simulations. They analyze the gradient descent dynamics of a logistic regression model trained on data generated from two Gaussian distributions. A key theoretical tool is the concept of "conformal time," which simplifies the analysis of late-time dynamics. They also leverage insights from the theory of linear separability and its connection to the implicit bias of gradient descent. To gain deeper intuition, they construct a simplified one-dimensional toy model that captures the essential features of the full problem.

Datasets

The paper uses synthetic datasets generated from two Gaussian distributions with controlled separation and noise. The specific parameters of these Gaussians, particularly the ratio of dimensions to samples ($\lambda = d/N$), are varied to explore different regimes of data separability. No new benchmark datasets are introduced.

Key Insights and Ideas

  • Grokking at the Edge of Separability: The central finding is that grokking is intimately linked to the data being "on the verge of linear separability." This critical point, where the data transitions from being inseparable to separable, is where grokking is amplified.
  • Critical Phenomena Analogy: The behavior observed near this critical point is analogous to "critical slowing down" in physics, where systems near a phase transition exhibit very slow dynamics. This explains why the model might linger in an overfitted state for a long time before transitioning to a generalizing solution.
  • Implicit Bias and Overfitting: The implicit bias of gradient descent, particularly in logistic regression, favors solutions that are separable from the origin. If the training data is separable from the origin, the model will tend to overfit. If it's not separable, it will generalize perfectly asymptotically.
  • The Role of "Flat Directions": Near the critical point, the loss landscape has "flat directions" with very small gradients. These directions can cause the training process to stall in quasi-stable, overfitted solutions for extended periods.
  • Separability from the Origin is Key: The paper emphasizes that "separability from the origin" (rather than just linear separability) is the crucial factor determining whether the model generalizes perfectly or overfits in the long run.

Key Results

  • Empirical and Analytical Proof of Grokking: The authors demonstrate both numerically and analytically that grokking occurs in their simplified logistic regression model when $\lambda$ is close to $1/2$ (the critical point for separability).
  • Delayed Generalization: For datasets near the edge of separability, the model exhibits delayed generalization, characterized by a non-monotonic test loss and a gradual increase in test accuracy after an initial period of overfitting.
  • Divergence of Grokking Time: The "grokking time" (the time it takes for generalization to significantly improve) diverges as the data approaches the critical point of separability.
  • One-Dimensional Model Captures Essence: A simplified one-dimensional model with two data points quantitatively reproduces the grokking phenomenon and its dependence on the separability parameter.

Limitations and Future Work

  • Simplified Model: The study is conducted on a simplified binary logistic classification task with specific data distributions (Gaussians). The authors acknowledge that extending these findings to more complex data distributions, hierarchical structures, or non-linear models is a crucial next step.
  • Constant Labels: The primary analysis assumes constant labels for the data points. While they explore variations with non-constant labels, a full generalization to discriminative labels is left for future work.
  • Gradient Descent Focus: The analysis primarily focuses on gradient descent and its limit. The impact of large learning rates or adaptive optimizers (though explored in appendices) could be further investigated.
  • Universality Classes: The authors conjecture that grokking might be related to critical phenomena and suggest exploring "universality classes" of grokking, where different underlying mechanisms could lead to similar critical behavior.
  • Non-linear Models: Extending the analysis to non-linear logistic regression and deep learning models is a significant future direction.

Summary updated

BibTeX
@inproceedings{beck2025grokking,
  author = {Alon Beck and Noam 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