Lune

NeurIPS2024顶会

One-Layer Transformer Provably Learns One-Nearest Neighbor In Context

Zihao Li, Yuan Cao, Cheng Gao, Yihan He, Han Liu, Jason M. Klusowski, Jianqing Fan, Mengdi Wang

摘要

Transformers have achieved great success in recent years. Interestingly, transformers have shown particularly strong in-context learning capability -- even without fine-tuning, they are still able to solve unseen tasks well purely based on task-specific prompts. In this paper, we study the capability of one-layer transformers in learning one of the most classical nonparametric estimators, the one-nearest neighbor prediction rule. Under a theoretical framework where the prompt contains a sequence of labeled training data and unlabeled test data, we show that, although the loss function is nonconvex when trained with gradient descent, a single softmax attention layer can successfully learn to behave like a one-nearest neighbor classifier. Our result gives a concrete example of how transformers can be trained to implement nonparametric machine learning algorithms, and sheds light on the role of softmax attention in transformer models.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 12 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Transformers Efficiently Perform In-Context Logistic Regression via Normalized Gradient Descent 引用了 Towards Understanding Transformers in Learning Random Walks
  • Transformers Efficiently Perform In-Context Logistic Regression via Normalized Gradient Descent 引用了 Offline Reinforcement Learning as One Big Sequence Modeling Problem
  • Transformers Efficiently Perform In-Context Logistic Regression via Normalized Gradient Descent 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Towards Understanding Transformers in Learning Random Walks 引用了 Offline Reinforcement Learning as One Big Sequence Modeling Problem
  • Towards Understanding Transformers in Learning Random Walks 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Towards Understanding Transformers in Learning Random Walks 引用了 Decision Transformer: Reinforcement Learning via Sequence Modeling
  • Offline Reinforcement Learning as One Big Sequence Modeling Problem 引用了 Decision Transformer: Reinforcement Learning via Sequence Modeling
  • Decision Transformer: Reinforcement Learning via Sequence Modeling 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Attention-based clustering 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper12

  1. Attention-based clusteringRodrigo Maulen-Soto, Pierre Marion, Claire BoyerNeurIPS 2025 · 3 次引用
  2. Decoupling Positional and Symbolic Attention in TransformersFelipe Urrutia, Jorge Salas, Alexander Kozachinskiy, Cristian Buc Calderon 等ICLR 2026 · 3 次引用
  3. Transformers Efficiently Perform In-Context Logistic Regression via Normalized Gradient DescentChenyang Zhang, Yuan CaoICML 2026 · 1 次引用
  4. In-context Learning of Linear Dynamical Systems with Transformers: Approximation Bounds and Depth-separationFrank Cole, Yuxuan Zhao, Yulong Lu, Tianhao ZhangNeurIPS 2025 · 1 次引用
  5. Towards Understanding Transformers in Learning Random WalksWei Shi, Yuan CaoNeurIPS 2025 · 1 次引用

它引用的 Paper18

  1. An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn 等ICLR 2021 · 21,477 次引用
  2. Photorealistic Text-to-Image Diffusion Models with Deep Language UnderstandingChitwan Saharia, William Chan, Saurabh Saxena, Lala Li 等NeurIPS 2022 · 8,965 次引用
  3. Decision Transformer: Reinforcement Learning via Sequence ModelingLili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee 等NeurIPS 2021 · 2,557 次引用
  4. An Explanation of In-context Learning as Implicit Bayesian InferenceSang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu MaICLR 2022 · 1,030 次引用
  5. Offline Reinforcement Learning as One Big Sequence Modeling ProblemMichael Janner, Qiyang Li, Sergey LevineNeurIPS 2021 · 950 次引用

相关 Paper

  1. In-Context Learning with Transformers: Softmax Attention Adapts to Function LipschitznessLiam Collins, Advait Parulekar, Aryan Mokhtari, Sujay Sanghavi 等NeurIPS 2024 · 33 次引用
  2. Transformers Implement Functional Gradient Descent to Learn Non-Linear Functions In ContextXiang Cheng, Yuxin Chen, Suvrit SraICML 2024 · 64 次引用
  3. In-context Convergence of TransformersYu Huang, Yuan Cheng, Yingbin LiangICML 2024 · 114 次引用
  4. In-Context Algorithm Emulation in Fixed-Weight TransformersJerry Yao-Chieh Hu, Hude Liu, Jennifer Yuntong Zhang, Han LiuICLR 2026 · 7 次引用
  5. The Closeness of In-Context Learning and Weight Shifting for Softmax RegressionShuai Li, Zhao Song, Yu Xia, Tong Yu 等NeurIPS 2024 · 53 次引用
黄昏的海面,两侧是细线勾勒的悬崖