Abstract
This paper investigates the "stage-wise progression" observed during Transformer training, where models experience long plateaus followed by sudden performance jumps. By studying Transformers trained on in-context $n$-gram tasks, we demonstrate that simpler sub-patterns (sub-$n$-grams) act as near-stationary points in the loss landscape. We prove that the gradient of the population loss effectively vanishes at these intermediate stages, creating mathematical "traps" that necessitate phase transitions for the model to learn more complex dependencies.
Introduction
Transformer training often exhibits non-monotonic behavior, characterized by stagnation periods and sudden "grokking" events. While mechanistic interpretability has identified specific circuits like induction heads associated with these jumps, a formal mathematical explanation for this landscape behavior was missing. This work addresses why models do not learn complex patterns directly, focusing on in-context $n$-gram prediction tasks where the model must predict the next token based on the previous $n-1$ tokens seen in the prompt.
Methods
The study utilizes a "disentangled attention-only Transformer" to ensure mathematical tractability while preserving representational power. In this setup, the outputs of different attention heads are concatenated rather than summed, allowing for a clearer analysis of individual head contributions.
The authors derive a sufficient stationary condition for cross-entropy loss, proving that if a model accurately predicts the statistics of a specific suffix (a sub-sequence of the history), the gradient becomes nearly zero. They mathematically construct parameter configurations representing $k$-gram estimators (where $k < n$) and provide asymptotic proofs showing that the gradient at these sub-$n$-gram solutions vanishes in the limit of infinite sequence length and large parameter norms.
Datasets
Experiments rely on synthetic $n$-gram datasets generated from Markov chains with transition probabilities sampled from a Dirichlet prior. Typical parameters include a vocabulary size of 3 to 5, sequence lengths of 32 to 128, and target $n$-grams of order 3 or 4. This synthetic setup allows the researchers to know the "ground truth" optimal loss for every hierarchical level (unigram, bigram, etc.), which is impossible with real-world text data.
Key Insights and Results
The core finding is that sub-$n$-grams are not merely intermediate steps but mathematical traps. The "self-bounding" property of the softmax function causes gradients to scale with output values; when an attention head focuses on specific tokens, its gradient diminishes, "locking" the model into a plateau.
Learning proceeds hierarchically: unigrams (token frequency) are mastered first, followed by bigrams (what follows the current token), then trigrams, and so on. Each level of mastery corresponds to a specific plateau in the loss curve. Theorem 4.1 quantifies the gradient norm at these sub-$n$-gram points, showing it consists of a statistical error term and a term that decays exponentially as the model's weights grow.
Empirical results confirm that Transformer test loss plateaus align perfectly with the theoretical cross-entropy of $k$-gram estimators. Furthermore, the paper provides a theoretical home for "induction heads," showing they are the physical manifestation of the model moving from a unigram stationary point to a bigram or trigram stationary point.
Discussion and Limitations
While providing a rigorous framework for understanding training plateaus, the study relies on idealized conditions such as infinite sequence length and simplified architectures. The formal proofs focus on disentangled, attention-only versions, though the authors provide a sketch for how these principles apply to standard Transformers with MLPs and residual connections. Future work is needed to fully model the dynamics of how models eventually escape these plateaus through stochastic noise or weight growth.
Summary updated