Leaner transformers can easily learn to cluster
Charlotte Park, Kenneth L. Clarkson, Lior Horesh, Takuya Ito, Parikshit Ram
NeurIPS 2026
TL;DR. We show that a small transformer can be easily trained to execute $k$-means clustering, and precisely characterize factors affecting the learning convergence and algorithmic generalization.
Abstract. Transformers have in-context learning capabilities, where some known learning algorithms can be executed in the forward pass through the model. Recent work show that transformers can exactly perform Lloyd's algorithm for -means clustering with points in dimensions with an embedding size (thus, requiring attention projection matrices of size ). 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 . 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 stochastic gradients based learning algorithms. 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.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:46 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
The paper makes a conceptually interesting contribution to the literature on algorithms that can be implemented by transformers by showing that a leaner transformer than prior art can implement Lloyd's algorithm for K-means clustering.
The main concerns of the reviewers which should be addressed in the rebuttal are in terms of substantiating the extent to which the stated contributions are supported by the empirical and theoretical results — which currently it appears to do only to a limited extent.
Concretely it would be helpful if the rebuttal could:
-
Substantiate the central claim of having learned a clustering algorithm. Reviewers zXnc and ygcx question whether the claims of outperforming Lloyd's algorithm, and of having learned a full clustering algorithm rather than a strong single-step refinement, can be squared with the divergence under naive iteration (zXnc-W4, ygcx-Q4, ygcx-Q5). The rebuttal should either add an initialization-style baseline (ygcx-Q4) or argue directly why the re-embedded iteration should be read as more than repeated initialization.
-
Identify the regime where the leaner architecture is a net win end-to-end. All three reviewers observe, from different angles, that the parameter savings of the BN embedding arise precisely where the paper's own theory and ablations indicate its optimization deteriorates (pqBh-W2, zXnc-W2, ygcx-Q1). The rebuttal should identify a concrete (d, k) regime where BN is preferable when accounting for total training cost, or explain the significance of the contribution in light of these limitations.
-
Clearly scope what the theory certifies. Reviewers pqBh and ygcx note that the learnability analysis does not cover the recommended configuration (pqBh-W1, ygcx-Q2, ygcx-Q3). The rebuttal should state precisely which claims the theory supports (directional effects) versus which remain heuristic, so that the reader leaves with a more precise characterization of the algorithmic implications of the theory, or argue why the departures from theory should not detract from the significance of the results.
Moreover, the rebuttal should address some of the other questions raised by the thorough reviews to the extent possible in the rebuttal process.
Final justification
I read the rebuttal and the reviews and the discussion exchanges. pqBH raised from borderline reject to borderline accept (weakness 2 resolved by the rebuttal, the rest reclassified as limitations), zXnc held at reject (synthetic data; unconvinced on the Lloyd's baseline and the practical motivation), and ygcx held at borderline reject (gains only at large k; single-step Lloyd's as an unfair baseline).
The authors addressed the three concerns raised in the initial meta-review with thorough responses. 1) On whether an algorithm was actually learned: the fact that the points are embedded again at each step has invited criticism that the model is not approximating a full algorithm but only a single step, but it is worth noting that the sufficient statistic for the clustering (the cluster centers) is passed on from one step to the other. It is the cluster assignments that are lost from one step to the next, but those can be recovered given the cluster centers. Notably, Fig 6 shows a comparison across multiple steps running Lloyd's algorithm as a baseline (to convergence) against the proposed re-embedding machinery — which, while it is not elegant, does not mean that an algorithm has not been learnt. 2) On the practical gain from the leaner architecture: the new A100 measurements show up to 8.4x total runtime and 54.7% memory reduction at k=1000, d=32, alongside a candid concession that total training time to convergence cannot be claimed — the contribution is the characterization of this tradeoff, which I find is a fair framing. 3) On the scope of the theory: the Lipschitz analysis is where the real theoretical work of the paper lies — it is what makes the OH vs BN tradeoff derivable rather than just observed. The theory predicts, ahead of the experiments, that BN pays for its parameter savings in slower convergence and that this gap should close as d grows, and both parts play out in the experiments (Figs 2, 3, 14, 15). The generalization bound, on the other hand, is imported from the SGD stability literature under assumptions the actual training pipeline does not satisfy and is never tested on its own terms; the authors are upfront about this and it remains a limitation rather than a flaw.
My recommendation departs from the raw scores, so I will set out the grounds. The sustained objections rest on characterizations that are inconsistent with the record. The claim that the paper only compares against a single Lloyd's iteration is contradicted by the converged multi-step comparisons in Figs 6–8 and 17, which the responses quantify and which the final justifications do not engage. The characterization of single-step Lloyd's as "almost equivalent to random assignment" is not correct — initial centers are sampled from the data (Appendix D), the converged centers from one step are used in the next step for both Lloyd's as well as the proposed approach (rather than random or new datapoints at every step), and a single iteration is a full assign-and-recenter step; it serves as the natural single-step control against a single forward pass of the model. The claim that the benefits require large k is accurate, but the justification does not engage the response to pqBH-W2, which identifies standard application regimes where k ≫ d holds (vector quantization, similarity-search indexing). The concern that does survive is synthetic-data scope, which is real, acknowledged in the limitations, and standard for capability studies in this literature; to my mind it does not disqualify a paper of this type.
For the camera-ready I expect the authors to fold in the single-step/multi-step exposition and the ablation reading of Fig 6 from the rebuttal [ygcx], include the wall-clock and memory results with the explicit statement that total training-time superiority is not claimed [pqBH], and add the finite-γ approximation discussion and the gradient-clipping account of Fig 15d from the responses [ygcx].
Decision: Accept
Read meta-review
Meta-review
The paper makes a conceptually interesting contribution to the literature on algorithms that can be implemented by transformers by showing that a leaner transformer than prior art can implement Lloyd's algorithm for K-means clustering.
The main concerns of the reviewers which should be addressed in the rebuttal are in terms of substantiating the extent to which the stated contributions are supported by the empirical and theoretical results — which currently it appears to do only to a limited extent.
Concretely it would be helpful if the rebuttal could:
-
Substantiate the central claim of having learned a clustering algorithm. Reviewers zXnc and ygcx question whether the claims of outperforming Lloyd's algorithm, and of having learned a full clustering algorithm rather than a strong single-step refinement, can be squared with the divergence under naive iteration (zXnc-W4, ygcx-Q4, ygcx-Q5). The rebuttal should either add an initialization-style baseline (ygcx-Q4) or argue directly why the re-embedded iteration should be read as more than repeated initialization.
-
Identify the regime where the leaner architecture is a net win end-to-end. All three reviewers observe, from different angles, that the parameter savings of the BN embedding arise precisely where the paper's own theory and ablations indicate its optimization deteriorates (pqBh-W2, zXnc-W2, ygcx-Q1). The rebuttal should identify a concrete (d, k) regime where BN is preferable when accounting for total training cost, or explain the significance of the contribution in light of these limitations.
-
Clearly scope what the theory certifies. Reviewers pqBh and ygcx note that the learnability analysis does not cover the recommended configuration (pqBh-W1, ygcx-Q2, ygcx-Q3). The rebuttal should state precisely which claims the theory supports (directional effects) versus which remain heuristic, so that the reader leaves with a more precise characterization of the algorithmic implications of the theory, or argue why the departures from theory should not detract from the significance of the results.
Moreover, the rebuttal should address some of the other questions raised by the thorough reviews to the extent possible in the rebuttal process.
Final justification
I read the rebuttal and the reviews and the discussion exchanges. pqBH raised from borderline reject to borderline accept (weakness 2 resolved by the rebuttal, the rest reclassified as limitations), zXnc held at reject (synthetic data; unconvinced on the Lloyd's baseline and the practical motivation), and ygcx held at borderline reject (gains only at large k; single-step Lloyd's as an unfair baseline).
The authors addressed the three concerns raised in the initial meta-review with thorough responses. 1) On whether an algorithm was actually learned: the fact that the points are embedded again at each step has invited criticism that the model is not approximating a full algorithm but only a single step, but it is worth noting that the sufficient statistic for the clustering (the cluster centers) is passed on from one step to the other. It is the cluster assignments that are lost from one step to the next, but those can be recovered given the cluster centers. Notably, Fig 6 shows a comparison across multiple steps running Lloyd's algorithm as a baseline (to convergence) against the proposed re-embedding machinery — which, while it is not elegant, does not mean that an algorithm has not been learnt. 2) On the practical gain from the leaner architecture: the new A100 measurements show up to 8.4x total runtime and 54.7% memory reduction at k=1000, d=32, alongside a candid concession that total training time to convergence cannot be claimed — the contribution is the characterization of this tradeoff, which I find is a fair framing. 3) On the scope of the theory: the Lipschitz analysis is where the real theoretical work of the paper lies — it is what makes the OH vs BN tradeoff derivable rather than just observed. The theory predicts, ahead of the experiments, that BN pays for its parameter savings in slower convergence and that this gap should close as d grows, and both parts play out in the experiments (Figs 2, 3, 14, 15). The generalization bound, on the other hand, is imported from the SGD stability literature under assumptions the actual training pipeline does not satisfy and is never tested on its own terms; the authors are upfront about this and it remains a limitation rather than a flaw.
My recommendation departs from the raw scores, so I will set out the grounds. The sustained objections rest on characterizations that are inconsistent with the record. The claim that the paper only compares against a single Lloyd's iteration is contradicted by the converged multi-step comparisons in Figs 6–8 and 17, which the responses quantify and which the final justifications do not engage. The characterization of single-step Lloyd's as "almost equivalent to random assignment" is not correct — initial centers are sampled from the data (Appendix D), the converged centers from one step are used in the next step for both Lloyd's as well as the proposed approach (rather than random or new datapoints at every step), and a single iteration is a full assign-and-recenter step; it serves as the natural single-step control against a single forward pass of the model. The claim that the benefits require large k is accurate, but the justification does not engage the response to pqBH-W2, which identifies standard application regimes where k ≫ d holds (vector quantization, similarity-search indexing). The concern that does survive is synthetic-data scope, which is real, acknowledged in the limitations, and standard for capability studies in this literature; to my mind it does not disqualify a paper of this type.
For the camera-ready I expect the authors to fold in the single-step/multi-step exposition and the ablation reading of Fig 6 from the rebuttal [ygcx], include the wall-clock and memory results with the explicit statement that total training-time superiority is not claimed [pqBH], and add the finite-γ approximation discussion and the gradient-clipping account of Fig 15d from the responses [ygcx].
Decision: Accept
- Rating
- 3/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes a compact Transformer architecture with an embedding dimension of capable of precisely executing the Lloyd -means clustering algorithm, reducing the parameter count by up to 75% compared to existing $ d+k$-dimensional constructions. It systematically investigates the convergence and generalization of learning this algorithm end-to-end via a smoothed regularization objective, theoretically characterizing how the embedding scheme, regularization penalty, and attention temperature influence optimization difficulty. Experimental results validate the model's multi-step iterative performance and cross-distribution generalization capabilities, though a fundamental failure is observed on heavy-tailed Cauchy distributions.
Strengths and weaknesses
Strengths:
-
The embedding dimension is reduced from to , resulting in fewer parameters and faster inference.
-
The theory fully characterizes the relationship between the Lipschitz constant and factors such as the embedding scheme, regularization, and attention temperature; experimental results align with theoretical predictions.
-
It was discovered that re-embedding at each step enables a single-step trained model to achieve multi-step optimization, offering high practical utility.
Weaknesses:
-
The model is tied to specific values and cannot generalize to different dimensions or numbers of clusters, resulting in poor flexibility.
-
It fails completely with the Cauchy distribution; the gap in the smoothness upper bound is excessive, rendering it unsuitable for heavy-tailed scenarios. It may only be appropriate for simple distributions and entirely inapplicable to complex ones.
-
While the theory requires , practical implementation uses a finite softmax; furthermore, the Lipschitz bound depends exponentially on temperature, leading to gradient explosion when is large.
Questions
-
The core contribution of the paper is reducing the embedding dimension from to . However, this improvement offers significant advantages only when is large; in practice, clusters are often not that large. If is small (e.g., or ), does this improvement offer any other benefits? When is small and is large, the convergence speed of BN is significantly slower than that of OH, consistent with theoretical predictions, yet the paper offers no solution to improve optimization while maintaining parameter efficiency. In other words, the paper trades convergence speed for parameter efficiency, and the cost of this trade-off is theoretically exponential. For practical applications, this implies that a smaller model might require exponentially more training steps to achieve the same performance, potentially negating the computational gains derived from the reduction in parameters.
-
The construction in Theorem 1 requires an inverse temperature of (i.e., hardmax/argmax attention), whereas actual training employs standard softmax with a finite temperature . The construction theoretically proven to execute Lloyd's algorithm exactly serves only as an approximation in practice. The paper states on page 6, "we use standard softmax attention for our learnability analysis and experiments"; what is the magnitude of the error bound introduced by this approximation?
-
The Lipschitz constant derived in Theorem 2 (and Theorem 5 in Appendix I) includes an exponential term. When is even moderately large, the Lipschitz constant explodes, leading to gradient instability. Is this consistent with the phenomenon observed in Figure 15d, where OH experiences a gradient explosion at ? Is there a solution to this problem?
-
The paper trains a "single-step clustering" model but attempts multi-step iteration during evaluation. A key finding is that directly applying iterative attention updates leads to divergence (Figure 6, left), whereas only "re-embedding" at each step works (Figure 6, right). This effectively suggests that the learned models did not truly capture the iterative structure of Lloyd's algorithm; instead, the performance gains observed over multiple steps stem primarily from the "re-embedding" engineering trick rather than the model actually learning iterative optimization. This contradicts the implication of the paper's title, "Leaner transformers can easily learn to cluster"; what the models actually learned resembles a "high-quality single-step initialization" rather than the full clustering algorithm. If the model merely learned a good initialization, then the baselines used for comparison are inappropriate, and the experimental setup should have included various initialization methods.
-
The paper frequently compares the learned models against "single-step Lloyd" . However, Lloyd's algorithm typically requires multiple iterations to converge, making single-step Lloyd an inherently weak baseline. Although the paper presents a multi-step comparison in Figure 6, its primary conclusions still rely on this weak baseline.
Limitations
yes
Final justification
The improvements proposed in this paper only yield benefits when is very large, but in real-world datasets, $ k$ is often not particularly large, thus reducing the paper's contribution. Furthermore, comparing the methods, such as with a single-step Lloyd's algorithm, is unfair; after reading the authors' responses, it seems more like an experiment and comparison designed specifically for the proposed method. A single-step Lloyd's algorithm is almost equivalent to random assignment, which is impractical in practice. Other reviewers have also raised similar questions. The authors' responses do not address the concern of why a worse baseline (one iteration) was deliberately used.
Formatting concerns
NA
3 comments
Thanks for the author's reply. Some of my concerns, such as questions 2 and 3, have been addressed. However, other issues, such as the substantial gains brought about by the contributions of this paper and the comparison with single-step algorithms, have not been adequately resolved. These issues make the actual benefits of the contribution in this paper less convincing. Therefore, I tend to maintain my score.
We thank the reviewer for their comment, and are glad to hear that questions 2 and 3 are addressed.
Regarding our contributions, we claim that a leaner transformer, reducing parameters to parameters, can express and learn to cluster. We show this both theoretically (Theorem 1) and empirically (Figure 6 (right) 7, 8, 12) with significant gains over existing Lloyd's -means clustering algorithm as we describe in our response to [zXnc-W4]. Beyond these, one of our contributions is also characterizing the tradeoff introduced by this smaller transformer (Theorem 2) showing how the smaller transformer can have slower training convergence, which we also verify empirically (Figure 2 and Appendix F).
In terms of "comparison to single-step algorithms", we would really like to understand what is missing at a technical level. In our response to [ygcx-Q4], we lay out how we use single-step clustering to train these models, but evaluate them for multi-step clustering by applying the model iteratively as many standard clustering algorithms. This demonstrates that we can train these models quite efficiently, and still gain strong performance -- up to 22% improvement in -means objective in multi-step clustering as described in our response to [zXnc-W4]. We had also requested a clarification regarding what the reviewer is referring to as "single-step initialization" in our response to [ygcx-Q4]. We would really appreciate some clarifications to better understand what can be improved at a technical level.
- Rating
- 2/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 2/4
- Significance
- 2/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes a leaner transformer architecture that executes Lloyd's algorithm with embedding dimension ( in prior work), analyzes factors affecting learnability of clustering from data, and presents empirical results on synthetic clustering tasks. While the theoretical derivations appear technically sound, the paper suffers from fundamental motivation issues: the practical value of the approach is unclear, the claimed parameter reduction is misleading for realistic use cases, and experiments are confined to synthetic data without any demonstration of real-world applicability.
Strengths and weaknesses
Strengths:
-
The binary embedding scheme provides an elegant and nontrivial reduction of the prior one-hot construction.
-
The theoretical analysis appears technically sound.
-
The paper offers extensive ablations across hyperparameters, systematically validated on synthetic clustering tasks.
Weaknesses:
-
It is unclear why one should use a transformer to learn clustering in the first place. Classical algorithms like Lloyd's are simple, fast, universally applicable across (d, k, n), and require no training. The paper does not articulate a concrete scenario where a learned transformer would be preferable---whether in terms of speed, accuracy, data efficiency, or any other practical metric.
-
The claimed "up to 75% parameter reduction" is misleading for most real-world settings, where often k < d and k is likely in the hundreds or thousands. In such cases, the reduction is relatively minor. The paper offers no guidance on when this reduction actually matters for real applications.
-
All experiments are confined to synthetic data generated from simple distributions in low dimensions. No evaluation is performed on any real-world clustering benchmark. It remains unknown whether the learned models would work on data with realistic structure or noise.
-
The claim that the learned models "outperform Lloyd's" is not properly contextualized. The comparison is against a single Lloyd's iteration, not the converged algorithm. This is a weak baseline and the phrasing is likely to mislead readers into interpreting a stronger result than what is actually demonstrated.
Questions
-
Can you articulate a concrete application scenario where a learned transformer would be preferred over running standard Lloyd's algorithm?
-
Could you discuss the advantages of the presented leaner transformers when considering practical clustering tasks?
Limitations
N/A
Final justification
The authors have partially addressed my concerns regarding W1 and W2. However, I am not fully convinced by their responses to W3 and W4, and Q1 and Q2. Therefore, I will keep my original score, but reduce my level of confidence from 4 to 3.
Formatting concerns
N/A
1 comment
Rebuttal
[zXnc-W1/Q1] why transformers for clustering?
Our work is part of the line of research focused on understanding what algorithms transformers can express in-context, and if these transformers can learn such algorithmic behaviour and generalize to new unseen tasks within that problem domain [A, B]. Recent results indicate that transformers can express clustering algorithms with a specific architecture [C], and we study whether clustering mechanisms can be expressed and learned within a smaller (leaner) transformer architecture. Thus, our goal is to understand transformer capabilities rather than claim that a trained transformer can universally replace general algorithms, just as studying in-context learning for linear regression does not suggest transformers should replace linear solvers.
Within this framing, we study the scenario where a set of clustering tasks is available for training, and our results indicate that the trained transformers can significantly outperform Lloyd's algorithm if the downstream clustering tasks align with the task distribution used for training. This finding corroborates existing literature [B] that have shown, for example, that the trained transformer outperforms gradient descent for linear regression (for unseen linear regression tasks coming from a distribution of tasks used for training the model).
- [A] Li et al. "Transformers as algorithms: Generalization and stability in in-context learning". ICML 2023.
- [B] von Oswald et al. "Transformers learn in-context by gradient descent". ICML 2023.
- [C] Clarkson et al. "Finding clustering algorithms in the transformer architecture" Arxiv 2025.
[zXnc-W2/Q2] Claimed gain from leaner transformer not clear [AC-2]
Please see our response to [pqBH-W2] for Reviewer pqBH.
[zXnc-W3] Synthetic data experiments
Our empirical analyses focuses on synthetic data as this is standard in the in-context-learning literature, and the goal here is not to see if the learned models can generally replace the general algorithms (such as gradient descent) they are emulating, but rather to understand conditions when the models can learn something meaningful and also generalize to new tasks. Synthetic data allows us to control the training and evaluation task distributions, studying the effect of distribution mismatches (as we study in Fig 7, 8 and 12).
[zXnc-W4] Outperforming Lloyd's not contextualized [AC-1]
First we would like to note that the training (Alg 1) is with single-step clustering to make the training procedure efficient. Hence, we compare the single-step clustering performance of the trained model to a single Lloyd's iteration in Fig 2 and Fig 5 to understand in-distribution generalization (generalization on tasks used for training). However, we also thoroughly compare multi-step clustering with the trained models to general multi-iteration Lloyd's (Alg 2) in Figures 6, 7, 8, 12. Please refer to our response for [ygcx-Q4] (Reviewer ygcx) to further understand single-step and multi-step clustering with the models, and our ablation of the token embedding with an alternate multi-step clustering (Fig 6 left vs right).
Our multi-step clustering results indicate that the trained transformers outperform Lloyd's on new (unseen during training) clustering tasks by a significant margin -- the average converged log -means objective of 5.25 for Lloyd's vs 5 for the trained models in Fig 6 (right) or a 22% average improvement in the average -means objective. A caveat is that this comparison is on clustering tasks generated from the task distributions (Appendix D) on which the transformers were trained on. We also explored tasks generated from different non-training distributions in Fig 7, 8, and 12, where trained model still outperforms Lloyd's for multi-step clustering in almost all cases, with different margins.
- Rating
- 4/6
- Confidence
- 2/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper extends Clarkson et al. [27], who showed a transformer with can exactly emulate Lloyd's algorithm for -means, by swapping the one-hot cluster encoding for a binary one, cutting the embedding to while keeping exact expressivity (Theorem 1, lines 101–105). It then trains these transformers on distributions of clustering tasks via a smoothed surrogate of the discrete objective, analyzes the convergence/generalization tradeoffs (Theorem 2, lines 187–199), and probes in- and out-of-distribution behavior (Sections 3–4).
Strengths and weaknesses
Strengths.
-
The expressivity reduction is clean and the binary-encoding construction is fully worked out (Appendix B, lines 569–612), correctly handling the
avghardmaxsubtlety in the center update (lines 596–607). The paper is honest that this modifies the prior proof rather than inventing a new one. -
The smoothing analysis is informative: it gives a principled argument that the L2-regularized min (sparsemax) yields a tighter bound than the NE-regularized min (softmax) (Proposition 1, lines 832–850), and this holds up consistently across ablations (Figures 2, 10, 15, 16).
Weaknesses.
-
The learnability theory doesn't cover the recommended method. The SGD stability results behind equations (7)–(9) assume a -smooth loss, but the advocated L2-regularized min is not -smooth, acknowledged only in the appendix (lines 540–545). The generalization bound (eq. 8) further assumes an schedule, while experiments use Adam with a constant rate (line 206). And the Lipschitz constant scales as (eq. 10, eq. 192), numerically vacuous and usable only for reading off directional effects. So the theory motivates the OH-vs-BN tradeoff but doesn't rigorously explain the central recommendation.
-
The architectural win is narrow. The "up to 75%" reduction (line 42) holds only when (footnote 1), and the leaner encoding also worsens the Lipschitz constant and slows convergence (lines 197–198; Figure 15, lines 765–777). The paper repeatedly notes the BN benefit "vanishes as grows" (lines 52, 199, 229–230), i.e. exactly where parameter savings would matter most, the distinguishing advantage disappears. A wall-clock training comparison (not just inference, Figure 1) is needed to show the savings are practically meaningful.
-
Limited scope undercuts the framing. A separate model is trained per pair (lines 144–145, 357–359), so the learned "algorithm" is far less general than the Lloyd's it beats; the zero-padding fix for (lines 510–517) is conjectural and untested. All experiments are synthetic, low-dimensional (), small- ().
Minor. Figure 3 labels both (c) and (d) as "OH" (page 6); (d) appears to be BN. Figure 9 abbreviates Earth-mover distance as "(END)". Line 648: "simple" should be "simplex."
Questions
See weaknesses. A rebuttal that resolves them or my possibly incorrect understanding would be appreaciated.
Limitations
yes
Final justification
The author rebuttal resolved well my Weakness 2, while other weaknesses remain open as limitations. I'm raising my score to 4, borderline accept.
Formatting concerns
no
1 comment
Rebuttal
[pqBH-W1] Learnability theory [AC-3]
The reviewer rightly notes that our learnability (convergence/generalization) theory focuses on -Lipschitz, -smooth losses, and is motivated by understanding the analysis of SGD (stochastic gradient descent) based learning. However, we empirically evaluate our scheme with a loss which is not smooth, and use the Adam optimizer for training.
First, our motivation behind the learnability theory is to understand the effect of the various factors in the training such as data dimensionality , number of clusters , the mechanism to smooth the discrete clustering loss (softmax vs sparsemax, temperature ), the token embedding schemes (OH vs BN), with the focus on understanding "directional effects" (discussed in lines 193-199). The exponential dependence, while unfavourable, is an artifact of the input stability of softmax [Lemma B.1 in E], though softmax usually operates quite stably in practice.
We would like to highlight that these directional effects were clearly validated empirically (with results in Figures 2-5, and Appendix F) implying that the theoretical dependencies aligned well with real learnability behaviours. We do not claim to make a "central recommendation" as the universally best configuration but rather want to understand factors that can improve or hurt performance.
As we note in our limitations, L2-regularized argmax (sparsemax) based loss function is not generally smooth. However, sparsemax is piecewise linear [A], thus differentiable almost everywhere, with a much more favourable Lipschitz constant than softmax, and is piecewise smooth [B] as it is piecewise linear. As sparsemax is defined as a Euclidean projection on the probability simplex, its gradients are usually quite stable during training and work well with standard optimizers in practice despite general non-smoothness. Thus we consider sparsemax (along with the smooth softmax) in our empirical evaluations, and see that the theoretical benefit of the tighter upperbound with sparsemax does transfer to better empirical training and generalization.
We motivated the learnability with SGD based analysis (results are known for specific learning rate schedules) for the ease of exposition as SGD is well-understood in literature. However, we used Adam (with learning rate decay on plateau) for the actual implementation as is standard in neural network training, though its analysis is much more nuanced. Close variants of Adam have been studied [C,D], and it has been shown that their convergence also depends on for -Lipschitz, -smooth losses -- the role of comes in through the requirement that the stochastic gradient norms are bounded.
- [A] Martins and Astudillo. "From Softmax to Sparsemax: A Sparse Model of Attention and Multi-Label Classification." ICML 2016.
- [B] Blondel et al. "Learning Classifiers with Fenchel-Young Losses: Generalized Entropies, Margins, and Algorithms." AISTATS 2019.
- [C] Reddi et al. "On the convergence of Adam and beyond." ICLR 2018.
- [D] Zhou et al. "On the Convergence of Adaptive Gradient Methods for Nonconvex Optimization." TMLR 2024.
- [E] Li et al. "Transformers as algorithms: Generalization and stability in in-context learning". ICML 2023.
[pqBH-W2] Architectural victory is narrow [AC-2]
We first apologize for the confusion caused by our footnote regarding . In general, the relationship between and (or the lack thereof) depends on the application of clustering. If in some application, then the "75% reduction in the number of parameters" holds. Conversely, if , then the gain would be minimal in terms of the number of parameters.
However, in many applications, could be decoupled from and instead depend on , and for large enough , can be significantly larger than ; in this case, the reduction in the number of parameters will be even higher than the case --- for , the reduction approaches 99%. Here are a couple of example applications:
- When compressing/distilling data via vector quantization, a very small compression ratio of ~0.1% implies regardless of . If and , then .
- Clustering is also often used for indexing data for similarity search (see product quantization in FAISS), where with (see ANN Benchmark), and depends on . An index of size 0.1% (which is already super conservative; usually index sizes are of the same order as the original dataset) would imply .
To motivate the gains, we presented the inference (forward pass) runtimes (Fig 1) for a single value of , with the understanding that forward passes are usually the cheapest part in a training loop, but are the only computation during inference. The gain from the leaner transformer is significant but small in Fig 1. In the following tables we present a comparison for varying values of relative to a fixed () in terms of total time (forward pass runtime Fwd and backward pass runtime Bwd) and peak memory used. These numbers are on a GPU (Nvidia A100 40GB), averaged over 200 trials with 50 trials for warmup. Note that, in transformer based architectures, the memory usage is usually dominated by the attention matrix (which is of size ):
Runtimes total(foward/backward) (in ms)
| OH Total(Fwd/Bwd) | BN Total(Fwd/Bwd) | Speedup Total(Fwd/Bwd) | |
|---|---|---|---|
| 6 | 27.9 (1.5/26.4) | 27.8 (1.5/26.3) | 1.0x (1.0x/1.0x) |
| 25 | 30.5 (1.5/29.0) | 29.0 (1.8/27.2) | 1.1x (0.8x/1.1x) |
| 100 | 46.8 (1.8/45.0) | 30.6 (1.8/28.8) | 1.5x (1.0x/1.6x) |
| 400 | 129.0 (2.0/127.0) | 39.8 (1.8/38.0) | 3.2x (1.1x/3.3x) |
| 1000 | 494.1 (2.1/492.1) | 58.6 (1.6/57.0) | 8.4x (1.3x/8.6x) |
Peak Memory (MB)
| OH | BN | Reduction | |
|---|---|---|---|
| 6 | 2668 | 2658 | 0.4% |
| 25 | 2712 | 2673 | 1.4% |
| 100 | 2917 | 2715 | 6.9% |
| 400 | 3788 | 2879 | 24.0% |
| 1000 | 7059 | 3200 | 54.7% |
The results highlight the gains from the leaner architecture both in terms of the total runtimes (where the backward pass dominates) and the peak memory, and the effect magnifies very significantly as grows relative to .
We would also like to clarify the following comment by reviewer pqBH where they say that "The paper repeatedly notes the BN benefit ”vanishes as d grows” (lines 52, 199, 229–230)". We would like to clarify that, contrary to the reviewer's comment, we claim that BN converges slower than OH for same etc (lines 52, 199, 229–230), and the margin between BN and OH vanishes as grows (as shown in Fig 2,3 and Appendix F). Note that this convergence is in terms of the total number of optimization steps; the actual cost of each step (forward pass and backward pass runtime + memory overhead) can be significantly lower with BN. This highlights a tradeoff between OH and BN -- while the gains of BN over OH is clear in terms of memory overhead (significant) and inference time (shown in Fig 1), our analysis is unable to make any claims regarding the time to convergence of BN vs OH due to the above as the precise tradeoff between BN and OH will depend on the data distribution as well as the hardware.
[pqBH-W3] Limited scope: separate model per , synthetic data.
As we explicitly listed in our limitations, we do currently need to train a model for each as the depends on . This aligns with existing literature on in-context capabilities of transformers as algorithms (gradient descent, bayesian inference, etc) where we train a model for each data dimensionality (and for each value of the number of classes for in-context supervised classification). We suggest training a model with a large , and operating on data with dimensionality via zero-padding as one viable avenue but this requires new research to understand how to train such a (large) model; note that the theoretical construction in Thm 1 will operate as expected with zero-padding as zero-padding leaves the Euclidean distances unchanged, allowing the attention updates (eq 4) to perform the required operations.
Regarding the use of synthetic data, please see our response to [zXnc-W3] for Reviewer zXnc.
Minor
We thank the reviewer for thoroughly processing our paper.
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Rebuttal
Please see our response to [pqBH-W3] for Reviewer pqBH.
We aimed to thoroughly evaluate the training procedure and thus considered multiple families of distributions (normal, log-normal, Gumbel, Cauchy, Laplace). We explicitly highlighted the failure with Cauchy, and tried to understand why it fails, thus identifying the main cause as the gap in the smoothed upper bound. We do not propose any solution to this specific failure yet, and any solution would probably require novel research in regularized argmax that can handle center-to-point pairwise distance distributions induced by mixture of Cauchy distributions.
Please see our response to [pqBH-W2] for Reviewer pqBH.
Thm 1 uses γ=∞ as the focus there is to show that the transformer architecture with BN token embeddings is able to express Lloyd's algorithm for clustering. When training the models, the goal is to learn to cluster --- that is, to explicitly minimize the k-means clustering objective. We are not training the models to exactly emulate Lloyd's algorithm; that would be a different learning objective. Thus in all our training experiments, we use γ=1/demb which is standard in transformer training.
As a separate analysis, one can study the difference (between the model output and Lloyd's algorithm) if the construction in Thm 1 uses a finite γ instead. For a set of n points in [0,1]d in d dimensions being clustered into k clusters, one can roughly bound the difference between Lloyd's center updates, and the updates via theoretical construction at finite γ with a term which is O(exp(−γΔ)(n+k)d), where Δ>0 is the smallest margin between distance to the closest center and the second closest center (and usually grows with d). Section 2.3 in Clarkson et al (2025) already empirically studies this approximation.
In Thm 2, α∼O(exp(γ)), and in all our experiments, we use the standard value in transformer training of γ=1/demb. This is in contrast to Thm 1, where we require γ→∞, but this focuses on showing that the transformer architecture (with the BN token embedding) can express Lloyd's algorithm for k-means clustering; Thm 2 is related to training convergence and generalization.
Regarding the unfavourable convergence in Fig 15d with k=25, 3/10 random trials for OH (with NE and L2 loss regularization) experience some intermediate numerical issues which throws the model off, and the training does not recover in the allotted 104 steps. We would like to note a couple of things here:
First, we want to clarify that, once training is completed, the trained models (and Lloyd's algorithm) are evaluated on new clustering tasks not seen during training (generated from different task distributions to evaluate different forms of generalization), and both the models and Lloyd's algorithm get the data X and the same initial centers C(0) as input. It is not clear to us what the reviewer refers to as "single-step initialization", and would appreciate clarification. In the following, we explain what we mean by "single-step clustering" (during training) vs "multi-step clustering".
For a clustering task with data X and initial centers C(0), T iterations of Lloyd's algorithm (Alg 2) does the following:
With a trained model Fγ(⋅,⋅;Θ) which uses token embeddings (OH/BN) and attention based updates (eq 4), we perform T iterations of "multi-step clustering" as follows:
This follows the iterative nature of Lloyd's algorithm, with Fγ(⋅,⋅;Θ) replacing the assign/update step in each iteration. This is what is evaluated in Fig 6 (right), 7, 8, 12. With "single-step clustering", we refer to the fact that, during training, this model is executed on each training clustering task for only 1 step, and the training loss is computed with C(1), the output of the one-step update. This makes the training extremely efficient as we are training a single transformer layer without any recursion. However, we see that this model learns some clustering mechanisms as we can reapply it for T iterations, and progressively improves clustering quality, much like applying the "assign/center-update" step in Lloyd's algorithm iteratively.
Fig 6 (left) is ablating the role of the token embedding in Fγ by evaluating an alternate form of "multi-step clustering" that only applies the attention updates in (4) iteratively as follows:
The result in Fig 6 (left) shows that just applying the attention updates recursively does not improve the clustering quality, and both the token embeddings (ON/BN) and the attention updates (eq 4) in the trained model Fγ(⋅,⋅;Θ) are essential for the trained transformer to successfully cluster iteratively.
We will improve our current presentation to better explain this.
Please see our response to [zXnc-W4] for Reviewer zXnc.