- Rating
- 3
- Clarity
- 4
- Confidence
- 3
- Originality
- 2
- Quality
- 3
- Significance
- 3
Read review
Summary
This paper studies the expressivity and learning guarantees of a one-layer transformer with and without Chain of Thought (CoT). The authors show that a one-layer transformer fails to implement k-Nearest Neighbors (kNN) even for well-separated cases when k is odd, and show that a single-layer, transformer-only network can implement kNN with CoT. Further, they show that gradient descent applied to the population loss recovers the parameters that implement the intermediate tokens that realize kNN.
Strengths and weaknesses
Strengths.
- The paper is very well-written, and its core ideas are communicated effectively.
- It presents a clear operational view of transformers, both with and without Chain of Thought (CoT).
Weaknesses
- Need for broader comparison with prior work: The core idea, that a recursively applied transformer circuit can express iterative algorithms, is very close to recent studies such as Huang et al. (2025) [15], which explored single-step versus multi-step gradient descent. In this paper, the algorithm implements k-NN through a sequential nearest-neighbor selection procedure (Lines 171–173). Given this conceptual similarity, could you explicitly compare your work with this earlier literature to clarify your exact contributions?
- Unclear embedding construction: The embedding construction used in this setting is not fully explained and feels somewhat ad hoc. For example, why are stochastic positional encodings necessary?
- Limited scope of experiments: The simulation results focus exclusively on one-layer transformers. Further experiments are needed to determine if the proposed mechanism scales to larger models and more realistic datasets.
In light of these points, I urge the authors to expand the comparison with prior work to better isolate their conceptual contributions. Additionally, extending the experimental section to demonstrate the applicability of the presented mechanism in larger models would significantly strengthen the paper.
Questions
NA
Limitations
Yes
Paper formatting concerns
Na
Final justification
Based on our discussion, I have decided to keep my score the same. My justification is as follows:
-
From what I could follow, the proof idea and the conceptual approach (implementing iterative methods with CoT) have already been covered in earlier literature, which means that the paper's primary potential contribution should lie in the context of implementing and learning -NN.
-
Regarding the discussion on -NN, I find it difficult to believe that scaling up the model does not help in learning -NN for larger values of in practice. Therefore, it is still not obvious to me how the CoT approach implemented here will help at a larger scale. Ultimately, the discussion and the experiments need to be expanded to establish a clearer picture of how CoT improves -NN.
We sincerely appreciate your thoughtful feedback. Below, we respond to the weaknesses you identified and provide detailed answers to your questions.
W1. Comparison with Huang et al. (2025) [3]. Could you explicitly compare your work with this earlier literature to clarify your exact contributions?
A1. Thank you for pointing out this important connection. Both our work and Huang et al. [3] study how a learned single-step Transformer computation can be recursively applied to produce a multi-step algorithm. The underlying tasks and mechanisms, however, are substantially different.
Huang et al. [3] consider linear regression, for which gradient descent is already a canonical iterative algorithm. Each CoT step is trained to reproduce one gradient-descent update, and repeatedly applying the same update rule naturally yields a multi-step optimization procedure. By contrast, K-NN is conventionally formulated as a direct top-K retrieval-and-aggregation rule rather than as an iterative process. Our work identifies a non-obvious sequential realization of K-NN: at each step, the Transformer retrieves the nearest context point that has not yet been selected, while the generated positional state records the selected neighbors and suppresses them in subsequent attention computations. Recursively applying this transition therefore converts a nominally non-iterative prediction rule into a sequential retrieval algorithm.
A second distinction concerns supervision. Huang et al. [3] supervise the intermediate computation step by step, whereas our training objective supervises only the first target state. At test time, the learned transition is applied autoregressively to generate the remaining intermediate states and recover the full K-NN prediction. Thus, our result shows that first-step supervision can be sufficient to identify a reusable transition rule whose repeated application implements a longer reasoning process. We view this as an interesting observation.
Moreover, Huang et al. [3] analyze linear attention, which is a simplification of softmax attention, and establish convergence to a finite parameter limit. The nonlinearity of softmax commonly makes the corresponding loss and gradient difficult to express in a tractable closed form. In our setting, we must first use distributional symmetries to prove that gradient descent remains on the invariant manifold W(t)=diag(α(t)Id,0,β(t)IN+1). After this reduction, the parameters do not converge to finite values: Appendix E.3 proves α(t)→+∞ and β(t)→−∞ through contradiction and compactness arguments, while Appendices E.5-E.6 prove that their relative scale converges, −β(t)/α(t)→2, using drift estimates and crossing arguments. Therefore, although both works establish convergence results, characterizing the divergent softmax dynamics and identifying its limiting direction is technically more involved.
We will revise the related-work discussion to make this comparison explicit.
W2. Embedding construction is not fully explained and feels somewhat ad hoc. Why are stochastic positional encodings necessary?
A2. We thank the reviewer for this comment.
Regarding the embedding construction, please note that our setting is consistent with existing work on in-context learning [4–7], where the embedding consists of a feature block, a label block, and a positional encoding block.
Regarding the positional encoding, our use of stochastic positional encodings follows [1-2]. Specifically, [1] introduces stochastic positional encodings as an alternative to fixed absolute positional encodings, which may generalize poorly to unseen sequence lengths. More closely related to our setting, [2] theoretically analyzes the training dynamics of one-layer Transformers with near-orthogonal stochastic positional encodings.
A key observation in [2] is that stochastic positional encoding improves length generalization while inducing distributional symmetry that simplifies the characterization of gradient-descent trajectories. Our analysis builds on the same principle: randomness in the positional encodings induces a signed-permutation symmetry in the positional block, allowing us to show in Appendix E.2 that gradient descent remains confined to a low-dimensional invariant manifold.
Our expressive power guarantees (Theorem 3.1, Proposition 3.2) can be directly extended to any mutually orthogonal positional encodings, since the proof primarily uses orthogonality and is otherwise unchanged. However, our training analysis relies on the signed-permutation symmetry of stochastic positional encodings used in Appendix E.2; without this symmetry, an analogous guarantee would require a substantially different analysis of the full positional block. We will clarify this distinction in the revision.
W3. Limited scope of experiments.
A3. We conduct additional experiments with N=40, d=10, replacing the single-head, single-layer Transformer with either a four-head, one-layer model or a single-head, two-layer model. Both variants are successfully optimized, exhibiting substantial decreases in training loss and achieving high test accuracy across different values of K. These results suggest that both multi-head and multi-layer Transformers can learn the proposed sequential K-NN mechanism, indicating that the mechanism is not empirically restricted to the one-layer architecture analyzed in the paper.
References:
[1] Positional description matters for transformers arithmetic. ArXiv 2023
[2] Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannot. ICML 2024
[3] Transformers Learn to Implement Multi-step Gradient Descent with Chain of Thought. ICLR 2025
[4] One-Layer Transformer Provably Learns One-Nearest Neighbor In Context. NeurIPS 2024
[5] Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection
[6] In-context Learning on Function Classes Unveiled for Transformers. ICML 2024
[7] In-Context Deep Learning via Transformer Models. ICML 2025