In-Context Occam's Razor: How Transformers Prefer Simpler Hypotheses on the Fly
Not on the map. Why?
Abstract (arXiv)
In-context learning (ICL) enables transformers to adapt to new tasks through contextual examples without parameter updates. While existing research has typically studied ICL in fixed-complexity environments, practical language models encounter tasks spanning diverse complexity levels. This paper investigates how transformers navigate hierarchical task structures where higher-complexity categories can perfectly represent any pattern generated by simpler ones. We design well-controlled testbeds based on Markov chains and linear regression that reveal transformers not only identify the appropriate complexity level for each task but also accurately infer the corresponding parameters--even when the in-context examples are compatible with multiple complexity hypotheses. Notably, when presented with data generated by simpler processes, transformers consistently favor the least complex sufficient explanation. We theoretically explain this behavior through a Bayesian framework, demonstrating that transformers effectively implement an in-context Bayesian Occam's razor by balancing model fit against complexity penalties. We further ablate on the roles of model size, training mixture distribution, inference context length, and architecture. Finally, we validate this Occam's razor-like inductive bias on a pretrained GPT-4 model with Boolean-function tasks as case study, suggesting it may be inherent to transformers trained on diverse task distributions.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Builds on 27 of its 36 references that are in the map. First posted on arXiv 24 Jun 2025.
Builds on
27 of 36 references.
References · 27
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
- 2022Transformers learn in-context by gradient descentcited by 732
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 715
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
- 2023Trained Transformers Learn Linear Models In-Contextcited by 337
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 298
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
- 2023Label Words are Anchors: An Information Flow Perspective for Understanding In-Context Learningcited by 236
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 222
- 2023What In-Context Learning "Learns" In-Context: Disentangling Task Recognition and Task Learningcited by 152
15 more
- 2023Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressioncited by 146
- 2024The Evolution of Statistical Induction Heads: In-Context Learning Markov Chainscited by 118
- 2023In-Context Learning through the Bayesian Prismcited by 83
- 2024Training Dynamics of Multi-Head Softmax Attention for In-Context Learning: Emergence, Convergence, and Optimalitycited by 74
- 2023Understanding In-Context Learning in Transformers and LLMs by Learning to Learn Discrete Functionscited by 63
- 2024Asymptotic theory of in-context learning by linear attentioncited by 55
- 2024Competition Dynamics Shape Algorithmic Phases of In-Context Learningcited by 54
- 2024Unveiling Induction Heads: Provable Training Dynamics and Feature Learning in Transformerscited by 50
- 2023Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear Regressioncited by 49
- 2025Training Dynamics of In-Context Learning in Linear Attentioncited by 46
- 2024Dual Operating Modes of In-Context Learningcited by 43
- 2024In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initializationcited by 33
- 2024Transformers on Markov Data: Constant Depth Sufficescited by 27
- 2024Fine-grained Analysis of In-context Linear Estimation: Data, Architecture, and Beyondcited by 24
- 2024Everything Everywhere All at Once: LLMs can In-Context Learn Multiple Tasks in Superpositioncited by 14
Built on by
Citing papers per year: 2025: 1; 2026: 4.
5 papers.
- 2025Optimal In-context Adaptivity and Distributional Robustness of Transformerscited by 4
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledgecited by 3
- 2026Incremental Learning of Sparse Attention Patterns in Transformerscited by 2
- 2026Bayesian Optimality of In-Context Learning with Selective State Spacescited by 1
- 2026Learning Source Structure: Bayesian Prediction with Transformerscited by 0
- 2026Learning Source Structure: Bayesian Prediction with Transformers13 Oct 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
- 2026Bayesian Optimality of In-Context Learning with Selective State Spaces19 Feb 2026
- 2025Optimal In-context Adaptivity and Distributional Robustness of Transformers27 Oct 2025