TL;DR
What actually happens to a cloud of tokens as they pass through the layers of a deep transformer? By treating tokens like a swarm of interacting particles in physics, the authors prove that at low softmax temperatures, tokens rapidly snap onto a specific geometric subspace defined by the model's query, key, and value weights—and stay parked there for a predictable number of layers. Surprisingly, if the network goes too deep, this "metastable" formation breaks apart, and the tokens drift off toward an entirely different destination dictated solely by the value matrix.
What Problem Does This Paper Address?
Transformers power modern AI, yet we still lack a crisp mathematical picture of how internal token representations evolve layer by layer at inference time. A growing line of research models deep transformers by taking two continuous limits: infinitely many layers (making layer depth act like continuous time, $t$) and infinitely many tokens (turning discrete tokens into a smooth probability distribution). Because layer normalization keeps token vectors at unit length, you can picture tokens as particles swarming across the surface of a high-dimensional sphere, governed by a partial differential equation (PDE).
Previous work looked at what happens in the idealized "zero-temperature" limit ($\beta \to \infty$, where softmax becomes a hard argmax), showing qualitatively that tokens collapse onto a specific subspace. However, real transformers operate at finite $\beta$ (low, non-zero temperature). Nobody had quantified how fast tokens concentrate in this realistic regime, exact shapes of the target distribution they form, or how long the zero-temperature approximation actually holds up as depth $t$ increases.
Methods
The authors analyze a simplified, encoder-only, single-head attention architecture with shared weights across layers (like ALBERT) and without MLPs. They combine Query and Key matrices into $B = Q^\top K$ and denote the Value matrix as $V$.
What is novel here is importing heavy-duty mathematical machinery from Consensus-Based Optimization (CBO)—a framework usually used to study swarms of particles trying to find the minimum of a landscape:
- Lyapunov-type estimates ($\beta = \infty$): Assuming $VB^\top$ is symmetric, they build an "energy" functional that measures how far the token distribution is from the top eigenspace $E$ of $VB^\top$, proving exponential convergence to an exact stationary distribution.
- Quantitative Laplace principle (finite $\beta$): Softmax is essentially a smooth maximum. Using a quantitative version of the Laplace principle, they bound the Wasserstein-2 distance ($W_2$, the "earth mover's" distance between probability distributions) between the real finite-temperature flow and the idealized zero-temperature flow over time $t$.
Datasets
Not discussed in the paper. Because this is a theoretical investigation of inference-time mathematical dynamics, the authors validate their theorems using synthetic numerical simulations—evolving ensembles of $n = 200$ to $2,000$ tokens sampled from uniform or von Mises–Fisher mixture distributions on spheres ($d = 3$ and $d = 10$).
Key Insights and Ideas
- Attention is secret swarm optimization: When $V$ is the identity matrix, self-attention on a sphere is mathematically identical to noiseless, kernelized Consensus-Based Optimization. Tokens aren't just mixing context; they are running a collective search algorithm.
- Initial memory isn't completely erased—it's projected: In the zero-temperature limit, tokens don't all collapse to a single point (token uniformity) right away. Instead, they converge to $\Pi_\sharp \rho_0$—the orthogonal projection of the initial token distribution $\rho_0$ onto the top eigenspace $E$ of $VB^\top$, normalized back to the sphere.
- The $\mathcal{O}(\log \beta)$ "Goldilocks" window: Finite-temperature transformers experience a tug-of-war. Early on, tokens are pulled exponentially fast toward the $VB^\top$ subspace. Meanwhile, small "thermal" errors from finite $\beta$ compound exponentially over depth $t$. This creates a metastable sweet spot up to depth $t \sim \mathcal{O}(\log \beta)$—which corresponds to the finite depths of practical models!
- A hidden second act: What happens after $t \sim \log \beta$? The authors discover numerically (and state as a formal conjecture) that Query and Key matrices lose their grip. The tokens abandon the $VB^\top$ subspace and migrate toward the dominant eigenspace of the Value matrix $V$ alone.
Key Results
-
Main Concentration Bound (Theorem 1): The $W_2$ distance between the token distribution $\rho_t^\beta$ at time $t$ and the projected initial distribution $\Pi_\sharp \rho_0$ is bounded by two competing terms: $$W_2(\rho_t^\beta, \Pi_\sharp \rho_0) \lesssim \sqrt{\frac{\log(\beta + 1)}{\beta}} e^{C_1 t} + e^{-c t}$$ Here, $c = \frac{p \gamma}{\sigma_{\max}(B)}$ depends on the spectral gap $\gamma$ between the top two eigenvalues of $VB^\top$.
-
Zero-Temperature Stationary State (Corollary 2): Setting $\beta \to \infty$ kills the first term, giving the first exact identification of the zero-temperature stationary limit $\Pi_\sharp \rho_0$, approached exponentially fast at rate $e^{-ct}$.
- Empirical Validation: Across 3D and 10D simulations (e.g., $\beta = 10, 100, 10^3$), the $W_2$ distance visibly drops to a minimum right around $t = \log \beta$ before rebounding as tokens transition to align with the top eigenvectors of $V$.
Limitations and Future Work
To make the PDEs tractable, the authors make several simplifying assumptions:
- Architectural simplifications: The model omits MLPs, causal masking, and multi-head attention, and assumes tied weights across continuous depth and infinite tokens. Discretizing both time (finite layers) and space (finite tokens $n$) is a key next step.
- Matrix symmetry: Proving convergence to $\Pi_\sharp \rho_0$ requires $VB^\top$ to be symmetric and $B$ to be invertible (without symmetry, tokens might swirl inside $E$ without settling). Note, however, that their finite-to-zero temperature stability bound holds without symmetry.
- Strict positivity: The initial distribution must have a strictly positive density everywhere on the sphere (though the authors note adding diffusion/noise to the transformer could remove this requirement).
- Proving Conjecture 1: Rigorously proving the late-stage terminal drift toward the eigenspaces of $V$—and exploring its links to classical Oja flows—remains an open mathematical frontier.
Summary updated