mlsanityData to 7 Oct 2026

Demonstrations, CoT, and Prompting: A Theoretical Analysis of ICL

arXiv 2603.19611 ↗First posted 20 Mar 2026cs.LGcited by 0

Not on the map. Why?

Abstract (arXiv)

In-Context Learning (ICL) enables pretrained LLMs to adapt to downstream tasks by conditioning on a small set of input-output demonstrations, without any parameter updates. Although there have been many theoretical efforts to explain how ICL works, most either rely on strong architectural or data assumptions, or fail to capture the impact of key practical factors such as demonstration selection, Chain-of-Thought (CoT) prompting, the number of demonstrations, and prompt templates. We address this gap by establishing a theoretical analysis of ICL under mild assumptions that links these design choices to generalization behavior. We derive an upper bound on the ICL test loss, showing that performance is governed by (i) the quality of selected demonstrations, quantified by Lipschitz constants of the ICL loss along paths connecting test prompts to pretraining samples, (ii) an intrinsic ICL capability of the pretrained model, and (iii) the degree of distribution shift. Within the same framework, we analyze CoT prompting as inducing a task decomposition and show that it is beneficial when demonstrations are well chosen at each substep and the resulting subtasks are easier to learn. Finally, we characterize how ICL performance sensitivity to prompt templates varies with the number of demonstrations. Together, our study shows that pretraining equips the model with the ability to generalize beyond observed tasks, while CoT enables the model to compose simpler subtasks into more complex ones, and demonstrations and instructions enable it to retrieve similar or complex tasks, including those that can be composed into more complex ones, jointly supporting generalization to unseen tasks. All theoretical insights are corroborated by experiments.

Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 41 of its 50 references that are in the map. First posted on arXiv 20 Mar 2026.

Builds on

41 of 50 references.

References · 41

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2023GPT-4 Technical Reportcited by 18,132
  3. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  4. 2021Training Verifiers to Solve Math Word Problemscited by 9,743
  5. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  6. 2020Measuring Massive Multitask Language Understandingcited by 7,768
  7. 2021Measuring Mathematical Problem Solving With the MATH Datasetcited by 5,203
  8. 2023GPQA: A Graduate-Level Google-Proof Q&A Benchmarkcited by 2,748
  9. 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,413
  10. 2021Calibrate Before Use: Improving Few-Shot Performance of Language Modelscited by 1,371
  11. 2021What Makes Good In-Context Examples for GPT-3?cited by 1,184
  12. 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
29 more
  1. 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
  2. 2022Transformers learn in-context by gradient descentcited by 714
  3. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
  4. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
  5. 2023Trained Transformers Learn Linear Models In-Contextcited by 331
  6. 2021Do Prompt-Based Models Really Understand the Meaning of their Prompts?cited by 324
  7. 2023Towards Revealing the Mystery behind Chain of Thought: A Theoretical Perspectivecited by 293
  8. 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
  9. 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
  10. 2024Chain of Thought Empowers Transformers to Solve Inherently Serial Problemscited by 256
  11. 2022Selective Annotation Makes Language Models Better Few-Shot Learnerscited by 242
  12. 2022Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizerscited by 204
  13. 2024Many-Shot In-Context Learningcited by 203
  14. 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 168
  15. 2023The Expressive Power of Low-Rank Adaptationcited by 100
  16. 2023In-Context Learning through the Bayesian Prismcited by 78
  17. 2023Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear Regressioncited by 47
  18. 2024Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscapecited by 43
  19. 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformerscited by 36
  20. 2024Transformers are Minimax Optimal Nonparametric In-Context Learnerscited by 36
  21. 2023Investigating the Effectiveness of Task-Agnostic Prefix Prompt for Instruction Followingcited by 33
  22. 2024Pretrained transformer efficiently learns low-dimensional target functions in-contextcited by 29
  23. 2023Why Can Large Language Models Generate Correct Chain-of-Thoughts?cited by 16
  24. 2023The Expressive Power of Tuning Only the Normalization Layerscited by 13
  25. 2024A Theoretical Understanding of Chain-of-Thought: Coherent Reasoning and Error-Aware Demonstrationcited by 13
  26. 2025Transformer learns the cross-task prior and regularization for in-context learningcited by 7
  27. 2025In-Context Linear Regression Demystified: Training Dynamics and Mechanistic Interpretability of Multi-Head Softmax Attentioncited by 6
  28. 2025Provable In-Context Learning of Nonlinear Regression with Transformerscited by 4
  29. 2025Towards Auto-Regressive Next-Token Prediction: In-Context Learning Emerges from Generalizationcited by 3

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2023Dr.ICL: Demonstration-Retrieved In-context Learning
  2. 2026Many-Shot CoT-ICL: Making In-Context Learning Truly Learn
  3. 2024Investigating the Pre-Training Dynamics of In-Context Learning: Task Recognition vs. Task Learning
  4. 2025Is In-Context Learning Learning?
  5. 2023Are Human-generated Demonstrations Necessary for In-context Learning?
  6. 2024Does In-Context Learning Really Learn? Rethinking How Large Language Models Respond and Solve Tasks via In-Context Learning
  7. 2024From Introspection to Best Practices: Principled Analysis of Demonstrations in Multimodal In-Context Learning
  8. 2025Refract ICL: Rethinking Example Selection in the Era of Million-Token Models