Lune

NeurIPS2024Top-tier venue

In-Context Learning with Transformers: Softmax Attention Adapts to Function Lipschitzness

Liam Collins, Advait Parulekar, Aryan Mokhtari, Sujay Sanghavi, Sanjay Shakkottai

Abstract

A striking property of transformers is their ability to perform in-context learning (ICL), a machine learning framework in which the learner is presented with a novel context during inference implicitly through some data, and tasked with making a prediction in that context. As such, that learner must adapt to the context without additional training. We explore the role of softmax attention in an ICL setting where each context encodes a regression task. We show that an attention unit learns a window that it uses to implement a nearest-neighbors predictor adapted to the landscape of the pretraining tasks. Specifically, we show that this window widens with decreasing Lipschitzness and increasing label noise in the pretraining tasks. We also show that on low-rank, linear problems, the attention unit learns to project onto the appropriate subspace before inference. Further, we show that this adaptivity relies crucially on the softmax activation and thus cannot be replicated by the linear activation often studied in prior theoretical analyses.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

12 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Fine-grained Analysis of In-context Linear Estimation: Data, Architecture, and Beyond cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Fine-grained Analysis of In-context Linear Estimation: Data, Architecture, and Beyond cites Language Models are Few-Shot Learners
  • Fine-grained Analysis of In-context Linear Estimation: Data, Architecture, and Beyond cites Transformers Learn In-Context by Gradient Descent
  • Fine-grained Analysis of In-context Linear Estimation: Data, Architecture, and Beyond cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Towards Understanding How Transformers Learn In-context Through a Representation Learning Lens cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Towards Understanding How Transformers Learn In-context Through a Representation Learning Lens cites Language Models are Few-Shot Learners
  • Towards Understanding How Transformers Learn In-context Through a Representation Learning Lens cites Transformers Learn In-Context by Gradient Descent
  • Towards Understanding How Transformers Learn In-context Through a Representation Learning Lens cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • An Explanation of In-context Learning as Implicit Bayesian Inference cites Language Models are Few-Shot Learners
  • From Unstructured Data to In-Context Learning: Exploring What Tasks Can Be Learned and When cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • From Unstructured Data to In-Context Learning: Exploring What Tasks Can Be Learned and When cites Language Models are Few-Shot Learners
  • From Unstructured Data to In-Context Learning: Exploring What Tasks Can Be Learned and When cites Transformers Learn In-Context by Gradient Descent
  • From Unstructured Data to In-Context Learning: Exploring What Tasks Can Be Learned and When cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Transformers Learn In-Context by Gradient Descent cites Language Models are Few-Shot Learners
  • Transformers Learn In-Context by Gradient Descent cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites Language Models are Few-Shot Learners
  • What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites Are Transformers universal approximators of sequence-to-sequence functions?
  • From Condensation to Rank Collapse: A Two-Stage Analysis of Transformer Training Dynamics cites Language Models are Few-Shot Learners
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers12

  1. Towards Understanding How Transformers Learn In-context Through a Representation Learning LensRuifeng Ren, Yong LiuNeurIPS 2024 · 26 citations
  2. Fine-grained Analysis of In-context Linear Estimation: Data, Architecture, and BeyondYingcong Li, Ankit Singh Rawat, Samet OymakNeurIPS 2024 · 24 citations
  3. From Condensation to Rank Collapse: A Two-Stage Analysis of Transformer Training DynamicsZheng-An Chen, Tao LuoNeurIPS 2025 · 13 citations
  4. On the Power of Convolution-Augmented TransformerMingchen Li, Xuechen Zhang, Yixiao Huang, Samet OymakAAAI 2025 · 7 citations
  5. From Unstructured Data to In-Context Learning: Exploring What Tasks Can Be Learned and WhenKevin Christian Wibisono, Yixin WangNeurIPS 2024 · 5 citations

Builds on35

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. An Explanation of In-context Learning as Implicit Bayesian InferenceSang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu MaICLR 2022 · 1,030 citations
  3. What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 citations
  4. Transformers Learn In-Context by Gradient DescentJohannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento et al.ICML 2023 · 729 citations
  5. Are Transformers universal approximators of sequence-to-sequence functions?Chulhee Yun, Srinadh Bhojanapalli, Ankit Singh Rawat, Sashank J. Reddi et al.ICLR 2020 · 481 citations

Related papers

  1. Transformers Efficiently Perform In-Context Logistic Regression via Normalized Gradient DescentChenyang Zhang, Yuan CaoICML 2026 · 1 citation
  2. The Closeness of In-Context Learning and Weight Shifting for Softmax RegressionShuai Li, Zhao Song, Yu Xia, Tong Yu et al.NeurIPS 2024 · 53 citations
  3. One-Layer Transformer Provably Learns One-Nearest Neighbor In ContextZihao Li, Yuan Cao, Cheng Gao, Yihan He et al.NeurIPS 2024 · 25 citations
  4. How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?Jingfeng Wu, Difan Zou, Zixiang Chen, Vladimir Braverman et al.ICLR 2024 · 94 citations
  5. In-Context Linear Regression Demystified: Training Dynamics and Mechanistic Interpretability of Multi-Head Softmax AttentionJianliang He, Xintian Pan, Siyu Chen, Zhuoran YangICML 2025
Dusk over the sea between two cliffs drawn in fine vertical lines