Lune

NeurIPS2024Top-tier venue

Linear Transformers are Versatile In-Context Learners

Max Vladymyrov, Johannes von Oswald, Mark Sandler, Rong Ge

Abstract

Recent research has demonstrated that transformers, particularly linear attention models, implicitly execute gradient-descent-like algorithms on data provided in-context during their forward inference step. However, their capability in handling more complex problems remains unexplored. In this paper, we prove that each layer of a linear transformer maintains a weight vector for an implicit linear regression problem and can be interpreted as performing a variant of preconditioned gradient descent. We also investigate the use of linear transformers in a challenging scenario where the training data is corrupted with different levels of noise. Remarkably, we demonstrate that for this problem linear transformers discover an intricate and highly effective optimization algorithm, surpassing or matching in performance many reasonable baselines. We analyze this algorithm and show that it is a novel approach incorporating momentum and adaptive rescaling based on noise levels. Our findings show that even linear transformers possess the surprising ability to discover sophisticated optimization strategies.

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.

13 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

  • On Mesa-Optimization in Autoregressively Trained Transformers: Emergence and Capability cites Data Distributional Properties Drive Emergent In-Context Learning in Transformers
  • On Mesa-Optimization in Autoregressively Trained Transformers: Emergence and Capability cites Language Models are Few-Shot Learners
  • On Mesa-Optimization in Autoregressively Trained Transformers: Emergence and Capability cites Transformers Learn In-Context by Gradient Descent
  • On Mesa-Optimization in Autoregressively Trained Transformers: Emergence and Capability cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • From Unstructured Data to In-Context Learning: Exploring What Tasks Can Be Learned and When cites Data Distributional Properties Drive Emergent In-Context Learning in Transformers
  • 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
  • Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time cites Data Distributional Properties Drive Emergent In-Context Learning in Transformers
  • Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time cites Language Models are Few-Shot Learners
  • Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time cites Transformers Learn In-Context by Gradient Descent
  • Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear Regression cites Language Models are Few-Shot Learners
  • Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear Regression cites Transformers Learn In-Context by Gradient Descent
  • Transformers Learn In-Context by Gradient Descent cites Data Distributional Properties Drive Emergent In-Context Learning in Transformers
  • 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 Language Models are Few-Shot Learners
  • In-Context Algorithm Emulation in Fixed-Weight Transformers cites Language Models are Few-Shot Learners
  • In-Context Algorithm Emulation in Fixed-Weight Transformers cites Transformers Learn In-Context by Gradient Descent
  • In-Context Algorithm Emulation in Fixed-Weight Transformers cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers13

  1. Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear RegressionDeqing Fu, Tianqi Chen, Robin Jia, Vatsal SharanNeurIPS 2024 · 54 citations
  2. Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and TimeBlake Bordelon, Mary I. Letey, Cengiz PehlevanICLR 2026 · 14 citations
  3. On Mesa-Optimization in Autoregressively Trained Transformers: Emergence and CapabilityChenyu Zheng, Wei Huang, Rongzhen Wang, Guoqiang Wu et al.NeurIPS 2024 · 10 citations
  4. In-Context Algorithm Emulation in Fixed-Weight TransformersJerry Yao-Chieh Hu, Hude Liu, Jennifer Yuntong Zhang, Han LiuICLR 2026 · 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 on20

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 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. Data Distributional Properties Drive Emergent In-Context Learning in TransformersStephanie C. Y. Chan, Adam Santoro, Andrew K. Lampinen, Jane X. Wang et al.NeurIPS 2022 · 407 citations

Related papers

  1. Trained Transformer Classifiers Generalize and Exhibit Benign Overfitting In-ContextSpencer Frei, Gal VardiICLR 2025
  2. Transformers learn to implement preconditioned gradient descent for in-context learningKwangjun Ahn, Xiang Cheng, Hadi Daneshmand, Suvrit SraNeurIPS 2023 · 324 citations
  3. How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear RegressionXingwu Chen, Lei Zhao, Difan ZouNeurIPS 2024 · 19 citations
  4. Can Looped Transformers Learn to Implement Multi-step Gradient Descent for In-context Learning?Khashayar Gatmiry, Nikunj Saunshi, Sashank J. Reddi, Stefanie Jegelka et al.ICML 2024 · 43 citations
  5. One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-AttentionArvind V. Mahankali, Tatsunori Hashimoto, Tengyu MaICLR 2024 · 160 citations
Dusk over the sea between two cliffs drawn in fine vertical lines