mlsanityData to 14 Oct 2026

Towards Compute-Optimal Many-Shot In-Context Learning

arXiv 2507.16217 ↗First posted 22 Jul 2025cs.CL cs.AI cs.LGcited by 3

Not on the map. Why?

Abstract (arXiv)

Long-context large language models (LLMs) are able to process inputs containing up to several million tokens. In the scope of in-context learning (ICL), this translates into using hundreds/thousands of demonstrations in the input prompt, enabling many-shot ICL. In practice, a fixed set of demonstrations is often selected at random in many-shot settings due to (1) high inference costs, (2) the benefits of caching and reusing computations, and (3) the similar performance offered by this strategy compared to others when scaled. In this work, we propose two straightforward strategies for demonstration selection in many-shot ICL that improve performance with minimal computational overhead. Our first method combines a small number of demonstrations, selected based on their similarity to each test sample, with a disproportionately larger set of random demonstrations that are cached. The second strategy improves the first by replacing random demonstrations with those selected using centroids derived from test sample representations via k-means clustering. Our experiments with Gemini Pro and Flash across several datasets indicate that our strategies consistently outperform random selection and surpass or match the most performant selection approach while supporting caching and reducing inference cost by up to an order of magnitude. We also show that adjusting the proportion of demonstrations selected based on different criteria can balance performance and inference cost in many-shot ICL.

Key facts. Cited by 3 papers in the map (data through 14 Oct 2026). Builds on 34 of its 47 references that are in the map. First posted on arXiv 22 Jul 2025.

Builds on

34 of 47 references.

References · 34

  1. 2017Attention Is All You Needcited by 60,361
  2. 2020Language Models are Few-Shot Learnerscited by 32,419
  3. 2024Gemini 1.5: Unlocking multimodal understanding across millions of tokens of contextcited by 3,224
  4. 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,807
  5. 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
  6. 2021Calibrate Before Use: Improving Few-Shot Performance of Language Modelscited by 1,392
  7. 2021What Makes Good In-Context Examples for GPT-3?cited by 1,195
  8. 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,135
  9. 2019Adversarial NLI: A New Benchmark for Natural Language Understandingcited by 807
  10. 2022Transformers learn in-context by gradient descentcited by 732
  11. 2024LLMs-as-Judges: A Comprehensive Survey on LLM-based Evaluation Methodscited by 465
  12. 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 313
22 more
  1. 2023In-Context Learning Creates Task Vectorscited by 312
  2. 2023Sentiment Analysis in the Era of Large Language Models: A Reality Checkcited by 268
  3. 2024Many-Shot In-Context Learningcited by 206
  4. 2022Active Example Selection for In-Context Learningcited by 196
  5. 2024Data Engineering for Scaling Language Models to 128K Contextcited by 186
  6. 2023Time Travel in LLMs: Tracing Data Contamination in Large Language Modelscited by 177
  7. 2024GSM-Plus: A Comprehensive Benchmark for Evaluating the Robustness of LLMs as Mathematical Problem Solverscited by 158
  8. 2022LIFT: Language-Interfaced Fine-Tuning for Non-Language Machine Learning Taskscited by 148
  9. 2024In-Context Learning with Long-Context Models: An In-Depth Explorationcited by 128
  10. 2022Ground-Truth Labels Matter: A Deeper Look into Input-Label Demonstrationscited by 116
  11. 2024Gecko: Versatile Text Embeddings Distilled from Large Language Modelscited by 83
  12. 2022Structured Prompting: Scaling In-Context Learning to 1,000 Examplescited by 81
  13. 2024Many-Shot In-Context Learning in Multimodal Foundation Modelscited by 67
  14. 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 57
  15. 2023How Do In-Context Examples Affect Compositional Generalization?cited by 51
  16. 2024Dual Operating Modes of In-Context Learningcited by 43
  17. 2024Teach Better or Show Smarter? On Instructions and Exemplars in Automatic Prompt Optimizationcited by 29
  18. 2025From Few to Many: Self-Improving Many-Shot Reasoners Through Iterative Optimization and Generationcited by 21
  19. 2024Can Many-Shot In-Context Learning Help LLMs as Evaluators? A Preliminary Empirical Studycited by 15
  20. 2024Revisiting In-Context Learning with Long Context Language Modelscited by 8
  21. 2024Many-Shot In-Context Learning for Molecular Inverse Designcited by 6
  22. 2024Memorization in In-Context Learningcited by 6

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 3.

3 papers.