In-context learning and Occam's razor
Not on the map. Why?
Abstract (arXiv)
A central goal of machine learning is generalization. While the No Free Lunch Theorem states that we cannot obtain theoretical guarantees for generalization without further assumptions, in practice we observe that simple models which explain the training data generalize best: a principle called Occam's razor. Despite the need for simple models, most current approaches in machine learning only minimize the training error, and at best indirectly promote simplicity through regularization or architecture design. Here, we draw a connection between Occam's razor and in-context learning: an emergent ability of certain sequence models like Transformers to learn at inference time from past observations in a sequence. In particular, we show that the next-token prediction loss used to train in-context learners is directly equivalent to a data compression technique called prequential coding, and that minimizing this loss amounts to jointly minimizing both the training error and the complexity of the model that was implicitly learned from context. Our theory and the empirical experiments we use to support it not only provide a normative account of in-context learning, but also elucidate the shortcomings of current in-context learning methods, suggesting ways in which they can be improved. We make our code available at https://github.com/3rdCore/PrequentialCode.
Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Builds on 41 of its 68 references that are in the map. First posted on arXiv 17 Oct 2024.
Builds on
41 of 68 references.
References · 41
- 2014Adam: A Method for Stochastic Optimizationcited by 37,240
- 2023GPT-4 Technical Reportcited by 18,396
- 2023Mamba: Linear-Time Sequence Modeling with Selective State Spacescited by 4,718
- 2024Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Dualitycited by 1,336
- 2018Self-Attention with Relative Position Representationscited by 1,120
- 2022In-context Learning and Induction Headscited by 964
- 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
- 2022TabPFN: A Transformer That Solves Small Tabular Classification Problems in a Secondcited by 674
- 2021Transformers Can Do Bayesian Inferencecited by 360
29 more
- 2023Trained Transformers Learn Linear Models In-Contextcited by 337
- 2022Data Distributional Properties Drive Emergent In-Context Learning in Transformerscited by 309
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
- 2023Language Modeling Is Compressioncited by 225
- 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 199
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 170
- 2023Large Language Models Are Latent Variable Models: Explaining and Finding Good Demonstrations for In-Context Learningcited by 149
- 2023Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressioncited by 146
- 2023Human-Timescale Adaptation in an Open-Ended Task Spacecited by 138
- 2023Structured State Space Models for In-Context Reinforcement Learningcited by 111
- 2022General-Purpose In-Context Learning by Meta-Learning Transformerscited by 105
- 2023Uncovering mesa-optimization algorithms in Transformerscited by 100
- 2023In-Context Learning through the Bayesian Prismcited by 83
- 2018The Description Length of Deep Learning Modelscited by 72
- 2019Meta-learning of Sequential Strategiescited by 70
- 2023The No Free Lunch Theorem, Kolmogorov Complexity, and the Role of Inductive Biases in Machine Learningcited by 63
- 2023LLMZip: Lossless Text Compression using Large Language Modelscited by 44
- 2020Meta-trained agents implement Bayes-optimal agentscited by 38
- 2018DeepZip: Lossless Data Compression using Recurrent Neural Networkscited by 33
- 2024Learning Universal Predictorscited by 31
- 2023Deep neural networks have an inbuilt Occam's razorcited by 28
- 2023CausalLM is not optimal for in-context learningcited by 26
- 2023Memory-Based Meta-Learning on Non-Stationary Distributionscited by 15
- 2022Sequential Learning Of Neural Networks for Prequential MDLcited by 13
- 2024Does learning the right latent variables necessarily improve in-context learning?cited by 13
- 2014Compress and Controlcited by 7
- 2024Transformers for Supervised Online Continual Learningcited by 5
- 2020Measuring Information Transfer in Neural Networkscited by 4
- 2014Auto-encoders: reconstruction versus compressioncited by 3
Built on by
Citing papers per year: 2025: 5; 2026: 3.
8 papers.
- 2025On the generalization of language models from in-context learning and finetuning: a controlled studycited by 40
- 2025In-Context Parametric Inference: Point or Distribution Estimators?cited by 4
- 2025Fine-Tuned In-Context Learners for Efficient Adaptationcited by 2
- 2025Genomic Next-Token Predictors are In-Context Learnerscited by 1
- 2025Technical Debt in In-Context Learning: Diminishing Efficiency in Long Contextcited by 0
- 2026Fundamental Limitation in Explaining AIcited by 0
- 2026Can In-Context Learning Support Intrinsic Curiosity?cited by 0
- 2026Learning Source Structure: Bayesian Prediction with Transformerscited by 0
- 2026Learning Source Structure: Bayesian Prediction with Transformers13 Oct 2026
- 2026Can In-Context Learning Support Intrinsic Curiosity?17 Jun 2026
- 2026Fundamental Limitation in Explaining AI23 May 2026
- 2025Fine-Tuned In-Context Learners for Efficient Adaptation22 Dec 2025
- 2025Genomic Next-Token Predictors are In-Context Learners16 Nov 2025
- 2025On the generalization of language models from in-context learning and finetuning: a controlled study1 May 2025
- 2025In-Context Parametric Inference: Point or Distribution Estimators?17 Feb 2025
- 2025Technical Debt in In-Context Learning: Diminishing Efficiency in Long Context7 Feb 2025