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 framework to explain why tokens in deep Transformers form intermediate clusters before eventually collapsing into a single group. By modeling token evolution as a "mean-field" flow, the authors prove that the number of these meta-stable clusters is a predictable function of the model's temperature and embedding dimension, persisting for a duration that grows logarithmically with the number of tokens.

What Problem Does This Paper Address?

Despite the massive success of Transformer architectures, our theoretical understanding of how they represent data remains in its "embryonic stage." One striking phenomenon observed in these models is clustering: as tokens pass through successive layers, they tend to group together, which is thought to be how the model develops "concepts" or reaches a consensus for next-token prediction.

Previous research suggested that in an infinitely deep Transformer, all tokens would eventually collapse into a single point. However, real-world models have finite depth and, in practice, we see tokens form multiple distinct clusters that persist for many layers. This paper tackles the "why" and "how" of these intermediate, meta-stable clustering phases, providing a mathematical description of their structure and lifespan.

Methods

The authors build on a simplified model where token evolution is treated as a continuous-time flow on a unit sphere. They interpret the tokens as $N$ interacting particles governed by a mean-field Partial Differential Equation (PDE), specifically a Wasserstein gradient flow.

To analyze the emergence of clusters, they decompose the dynamics into three distinct stages:

  1. Linear Phase: Starting from a uniform distribution, tiny random fluctuations begin to coalesce around a "dominant mode."
  2. Quasi-linear Phase: This dominant pattern grows until it reaches a macroscopic scale, forming a structured manifold.
  3. Clustering Phase: The system settles into a meta-stable state with a specific number of clusters before the eventual total collapse.

A key technical tool used is the perturbative analysis of the PDE around uniform initialization. They identify the structure of the emerging clusters using Gegenbauer polynomials, showing that the specific "mode" (or number of clusters) that wins out is the one that maximizes a specific rescaling of these polynomials.

Schematic representation of the three-phase decomposition of token dynamics.

Datasets

The paper does not use real-world datasets. Instead, it relies on synthetic numerical simulations to validate the theoretical proofs. These simulations involve tracking the trajectories of up to $10^4$ particles on a circle ($S^1$) or sphere ($S^{d-1}$) to observe clustering behavior under different hyperparameter settings.

Key Insights and Ideas

  • Predictable Cluster Counts: The number of clusters formed is not random. It is explicitly determined by the inverse temperature parameter ($\beta$) and the embedding dimension ($d$). For a 2D embedding, the number of clusters is approximately $\sqrt{\beta}$ as the temperature drops.
  • Logarithmic Persistence: The authors prove that these intermediate clustering phases are "meta-stable," meaning they last for a time interval of $O(\ln N)$, where $N$ is the number of tokens. This explains why these representations are visible and useful in practical, finite-depth models.
  • Symmetry Breaking: The system starts in a uniform, unstable equilibrium. The "richness" of the resulting representation (how many clusters form) depends on which geometric symmetries are broken first during the linear phase.
  • Mean-Field Limit: The paper rigorously proves that as the number of tokens $N$ becomes very large, the discrete particle system behaves exactly like the continuous mean-field PDE, providing a solid theoretical foundation for studying large-context models.

Key Results

  • Mathematical Proofs: The authors provide rigorous proofs for the convergence of the $N$-particle system to the mean-field limit and characterize the lifespan of the meta-stable phase.
  • Numerical Confirmation: Simulations perfectly match the theoretical predictions. For example, setting $\beta=5$ resulted in 3 clusters, while $\beta=7$ resulted in 4 clusters, exactly as predicted by the Gegenbauer polynomial analysis.
  • Exit Time Scaling: They confirmed the $O(\ln N)$ scaling of the "exit time" (the time it takes to leave the uniform state and form clusters), showing a clear logarithmic dependence on the number of tokens.

Limitations and Future Work

The authors acknowledge several major simplifications:

  • Model Architecture: The model omits Multi-Layer Perceptron (MLP) layers and assumes simplified weight matrices ($Q=K=V=Id$). Real Transformers are significantly more complex, and MLP layers likely have a dramatic impact on the "dynamical landscape."
  • Assumption 3: The proof for the final clustering structure relies on a specific assumption about convergence to delta measures which, while numerically supported, remains a conjecture for the general case.
  • Future Directions: The authors suggest investigating the effects of adding noise (simulating random initialization) and extending the analysis to include MLP layers and non-trivial weight matrices to bridge the gap between this theoretical model and production-grade Transformers like GPT-4 or Gemini.

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