The emergence of clusters in self-attention dynamics

Borjan Geshkovski, Cyril Letrouit, Yury Polyanskiy, P. Rigollet
2/12/2026

No official code found. Best implementation: borjanG/2023-transformers (18 stars, last commit 2023-12-18).

Abstract

Viewing Transformers as interacting particle systems, we describe the geometry of learned representations when the weights are not time dependent. We show that particles, representing tokens, tend to cluster toward particular limiting objects as time tends to infinity. Cluster locations are determined by the initial tokens, confirming context-awareness of representations learned by Transformers. Using techniques from dynamical systems and partial differential equations, we show that the type of limiting object that emerges depends on the spectrum of the value matrix. Additionally, in the one-dimensional case we prove that the self-attention matrix converges to a low-rank Boolean matrix. The combination of these results mathematically confirms the empirical observation made by Vaswani et al. [VSP'17] that leaders appear in a sequence of tokens when processed by Transformers.

View on arXivView PDF

Code Implementations(1)

Codes for the paper The emergence of clusters in self-attention dynamics.

183Python, Jupyter NotebookMay 9, 20232 years ago

Similar Papers

Cite this paper

@article{geshkovski2026emergence,
  title  = {The emergence of clusters in self-attention dynamics},
  author = {Borjan Geshkovski and Cyril Letrouit and Yury Polyanskiy and P. Rigollet},
  year   = {2026},
  eprint = {2305.05465},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/pdf/2305.05465},
  journal = {NEURIPS 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2305.05465.svg)](https://codeofpaper.com/paper/2305.05465)

Discussion