Dual Operating Modes of In-Context Learning
Ziqian Lin, Kangwook Lee
摘要
In-context learning (ICL) exhibits dual operating modes: task learning, i.e., acquiring a new skill from in-context samples, and task retrieval, i.e., locating and activating a relevant pretrained skill. Recent theoretical work investigates various mathematical models to analyze ICL, but existing models explain only one operating mode at a time. We introduce a probabilistic model, with which one can explain the dual operating modes of ICL simultaneously. Focusing on in-context learning of linear functions, we extend existing models for pretraining data by introducing multiple task groups and task-dependent input distributions. We then analyze the behavior of the optimally pretrained model under the squared loss, i.e., the MMSE estimator of the label given in-context examples. Regarding pretraining task distribution as prior and in-context examples as the observation, we derive the closed-form expression of the task posterior distribution. With the closed-form expression, we obtain a quantitative understanding of the two operating modes of ICL. Furthermore, we shed light on an unexplained phenomenon observed in practice: under certain settings, the ICL risk initially increases and then decreases with more in-context examples. Our model offers a plausible explanation for this"early ascent"phenomenon: a limited number of in-context samples may lead to the retrieval of an incorrect skill, thereby increasing the risk, which will eventually diminish as task learning takes effect with more in-context samples. We also theoretically analyze ICL with biased labels, e.g., zero-shot ICL, where in-context examples are assigned random labels. Lastly, we validate our findings and predictions via experiments involving Transformers and large language models.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 33 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Looped Transformers are Better at Learning Learning Algorithms 引用了 An Explanation of In-context Learning as Implicit Bayesian Inference
- Looped Transformers are Better at Learning Learning Algorithms 引用了 Language Models are Few-Shot Learners
- Looped Transformers are Better at Learning Learning Algorithms 引用了 Transformers Learn In-Context by Gradient Descent
- Looped Transformers are Better at Learning Learning Algorithms 引用了 What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- Transformers on Markov data: Constant depth suffices 引用了 Language Models are Few-Shot Learners
- An Explanation of In-context Learning as Implicit Bayesian Inference 引用了 Language Models are Few-Shot Learners
- Transformers Learn In-Context by Gradient Descent 引用了 Language Models are Few-Shot Learners
- Transformers Learn In-Context by Gradient Descent 引用了 What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- What Can Transformers Learn In-Context? A Case Study of Simple Function Classes 引用了 An Explanation of In-context Learning as Implicit Bayesian Inference
- What Can Transformers Learn In-Context? A Case Study of Simple Function Classes 引用了 Language Models are Few-Shot Learners
- Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic tasks 引用了 Language Models are Few-Shot Learners
- Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic tasks 引用了 Transformers Learn In-Context by Gradient Descent
- Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic tasks 引用了 What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- True Zero-Shot Inference of Dynamical Systems Preserving Long-Term Statistics 引用了 An Explanation of In-context Learning as Implicit Bayesian Inference
- True Zero-Shot Inference of Dynamical Systems Preserving Long-Term Statistics 引用了 Language Models are Few-Shot Learners
- True Zero-Shot Inference of Dynamical Systems Preserving Long-Term Statistics 引用了 Transformers Learn In-Context by Gradient Descent
- True Zero-Shot Inference of Dynamical Systems Preserving Long-Term Statistics 引用了 What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- Many-Shot In-Context Learning 引用了 An Explanation of In-context Learning as Implicit Bayesian Inference
- Many-Shot In-Context Learning 引用了 Language Models are Few-Shot Learners
- Many-Shot In-Context Learning 引用了 Transformers Learn In-Context by Gradient Descent
- Many-Shot In-Context Learning 引用了 What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
引用它的顶会 Paper33
- Many-Shot In-Context LearningRishabh Agarwal, Avi Singh, Lei Zhang, Bernd Bohnet 等NeurIPS 2024 · 271 次引用
- Looped Transformers are Better at Learning Learning AlgorithmsLiu Yang, Kangwook Lee, Robert D. Nowak, Dimitris PapailiopoulosICLR 2024 · 82 次引用
- Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic tasksTianyu He, Darshil Doshi, Aritra Das, Andrey GromovNeurIPS 2024 · 52 次引用
- Transformers on Markov data: Constant depth sufficesNived Rajaraman, Marco Bondaschi, Ashok Vardhan Makkuva, Kannan Ramchandran 等NeurIPS 2024 · 33 次引用
- True Zero-Shot Inference of Dynamical Systems Preserving Long-Term StatisticsChristoph Jürgen Hemmer, Daniel DurstewitzNeurIPS 2025 · 25 次引用
它引用的 Paper17
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- An Explanation of In-context Learning as Implicit Bayesian InferenceSang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu MaICLR 2022 · 1,030 次引用
- What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 次引用
- Transformers Learn In-Context by Gradient DescentJohannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento 等ICML 2023 · 729 次引用
- TweetEval: Unified Benchmark and Comparative Evaluation for Tweet ClassificationFrancesco Barbieri, José Camacho-Collados, Luis Espinosa Anke, Leonardo NevesEMNLP Findings 2020 · 720 次引用
相关 Paper
- When can in-context learning generalize out of task distribution?Page C. Goddard, Lindsay M. Smith, Vudtiwat Ngampruetikorn, David J. SchwabICML 2025
- Prior Forgetting and In-Context OverfittingSungyoon LeeNeurIPS 2025 · 1 次引用
- Can In-context Learning Really Generalize to Out-of-distribution Tasks?Qixun Wang, Yifei Wang, Xianghua Ying, Yisen WangICLR 2025
- In-Context Learning through the Bayesian PrismMadhur Panwar, Kabir Ahuja, Navin GoyalICLR 2024 · 79 次引用
- What Do Language Models Learn in Context? The Structured Task HypothesisJiaoda Li, Yifan Hou, Mrinmaya Sachan, Ryan CotterellACL 2024 · 5 次引用
