Lune

NeurIPS2024Top-tier venue

In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initialization

Ruiqi Zhang, Jingfeng Wu, Peter L. Bartlett

Abstract

We study the in-context learning (ICL) ability of a Linear Transformer Block (LTB) that combines a linear attention component and a linear multi-layer perceptron (MLP) component. For ICL of linear regression with a Gaussian prior and a non-zero mean, we show that LTB can achieve nearly Bayes optimal ICL risk. In contrast, using only linear attention must incur an irreducible additive approximation error. Furthermore, we establish a correspondence between LTB and one-step gradient descent estimators with learnable initialization (GD-β\mathsf{GD}\text{-}\mathbf{\beta}), in the sense that every GD-β\mathsf{GD}\text{-}\mathbf{\beta} estimator can be implemented by an LTB estimator and every optimal LTB estimator that minimizes the in-class ICL risk is effectively a GD-β\mathsf{GD}\text{-}\mathbf{\beta} estimator. Finally, we show that GD-β\mathsf{GD}\text{-}\mathbf{\beta} estimators can be efficiently optimized with gradient flow, despite a non-convex training objective. Our results reveal that LTB achieves ICL by implementing GD-β\mathsf{GD}\text{-}\mathbf{\beta}, and they highlight the role of MLP layers in reducing approximation error.

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.

18 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

  • Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscape cites Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection
  • Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscape cites Transformers Learn In-Context by Gradient Descent
  • Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscape cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Looped Transformers are Better at Learning Learning Algorithms cites Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection
  • Looped Transformers are Better at Learning Learning Algorithms cites Language Models are Few-Shot Learners
  • Looped Transformers are Better at Learning Learning Algorithms cites Transformers Learn In-Context by Gradient Descent
  • Looped Transformers are Better at Learning Learning Algorithms cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Locating and Editing Factual Associations in GPT cites Language Models are Few-Shot Learners
  • Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection cites Language Models are Few-Shot Learners
  • Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection cites Transformers Learn In-Context by Gradient Descent
  • Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Pretrained Transformer Efficiently Learns Low-Dimensional Target Functions In-Context cites Language Models are Few-Shot Learners
  • Pretrained Transformer Efficiently Learns Low-Dimensional Target Functions In-Context cites Transformers Learn In-Context by Gradient Descent
  • Transformers are Minimax Optimal Nonparametric In-Context Learners cites Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscape
  • Transformers are Minimax Optimal Nonparametric In-Context Learners cites Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection
  • Transformers are Minimax Optimal Nonparametric In-Context Learners cites Language Models are Few-Shot Learners
  • Transformers are Minimax Optimal Nonparametric In-Context Learners cites Transformers Learn In-Context by Gradient Descent
  • Transformers are Minimax Optimal Nonparametric In-Context Learners cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regression cites Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection
  • How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regression cites Transformers Learn In-Context by Gradient Descent
  • How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regression 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 Language Models are Few-Shot Learners
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers18

  1. Looped Transformers are Better at Learning Learning AlgorithmsLiu Yang, Kangwook Lee, Robert D. Nowak, Dimitris PapailiopoulosICLR 2024 · 82 citations
  2. Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention LandscapeJuno Kim, Taiji SuzukiICML 2024 · 42 citations
  3. Transformers are Minimax Optimal Nonparametric In-Context LearnersJuno Kim, Tai Nakamaki, Taiji SuzukiNeurIPS 2024 · 42 citations
  4. Pretrained Transformer Efficiently Learns Low-Dimensional Target Functions In-ContextKazusato Oko, Yujin Song, Taiji Suzuki, Denny WuNeurIPS 2024 · 34 citations
  5. 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

Builds on21

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Locating and Editing Factual Associations in GPTKevin Meng, David Bau, Alex Andonian, Yonatan BelinkovNeurIPS 2022 · 3,415 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. Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm SelectionYu Bai, Fan Chen, Huan Wang, Caiming Xiong et al.NeurIPS 2023 · 356 citations

Related papers

  1. 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
  2. On learning linear dynamical systems in context with attention layersMaria-Luiza Vladarean, Xuhui Zhang, Suvrit SraICLR 2026
  3. Transformers Efficiently Perform In-Context Logistic Regression via Normalized Gradient DescentChenyang Zhang, Yuan CaoICML 2026 · 1 citation
  4. Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear RegressionDeqing Fu, Tianqi Chen, Robin Jia, Vatsal SharanNeurIPS 2024 · 54 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