Many-Shot In-Context Learning

Rishabh Agarwal, Avi Singh, Lei M. Zhang, Bernd Bohnet, Luis Rosias +10 more
4/17/2024
cs.LGcs.AIcs.CL

No official code found. Best implementation: CyberAgentAILab/cheat-sheet-icl (6 stars, MIT, last commit 2025-11-21). 3 more below.

Abstract

Large language models (LLMs) excel at few-shot in-context learning (ICL) -- learning from a few examples provided in context at inference, without any weight updates. Newly expanded context windows allow us to investigate ICL with hundreds or thousands of examples -- the many-shot regime. Going from few-shot to many-shot, we observe significant performance gains across a wide variety of generative and discriminative tasks. While promising, many-shot ICL can be bottlenecked by the available amount of human-generated examples. To mitigate this limitation, we explore two new settings: Reinforced and Unsupervised ICL. Reinforced ICL uses model-generated chain-of-thought rationales in place of human examples. Unsupervised ICL removes rationales from the prompt altogether, and prompts the model only with domain-specific questions. We find that both Reinforced and Unsupervised ICL can be quite effective in the many-shot regime, particularly on complex reasoning tasks. Finally, we demonstrate that, unlike few-shot learning, many-shot learning is effective at overriding pretraining biases, can learn high-dimensional functions with numerical inputs, and performs comparably to fine-tuning. We also find that inference cost increases linearly in the many-shot regime, and frontier LLMs benefit from many-shot ICL to varying degrees. Our analysis also reveals the limitations of next-token prediction loss as an indicator of downstream ICL performance.

View on arXivView PDF

Code Implementations(4)

MIT

Source Code for ACL2025-Findings paper: Selecting Demonstrations for Many-Shot In-Context Learning via Gradient Matching

20PythonMay 29, 20251 years agoMIT

My UCL master's dissertation on LoRA fine-tuning and many-shot in-context learning for historical machine translation.

00Python, Jupyter NotebookOct 31, 20241 years ago
MIT

[EMNLP 2025 Findings] Code for "Distilling Many-Shot In-Context Learning into a Cheat Sheet"

60Shell, PythonSep 25, 202511 months agoMIT

Sparse KV Cache for Many-shot-In-Context-Learning

00C, C++Aug 27, 202511 months ago

Similar Papers

Cite this paper

@article{agarwal2024manyshot,
  title  = {Many-Shot In-Context Learning},
  author = {Rishabh Agarwal and Avi Singh and Lei M. Zhang and Bernd Bohnet and Luis Rosias and Stephanie Chan and Biao Zhang and Ankesh Anand and Zaheer Abbas and Azade Nova and John D. Co-Reyes and Eric Chu and Feryal Behbahani and Aleksandra Faust and Hugo Larochelle},
  year   = {2024},
  eprint = {2404.11018},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2404.11018},
  url    = {http://arxiv.org/abs/2404.11018v3},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2404.11018.svg)](https://codeofpaper.com/paper/2404.11018)

Discussion