Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection
Not on the map. Why?
Cited by 22 in LLM reasoning, but placed by its own abstract, which didn’t fit.
Abstract (arXiv)
Neural sequence models based on the transformer architecture have demonstrated remarkable in-context learning (ICL) abilities, where they can perform new tasks when prompted with training and test examples, without any parameter update to the model. This work first provides a comprehensive statistical theory for transformers to perform ICL. Concretely, we show that transformers can implement a broad class of standard machine learning algorithms in context, such as least squares, ridge regression, Lasso, learning generalized linear models, and gradient descent on two-layer neural networks, with near-optimal predictive power on various in-context data distributions. Using an efficient implementation of in-context gradient descent as the underlying mechanism, our transformer constructions admit mild size bounds, and can be learned with polynomially many pretraining sequences. Building on these ``base'' ICL algorithms, intriguingly, we show that transformers can implement more complex ICL procedures involving in-context algorithm selection, akin to what a statistician can do in real life -- A single transformer can adaptively select different base ICL algorithms -- or even perform qualitatively different tasks -- on different input sequences, without any explicit prompting of the right algorithm or task. We both establish this in theory by explicit constructions, and also observe this phenomenon experimentally. In theory, we construct two general mechanisms for algorithm selection with concrete examples: pre-ICL testing, and post-ICL validation. As an example, we use the post-ICL validation mechanism to construct a transformer that can perform nearly Bayes-optimal ICL on a challenging task -- noisy linear models with mixed noise levels. Experimentally, we demonstrate the strong in-context algorithm selection capabilities of standard transformer architectures.
Key facts. Cited by 298 papers in the map (data through 14 Oct 2026). Builds on 41 of its 97 references that are in the map. First posted on arXiv 7 Jun 2023.
Builds on
41 of 97 references.
References · 41
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 30,186
- 2023GPT-4 Technical Reportcited by 18,396
- 2016Layer Normalizationcited by 5,669
- 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,592
- 2022Emergent Abilities of Large Language Modelscited by 2,512
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
- 2021What Makes Good In-Context Examples for GPT-3?cited by 1,195
- 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,135
- 2022In-context Learning and Induction Headscited by 964
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
- 2022A Generalist Agentcited by 808
29 more
- 2022Transformers learn in-context by gradient descentcited by 732
- 2022A Survey on In-context Learningcited by 721
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
- 2021Learning To Retrieve Prompts for In-Context Learningcited by 648
- 2021MetaICL: Learning to Learn In Contextcited by 454
- 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 406
- 2023Larger language models do in-context learning differentlycited by 394
- 2022Transformers Learn Shortcuts to Automatacited by 268
- 2023Looped Transformers as Programmable Computerscited by 237
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 222
- 2020Few-Shot Learning via Learning the Representation, Provablycited by 214
- 2022Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizerscited by 204
- 2016Learning to Optimizecited by 195
- 2021Noisy Channel Language Model Prompting for Few-Shot Text Classificationcited by 165
- 2022Impact of Pretraining Term Frequencies on Few-Shot Reasoningcited by 142
- 2019On the Turing Completeness of Modern Neural Network Architecturescited by 129
- 2020ProGen: Language Modeling for Protein Generationcited by 128
- 2022Unveiling Transformers with LEGO: a synthetic reasoning taskcited by 106
- 2021Self-Attention Networks Can Process Bounded Hierarchical Languagescited by 105
- 2022General-Purpose In-Context Learning by Meta-Learning Transformerscited by 105
- 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 102
- 2022Vision Transformers provably learn spatial structurecited by 93
- 2020On the Computational Power of Transformers and its Implications in Sequence Modelingcited by 85
- 2023A Study on ReLU and Softmax in Transformercited by 53
- 2021Approximating How Single Head Attention Learnscited by 38
- 2017A Simple Neural Attentive Meta-Learnercited by 23
- 2018Incremental Learning-to-Learn with Statistical Guaranteescited by 16
- 2022An Analysis of Attention via the Lens of Exchangeability and Latent Variable Modelscited by 16
- 2020On the Ability and Limitations of Transformers to Recognize Formal Languagescited by 13
Built on by
Citing papers per year: 2023: 26; 2024: 114; 2025: 84; 2026: 74.
298 papers.
Sort:
By area:
- 2023Trained Transformers Learn Linear Models In-Contextcited by 337
- 2023Looped Transformers are Better at Learning Learning Algorithmscited by 149
- 2023The mechanistic basis of data dependence and abrupt learning in an in-context classification taskcited by 118
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
- 2023In-Context Convergence of Transformerscited by 115
- 2024Can Mamba Learn How to Learn? A Comparative Study on In-Context Learning Taskscited by 105
- 2023The Expressive Power of Low-Rank Adaptationcited by 102
- 2023Uncovering mesa-optimization algorithms in Transformerscited by 100
- 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 96
- 2025A Survey of Graph Retrieval-Augmented Generation for Customized Large Language Modelscited by 88
- 2023Transformers as Decision Makers: Provable In-Context Reinforcement Learning via Supervised Pretrainingcited by 83
- 2024Can large language models explore in-context?cited by 76
38 more
- 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 75
- 2023Transformers as Support Vector Machinescited by 74
- 2024Can Looped Transformers Learn to Implement Multi-step Gradient Descent for In-context Learning?cited by 65
- 2023Understanding In-Context Learning in Transformers and LLMs by Learning to Learn Discrete Functionscited by 63
- 2023Transformers Implement Functional Gradient Descent to Learn Non-Linear Functions In Contextcited by 63
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 57
- 2024Is In-Context Learning in Large Language Models Bayesian? A Martingale Perspectivecited by 57
- 2024Asymptotic theory of in-context learning by linear attentioncited by 55
- 2023JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attentioncited by 52
- 2023Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear Regressioncited by 49
- 2025CausalPFN: Amortized Causal Effect Estimation via In-Context Learningcited by 49
- 2024Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscapecited by 46
- 2025Training Dynamics of In-Context Learning in Linear Attentioncited by 46
- 2024Is Mamba Capable of In-Context Learning?cited by 45
- 2024Why Larger Language Models Do In-context Learning Differently?cited by 45
- 2023Replacing softmax with ReLU in Vision Transformerscited by 44
- 2024A Theoretical Understanding of Self-Correction through In-context Alignmentcited by 44
- 2024Dual Operating Modes of In-Context Learningcited by 43
- 2025Learning without training: The implicit dynamics of in-context learningcited by 43
- 2024Attention with Markov: A Framework for Principled Analysis of Transformers via Markov Chainscited by 40
- 2023Deep Networks as Denoising Algorithms: Sample-Efficient Learning of Diffusion Models in High-Dimensional Graphical Modelscited by 39
- 2024Pre-trained Large Language Models Use Fourier Features to Compute Additioncited by 39
- 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformerscited by 38
- 2025When is Task Vector Provably Effective for Model Editing? A Generalization Analysis of Nonlinear Transformerscited by 38
- 2023Which Examples to Annotate for In-Context Learning? Towards Effective and Efficient Selectioncited by 37
- 2024Transformers are Minimax Optimal Nonparametric In-Context Learnerscited by 37
- 2025Bayesian Teaching Enables Probabilistic Reasoning in Large Language Modelscited by 37
- 2024How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?cited by 35
- 2023The Mystery of In-Context Learning: A Comprehensive Survey on Interpretation and Analysiscited by 34
- 2024EVOLvE: Evaluating and Optimizing LLMs For In-Context Explorationcited by 34
- 2024In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initializationcited by 33
- 2025Transformers Learn to Implement Multi-step Gradient Descent with Chain of Thoughtcited by 32
- 2024Pretrained transformer efficiently learns low-dimensional target functions in-contextcited by 31
- 2024A phase transition between positional and semantic learning in a solvable model of dot-product attentioncited by 30
- 2024Understanding Scaling Laws with Statistical and Approximation Theory for Transformer Neural Networks on Intrinsically Low-dimensional Datacited by 30
- 2024Separations in the Representational Capabilities of Transformers and Recurrent Architecturescited by 29
- 2024Unveiling the Statistical Foundations of Chain-of-Thought Prompting Methodscited by 29
- 2024Linear Transformers are Versatile In-Context Learnerscited by 28
50 most cited of 298 All 298 (JSON)
- 2026Learning Source Structure: Bayesian Prediction with Transformers13 Oct 2026
- 2026In-context classification: Calibration and noise in linear attention with softmax readout12 Oct 2026
- 2026Transformer-based In-Context Score Operator Learning for Diffusion Models9 Oct 2026
- 2026PDE-PFN: Prior-Data Fitted Neural PDE Solver9 Oct 2026
- 2026Retrieval-Based In-Context Learning: A Domain Adaptation Framework5 Oct 2026
- 2026When Can Prefixes Compile LoRA? Exact Resource-Capped Tests for Frozen Attention29 Sep 2026
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learning29 Sep 2026
- 2026ALICE: In-context, Zero-shot, Mutual Information Estimation28 Sep 2026
- 2026A Comparative Analysis of Attention versus State-Space Models for In-Context Learning26 Sep 2026
- 2026From Weak Data to Strong Policy: Q-Targets Enable Provable In-Context Reinforcement Learning24 Sep 2026
- 2026Retrieval-Guided Fine-Tuning as Noisy Estimation: Risk bounds and Architectural Analysis13 Sep 2026
- 2026Transformers as In-Context Samplers: From Closed-Form Diffusion to Estimation-Free Sampling8 Sep 2026
38 more
- 2026One-Layer Transformer Provably Learns Multiclass One-Nearest Neighbor in Context1 Sep 2026
- 2026Linear RNN Scaling Laws: When Longer Sequences Beat More Sequences23 Aug 2026
- 2026Handover of In-Context Learning State Across Session Boundaries14 Aug 2026
- 2026Training-Free Universal Approximation by Prompting Random Transformers10 Aug 2026
- 2026Soft Guidance Starts to Outperform CoT Prompting as LLMs Improve4 Aug 2026
- 2026Grounding latent algorithm routing in transformer reasoning27 Jul 2026
- 2026Vector Search As Nearest Neighbor Matching: RAG-based Policy Learning in Causal Inference20 Jul 2026
- 2026In-context learning of closed form solution to simple linear regression task using transformer with linear self-attention17 Jul 2026
- 2026A Minimal Interpretable Architecture for Zero-Shot Reconstruction of Dynamical Systems16 Jul 2026
- 2026A Unified Framework for In-Context Learning with Causal and Masked Language Models5 Jul 2026
- 2026Sequential Correlations Change In-Context Learning: Effective Context Length and Architectural Mismatch4 Jul 2026
- 2026Induction Heads Interpolate N-Grams2 Jul 2026
- 2026Transformers as Bayesian In-Context Experimenters: Smoothness-Adaptive Efficient ATE Estimation30 Jun 2026
- 2026When Does Depth Matter For In-Context Learning? Adaptive Inference in Deep Transformers15 Jun 2026
- 2026Provable Data Scaling Law for Meta Learning via Complexity Minimization1 Jun 2026
- 2026In-Context Reward Adaptation for Robust Preference Modeling28 May 2026
- 2026Understanding Generalization and Forgetting in In-Context Continual Learning27 May 2026
- 2026Transformers Can Learn Posterior Predictive Distributions In-Context26 May 2026
- 2026In-Context Optimization for Retrieval-Augmented Generation: A Gradient-Descent Perspective25 May 2026
- 2026When Correct Demonstrations Hurt: Rethinking the Role of Exemplars in In-Context Learning25 May 2026
- 2026Large language models reorganize representational geometry during in-context learning16 May 2026
- 2026Propagation of Chaos in Contextual Flow Maps16 May 2026
- 2026Transformer-like Inference from Optimal Control15 May 2026
- 2026In-Context Learning Operates as Concept Subspace Learning12 May 2026
- 2026Spectral Transformer Neural Processes10 May 2026
- 2026Learning Theory of Transformers: Local-to-Global Approximation via Softmax Partition of Unity9 May 2026
- 2026Transformers Can Implement Preconditioned Richardson Iteration for In-Context Gaussian Kernel Regression8 May 2026
- 2026Hypothesis generation and updating in large language models7 May 2026
- 2026Transformers Provably Implement In-Context Reinforcement Learning with Policy Improvement7 May 2026
- 2026Understanding In-Context Learning for Nonlinear Regression with Transformers: Attention as Featurizer6 May 2026
- 2026When Context Sticks: Studying Interference in In-Context Learning25 Apr 2026
- 2026Ordinary Least Squares is a Special Case of Transformer15 Apr 2026
- 2026A Bayesian Perspective on the Role of Epistemic Uncertainty for Delayed Generalization in In-Context Learning14 Apr 2026
- 2026DeCoVec: Building Decoding Space based Task Vector for Large Language Models via In-Context Learning13 Apr 2026
- 2026Learning to Adapt: In-Context Learning Beyond Stationarity13 Apr 2026
- 2026Transformers Learn Latent Mixture Models In-Context via Mirror Descent12 Apr 2026
- 2026Visual prompting reimagined: The power of the Activation Prompts7 Apr 2026
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledge21 Mar 2026
50 newest of 298 All 298 (JSON)
- 2024A Theoretical Understanding of Self-Correction through In-context Alignmentcited by 44
- 2024Pre-trained Large Language Models Use Fourier Features to Compute Additioncited by 39
- 2025Bayesian Teaching Enables Probabilistic Reasoning in Large Language Modelscited by 37
- 2024EVOLvE: Evaluating and Optimizing LLMs For In-Context Explorationcited by 34
- 2025Transformers Learn to Implement Multi-step Gradient Descent with Chain of Thoughtcited by 32
- 2024Unveiling the Statistical Foundations of Chain-of-Thought Prompting Methodscited by 29
- 2024Towards a Theoretical Understanding of the 'Reversal Curse' via Training Dynamicscited by 27
- 2025How Do LLMs Perform Two-Hop Reasoning in Context?cited by 20
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysiscited by 14
- 2024A Theoretical Understanding of Chain-of-Thought: Coherent Reasoning and Error-Aware Demonstrationcited by 13
- 2025Sample Complexity and Representation Ability of Test-time Scaling Paradigmscited by 12
- 2025Rethinking Invariance in In-context Learningcited by 8
12 most cited of 22 All 22 (JSON)
- 2026Soft Guidance Starts to Outperform CoT Prompting as LLMs Improve4 Aug 2026
- 2026Grounding latent algorithm routing in transformer reasoning27 Jul 2026
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledge21 Mar 2026
- 2026Provable and Practical In-Context Policy Optimization for Self-Improvement2 Mar 2026
- 2026Outcome-Based RL Provably Leads Transformers to Reason, but Only With the Right Data21 Jan 2026
- 2025Understanding the Role of Training Data in Test-Time Scaling4 Oct 2025
- 2025Chain-of-Thought Enhanced Shallow Transformers for Wireless Symbol Detection26 Jun 2025
- 2025Sample Complexity and Representation Ability of Test-time Scaling Paradigms5 Jun 2025
- 2025Deciphering Trajectory-Aided LLM Reasoning: An Optimization Perspective26 May 2025
- 2025Learning to Rank Chain-of-Thought: Using a Small Model21 May 2025
- 2025Rethinking Invariance in In-context Learning8 May 2025
- 2025Bayesian Teaching Enables Probabilistic Reasoning in Large Language Models21 Mar 2025
12 newest of 22 All 22 (JSON)
- 2024Can Mamba Learn How to Learn? A Comparative Study on In-Context Learning Taskscited by 105
- 2024Is Mamba Capable of In-Context Learning?cited by 45
- 2025From Markov to Laplace: How Mamba In-Context Learns Markov Chainscited by 11
- 2025How Can Mamba Learn In Context with Outliers and Generalize Provably?cited by 2
- 2025Mamba Can Learn Low-Dimensional Targets In-Context via Test-Time Feature Learningcited by 1
- 2024Can Custom Models Learn In-Context? An Exploration of Hybrid Architecture Performance on In-Context Learning Taskscited by 0
- 2025Mamba Can Learn Low-Dimensional Targets In-Context via Test-Time Feature Learning14 Oct 2025
- 2025How Can Mamba Learn In Context with Outliers and Generalize Provably?1 Oct 2025
- 2025From Markov to Laplace: How Mamba In-Context Learns Markov Chains14 Feb 2025
- 2024Can Custom Models Learn In-Context? An Exploration of Hybrid Architecture Performance on In-Context Learning Tasks6 Nov 2024
- 2024Can Mamba Learn How to Learn? A Comparative Study on In-Context Learning Tasks6 Feb 2024
- 2024Is Mamba Capable of In-Context Learning?5 Feb 2024
- 2024Demonstration Selection for In-Context Learning via Reinforcement Learningcited by 8
- 2026Transformers Provably Implement In-Context Reinforcement Learning with Policy Improvementcited by 3
- 2025Optimal Dynamic Regret by Transformers for Non-Stationary Reinforcement Learningcited by 2
- 2026From Weak Data to Strong Policy: Q-Targets Enable Provable In-Context Reinforcement Learningcited by 0
- 2026From Weak Data to Strong Policy: Q-Targets Enable Provable In-Context Reinforcement Learning24 Sep 2026
- 2026Transformers Provably Implement In-Context Reinforcement Learning with Policy Improvement7 May 2026
- 2025Optimal Dynamic Regret by Transformers for Non-Stationary Reinforcement Learning22 Aug 2025
- 2024Demonstration Selection for In-Context Learning via Reinforcement Learning5 Dec 2024
- 2023The Expressive Power of Low-Rank Adaptationcited by 102
- 2023Deep Networks as Denoising Algorithms: Sample-Efficient Learning of Diffusion Models in High-Dimensional Graphical Modelscited by 39
- 2024U-Nets as Belief Propagation: Efficient Classification, Denoising, and Diffusion in Generative Hierarchical Modelscited by 17
- 2026Transformer-based In-Context Score Operator Learning for Diffusion Modelscited by 0
- 2026Transformer-based In-Context Score Operator Learning for Diffusion Models9 Oct 2026
- 2024U-Nets as Belief Propagation: Efficient Classification, Denoising, and Diffusion in Generative Hierarchical Models29 Apr 2024
- 2023The Expressive Power of Low-Rank Adaptation26 Oct 2023
- 2023Deep Networks as Denoising Algorithms: Sample-Efficient Learning of Diffusion Models in High-Dimensional Graphical Models20 Sep 2023
- 2024Everything Everywhere All at Once: LLMs can In-Context Learn Multiple Tasks in Superpositioncited by 14
- 2025Scaling sparse feature circuit finding for in-context learningcited by 5
- 2026Understanding the Dynamics of Demonstration Conflict in In-Context Learningcited by 2
- 2026Implicit Statistical Inference in Transformers: Approximating Likelihood-Ratio Tests In-Contextcited by 0
- 2026Implicit Statistical Inference in Transformers: Approximating Likelihood-Ratio Tests In-Context11 Mar 2026
- 2026Understanding the Dynamics of Demonstration Conflict in In-Context Learning3 Mar 2026
- 2025Scaling sparse feature circuit finding for in-context learning18 Apr 2025
- 2024Everything Everywhere All at Once: LLMs can In-Context Learn Multiple Tasks in Superposition8 Oct 2024
- 2025A Survey of Graph Retrieval-Augmented Generation for Customized Large Language Modelscited by 88
- 2024RAGSys: Item-Cold-Start Recommender as RAG Systemcited by 4
- 2026In-Context Optimization for Retrieval-Augmented Generation: A Gradient-Descent Perspectivecited by 2
- 2026Vector Search As Nearest Neighbor Matching: RAG-based Policy Learning in Causal Inferencecited by 0
- 2026Vector Search As Nearest Neighbor Matching: RAG-based Policy Learning in Causal Inference20 Jul 2026
- 2026In-Context Optimization for Retrieval-Augmented Generation: A Gradient-Descent Perspective25 May 2026
- 2025A Survey of Graph Retrieval-Augmented Generation for Customized Large Language Models21 Jan 2025
- 2024RAGSys: Item-Cold-Start Recommender as RAG System27 May 2024
- 2023Trained Transformers Learn Linear Models In-Contextcited by 337
- 2023Looped Transformers are Better at Learning Learning Algorithmscited by 149
- 2023The mechanistic basis of data dependence and abrupt learning in an in-context classification taskcited by 118
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
- 2023In-Context Convergence of Transformerscited by 115
- 2023Uncovering mesa-optimization algorithms in Transformerscited by 100
- 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 96
- 2024Can large language models explore in-context?cited by 76
- 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 75
- 2023Transformers as Support Vector Machinescited by 74
- 2024Can Looped Transformers Learn to Implement Multi-step Gradient Descent for In-context Learning?cited by 65
- 2023Understanding In-Context Learning in Transformers and LLMs by Learning to Learn Discrete Functionscited by 63
12 most cited of 243 All 243 (JSON)
- 2026Learning Source Structure: Bayesian Prediction with Transformers13 Oct 2026
- 2026In-context classification: Calibration and noise in linear attention with softmax readout12 Oct 2026
- 2026PDE-PFN: Prior-Data Fitted Neural PDE Solver9 Oct 2026
- 2026Retrieval-Based In-Context Learning: A Domain Adaptation Framework5 Oct 2026
- 2026When Can Prefixes Compile LoRA? Exact Resource-Capped Tests for Frozen Attention29 Sep 2026
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learning29 Sep 2026
- 2026ALICE: In-context, Zero-shot, Mutual Information Estimation28 Sep 2026
- 2026A Comparative Analysis of Attention versus State-Space Models for In-Context Learning26 Sep 2026
- 2026Retrieval-Guided Fine-Tuning as Noisy Estimation: Risk bounds and Architectural Analysis13 Sep 2026
- 2026Transformers as In-Context Samplers: From Closed-Form Diffusion to Estimation-Free Sampling8 Sep 2026
- 2026One-Layer Transformer Provably Learns Multiclass One-Nearest Neighbor in Context1 Sep 2026
- 2026Linear RNN Scaling Laws: When Longer Sequences Beat More Sequences23 Aug 2026
12 newest of 243 All 243 (JSON)