Abstract
While Transformers have achieved unprecedented success in sequence modeling, the theoretical mechanisms governing their training dynamics remain poorly understood. This paper investigates how single-layer Transformers learn the underlying structure of first-order Markov chains. By reducing the high-dimensional weight matrices to a canonical low-rank parameterization and analyzing the resulting gradient flow, we characterize the "basins of convergence" that determine whether a model reaches a global optimum or becomes trapped in a local minimum. Our analysis reveals that standard initialization often biases models toward a "unigram" solution, failing to capture transition probabilities. We propose a data-agnostic initialization strategy that consistently guides the model toward the global bigram optimum.
Introduction
The transition from random initialization to structured logic in Transformers is often treated as a "black box." Recent empirical evidence suggests that even simple Transformers can struggle with basic sequence tasks, frequently settling for sub-optimal solutions that capture only marginal token frequencies (unigrams) rather than the conditional dependencies (bigrams) inherent in the data. This paper provides a rigorous mathematical framework to predict these outcomes based on the model's starting point and the statistical properties of the training data.
Theoretical Framework: Scalar Parameterization and Gradient Flow
To analyze the training dynamics, the authors simplify a single-layer Transformer with ReLU non-linearity into a canonical low-rank model. This reduction is justified by the empirical observation that Transformer weights naturally tend toward rank-one structures during training. The model is reduced to three key scalar parameters:
- $e$: Representing the embedding weights.
- $w$: Representing the feed-forward weights.
- $a$: Representing the attention mechanism.
By analyzing "gradient flow"—the continuous-time limit of gradient descent—the authors derive an energy function $\mathcal{E}(e, w)$. They prove that this energy remains constant along any specific training trajectory. This conservation law allows the training process to be visualized as a point moving along a fixed contour on a landscape, making it possible to mathematically determine the final convergence point based solely on the initial values of $e$ and $w$.
The Geometry of the Loss Landscape
The complexity of the learning task is governed by the "switching factor" of the Markov chain. For a binary Markov chain with switching probabilities $p$ and $q$, the sum $p+q$ determines the landscape's topology:
- Persistence ($p+q < 1$): The data tends to stay in the same state. The landscape is relatively simple, and most initializations lead to the global minimum.
- Oscillation ($p+q > 1$): The data frequently flips between states. This creates a treacherous landscape with a prominent local minimum—the "unigram trap."
The Initialization Trap
Standard Gaussian initialization typically places parameters very close to the origin $(0,0)$. The authors demonstrate that for oscillating data ($p+q > 1$), the region around the origin is almost entirely contained within the basin of convergence for the local minimum. Consequently, models initialized with small random weights are mathematically predisposed to learn only the unigram statistics, failing to capture the more complex bigram transitions necessary for optimal performance.
A Global Initialization Strategy
By mapping the boundaries (asymptotes) of the basins of convergence, the research identifies a "Global Safe Zone." Regardless of the data's switching factor, if the model is initialized within this specific region of the parameter space, it is guaranteed to bypass the local minimum and reach the global optimum. Specifically, the authors suggest a non-zero initialization strategy (e.g., setting $w = -1$ and $e = 0.5$) to ensure the model captures the full bigram structure of the Markov chain.
Empirical Results and Validation
The theoretical predictions were validated using both the simplified scalar model and standard GPT-2 style architectures. In experiments, models using standard initialization frequently hit a loss plateau corresponding to the unigram model. In contrast, models utilizing the proposed initialization consistently reached the lower loss associated with the true bigram model, confirming that the scalar analysis accurately reflects the behavior of full-scale Transformer architectures.
Conclusion and Future Directions
This work provides a foundational step toward a "physics of training" for Transformers. By identifying the energy functions and convergence basins of single-layer models, the authors offer a principled way to avoid common training pitfalls. Future research will focus on extending this analysis to multi-layer architectures, where inter-layer interactions add further complexity, and to higher-order Markov processes that more closely resemble the intricacies of natural language.
Summary updated