Linear-Time Demonstration Selection for In-Context Learning via Gradient Estimation
Ziniu Zhang, Zhenshuo Zhang, Dongyue Li, Lu Wang, Jennifer G. Dy, Hongyang R. Zhang
摘要
This paper introduces an algorithm to select demonstration examples for in-context learning of a query set. Given a set of n examples, how can we quickly select k out of n to best serve as the conditioning for downstream inference? This problem has broad applications in prompt tuning and chain-of-thought reasoning. Since model weights remain fixed during in-context learning, previous work has sought to design methods based on the similarity of token embeddings. This work proposes a new approach based on gradients of the output taken in the input embedding space. Our approach estimates model outputs through a first-order approximation using the gradients. Then, we apply this estimation to multiple randomly sampled subsets. Finally, we aggregate the sampled subset outcomes to form an influence score for each demonstration, and select k most relevant examples. This procedure only requires precomputing model outputs and gradients once, resulting in a linear-time algorithm relative to model and training set sizes. Extensive experiments across various models and datasets validate the efficiency of our approach. We show that the gradient estimation procedure yields approximations of full inference with less than 1% error across six datasets. This allows us to scale up subset selection that would otherwise run full inference by up to 37.7× on models with up to 34 billion parameters, and outperform existing selection methods based on input embeddings by 11% on average.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 5 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- WinQ: Accelerating Quantization-Aware Training of Language Models Around Saddle Points 引用了 Efficient Estimation of Kernel Surrogate Models for Task Attribution
- WinQ: Accelerating Quantization-Aware Training of Language Models Around Saddle Points 引用了 Scalable Multi-Objective and Meta Reinforcement Learning via Gradient Estimation
- Efficient Estimation of Kernel Surrogate Models for Task Attribution 引用了 Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?
- Efficient Estimation of Kernel Surrogate Models for Task Attribution 引用了 Scalable Multi-Objective and Meta Reinforcement Learning via Gradient Estimation
- Efficient Estimation of Kernel Surrogate Models for Task Attribution 引用了 What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- Rethinking the Role of Demonstrations: What Makes In-Context Learning Work? 引用了 Language Models are Few-Shot Learners
- Scalable Multi-Objective and Meta Reinforcement Learning via Gradient Estimation 引用了 Gradient Surgery for Multi-Task Learning
- What Can Transformers Learn In-Context? A Case Study of Simple Function Classes 引用了 Language Models are Few-Shot Learners
引用它的顶会 Paper5
- Efficient Estimation of Kernel Surrogate Models for Task AttributionZhenshuo Zhang, Minxuan Duan, Hongyang R. ZhangICLR 2026 · 6 次引用
- Scalable Multi-Objective and Meta Reinforcement Learning via Gradient EstimationZhenshuo Zhang, Minxuan Duan, Youran Ye, Hongyang R. ZhangAAAI 2026 · 3 次引用
- Unsupervised Process-Aware Coreset Selection for In-Context LearningWei Zheng, Zijie Wang, Xin Li, Bin Gong 等ICML 2026
- WinQ: Accelerating Quantization-Aware Training of Language Models Around Saddle PointsDongyue Li, Zechun Liu, Kai Yi, Zhenshuo Zhang 等ICML 2026
- Efficiently Learning Branching Networks for Multitask Algorithmic ReasoningDongyue Li, Zhenshuo Zhang, Minxuan Duan, Edgar Dobriban 等KDD 2026
它引用的 Paper18
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- Gradient Surgery for Multi-Task LearningTianhe Yu, Saurabh Kumar, Abhishek Gupta, Sergey Levine 等NeurIPS 2020 · 2,261 次引用
- What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 次引用
- Learning to Prompt for Continual LearningZifeng Wang, Zizhao Zhang, Chen-Yu Lee, Han Zhang 等CVPR 2022 · 635 次引用
- Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe 等EMNLP 2022 · 634 次引用
相关 Paper
- Selecting Demonstrations for Many-Shot In-Context Learning via Gradient MatchingJianfei Zhang, Bei Li, Jun Bai, Rumei Li 等ACL Findings 2025
- In-Context Learning with Iterative Demonstration SelectionChengwei Qin, Aston Zhang, Chen Chen, Anirudh Dagar 等EMNLP Findings 2024 · 19 次引用
- Revisiting Demonstration Selection Strategies in In-Context LearningKeqin Peng, Liang Ding, Yancheng Yuan, Xuebo Liu 等ACL 2024
- Representative Demonstration Selection for In-Context Learning with Two-Stage Determinantal Point ProcessZhao Yang, Yuanzhe Zhang, Dianbo Sui, Cao Liu 等EMNLP 2023 · 3 次引用
- Active Example Selection for In-Context LearningYiming Zhang, Shi Feng, Chenhao TanEMNLP 2022 · 84 次引用
