mlsanityData to 7 Oct 2026

Transformers are Universal In-context Learners

arXiv 2408.01367 ↗First posted 2 Aug 2024cs.CL stat.MLcited by 42

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

  1. 2017Attention Is All You Needcited by 59,932
  2. 2020Language Models are Few-Shot Learnerscited by 32,199
  3. 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
  4. 2016PointNet: Deep Learning on Point Sets for 3D Classification and Segmentationcited by 5,223
  5. 2018How Powerful are Graph Neural Networks?cited by 4,355
  6. 2016Error bounds for approximations with deep ReLU networkscited by 567
  7. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
  8. 2023Trained Transformers Learn Linear Models In-Contextcited by 331
  9. 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
  10. 2019Universal Invariant and Equivariant Graph Neural Networkscited by 182
  11. 2018Universality of Deep Convolutional Neural Networkscited by 176
  12. 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 168
21 more
  1. 2023A mathematical perspective on Transformerscited by 160
  2. 2021Sinkformers: Transformers with Doubly Stochastic Attentioncited by 136
  3. 2023The emergence of clusters in self-attention dynamicscited by 133
  4. 2017Approximating Continuous Functions by ReLU Nets of Minimal Widthcited by 120
  5. 2023What Formal Languages Can Transformers Express? A Surveycited by 120
  6. 2023Uncovering mesa-optimization algorithms in Transformerscited by 94
  7. 2023Attending to Graph Transformerscited by 81
  8. 2023Tighter Bounds on the Expressivity of Transformer Encoderscited by 65
  9. 2022Your Transformer May Not be as Powerful as You Expectcited by 55
  10. 2023How Smooth Is Attention?cited by 44
  11. 2020A Mathematical Theory of Attentioncited by 43
  12. 2021Universal Approximation Theorems for Differentiable Geometric Deep Learningcited by 41
  13. 2023Sumformer: Universal Approximation for Efficient Transformerscited by 30
  14. 2019Deep neural networks, generic universal interpolation, and controlled ODEscited by 28
  15. 2024How do Transformers perform In-Context Autoregressive Learning?cited by 16
  16. 2018Stochastic Deep Networkscited by 13
  17. 2023Globally injective and bijective neural operatorscited by 13
  18. 2022Small Transformers Compute Universal Metric Embeddingscited by 12
  19. 2024Generic controllability of equivariant systems and applications to particle systems and neural networkscited by 8
  20. 2023An Approximation Theory for Metric Space-Valued Functions With A View Towards Deep Learningcited by 7
  21. 2024Transformers are Expressive, But Are They Expressive Enough for Regression?cited by 6

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 4; 2025: 18; 2026: 20.

42 papers.

Sort:

By area:

  1. 2024Large Language Models as Markov Chainscited by 33
  2. 2024Measure-to-measure interpolation using Transformerscited by 28
  3. 2025Understanding Multimodal LLMs Under Distribution Shifts: An Information-Theoretic Approachcited by 15
  4. 2024Towards Understanding the Universality of Transformers for Next-Token Predictioncited by 9
  5. 2024Universal Approximation of Mean-Field Models via Transformerscited by 7
  6. 2025Solving Empirical Bayes via Transformerscited by 7
  7. 2025Transformer learns the cross-task prior and regularization for in-context learningcited by 7
  8. 2025Autoregressive Language Models are Secretly Energy-Based Models: Insights into the Lookahead Capabilities of Next-Token Predictioncited by 7
  9. 2025Transformers through the lens of support-preserving maps between measurescited by 5
  10. 2025Optimal and Diffusion Transports in Machine Learningcited by 5
  11. 2026Clustering in Deep Stochastic Transformerscited by 5
  12. 2026Approximation Theory for Lipschitz Continuous Transformerscited by 5
30 more
  1. 2025DDEQs: Distributional Deep Equilibrium Models through Wasserstein Gradient Flowscited by 4
  2. 2025Transformers Meet In-Context Learning: A Universal Approximation Theorycited by 4
  3. 2025New universal operator approximation theorem for encoder-decoder architecturescited by 3
  4. 2025Attention-based clusteringcited by 3
  5. 2025Optimization-Inspired Few-Shot Adaptation for Large Language Modelscited by 3
  6. 2025Exact Sequence Interpolation with Transformerscited by 2
  7. 2025A unified framework for establishing the universal approximation of transformer-type architecturescited by 2
  8. 2025A Mathematical Explanation of Transformerscited by 2
  9. 2025Sliced ReLU attention: Quasi-linear contextual expressivity via sortingcited by 2
  10. 2026On the Expressive Power of Floating-Point Transformerscited by 2
  11. 2026One Operator for Many Densities: Amortized Approximation of Conditioning by Neural Operatorscited by 2
  12. 2026Propagation of Chaos in Contextual Flow Mapscited by 2
  13. 2026Function graph transformers universally approximate operators between function spacescited by 2
  14. 2025Assessing the Limits of In-Context Learning beyond Functions using Partially Ordered Relationcited by 1
  15. 2026Flowers: A Warp Drive for Neural PDE Solverscited by 1
  16. 2026On the Expressive Power of Transformers for Contextual Relationscited by 1
  17. 2026Training Infinitely Deep and Wide Transformerscited by 1
  18. 2026Any-Dimensional Learning by Samplingcited by 1
  19. 2025Semialgebraic Neural Networks: From roots to representationscited by 0
  20. 2025Optimal Dynamic Regret by Transformers for Non-Stationary Reinforcement Learningcited by 0
  21. 2026Relational Knowledge Distillation Using Fine-tuned Function Vectorscited by 0
  22. 2026Universal priors: solving empirical Bayes via Bayesian inference and pretrainingcited by 0
  23. 2026Adaptivity Under Realizability Constraints: Comparing In-Context and Agentic Learningcited by 0
  24. 2026Attention-based PCAcited by 0
  25. 2026How Many Different Outputs Can a Transformer Generate?cited by 0
  26. 2026Identifiability and Order-Dimension Limits of In-Context Learning on Partial Orderscited by 0
  27. 2026Quasi Linear Kernel Attention with Infinite Capacitycited by 0
  28. 2026Universal Approximation of Measure-to-Measure Operators by Pushforwardscited by 0
  29. 2026The Role of Feed-Forward Layers in Transformer Dynamicscited by 0
  30. 2026Universal interpolation for deep residual self-attention networkscited by 0