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

Emergence of meta-stable clustering in mean-field transformer models

Giuseppe Bruno, Federico Pasqualotto, Andrea Agazzi

TL;DR

This paper provides a rigorous mathematical explanation for why tokens in a Transformer tend to form groups or "clusters" as they pass through successive layers. By modeling tokens as particles moving on a sphere, the authors prove that before tokens collapse into a single point of total consensus, they linger in "meta-stable" states with multiple clusters. This phenomenon explains how meaningful, diverse representations emerge in finite-depth models.

What Problem Does This Paper Address?

Despite the world-altering success of Transformer architectures, our theoretical understanding of how they build representations is still in its infancy. Recent research has suggested that as tokens move through an infinitely deep Transformer, they eventually "collapse" into a single cluster, representing total consensus.

However, real-world Transformers aren't infinitely deep, and total consensus is undesirable—we want the model to recognize distinct concepts and relationships. Numerical simulations often show tokens forming several distinct clusters that persist for many layers before finally merging. This paper tackles the "meta-stability" of these intermediate phases. The authors ask: Can we mathematically prove these clusters exist, predict how many will form, and determine how long they will last?

Methods

The authors build on a "mean-field" framework, treating the discrete tokens as a continuous distribution (a "cloud" of particles) on a unit sphere. They model the evolution of this cloud using a nonlinear Partial Differential Equation (PDE), specifically a Wasserstein gradient flow.

To analyze the long-term behavior, they decompose the dynamics into three distinct phases:

  1. The Linear Phase: Where tiny random fluctuations at initialization begin to grow.
  2. The Quasi-linear Phase: Where a "dominant mode" (a specific pattern) emerges from the noise.
  3. The Collapsing Phase: Where the tokens actually form distinct, stable clusters.
Schematic of the three phases of token evolution: Linear, Quasi-linear, and Collapsing.

The mathematical heavy lifting involves perturbative analysis and Gegenbauer polynomials. By looking at the coefficients of these polynomials, the authors can identify which "frequency" of clustering will dominate based on the model's hyperparameters.

Datasets

As a theoretical math paper, this work does not use standard empirical datasets like ImageNet or GLUE. Instead, the authors validate their proofs using:

  • Synthetic Particle Simulations: Simulating the trajectories of $10^4$ particles (tokens) sampled uniformly at random on a sphere.
  • Numerical PDE Solvers: Using the Lax–Friedrichs method to solve the continuity equations and confirm that the theoretical predictions match the simulated behavior.

Key Insights and Ideas

  • The "Goldilocks" Temperature: The number of clusters that form is explicitly tied to the inverse temperature parameter ($\beta$). The authors show that the number of clusters ($k_{max}$) is determined by the index that maximizes a specific rescaling of Gegenbauer polynomials. For large $eta$, the number of clusters scales roughly as $k_{max} \approx \sqrt{\beta}$.
  • Logarithmic Persistence: The meta-stable clustering phase isn't permanent, but it lasts for a time proportional to $O(\ln N)$, where $N$ is the number of tokens (context length). This is crucial because it explains why these representations are "stable enough" to be useful in practical, finite-depth networks.
  • Symmetry as a Shield: The reason these clusters don't immediately merge is due to emerging symmetries. The system becomes "trapped" on a manifold of solutions that are invariant under specific rotations, preventing the final collapse into a single point for a significant duration.

Key Results

  • Rigorous Convergence: The authors proved that as the number of tokens $N$ goes to infinity, the discrete particle system strictly follows the behavior predicted by their mean-field PDE.
  • Predictive Accuracy: In simulations with $\beta=5$ and $\beta=7$, the math correctly predicted the emergence of exactly 3 and 4 clusters, respectively.
  • Exit Time Verification: They numerically confirmed the logarithmic relationship between the number of tokens and the time it takes for the model to exit the meta-stable phase, aligning perfectly with their theoretical $O(\ln N)$ bound.

Limitations and Future Work

While this paper provides a beautiful mathematical foundation, it relies on several simplifying assumptions:

  • Simplified Architecture: The model assumes the Query, Key, and Value matrices are identity matrices ($Q=K=V=Id$) and omits the Multi-Layer Perceptron (MLP) layers found in real Transformers.
  • Uniform Initialization: The analysis assumes tokens start as i.i.d. samples from a uniform distribution on the sphere, which may not capture the structure of real input embeddings.

Future Directions: The authors suggest that adding MLP layers will likely change the "dynamical landscape," potentially creating even more complex stable states. They also aim to investigate how non-trivial weight matrices (learned during training) interact with this clustering mechanism to create the sophisticated "concepts" we see in models like GPT-4.

Summary updated

BibTeX
@inproceedings{bruno2025emergence,
  author = {Giuseppe Bruno and Federico Pasqualotto and Andrea Agazzi},
  title = {{Emergence of meta-stable clustering in mean-field transformer models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=eBS3dQQ8GV},
}
Figure