Single-Head Attention in High Dimensions: A Theory of Generalization, Weights Spectra, and Scaling Laws

Fabrizio Boncoraglio, Vittorio Erba, Emanuele Troiani, Yizhou Xu, Florent Krzakala, Lenka Zdeborová

Introduction

Despite the world-altering success of Transformer architectures, our theoretical understanding of their core engine—the attention mechanism—remains surprisingly thin. Empirical studies of trained large language models (LLMs) like LLaMA reveal that their weight matrices are far from random. Instead, they exhibit highly structured "spectra" (singular value distributions), frequently collapsing into low-rank forms characterized by a noise bulk and a few prominent spectral "outliers."

Until now, theoretical frameworks have struggled to explain why these specific spectral patterns emerge or how they directly relate to a model's ability to generalize. Furthermore, while empirical "scaling laws" dictate that model performance improves predictably with more data, a first-principles explanation for these laws in representation learning has been lacking. This paper bridges the gap between abstract high-dimensional mathematics and the striking, reproducible patterns observed in real-world AI, offering a sharp theoretical framework for how single-head attention layers learn.

Methodology and Experimental Setup

To isolate the mechanics of attention, the researchers analyze a single-head tied-attention layer (where the query and key weights are identical) through the lens of high-dimensional asymptotics. By framing the learning process as a "matrix sensing" problem, the authors deploy a powerful mathematical toolkit drawn from statistical physics and information theory:

  • Approximate Message Passing (AMP): A technique utilized to track the trajectory of non-convex optimization (such as neural network training) via a set of solvable scalar equations.
  • Random Matrix Theory (RMT): Applied to predict the exact distribution of singular values within the weight matrices.
  • Spin-Glass Theory: Used to map and understand the complex "energy landscape" of the training process.

The theoretical derivations assume that the embedding dimension ($d$), the number of samples ($n$), and the rank of the weights ($p$) scale proportionally. This yields "asymptotically sharp" formulas, meaning the mathematical predictions become exact as the model scales up.

Because this serves as a theoretical "unit test," the authors utilize a controlled synthetic environment. They employ an Attention-Indexed Model where the ground-truth "teacher" is itself an attention mechanism. The input tokens are generated as high-dimensional Gaussian random vectors, and the model is tested against two types of target spectra: Marchenko-Pastur (MP) targets (representing standard low-rank features) and Power-law targets (where features exhibit a hierarchy of strengths, mimicking the structured complexity of natural language).

Key Theoretical Insights

The application of this physics-inspired framework yields several profound insights into the mechanics of attention:

  • The Spectrum-Generalization Link: The theory formally demonstrates that the "outliers" in a weight matrix's spectrum correspond to the "learned features." Generalization improves precisely as more of these outliers escape the "noise bulk" of the matrix and align with the target task.
  • Implicit Low-Rank Bias: The authors show that weight decay—a standard regularization technique—does more than just constrain weight magnitudes. In the context of attention, it acts as a "nuclear norm" regularizer. This explains the natural gravitation of attention layers toward low-rank configurations, even when the architecture possesses the capacity to be high-rank.
  • Sequential Spectral Recovery: For complex tasks defined by power-law targets, the model does not learn all features simultaneously. Instead, it "picks off" the strongest features first. As the sample size increases, the learning cutoff shifts, allowing the model to capture progressively weaker, yet structurally important, features.
  • Emergence as a Phase Transition: The sudden "emergence" of capabilities often observed in LLMs can be mathematically framed as a spectral event: a specific feature's signal finally accumulates enough strength to pop out of the noise bulk of the weight matrix.

Main Results

The theoretical predictions of the paper are rigorously validated against empirical simulations:

  • Precision Matching: The derived formulas for training and test error match numerical simulations (trained via the Adam optimizer) with near-perfect precision.
  • Predicting the "Bulk": The theory successfully predicts the full singular-value distribution of the trained query-key map. This includes both the structured bulk and the isolated outliers, qualitatively mirroring observations in realistic Transformers.
  • Deriving Scaling Laws: For power-law targets, the authors derived explicit exponents detailing how error decreases as a function of sample size ($n$). Remarkably, these rates match those found in other high-dimensional statistical problems like LASSO, pointing to a deep universality in machine learning dynamics.
  • Threshold Discovery: The framework successfully identifies the "interpolation threshold"—the exact data regime where a model transitions from merely memorizing training samples to genuinely learning the underlying data structure.

Limitations and Future Directions

While this work represents a major leap forward in Transformer theory, the authors note several constraints that pave the way for future research:

  • Architectural Simplicity: Real-world Transformers utilize multi-head attention with untied (separate) Query, Key, and Value matrices. While tied attention is expressive enough to demonstrate core phenomena, multi-head dynamics likely introduce new, complex interactions.
  • Isotropic Data: The assumption of Gaussian/random input tokens simplifies the math but misses the internal structure and correlations inherent in real-world data modalities like text or images.
  • Network Depth: This is fundamentally a "shallow" theory focused on a single layer. Understanding how these spectral patterns propagate, interact, and evolve across dozens of stacked layers remains a critical frontier in fully decoding the Transformer architecture.

Summary updated

BibTeX
@inproceedings{boncoraglio2026single,
  author = {Fabrizio Boncoraglio and Vittorio Erba and Emanuele Troiani and Yizhou Xu and Florent Krzakala and Lenka Zdeborová},
  title = {{Single-Head Attention in High Dimensions: A Theory of Generalization, Weights Spectra, and Scaling Laws}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=3qan4Zg9rA},
}
Figure