One-Layer Transformers Provably Learn In-Context K-Nearest Neighbor Prediction with Chain-of-Thought
Chain-of-Thought (CoT) enables transformers to solve complex reasoning tasks by generating intermediate reasoning steps.
ProofPaper ↗
Key points
- In this work, we study this question in a stylized yet fully analyzable setting: in-context $K$-nearest-neighbor ($K$-NN) prediction with a one-layer transformer.
- Earlier work has demonstrated that one-layer transformers can be trained to perform $1$-NN without CoT (Li et al., 2024a) by having the softmax attention attend to the nearest neighbor in context.
- We then give an explicit construction of a one-layer transformer, and show that it can solve $K$-NN via CoT reasoning.
- In addition, we show that the resulting trained model applies to a broader test class than that assumed in the training analysis.
Sources (1)
- [1]One-Layer Transformers Provably Learn In-Context K-Nearest Neighbor Prediction with Chain-of-ThoughtarXiv (AI, ML, NLP, CV, robotics, multi-agent) · Oct 12, 01:50 PM
Chain-of-Thought (CoT) enables transformers to solve complex reasoning tasks by generating intermediate reasoning steps.
In this work, we study this question in a stylized yet fully analyzable setting: in-context $K$-nearest-neighbor ($K$-NN) prediction with a one-layer transformer.
Extractive summary: sentences quoted from the sources.
Before this
- Oct 12, 2026AReA: Adaptive Receptive-Field Attention for Efficient High-Resolution Diffusion Transformers
- Oct 12, 2026AUGUstus: Autonomous Driving VLA Model with Unified Generation and Understanding
- Oct 11, 2026autotrust/JEV-35B-NVFP4
- Oct 11, 2026History Replays Itself: Unleashing Long-Context Capability in Linear Attention
- Oct 10, 2026vllm-sr/d3
- Oct 9, 2026LiquidAI/LFM2.5-24B-A2B