Training-Induced Escape from Token Clustering in a Mean-Field Formulation of Transformers

Noboru Isobe, Daisuke Inoue, Masaaki Imaizumi

TL;DR

Mathematicians have recently shown that if you stack enough Transformer layers together, self-attention acts like gravity—pulling all token representations into tight, indistinct clusters. So how do trained Transformers actually get anything useful done? By bringing training into this physics-inspired picture, the authors prove that optimization teaches the network's feedforward layers to stage a last-minute "escape," letting tokens coast in a clustered state through the middle layers before breaking out right at the end to solve the task.

What Problem Does This Paper Address?

When a Transformer processes a prompt, it nudges token representations step-by-step across layers. If you zoom out and view thousands of tokens as a continuous cloud of probability on a sphere—a "mean-field" formulation—layer-by-layer inference looks just like fluid dynamics or particles moving through time.

Prior mathematical analyses of these dynamics found a striking phenomenon: self-attention naturally minimizes an interaction energy, which inevitably drives tokens to clump together into clusters as depth increases. That’s a problem, because if all your tokens collapse into the same representation, your model loses the nuance needed to predict diverse outputs. However, those prior theories treated the Transformer’s weights as fixed or random. They left out the most important part of deep learning: training. How does optimizing a loss function reshape the internal, layer-by-layer journey of tokens?

Methods

The authors model a deep Transformer in continuous depth (think Neural ODEs) where tokens live on a unit sphere. They use a standard theoretical setup called symmetric unnormalized self-attention (fixed across layers) paired with injected Brownian noise, turning token evolution into a non-local Fokker–Planck equation.

What’s new is how they introduce learning: each layer contains a parameter-linear feedforward network (FFN) whose weights are optimized to minimize a terminal loss function plus $L^2$ regularization (weight decay). This reframes Transformer training as a mean-field optimal control problem. Because tracking the entire trajectory of gradient descent is mathematically brutal, the authors cleverly analyze the two tractable endpoints of training:

  1. A single step of gradient descent, analyzed using the continuous-time adjoint method (backpropagation).
  2. Global minimizers of the training objective, analyzed by proving a double-well landscape and a local Polyak–Łojasiewicz (PL) inequality for the attention energy.

Datasets

Not discussed in the paper. Because this is a foundational theoretical study, the authors validate their math using controlled numerical particle simulations ($N = 64$ particles on a 2D circle) with synthetic target objectives—specifically, a directional alignment loss and a synthetic Bag-of-Words loss—rather than standard NLP benchmarks.

Key Insights and Ideas

Overview of the three-phase dynamics across Transformer layers: Clustering, Turnpiking, and Escaping. (Note: Let's look at the overarching trajectory in Figure 1 below.)

Figure 1: Overview of our results. The y-axis is an informal distance from the token distribution to a clustered state; in the analysis, the corresponding proxy is ∆ε,A in Section 3. Training can induce a phase of escaping from the clustered regime. The convergence rate from Phases 1 to 2 and the escape rate from Phases 2 to 3 are approximately given in Remark 3.10 and Proposition 3.5, respectively.
  • The Three-Phase Depth Profile: Training splits inference across deep layers into three distinct acts:
  • Initial Clustering: Early on, attention dominates, pulling tokens into a low-energy cluster. The FFN stays quiet to save on $L^2$ weight decay costs.
  • The Turnpike Plateau: Borrowed from optimal control theory, a "turnpike" means the cheapest way to travel a long distance is to merge onto a highway, cruise, and exit at the very end. Through the vast majority of interior layers, the token distribution simply camps out near the clustered state, expending almost zero FFN control effort.
  • Terminal Escape: In the final layers, the trained FFN suddenly steps on the gas, overpowering attention to push tokens out of the cluster toward representations that lower the task loss.
  • One Step of GD is Enough to Spark Escape: You don't need full convergence to see Phase 3. Because backpropagated gradients solved via the backward diffusion equation decay exponentially as they travel backward from the output, they are naturally amplified near the final layers—causing a terminal escape after just a single gradient update.
  • Echoes of Real LLMs: While purely theoretical, this mathematical structure rhymes uncanny well with empirical mysteries in full-scale LLMs—such as why pruning massive blocks of middle layers barely hurts performance, and why multilingual models abruptly shift into the target language only in their final layers.
Figure 3: Energy-landscape view of terminal es- cape.

Key Results

  • Double-Well Landscape (Proposition 3.2): Under a positive-definite attention matrix with a simple top eigenvalue ($\lambda_1 > \lambda_2$), the entropy-regularized attention energy has exactly two global minimizers (antipodal clusters), separated from other critical points by an explicit energy gap.
  • Exponential Turnpike Bound (Theorem 3.9): For sufficiently deep networks ($T > T^*$), optimal token trajectories stay exponentially close to a clustered state, bounded by $C(e^{-at} + e^{-a(T-t)})$. The boundary layers at the input and output have a constant width independent of total depth $T$.
  • Spectral & Geometric Control: In particle simulations ($N=64, T=80$), increasing the spectral gap of the attention matrix (making $\lambda_2$ smaller relative to $\lambda_1=1$) creates a deeper plateau and a sharper terminal escape. Across 20-seed robustness sweeps ($T \in \{40, 80, 120\}$), the plateau reliably stretches with $T$, and the three-phase profile holds even when noise is turned completely off ($\varepsilon = 0$).

Limitations and Future Work

The authors are admirably upfront about the boundaries of their toy model:

  • Architectural Simplifications: Attention weights are symmetric, unnormalized, shared across layers, and frozen—only the parameter-linear FFN is trained. Extending this to trainable, multi-head softmax attention is an open frontier.
  • Two-Well Regime & Biased Starts: The main turnpike theorem assumes the initial token distribution already has some bias (excluding near-uniform starts) and operates in a clean two-well landscape without complex metastable traps.
  • The $\varepsilon = 0$ Gap & Real Models: Noise ($\varepsilon > 0$) is mathematically required for smooth PDE solutions in the proofs, leaving the deterministic $\varepsilon = 0$ case theoretically open (though confirmed numerically). Finally, verifying whether this exact optimal-control mechanism drives layerwise behavior in pretrained, billion-parameter Transformers remains future work.

Summary updated

Abstract

Transformers perform inference by iteratively transforming token representations across layers. This layerwise computation has been studied empirically, and recent mean-field theories of Transformer dynamics explain how attention can drive token distributions toward clustering. However, existing analyses treat model parameters as prescribed, leaving open how training reshapes this clustering picture. We study this question in a noisy mean-field Transformer in which only a parameter-linear FFN is trained under $L^2$ regularization. We identify a training-induced phase of the inference dynamics across layers: after clustering in the early layers, the token distribution can leave the clustered regime near the final layers. A single gradient-descent update already produces this escape, and minimizers of the training objective satisfy an exponential turnpike bound under which clustering persists through the interior layers. Our analysis is based on an entropy-regularized interaction energy that captures the clustering bias of attention, for which we establish a double-well landscape and a local Polyak–Łojasiewicz inequality. More broadly, our results point toward a training-aware mean-field theory in which training and inference dynamics of Transformers are treated together.
BibTeX
@inproceedings{isobe2026training,
  author = {Noboru Isobe and Daisuke Inoue and Masaaki Imaizumi},
  title = {{Training-Induced Escape from Token Clustering in a Mean-Field Formulation of Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=IcdBtJcDy7},
}
Figure