Transformers learn to implement preconditioned gradient descent for in-context learning
Kwangjun Ahn, Xiang Cheng, Hadi Daneshmand, Suvrit Sra
Abstract
Several recent works demonstrate that transformers can implement algorithms like gradient descent. By a careful construction of weights, these works show that multiple layers of transformers are expressive enough to simulate iterations of gradient descent. Going beyond the question of expressivity, we ask: Can transformers learn to implement such algorithms by training over random problem instances? To our knowledge, we make the first theoretical progress on this question via an analysis of the loss landscape for linear transformers trained over random instances of linear regression. For a single attention layer, we prove the global minimum of the training objective implements a single iteration of preconditioned gradient descent. Notably, the preconditioning matrix not only adapts to the input distribution but also to the variance induced by data inadequacy. For a transformer with attention layers, we prove certain critical points of the training objective implement iterations of preconditioned gradient descent. Our results call for future theoretical studies on learning algorithms by training transformers.
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.
180 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- A Survey on In-context Learning cites An Explanation of In-context Learning as Implicit Bayesian Inference
- A Survey on In-context Learning cites One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attention
- A Survey on In-context Learning cites Language Models are Few-Shot Learners
- A Survey on In-context Learning cites Transformers Learn In-Context by Gradient Descent
- A Survey on In-context Learning cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- How Transformers Learn Causal Structure with Gradient Descent cites An Explanation of In-context Learning as Implicit Bayesian Inference
- How Transformers Learn Causal Structure with Gradient Descent cites One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attention
- How Transformers Learn Causal Structure with Gradient Descent cites Language Models are Few-Shot Learners
- How Transformers Learn Causal Structure with Gradient Descent cites Transformers Learn In-Context by Gradient Descent
- How Transformers Learn Causal Structure with Gradient Descent 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
- One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attention cites An Explanation of In-context Learning as Implicit Bayesian Inference
- One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attention cites Language Models are Few-Shot Learners
- One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attention cites Transformers Learn In-Context by Gradient Descent
- One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attention cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- The Expressive Power of Low-Rank Adaptation cites An Explanation of In-context Learning as Implicit Bayesian Inference
- The Expressive Power of Low-Rank Adaptation cites Language Models are Few-Shot Learners
- The Expressive Power of Low-Rank Adaptation cites Transformers Learn In-Context by Gradient Descent
- Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites An Explanation of In-context Learning as Implicit Bayesian Inference
- Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attention
- Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites Language Models are Few-Shot Learners
- Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites Transformers Learn In-Context by Gradient Descent
- Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks 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
- Transformers Learn In-Context by Gradient Descent cites Linear Transformers Are Secretly Fast Weight Programmers
- 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
Cited by top-tier papers180
- A Survey on In-context LearningQingxiu Dong, Lei Li, Damai Dai, Ce Zheng et al.EMNLP 2024 · 479 citations
- 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
- Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning TasksJongho Park, Jaeseung Park, Zheyang Xiong, Nayoung Lee et al.ICML 2024 · 124 citations
- How Transformers Learn Causal Structure with Gradient DescentEshaan Nichani, Alex Damian, Jason D. LeeICML 2024 · 117 citations
- The Expressive Power of Low-Rank AdaptationYuchen Zeng, Kangwook LeeICLR 2024 · 116 citations
Builds on11
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- An Explanation of In-context Learning as Implicit Bayesian InferenceSang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu MaICLR 2022 · 1,030 citations
- What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 citations
- Transformers Learn In-Context by Gradient DescentJohannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento et al.ICML 2023 · 729 citations
- Linear Transformers Are Secretly Fast Weight ProgrammersImanol Schlag, Kazuki Irie, Jürgen SchmidhuberICML 2021 · 394 citations
Related papers
- 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
- Linear Transformers are Versatile In-Context LearnersMax Vladymyrov, Johannes von Oswald, Mark Sandler, Rong GeNeurIPS 2024 · 37 citations
- 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
- Trained Transformer Classifiers Generalize and Exhibit Benign Overfitting In-ContextSpencer Frei, Gal VardiICLR 2025
- Transformers Implement Functional Gradient Descent to Learn Non-Linear Functions In ContextXiang Cheng, Yuxin Chen, Suvrit SraICML 2024 · 64 citations
