Transformers are Universal In-context Learners
Not on the map. Why?
Abstract (arXiv)
Transformers are deep architectures that define "in-context mappings" which enable predicting new tokens based on a given set of tokens (such as a prompt in NLP applications or a set of patches for a vision transformer). In this work, we study in particular the ability of these architectures to handle an arbitrarily large number of context tokens. To mathematically, uniformly address their expressivity, we consider the case that the mappings are conditioned on a context represented by a probability distribution of tokens which becomes discrete for a finite number of these. The relevant notion of smoothness then corresponds to continuity in terms of the Wasserstein distance between these contexts. We demonstrate that deep transformers are universal and can approximate continuous in-context mappings to arbitrary precision, uniformly over compact token domains. A key aspect of our results, compared to existing findings, is that for a fixed precision, a single transformer can operate on an arbitrary (even infinite) number of tokens. Additionally, it operates with a fixed embedding dimension of tokens (this dimension does not increase with precision) and a fixed number of heads (proportional to the dimension). The use of MLPs between multi-head attention layers is also explicitly controlled. We consider both unmasked attentions (as used for the vision transformer) and masked causal attentions (as used for NLP and time series applications). We tackle the causal setting leveraging a space-time lifting to analyze causal attention as a mapping over probability distributions of tokens.
Key facts. Cited by 42 papers in the map (data through 7 Oct 2026). Builds on 33 of its 45 references that are in the map. First posted on arXiv 2 Aug 2024.
Builds on
33 of 45 references.
References · 33
- 2017Attention Is All You Needcited by 59,932
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2016PointNet: Deep Learning on Point Sets for 3D Classification and Segmentationcited by 5,223
- 2018How Powerful are Graph Neural Networks?cited by 4,355
- 2016Error bounds for approximations with deep ReLU networkscited by 567
- 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
- 2019Universal Invariant and Equivariant Graph Neural Networkscited by 182
- 2018Universality of Deep Convolutional Neural Networkscited by 176
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 168
21 more
- 2023A mathematical perspective on Transformerscited by 160
- 2021Sinkformers: Transformers with Doubly Stochastic Attentioncited by 136
- 2023The emergence of clusters in self-attention dynamicscited by 133
- 2017Approximating Continuous Functions by ReLU Nets of Minimal Widthcited by 120
- 2023What Formal Languages Can Transformers Express? A Surveycited by 120
- 2023Uncovering mesa-optimization algorithms in Transformerscited by 94
- 2023Attending to Graph Transformerscited by 81
- 2023Tighter Bounds on the Expressivity of Transformer Encoderscited by 65
- 2022Your Transformer May Not be as Powerful as You Expectcited by 55
- 2023How Smooth Is Attention?cited by 44
- 2020A Mathematical Theory of Attentioncited by 43
- 2021Universal Approximation Theorems for Differentiable Geometric Deep Learningcited by 41
- 2023Sumformer: Universal Approximation for Efficient Transformerscited by 30
- 2019Deep neural networks, generic universal interpolation, and controlled ODEscited by 28
- 2024How do Transformers perform In-Context Autoregressive Learning?cited by 16
- 2018Stochastic Deep Networkscited by 13
- 2023Globally injective and bijective neural operatorscited by 13
- 2022Small Transformers Compute Universal Metric Embeddingscited by 12
- 2024Generic controllability of equivariant systems and applications to particle systems and neural networkscited by 8
- 2023An Approximation Theory for Metric Space-Valued Functions With A View Towards Deep Learningcited by 7
- 2024Transformers are Expressive, But Are They Expressive Enough for Regression?cited by 6
Built on by
Citing papers per year: 2024: 4; 2025: 18; 2026: 20.
42 papers.
Sort:
By area:
- 2024Large Language Models as Markov Chainscited by 33
- 2024Measure-to-measure interpolation using Transformerscited by 28
- 2025Understanding Multimodal LLMs Under Distribution Shifts: An Information-Theoretic Approachcited by 15
- 2024Towards Understanding the Universality of Transformers for Next-Token Predictioncited by 9
- 2024Universal Approximation of Mean-Field Models via Transformerscited by 7
- 2025Solving Empirical Bayes via Transformerscited by 7
- 2025Transformer learns the cross-task prior and regularization for in-context learningcited by 7
- 2025Autoregressive Language Models are Secretly Energy-Based Models: Insights into the Lookahead Capabilities of Next-Token Predictioncited by 7
- 2025Transformers through the lens of support-preserving maps between measurescited by 5
- 2025Optimal and Diffusion Transports in Machine Learningcited by 5
- 2026Clustering in Deep Stochastic Transformerscited by 5
- 2026Approximation Theory for Lipschitz Continuous Transformerscited by 5
30 more
- 2025DDEQs: Distributional Deep Equilibrium Models through Wasserstein Gradient Flowscited by 4
- 2025Transformers Meet In-Context Learning: A Universal Approximation Theorycited by 4
- 2025New universal operator approximation theorem for encoder-decoder architecturescited by 3
- 2025Attention-based clusteringcited by 3
- 2025Optimization-Inspired Few-Shot Adaptation for Large Language Modelscited by 3
- 2025Exact Sequence Interpolation with Transformerscited by 2
- 2025A unified framework for establishing the universal approximation of transformer-type architecturescited by 2
- 2025A Mathematical Explanation of Transformerscited by 2
- 2025Sliced ReLU attention: Quasi-linear contextual expressivity via sortingcited by 2
- 2026On the Expressive Power of Floating-Point Transformerscited by 2
- 2026One Operator for Many Densities: Amortized Approximation of Conditioning by Neural Operatorscited by 2
- 2026Propagation of Chaos in Contextual Flow Mapscited by 2
- 2026Function graph transformers universally approximate operators between function spacescited by 2
- 2025Assessing the Limits of In-Context Learning beyond Functions using Partially Ordered Relationcited by 1
- 2026Flowers: A Warp Drive for Neural PDE Solverscited by 1
- 2026On the Expressive Power of Transformers for Contextual Relationscited by 1
- 2026Training Infinitely Deep and Wide Transformerscited by 1
- 2026Any-Dimensional Learning by Samplingcited by 1
- 2025Semialgebraic Neural Networks: From roots to representationscited by 0
- 2025Optimal Dynamic Regret by Transformers for Non-Stationary Reinforcement Learningcited by 0
- 2026Relational Knowledge Distillation Using Fine-tuned Function Vectorscited by 0
- 2026Universal priors: solving empirical Bayes via Bayesian inference and pretrainingcited by 0
- 2026Adaptivity Under Realizability Constraints: Comparing In-Context and Agentic Learningcited by 0
- 2026Attention-based PCAcited by 0
- 2026How Many Different Outputs Can a Transformer Generate?cited by 0
- 2026Identifiability and Order-Dimension Limits of In-Context Learning on Partial Orderscited by 0
- 2026Quasi Linear Kernel Attention with Infinite Capacitycited by 0
- 2026Universal Approximation of Measure-to-Measure Operators by Pushforwardscited by 0
- 2026The Role of Feed-Forward Layers in Transformer Dynamicscited by 0
- 2026Universal interpolation for deep residual self-attention networkscited by 0
- 2026Universal interpolation for deep residual self-attention networks1 Oct 2026
- 2026The Role of Feed-Forward Layers in Transformer Dynamics28 Sep 2026
- 2026Universal Approximation of Measure-to-Measure Operators by Pushforwards28 Sep 2026
- 2026Quasi Linear Kernel Attention with Infinite Capacity28 Sep 2026
- 2026Identifiability and Order-Dimension Limits of In-Context Learning on Partial Orders14 Aug 2026
- 2026Any-Dimensional Learning by Sampling8 Jul 2026
- 2026How Many Different Outputs Can a Transformer Generate?21 May 2026
- 2026Attention-based PCA18 May 2026
- 2026Function graph transformers universally approximate operators between function spaces18 May 2026
- 2026Training Infinitely Deep and Wide Transformers17 May 2026
- 2026Propagation of Chaos in Contextual Flow Maps16 May 2026
- 2026One Operator for Many Densities: Amortized Approximation of Conditioning by Neural Operators7 May 2026
30 more
- 2026Adaptivity Under Realizability Constraints: Comparing In-Context and Agentic Learning6 May 2026
- 2026On the Expressive Power of Transformers for Contextual Relations26 Mar 2026
- 2026Flowers: A Warp Drive for Neural PDE Solvers17 Feb 2026
- 2026Approximation Theory for Lipschitz Continuous Transformers17 Feb 2026
- 2026Universal priors: solving empirical Bayes via Bayesian inference and pretraining16 Feb 2026
- 2026Clustering in Deep Stochastic Transformers29 Jan 2026
- 2026On the Expressive Power of Floating-Point Transformers23 Jan 2026
- 2026Relational Knowledge Distillation Using Fine-tuned Function Vectors13 Jan 2026
- 2025Autoregressive Language Models are Secretly Energy-Based Models: Insights into the Lookahead Capabilities of Next-Token Prediction17 Dec 2025
- 2025Sliced ReLU attention: Quasi-linear contextual expressivity via sorting12 Dec 2025
- 2025Optimal and Diffusion Transports in Machine Learning7 Dec 2025
- 2025A Mathematical Explanation of Transformers5 Oct 2025
- 2025Transformers through the lens of support-preserving maps between measures30 Sep 2025
- 2025Optimal Dynamic Regret by Transformers for Non-Stationary Reinforcement Learning22 Aug 2025
- 2025A unified framework for establishing the universal approximation of transformer-type architectures30 Jun 2025
- 2025Assessing the Limits of In-Context Learning beyond Functions using Partially Ordered Relation16 Jun 2025
- 2025Transformers Meet In-Context Learning: A Universal Approximation Theory5 Jun 2025
- 2025Optimization-Inspired Few-Shot Adaptation for Large Language Models25 May 2025
- 2025Attention-based clustering19 May 2025
- 2025Transformer learns the cross-task prior and regularization for in-context learning17 May 2025
- 2025New universal operator approximation theorem for encoder-decoder architectures31 Mar 2025
- 2025DDEQs: Distributional Deep Equilibrium Models through Wasserstein Gradient Flows3 Mar 2025
- 2025Solving Empirical Bayes via Transformers14 Feb 2025
- 2025Exact Sequence Interpolation with Transformers4 Feb 2025
- 2025Understanding Multimodal LLMs Under Distribution Shifts: An Information-Theoretic Approach1 Feb 2025
- 2025Semialgebraic Neural Networks: From roots to representations2 Jan 2025
- 2024Measure-to-measure interpolation using Transformers7 Nov 2024
- 2024Universal Approximation of Mean-Field Models via Transformers6 Oct 2024
- 2024Towards Understanding the Universality of Transformers for Next-Token Prediction3 Oct 2024
- 2024Large Language Models as Markov Chains3 Oct 2024
- 2024Large Language Models as Markov Chainscited by 33
- 2024Measure-to-measure interpolation using Transformerscited by 28
- 2024Towards Understanding the Universality of Transformers for Next-Token Predictioncited by 9
- 2024Universal Approximation of Mean-Field Models via Transformerscited by 7
- 2025Solving Empirical Bayes via Transformerscited by 7
- 2025Transformer learns the cross-task prior and regularization for in-context learningcited by 7
- 2025Autoregressive Language Models are Secretly Energy-Based Models: Insights into the Lookahead Capabilities of Next-Token Predictioncited by 7
- 2025Transformers through the lens of support-preserving maps between measurescited by 5
- 2025Optimal and Diffusion Transports in Machine Learningcited by 5
- 2026Clustering in Deep Stochastic Transformerscited by 5
- 2026Approximation Theory for Lipschitz Continuous Transformerscited by 5
- 2025DDEQs: Distributional Deep Equilibrium Models through Wasserstein Gradient Flowscited by 4
12 most cited of 40 All 40 (JSON)
- 2026Universal interpolation for deep residual self-attention networks1 Oct 2026
- 2026The Role of Feed-Forward Layers in Transformer Dynamics28 Sep 2026
- 2026Universal Approximation of Measure-to-Measure Operators by Pushforwards28 Sep 2026
- 2026Quasi Linear Kernel Attention with Infinite Capacity28 Sep 2026
- 2026Identifiability and Order-Dimension Limits of In-Context Learning on Partial Orders14 Aug 2026
- 2026Any-Dimensional Learning by Sampling8 Jul 2026
- 2026How Many Different Outputs Can a Transformer Generate?21 May 2026
- 2026Attention-based PCA18 May 2026
- 2026Function graph transformers universally approximate operators between function spaces18 May 2026
- 2026Training Infinitely Deep and Wide Transformers17 May 2026
- 2026Propagation of Chaos in Contextual Flow Maps16 May 2026
- 2026One Operator for Many Densities: Amortized Approximation of Conditioning by Neural Operators7 May 2026
12 newest of 40 All 40 (JSON)