mlsanityData to 14 Oct 2026

Selecting Demonstrations for Many-Shot In-Context Learning via Gradient Matching

arXiv 2506.04579 ↗First posted 5 Jun 2025cs.CLcited by 3

Not on the map. Why?

Abstract (arXiv)

In-Context Learning (ICL) empowers Large Language Models (LLMs) for rapid task adaptation without Fine-Tuning (FT), but its reliance on demonstration selection remains a critical challenge. While many-shot ICL shows promising performance through scaled demonstrations, the selection method for many-shot demonstrations remains limited to random selection in existing work. Since the conventional instance-level retrieval is not suitable for many-shot scenarios, we hypothesize that the data requirements for in-context learning and fine-tuning are analogous. To this end, we introduce a novel gradient matching approach that selects demonstrations by aligning fine-tuning gradients between the entire training set of the target task and the selected examples, so as to approach the learning effect on the entire training set within the selected examples. Through gradient matching on relatively small models, e.g., Qwen2.5-3B or Llama3-8B, our method consistently outperforms random selection on larger LLMs from 4-shot to 128-shot scenarios across 9 diverse datasets. For instance, it surpasses random selection by 4% on Qwen2.5-72B and Llama3-70B, and by around 2% on 5 closed-source LLMs. This work unlocks more reliable and effective many-shot ICL, paving the way for its broader application.

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

Builds on

34 of 44 references.

References · 34

  1. 2017Attention Is All You Needcited by 60,361
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  3. 2020Language Models are Few-Shot Learnerscited by 32,419
  4. 2024The Llama 3 Herd of Modelscited by 14,715
  5. 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,944
  6. 2019HellaSwag: Can a Machine Really Finish Your Sentence?cited by 4,100
  7. 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,915
  8. 2017A Broad-Coverage Challenge Corpus for Sentence Understanding through Inferencecited by 2,682
  9. 2018CommonsenseQA: A Question Answering Challenge Targeting Commonsense Knowledgecited by 1,822
  10. 2021What Makes Good In-Context Examples for GPT-3?cited by 1,195
  11. 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,135
  12. 2024M3-Embedding: Multi-Linguality, Multi-Functionality, Multi-Granularity Text Embeddings Through Self-Knowledge Distillationcited by 1,073
22 more
  1. 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 740
  2. 2021Learning To Retrieve Prompts for In-Context Learningcited by 648
  3. 2020Dataset Condensation with Gradient Matchingcited by 516
  4. 2022Complexity-Based Prompting for Multi-Step Reasoningcited by 388
  5. 2021True Few-Shot Learning with Language Modelscited by 344
  6. 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 313
  7. 2022Demystifying Prompts in Language Models via Perplexity Estimationcited by 216
  8. 2022Active Example Selection for In-Context Learningcited by 196
  9. 2020MTOP: A Comprehensive Multilingual Task-Oriented Semantic Parsing Benchmarkcited by 158
  10. 2023Large Language Models Are Latent Variable Models: Explaining and Finding Good Demonstrations for In-Context Learningcited by 149
  11. 2020Compositional Generalization and Natural Language Variation: Can a Semantic Parsing Approach Handle Both?cited by 147
  12. 2023Compositional Exemplars for In-context Learningcited by 144
  13. 2023Unified Demonstration Retriever for In-Context Learningcited by 142
  14. 2020Break It Down: A Question Understanding Benchmarkcited by 131
  15. 2024In-Context Learning with Long-Context Models: An In-Depth Explorationcited by 128
  16. 2020Task-Oriented Dialogue as Dataflow Synthesiscited by 122
  17. 2018NL2Bash: A Corpus and Semantic Parser for Natural Language Interface to the Linux Operating Systemcited by 98
  18. 2023Dr.ICL: Demonstration-Retrieved In-context Learningcited by 72
  19. 2024Many-Shot In-Context Learning in Multimodal Foundation Modelscited by 67
  20. 2024Can Many-Shot In-Context Learning Help LLMs as Evaluators? A Preliminary Empirical Studycited by 15
  21. 2023PaRaDe: Passage Ranking using Demonstrations with Large Language Modelscited by 10
  22. 2021Question Decomposition with Dependency Graphscited by 7

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 1; 2026: 2.

3 papers.