NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

The emergence of clusters in self-attention dynamics

Borjan Geshkovski, Cyril Letrouit, Yury Polyanskiy, Philippe Rigollet · DOI

TL;DR

This paper provides a rigorous mathematical explanation for why Transformers tend to group tokens into a few "leaders" as they pass through successive layers. By modeling self-attention as a system of interacting particles, the authors prove that tokens naturally cluster toward specific geometric structures—like the vertices of a polytope or parallel hyperplanes—depending on the spectral properties of the model's weight matrices.

What Problem Does This Paper Address?

Despite the massive success of Transformers in AI, we still have a limited understanding of the geometric structure of the representations they learn. Empirically, researchers have noticed that as a sequence of tokens (like words in a sentence) moves through a Transformer, a few "leader" tokens emerge that capture the attention of most others.

The authors seek to move beyond empirical observation to provide a formal mathematical theory. They ask: What is the long-term geometric fate of tokens in a Transformer? and How do the learned weight matrices (Query, Key, and Value) determine this geometry?

Methods

The authors treat the Transformer architecture as a continuous-time dynamical system. Instead of looking at discrete layers, they view the evolution of tokens as particles $x_i(t)$ moving through time $t$.

Key technical components include:

  • Interacting Particle Systems: They define the evolution of tokens using an Ordinary Differential Equation (ODE) where the "force" acting on each particle is the self-attention mechanism.
  • Time-Rescaling: To prevent tokens from simply flying off to infinity (a common behavior in unnormalized systems), they introduce a rescaling technique that acts as a mathematical surrogate for the Layer Normalization used in practice.
  • Spectral Analysis: The core of their proofs involves analyzing the eigenvalues and eigenvectors of the Value matrix ($V$). They show that the "shape" of the final clusters is a direct consequence of $V$'s spectrum.
  • Continuity Equations: To ensure their findings hold for any number of tokens, they prove the global existence and uniqueness of these dynamics using the mean-field limit (a tool from statistical mechanics).

Datasets

This is primarily a theoretical paper, so it does not "train" on standard massive datasets. Instead, the authors used:

  • Synthetic Data: Randomly initialized tokens within a hypercube $[-5, 5]^d$ to test their theorems numerically.
  • Pre-trained Models: They analyzed the weight matrices of the ALBERT-xlarge-v2 model (available on Hugging Face) to verify that the assumptions in their theorems (like the existence of a leading eigenvalue in the Value matrix) actually hold in real-world, high-performing models.

Key Insights and Ideas

  • Clustering is Generic: The paper shows that clustering isn't a fluke; it is an inherent property of the self-attention mechanism when weights are shared across layers.
  • The Value Matrix as a Geometric Architect: The geometry of the clusters is dictated by the Value matrix $V$.
  • If $V$ is the identity matrix, tokens cluster toward the vertices of a convex polytope (see Figure 5).
  • If $V$ has a single dominant positive eigenvalue, tokens cluster toward at most three parallel hyperplanes (see Figure 6).
  • Mathematical Proof of "Leaders": In the one-dimensional case, they prove the self-attention matrix $P(t)$ converges to a low-rank Boolean matrix. This means that eventually, every token pays full attention to only one or two "leader" tokens, confirming the 2017 observations by Vaswani et al.
Figure 5: Tokens clustering toward the vertices of a convex polytope when V is the identity matrix.

Key Results

  • Low-Rank Emergence: The authors demonstrate that the self-attention matrix $P(t)$ naturally loses rank over time. As shown in Figure 3, a matrix that starts with rank 11 for 40 tokens can drop to rank 2 as $t$ increases, concentrating information into a tiny subset of the sequence.
  • Context Awareness: The locations of the final clusters are determined by the initial tokens. This mathematically confirms that the representations are "context-aware"—the meaning of a token changes based on its neighbors in the sequence.
  • Empirical Alignment: By examining ALBERT, they found that real-world Value matrices often possess the specific spectral properties (like a simple leading eigenvalue) required by their theorems, suggesting their theory applies to practical LLMs.
Figure 3: The self-attention matrix P(t) converging to a low-rank structure over time.

Limitations and Future Work

  • Weight Sharing: The current proofs assume the weight matrices ($Q, K, V$) are the same at every layer (time-independent). While this describes models like ALBERT, most modern LLMs (like GPT-4) use different weights at each layer.
  • Simplified Architecture: The main theorems focus on "pure" self-attention. While the authors provide numerical evidence that adding Feed-Forward Networks (FFNs) and Multi-Head Attention doesn't destroy the clustering effect, a full mathematical proof for the complete Transformer block remains an open challenge.
  • Normalization: The authors use a rescaling surrogate for LayerNorm. Future work could look at the specific dynamics introduced by the actual LayerNorm operation.

Summary updated

BibTeX
@inproceedings{geshkovski2023emergence,
  author = {Borjan Geshkovski and Cyril Letrouit and Yury Polyanskiy and Philippe Rigollet},
  title = {{The emergence of clusters in self-attention dynamics}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=aMjaEkkXJx},
}
Figure