Grokking is when a neural network suddenly picks up the general pattern in its data after many training iterations, long after it has memorized the training set.
What is Grokking?
Grokking is a sudden improvement in generalization during training, usually after the network appears to have memorized the training data for a long time. This was first systematically studied by Power et al. in 2022.
The Training Dynamics
Typically, training proceeds in phases:
- Initial Learning: The model quickly learns to fit the training data
- Memorization Phase: Training accuracy reaches near 100%, but test accuracy remains low
- Compression Phase: The model starts to simplify its internal representations
- Grokking: Test accuracy suddenly jumps to match training accuracy
This suggests that the model first memorizes, then gradually discovers a more general algorithm that explains the data.
Mathematical Analysis
The phase transition can be modeled as a logistic function of training time, with test accuracy jumping sharply around an inflection point.
Mechanistic Interpretability
Studying grokking provides insights into:
- How circuits form in neural networks
- The relationship between memorization and generalization
- The dynamics of weight decay and regularization
This matters for AI safety research because it shows how and when models develop capabilities that generalize instead of memorizing.