ResearchResearch paperReasoning & Planning · Efficiency & Inference · Training & Scaling1 source · Oct 12, 2026

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.

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)

Extractive summary: sentences quoted from the sources.

Before this

  1. Oct 12, 2026AReA: Adaptive Receptive-Field Attention for Efficient High-Resolution Diffusion Transformers
  2. Oct 12, 2026AUGUstus: Autonomous Driving VLA Model with Unified Generation and Understanding
  3. Oct 11, 2026autotrust/JEV-35B-NVFP4
  4. Oct 11, 2026History Replays Itself: Unleashing Long-Context Capability in Linear Attention
  5. Oct 10, 2026vllm-sr/d3
  6. Oct 9, 2026LiquidAI/LFM2.5-24B-A2B

Related