Asymptotics of SGD in Sequence-Single Index Models and Single-Layer Attention Networks

Luca Arnaboldi, Bruno Loureiro, Ludovic Stephan, Florent Krzakala, Lenka Zdeborova · DOI

TL;DR

This paper provides the first rigorous mathematical characterization of how Stochastic Gradient Descent (SGD) learns using single-layer attention mechanisms. By extending classical single-index models to sequential data, the authors reveal how sequence length accelerates training and how positional encodings can both help and hinder optimization.

What Problem Does This Paper Address?

While we have a solid theoretical grasp of how neural networks learn from simple vector inputs, attention-based architectures (like Transformers) process sequential data, which introduces complex dependencies. Previous theoretical work successfully mapped out the exact training dynamics and sample complexities for "single-index" and "multi-index" vector models under SGD. However, a rigorous understanding of the optimization landscape and training trajectories for attention layers processing sequences has been missing. This paper fills that gap by analyzing how sequential data structure (sequence length and positioning) affects the speed and success of SGD.

Methods

The authors introduce Sequence Single-Index (SSI) models, a sequential generalization of classical single-index models. They analyze a simplified single-layer attention mechanism where the query and key matrices are tied, and the value matrix is fixed to the identity.

To track high-dimensional SGD dynamics, they derive a closed-form expression for the population loss using two "sufficient statistics" (or order parameters):

  1. Semantic alignment ($m$): How well the weights align with the true target feature.
  2. Positional alignment ($e$): How the weights align with positional encodings.

They approximate the discrete SGD steps using a continuous-time Ordinary Differential Equation (ODE) framework (the Gradient Flow approximation). Crucially, they introduce the Sequence Information Exponent (SIE)—derived via Hermite polynomial expansions of the data's link function—to precisely quantify the sample complexity required for the network to escape its initial uninformative state (a phase known as "escaping mediocrity").

Datasets

The paper relies entirely on synthetic data to maintain mathematical rigor. The inputs are sequences of tokens represented as a Gaussian matrix $X \in \mathbb{R}^{L \times d}$ with independent entries, where $L$ is the sequence length and $d$ is the embedding dimension. The labels are generated using a vector-valued link function $g(X \cdot w_\star)$. No real-world datasets are discussed.

Key Insights and Ideas

  • The Power of Weight Tying: Attention mechanisms inherently reuse (or "tie") weights across different positions in a sequence. The paper proves that this structural constraint acts as a massive accelerator for learning compared to standard fully connected ("untied") networks.
  • Positional Encodings Alter the Landscape: Positional encodings do more than just tell the model where a token is; they fundamentally reshape the population loss landscape. They can lower the SIE, allowing the model to break out of flat initialization regions much faster.
  • The Trap of Local Minima: While positional encodings can speed up early training, they also introduce a rich landscape of local and global minima. Depending on the data's nature, SGD can get trapped in a purely positional local minimum, failing to learn the underlying semantic rules.

Key Results

  • Sample Complexity Bounds: The authors prove that the time/samples needed to achieve weak recovery scales with the embedding dimension $d$ based on the SIE: $O_L(d)$ for $\text{SIE}=1$, $O_L(d \log^2 d)$ for $\text{SIE}=2$, and $O_L(d^{\text{SIE}-1})$ for $\text{SIE} \ge 3$.
  • Quantifiable Speedup: Tying weights yields a training speedup (gain) over untied networks that scales up to $L^{\text{SIE}\lor 2}$. For an $\text{SIE}=2$ target, the gain scales quadratically ($L^2$) with sequence length, which the authors validate empirically.
Quadratic training speedup as a function of sequence length L
  • Phase Diagram of Attention Learning: The authors map out a detailed phase diagram showing distinct training behaviors based on the balance between semantic and positional data, demonstrating exactly when SGD successfully finds the global minimum versus when it gets trapped.
Phase diagram of SGD behavior depending on semantic and positional parameters

Limitations and Future Work

  • Simplified Attention Architecture: The analysis is restricted to a single-layer, single-head attention mechanism with tied query/key weights and an identity value matrix. Real-world Transformers use multi-layer, multi-head architectures with trainable value matrices.
  • Uncorrelated Tokens: The data model assumes tokens are independent Gaussians. In real-world sequential data (like natural language), tokens are highly correlated across time.
  • Future Directions: The authors suggest extending this framework to multi-index sequence models, multi-layer architectures, and more realistic data distributions that incorporate token-to-token correlations.

Summary updated

Abstract

We study the dynamics of stochastic gradient descent (SGD) for a class of sequence models termed Sequence Single-Index (SSI) models, where the target depends on a single direction in input space applied to a sequence of tokens. This setting generalizes classical single-index models to the sequential domain, encompassing simplified one-layer attention architectures. We derive a closed-form expression for the population loss in terms of a pair of sufficient statistics capturing semantic and positional alignment, and characterize the induced high-dimensional SGD dynamics for these coordinates. Our analysis reveals two distinct training phases: escape from uninformative initialization and alignment with the target subspace, and demonstrates how the sequence length and positional encoding influence convergence speed and learning trajectories. These results provide a rigorous and interpretable foundation for understanding how sequential structure in data can be beneficial for learning with attention-based models.
BibTeX
@inproceedings{arnaboldi2025asymptotics,
  author = {Luca Arnaboldi and Bruno Loureiro and Ludovic Stephan and Florent Krzakala and Lenka Zdeborova},
  title = {{Asymptotics of SGD in Sequence-Single Index Models and Single-Layer Attention Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=Hn8z3Ee4Xa},
}
Figure