Abstract
Despite the empirical dominance of the Transformer architecture, theoretical explanations for its superiority over traditional models like Fully-Connected Networks (FCNs) have historically focused on expressivity rather than learnability. This paper provides a rigorous mathematical proof demonstrating that Transformers are not only more expressive but also more efficient at learning structural tasks via Gradient Descent (GD). By analyzing the Sparse Token Selection ($STS_q$) task, the authors show that a one-layer Transformer achieves global convergence with minimal width, while FCNs suffer from a "width explosion." Additionally, the study identifies Stochastic Positional Encoding (SPE) as the primary driver for out-of-distribution length generalization.
Introduction
The success of Transformers in natural language processing is often attributed to their ability to model long-range dependencies and structural relationships. However, a fundamental question remains: Why does the Transformer architecture succeed where older architectures fail? Previous theoretical work established that Transformers could represent complex functions more efficiently than FCNs (expressivity), but it did not guarantee that standard training algorithms like Gradient Descent would actually find those solutions (learnability).
This research bridges that gap by focusing on a proxy for structural reasoning: Sparse Token Selection ($STS_q$). In this task, a model must identify and average a specific subset of $q$ tokens from a sequence of length $T$. The authors provide a formal proof that Transformers are naturally biased toward solving this task efficiently, whereas FCNs face insurmountable scaling challenges.
Methodology
The researchers analyzed a one-layer, one-head Transformer with softmax attention. To ensure mathematical tractability while preserving the architecture's core dynamics, they employed several key strategies:
- Reparameterization: The Query ($Q$) and Key ($K$) matrices were combined into a single trainable matrix $W$. This simplification is common in theoretical deep learning and maintains the model's ability to learn attention patterns.
- Stochastic Positional Encoding (SPE): Instead of fixed sine/cosine positional encodings, the authors utilized randomized positional vectors sampled freshly for each epoch. This prevents the model from memorizing specific indices and forces it to learn the underlying relational structure.
- Population Loss Analysis: The study focused on training dynamics within the "population loss"—the limit of infinite data. This allowed the authors to prove global convergence, showing that the model is guaranteed to reach an optimal solution from zero initialization.
- Lower Bound Proofs: Using linear algebra and kernel methods, the authors established the minimum requirements for an FCN to approximate the same selection task, highlighting a significant architectural disparity.
The Efficiency Gap: Transformers vs. FCNs
The most significant finding of the paper is the "exponential separation" in required model width.
- Transformer Efficiency: A Transformer requires a width of only $O(d + q \log T)$ to learn the $STS_q$ task. This suggests that the attention mechanism is inherently suited for filtering and aggregating information across sequences.
- FCN Width Explosion: In contrast, an FCN requires a width of $\Omega(Td)$ neurons to achieve comparable performance. As the sequence length $T$ increases, the FCN becomes exponentially more expensive to parameterize and train compared to the Transformer.
This separation proves that the Transformer's advantage is not just a matter of having more parameters, but rather having the right parameters arranged in a way that Gradient Descent can effectively optimize.
The Role of Stochastic Positional Encoding
A recurring challenge in sequence modeling is "Length Generalization"—the ability of a model trained on short sequences to perform accurately on longer ones. The authors found that fixed positional encodings often lead to overfitting on specific sequence lengths.
By introducing Stochastic Positional Encoding (SPE), the model is forced to learn a general selection rule. The authors proved that with SPE, the Out-of-Distribution (OOD) loss on longer sequences converges to zero as the training loss decreases. Empirical simulations supported this, showing that while both fixed and stochastic encodings can achieve zero training error, only the stochastic version generalizes to longer test sequences.
Conclusion and Future Directions
This paper provides a theoretical foundation for the Transformer's success, moving beyond simple expressivity to prove that these models are fundamentally more learnable for structural tasks than FCNs. The results highlight the critical role of the attention mechanism in avoiding the width explosion seen in traditional networks and the importance of randomized encodings for robust generalization.
While the study focuses on a simplified one-layer, one-head model, it sets the stage for future research into multi-layer architectures and more complex, non-linear tasks. Understanding these dynamics is essential for designing the next generation of efficient and generalizable AI models.
Summary updated