arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2506.04579cs.CL
收藏

通过梯度匹配为多示例上下文学习选择演示

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

School of Computer Science and Engineering, Beihang University, China(北京航空航天大学计算机科学与工程学院);Meituan, Inc.(美团公司);Beijing Institute for General Artificial Intelligence, China(北京通用人工智能研究院);Ping An Technology, China(平安科技);Department of Computer Science, University of Manchester, UK(曼彻斯特大学计算机科学系)

Jianfei Zhang, Bei Li, Jun Bai, Rumei Li, Yanmeng Wang, Chenghua Lin, Wenge Rong

AI总结:

本文提出一种基于梯度匹配的多示例上下文学习演示选择方法,通过在小模型上对齐微调梯度选择示例,在多个数据集和模型规模上显著优于随机选择。

摘要:

上下文学习(In-Context Learning,ICL)使大语言模型(Large Language Models,LLMs)无需微调(Fine-Tuning,FT)即可快速适应任务,但其对演示选择的依赖仍是一项关键挑战。尽管多示例 ICL 通过扩大演示规模展现出良好性能,但现有工作中多示例演示的选择方法仍局限于随机选择。由于传统的实例级检索并不适用于多示例场景,我们假设上下文学习与微调的数据需求具有相似性。为此,我们提出一种新颖的梯度匹配方法,通过对齐目标任务整个训练集与所选示例之间的微调梯度来选择演示,从而在所选示例中逼近在整个训练集上的学习效果。通过在相对较小的模型(例如 Qwen2.5-3B 或 Llama3-8B)上进行梯度匹配,我们的方法在 9 个多样化数据集上、从 4-shot 到 128-shot 场景中,在更大的 LLM 上一致优于随机选择。例如,在 Qwen2.5-72B 和 Llama3-70B 上比随机选择高出 4%,在 5 个闭源 LLM 上高出约 2%。这项工作解锁了更可靠、更有效的多示例 ICL,为其更广泛的应用铺平了道路。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑