Understanding In-Context Learning in Transformers and LLMs by Learning to Learn Discrete Functions
Not on the map. Why?
Abstract (arXiv)
In order to understand the in-context learning phenomenon, recent works have adopted a stylized experimental framework and demonstrated that Transformers can learn gradient-based learning algorithms for various classes of real-valued functions. However, the limitations of Transformers in implementing learning algorithms, and their ability to learn other forms of algorithms are not well understood. Additionally, the degree to which these capabilities are confined to attention-based models is unclear. Furthermore, it remains to be seen whether the insights derived from these stylized settings can be extrapolated to pretrained Large Language Models (LLMs). In this work, we take a step towards answering these questions by demonstrating the following: (a) On a test-bed with a variety of Boolean function classes, we find that Transformers can nearly match the optimal learning algorithm for 'simpler' tasks, while their performance deteriorates on more 'complex' tasks. Additionally, we find that certain attention-free models perform (almost) identically to Transformers on a range of tasks. (b) When provided a teaching sequence, i.e. a set of examples that uniquely identifies a function in a class, we show that Transformers learn more sample-efficiently. Interestingly, our results show that Transformers can learn to implement two distinct algorithms to solve a single task, and can adaptively select the more sample-efficient algorithm depending on the sequence of in-context examples. (c) Lastly, we show that extant LLMs, e.g. LLaMA-2, GPT-4, can compete with nearest-neighbor baselines on prediction tasks that are guaranteed to not be in their training set.
Key facts. Cited by 62 papers in the map (data through 7 Oct 2026). Builds on 35 of its 55 references that are in the map. First posted on arXiv 4 Oct 2023.
Builds on
35 of 55 references.
References · 35
- 2017Attention Is All You Needcited by 59,932
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,160
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,413
- 2021What Makes Good In-Context Examples for GPT-3?cited by 1,184
- 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,122
- 2022In-context Learning and Induction Headscited by 930
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
- 2022Transformers learn in-context by gradient descentcited by 714
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
23 more
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
- 2023Retentive Network: A Successor to Transformer for Large Language Modelscited by 594
- 2021MetaICL: Learning to Learn In Contextcited by 450
- 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
- 2023Hyena Hierarchy: Towards Larger Convolutional Language Modelscited by 388
- 2023Larger language models do in-context learning differentlycited by 386
- 2022Diagonal State Spaces are as Effective as Structured State Spacescited by 350
- 2022Data Distributional Properties Drive Emergent In-Context Learning in Transformerscited by 303
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
- 2019Theoretical Limitations of Self-Attention in Neural Sequence Modelscited by 286
- 2022Transformers Learn Shortcuts to Automatacited by 260
- 2022Neural Networks and the Chomsky Hierarchycited by 214
- 2021Noisy Channel Language Model Prompting for Few-Shot Text Classificationcited by 163
- 2022Impact of Pretraining Term Frequencies on Few-Shot Reasoningcited by 142
- 2021Saturated Transformers are Constant-Depth Threshold Circuitscited by 137
- 2019On the Turing Completeness of Modern Neural Network Architecturescited by 129
- 2022Overcoming a Theoretical Limitation of Self-Attentioncited by 110
- 2023A Theory of Emergent In-Context Learning as Implicit Structure Inductioncited by 86
- 2023In-Context Learning through the Bayesian Prismcited by 78
- 2022Simplicity Bias in Transformers and their Ability to Learn Sparse Boolean Functionscited by 68
- 2020How Can Self-Attention Networks Recognize Dyck-n Languages?cited by 51
- 2023A Closer Look at In-Context Learning under Distribution Shiftscited by 25
- 2020On the Practical Ability of Recurrent Neural Networks to Recognize Hierarchical Languagescited by 22
Built on by
Citing papers per year: 2024: 28; 2025: 24; 2026: 10.
62 papers.
Sort:
By area:
- 2024Many-Shot In-Context Learningcited by 203
- 2024Can Mamba Learn How to Learn? A Comparative Study on In-Context Learning Taskscited by 104
- 2024In-Context Language Learning: Architectures and Algorithmscited by 86
- 2024Can large language models explore in-context?cited by 75
- 2024Mechanistic Design and Scaling of Hybrid Architecturescited by 57
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 55
- 2024A Theoretical Understanding of Self-Correction through In-context Alignmentcited by 43
- 2024Elephants Never Forget: Memorization and Learning of Tabular Data in Large Language Modelscited by 34
- 2024The broader spectrum of in-context learningcited by 33
- 2024In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initializationcited by 30
- 2024Separations in the Representational Capabilities of Transformers and Recurrent Architecturescited by 29
- 2024Deeper Insights Without Updates: The Power of In-Context Learning Over Fine-Tuningcited by 20
38 more
- 2024State-Free Inference of State-Space Models: The Transfer Function Approachcited by 18
- 2025Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Pointscited by 15
- 2024Transformers Learn Low Sensitivity Functions: Investigations and Implicationscited by 13
- 2024Exploring the Robustness of In-Context Learning with Noisy Labelscited by 13
- 2024XLand-100B: A Large-Scale Multi-Task Dataset for In-Context Reinforcement Learningcited by 13
- 2024Vector-ICL: In-context Learning with Continuous Vector Representationscited by 13
- 2025Problem-Solving Logic Guided Curriculum In-Context Learning for LLMs Complex Reasoningcited by 12
- 2025Task Generalization With AutoRegressive Compositional Structure: Can Learning From D Tasks Generalize to DT Tasks?cited by 11
- 2025Compositional Generalization from Learned Skills via CoT Training: A Theoretical and Structural Analysis for Reasoningcited by 10
- 2025Beyond Induction Heads: In-Context Meta Learning Induces Multi-Phase Circuit Emergencecited by 10
- 2024On Limitation of Transformer for Learning HMMscited by 9
- 2025LLM Security: Vulnerabilities, Attacks, Defenses, and Countermeasurescited by 8
- 2025On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learningcited by 7
- 2025Solving Empirical Bayes via Transformerscited by 7
- 2025Transformer learns the cross-task prior and regularization for in-context learningcited by 7
- 2026Efficient and Minimax Optimal In-context Nonparametric Regression with Transformerscited by 7
- 2025Analyzing limits for in-context learningcited by 6
- 2025Graph Diffusion Transformers are In-Context Molecular Designerscited by 6
- 2024DETAIL: Task DEmonsTration Attribution for Interpretable In-context Learningcited by 5
- 2024On Mesa-Optimization in Autoregressively Trained Transformers: Emergence and Capabilitycited by 5
- 2024Cognitive LLMs: Towards Integrating Cognitive Architectures and Large Language Models for Manufacturing Decision-makingcited by 5
- 2024Task Diversity Shortens the ICL Plateaucited by 5
- 2024Re-examining learning linear functions in contextcited by 5
- 2024Sub-SA: Strengthen In-context Learning via Submodular Selective Annotationcited by 4
- 2024Learning vs Retrieval: The Role of In-Context Examples in Regression with Large Language Modelscited by 4
- 2025On the Robustness of Transformers against Context Hijacking for Linear Classificationcited by 4
- 2025In-Context Occam's Razor: How Transformers Prefer Simpler Hypotheses on the Flycited by 4
- 2024From Unstructured Data to In-Context Learning: Exploring What Tasks Can Be Learned and Whencited by 3
- 2025Latent Concept Disentanglement in Transformer-based Language Modelscited by 3
- 2025The Initialization Determines Whether In-Context Learning Is Gradient Descentcited by 3
- 2024Identifying and Analyzing Performance-Critical Tokens in Large Language Modelscited by 2
- 2025From predictions to confidence intervals: an empirical study of conformal prediction methods for in-context learningcited by 2
- 2025Data Shifts Hurt CoT: A Theoretical Studycited by 2
- 2025Softmax ≥ Linear: Transformers may learn to classify in-context by kernel gradient descentcited by 2
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledgecited by 2
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learningcited by 1
- 2025Assessing the Limits of In-Context Learning beyond Functions using Partially Ordered Relationcited by 1
- 2025SSA: Improving Performance With a Better Scoring Functioncited by 1
50 most cited of 62 All 62 (JSON)
- 2026Identifiability and Order-Dimension Limits of In-Context Learning on Partial Orders14 Aug 2026
- 2026Grounding latent algorithm routing in transformer reasoning27 Jul 2026
- 2026Data-Efficient Adaptation of LLMs via Attention Head Reweighting15 Jul 2026
- 2026Transformers Can Implement Preconditioned Richardson Iteration for In-Context Gaussian Kernel Regression8 May 2026
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledge21 Mar 2026
- 2026Incremental Learning of Sparse Attention Patterns in Transformers22 Feb 2026
- 2026In-Context Function Learning in Large Language Models12 Feb 2026
- 2026Trapped by simplicity: When Transformers fail to learn from noisy features9 Feb 2026
- 2026Gaussian Match-and-Copy: A Minimalist Benchmark for Studying Transformer Induction7 Feb 2026
- 2026Efficient and Minimax Optimal In-context Nonparametric Regression with Transformers21 Jan 2026
- 2025The Initialization Determines Whether In-Context Learning Is Gradient Descent3 Dec 2025
- 2025Softmax ≥ Linear: Transformers may learn to classify in-context by kernel gradient descent12 Oct 2025
38 more
- 2025Graph Diffusion Transformers are In-Context Molecular Designers9 Oct 2025
- 2025The Impact of Role Design in In-Context Learning for Large Language Models27 Sep 2025
- 2025SSA: Improving Performance With a Better Scoring Function20 Aug 2025
- 2025Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Points18 Aug 2025
- 2025Mockingbird: How does LLM perform in general machine learning tasks?6 Aug 2025
- 2025In-Context Occam's Razor: How Transformers Prefer Simpler Hypotheses on the Fly24 Jun 2025
- 2025Latent Concept Disentanglement in Transformer-based Language Models20 Jun 2025
- 2025Assessing the Limits of In-Context Learning beyond Functions using Partially Ordered Relation16 Jun 2025
- 2025Data Shifts Hurt CoT: A Theoretical Study12 Jun 2025
- 2025Beyond Induction Heads: In-Context Meta Learning Induces Multi-Phase Circuit Emergence22 May 2025
- 2025Transformer learns the cross-task prior and regularization for in-context learning17 May 2025
- 2025LLM Security: Vulnerabilities, Attacks, Defenses, and Countermeasures2 May 2025
- 2025From predictions to confidence intervals: an empirical study of conformal prediction methods for in-context learning22 Apr 2025
- 2025In-Context Learning with Hypothesis-Class Guidance27 Feb 2025
- 2025On the Robustness of Transformers against Context Hijacking for Linear Classification21 Feb 2025
- 2025Problem-Solving Logic Guided Curriculum In-Context Learning for LLMs Complex Reasoning21 Feb 2025
- 2025Solving Empirical Bayes via Transformers14 Feb 2025
- 2025Task Generalization With AutoRegressive Compositional Structure: Can Learning From D Tasks Generalize to DT Tasks?13 Feb 2025
- 2025Compositional Generalization from Learned Skills via CoT Training: A Theoretical and Structural Analysis for Reasoning7 Feb 2025
- 2025Analyzing limits for in-context learning5 Feb 2025
- 2025On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learning30 Jan 2025
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learning6 Jan 2025
- 2024The broader spectrum of in-context learning5 Dec 2024
- 2024Re-examining learning linear functions in context18 Nov 2024
- 2024Vector-ICL: In-context Learning with Continuous Vector Representations8 Oct 2024
- 2024Task Diversity Shortens the ICL Plateau7 Oct 2024
- 2024Deeper Insights Without Updates: The Power of In-Context Learning Over Fine-Tuning7 Oct 2024
- 2024Learning vs Retrieval: The Role of In-Context Examples in Regression with Large Language Models6 Sep 2024
- 2024Cognitive LLMs: Towards Integrating Cognitive Architectures and Large Language Models for Manufacturing Decision-making17 Aug 2024
- 2024Sub-SA: Strengthen In-context Learning via Submodular Selective Annotation8 Jul 2024
- 2024Separations in the Representational Capabilities of Transformers and Recurrent Architectures13 Jun 2024
- 2024XLand-100B: A Large-Scale Multi-Task Dataset for In-Context Reinforcement Learning13 Jun 2024
- 2024On Limitation of Transformer for Learning HMMs6 Jun 2024
- 2024From Unstructured Data to In-Context Learning: Exploring What Tasks Can Be Learned and When31 May 2024
- 2024A Theoretical Understanding of Self-Correction through In-context Alignment28 May 2024
- 2024On Mesa-Optimization in Autoregressively Trained Transformers: Emergence and Capability27 May 2024
- 2024DETAIL: Task DEmonsTration Attribution for Interpretable In-context Learning22 May 2024
- 2024State-Free Inference of State-Space Models: The Transfer Function Approach10 May 2024
50 newest of 62 All 62 (JSON)
- 2024A Theoretical Understanding of Self-Correction through In-context Alignmentcited by 43
- 2025Problem-Solving Logic Guided Curriculum In-Context Learning for LLMs Complex Reasoningcited by 12
- 2025Compositional Generalization from Learned Skills via CoT Training: A Theoretical and Structural Analysis for Reasoningcited by 10
- 2024Cognitive LLMs: Towards Integrating Cognitive Architectures and Large Language Models for Manufacturing Decision-makingcited by 5
- 2025Data Shifts Hurt CoT: A Theoretical Studycited by 2
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledgecited by 2
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learningcited by 1
- 2026Grounding latent algorithm routing in transformer reasoningcited by 0
- 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
- 2025Data Shifts Hurt CoT: A Theoretical Study12 Jun 2025
- 2025Problem-Solving Logic Guided Curriculum In-Context Learning for LLMs Complex Reasoning21 Feb 2025
- 2025Compositional Generalization from Learned Skills via CoT Training: A Theoretical and Structural Analysis for Reasoning7 Feb 2025
- 2025Randomly Sampled Language Reasoning Problems Elucidate Limitations of In-Context Learning6 Jan 2025
- 2024Cognitive LLMs: Towards Integrating Cognitive Architectures and Large Language Models for Manufacturing Decision-making17 Aug 2024
- 2024A Theoretical Understanding of Self-Correction through In-context Alignment28 May 2024
- 2024Many-Shot In-Context Learningcited by 203
- 2024In-Context Language Learning: Architectures and Algorithmscited by 86
- 2024Can large language models explore in-context?cited by 75
- 2024Mechanistic Design and Scaling of Hybrid Architecturescited by 57
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 55
- 2024Elephants Never Forget: Memorization and Learning of Tabular Data in Large Language Modelscited by 34
- 2024The broader spectrum of in-context learningcited by 33
- 2024In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initializationcited by 30
- 2024Separations in the Representational Capabilities of Transformers and Recurrent Architecturescited by 29
- 2024Deeper Insights Without Updates: The Power of In-Context Learning Over Fine-Tuningcited by 20
- 2024State-Free Inference of State-Space Models: The Transfer Function Approachcited by 18
- 2025Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Pointscited by 15
12 most cited of 52 All 52 (JSON)
- 2026Identifiability and Order-Dimension Limits of In-Context Learning on Partial Orders14 Aug 2026
- 2026Data-Efficient Adaptation of LLMs via Attention Head Reweighting15 Jul 2026
- 2026Transformers Can Implement Preconditioned Richardson Iteration for In-Context Gaussian Kernel Regression8 May 2026
- 2026Incremental Learning of Sparse Attention Patterns in Transformers22 Feb 2026
- 2026In-Context Function Learning in Large Language Models12 Feb 2026
- 2026Trapped by simplicity: When Transformers fail to learn from noisy features9 Feb 2026
- 2026Gaussian Match-and-Copy: A Minimalist Benchmark for Studying Transformer Induction7 Feb 2026
- 2026Efficient and Minimax Optimal In-context Nonparametric Regression with Transformers21 Jan 2026
- 2025The Initialization Determines Whether In-Context Learning Is Gradient Descent3 Dec 2025
- 2025Softmax ≥ Linear: Transformers may learn to classify in-context by kernel gradient descent12 Oct 2025
- 2025The Impact of Role Design in In-Context Learning for Large Language Models27 Sep 2025
- 2025SSA: Improving Performance With a Better Scoring Function20 Aug 2025
12 newest of 52 All 52 (JSON)