On Mesa-Optimization in Autoregressively Trained Transformers: Emergence and Capability
Not on the map. Why?
Abstract (arXiv)
Autoregressively trained transformers have brought a profound revolution to the world, especially with their in-context learning (ICL) ability to address downstream tasks. Recently, several studies suggest that transformers learn a mesa-optimizer during autoregressive (AR) pretraining to implement ICL. Namely, the forward pass of the trained transformer is equivalent to optimizing an inner objective function in-context. However, whether the practical non-convex training dynamics will converge to the ideal mesa-optimizer is still unclear. Towards filling this gap, we investigate the non-convex dynamics of a one-layer linear causal self-attention model autoregressively trained by gradient flow, where the sequences are generated by an AR process xt+1 = W xt. First, under a certain condition of data distribution, we prove that an autoregressively trained transformer learns W by implementing one step of gradient descent to minimize an ordinary least squares (OLS) problem in-context. It then applies the learned widehatW for next-token prediction, thereby verifying the mesa-optimization hypothesis. Next, under the same data conditions, we explore the capability limitations of the obtained mesa-optimizer. We show that a stronger assumption related to the moments of data is the sufficient and necessary condition that the learned mesa-optimizer recovers the distribution. Besides, we conduct exploratory analyses beyond the first data condition and prove that generally, the trained transformer will not perform vanilla gradient descent for the OLS problem. Finally, our simulation results verify the theoretical results.
Key facts. Cited by 5 papers in the map (data through 7 Oct 2026). Builds on 50 of its 63 references that are in the map. First posted on arXiv 27 May 2024.
Builds on
50 of 63 references.
References · 50
- 2017Attention Is All You Needcited by 59,932
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2023Visual Instruction Tuningcited by 7,792
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
- 2021Zero-Shot Text-to-Image Generationcited by 4,276
- 2024Gemini 1.5: Unlocking multimodal understanding across millions of tokens of contextcited by 3,175
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,413
- 2024Visual Autoregressive Modeling: Scalable Image Generation via Next-Scale Predictioncited by 1,005
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
- 2013Exact solutions to the nonlinear dynamics of learning in deep linear neural networkscited by 748
- 2022Transformers learn in-context by gradient descentcited by 714
38 more
- 2022Autoregressive Image Generation using Residual Quantizationcited by 706
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
- 2023The Dawn of LMMs: Preliminary Explorations with GPT-4V(ision)cited by 677
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
- 2016Linear Convergence of Gradient and Proximal-Gradient Methods Under the Polyak-Lojasiewicz Conditioncited by 526
- 2023VisionLLM: Large Language Model is also an Open-Ended Decoder for Vision-Centric Taskscited by 499
- 2019Implicit Regularization in Deep Matrix Factorizationcited by 402
- 2021Transformers Can Do Bayesian Inferencecited by 338
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 2018Adversarially Robust Generalization Requires More Datacited by 318
- 2022Data Distributional Properties Drive Emergent In-Context Learning in Transformerscited by 303
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
- 2019Risks from Learned Optimization in Advanced Machine Learning Systemscited by 250
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 220
- 2024AnyGPT: Unified Multimodal LLM with Discrete Sequence Modelingcited by 213
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 168
- 2023The Learnability of In-Context Learningcited by 126
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 114
- 2023In-Context Convergence of Transformerscited by 112
- 2023Linear attention is (maybe) all you need (to understand transformer optimization)cited by 97
- 2023Uncovering mesa-optimization algorithms in Transformerscited by 94
- 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 93
- 2023How Do Transformers Learn Topic Structure: Towards a Mechanistic Understandingcited by 85
- 2024Training Dynamics of Multi-Head Softmax Attention for In-Context Learning: Emergence, Convergence, and Optimalitycited by 71
- 2023Understanding In-Context Learning in Transformers and LLMs by Learning to Learn Discrete Functionscited by 62
- 2023Learning Mixtures of Gaussians Using the DDPM Objectivecited by 56
- 2024Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscapecited by 43
- 2023On the Optimization and Generalization of Multi-head Attentioncited by 37
- 2024Mechanics of Next Token Prediction with Self-Attentioncited by 34
- 2024In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initializationcited by 30
- 2023Revisiting Discriminative vs. Generative Classifiers: Theory and Implicationscited by 29
- 2024Linear Transformers are Versatile In-Context Learnerscited by 28
- 2023A Closer Look at In-Context Learning under Distribution Shiftscited by 25
- 2023Toward Understanding Generative Data Augmentationcited by 25
- 2024How Well Can Transformers Emulate In-context Newton's Method?cited by 23
- 2024Superiority of Multi-Head Attention in In-Context Linear Regressioncited by 17
- 2024How do Transformers perform In-Context Autoregressive Learning?cited by 16
- 2021Information-Theoretic Characterization of the Generalization Error for Iterative Semi-Supervised Learningcited by 11
Built on by
Citing papers per year: 2024: 1; 2025: 4.
5 papers.
- 2024Can In-context Learning Really Generalize to Out-of-distribution Tasks?cited by 23
- 2025Scaling Diffusion Transformers Efficiently via μPcited by 6
- 2025Disentangling Feature Structure: A Mathematically Provable Two-Stage Training Dynamics in Transformerscited by 3
- 2025In-Context Learning of Linear Dynamical Systems with Transformers: Approximation Bounds and Depth-Separationcited by 1
- 2025A Theory for Conditional Generative Modeling on Multiple Data Sourcescited by 1
- 2025Scaling Diffusion Transformers Efficiently via μP21 May 2025
- 2025Disentangling Feature Structure: A Mathematically Provable Two-Stage Training Dynamics in Transformers28 Feb 2025
- 2025A Theory for Conditional Generative Modeling on Multiple Data Sources20 Feb 2025
- 2025In-Context Learning of Linear Dynamical Systems with Transformers: Approximation Bounds and Depth-Separation12 Feb 2025
- 2024Can In-context Learning Really Generalize to Out-of-distribution Tasks?13 Oct 2024