Leaner Transformers Can Easily Learn to Cluster
Recent work shows that transformers can exactly perform Lloyd's algorithm for $k$-means clustering with $n$ points in $d$ dimensions with an embedding size $d{\textsf{emb}} = d+k$ (thus, requiring attention projection matrices of size $(d+k)^2$).
ProofPaper ↗
Key points
- Transformers have in-context learning capabilities, where some known learning algorithms can be executed in the forward pass through the model.
- In this work, we build upon this result in the following ways: First, we present an equally expressive but smaller transformer that executes Lloyd's algorithm with embedding size $d{\textsf{emb}} = (d + \lceil \log2 k \rceil)$.
- Next, we train these transformers to learn the clustering algorithms given a distribution of clustering tasks, and theoretically characterize and empirically validate the factors affecting the convergence and in-distribution generalization of learning algorithms based on stochastic gradients.
- Finally, we probe the general clustering abilities of these learned algorithms (in the form of transformers), and try to understand situations where they succeed and fail.
Sources (1)
- [1]Leaner Transformers Can Easily Learn to ClusterarXiv (AI, ML, NLP, CV, robotics, multi-agent) · Oct 7, 09:46 AM
Recent work shows that transformers can exactly perform Lloyd's algorithm for $k$-means clustering with $n$ points in $d$ dimensions with an embedding size $d_{\textsf{emb}} = d+k$ (thus, requiring attention projection matrices of size $(d+k)^2$).
Transformers have in-context learning capabilities, where some known learning algorithms can be executed in the forward pass through the model.
Extractive summary: sentences quoted from the sources.
Before this
- Oct 7, 2026Iris-3B: Going Beyond the Latent with Pixel-Space Diffusion Training, Conversion and Fine-Tuning
- Oct 6, 2026Spatial Induction Heads: In-Context Learning of Multidimensional Cellular Automata
- Oct 6, 2026EmbeddingGemma 2: an open, lightweight multimodal embedding model
- Oct 6, 2026Continuous Memory Machines
- Oct 6, 2026Adversarially Trained Linear Transformers Are Optimal Robust In-Context Learners for Gaussian Mixtures
- Oct 5, 2026LiquidAI/d1-omni-600M