[论文解读] Learning to Retrieve In-Context Examples for Large Language Models
本文介绍 LLM-R,一种迭代框架,通过从一个 LLM 启示的奖励模型蒸馏来学习密集检索器,以为大型语言模型挑选高质量的上下文示例。
Large language models (LLMs) have demonstrated their ability to learn in-context, allowing them to perform various tasks based on a few input-output examples. However, the effectiveness of in-context learning is heavily reliant on the quality of the selected examples. In this paper, we propose a novel framework to iteratively train dense retrievers that can identify high-quality in-context examples for LLMs. Our framework initially trains a reward model based on LLM feedback to evaluate the quality of candidate examples, followed by knowledge distillation to train a bi-encoder based dense retriever. Our experiments on a suite of $30$ tasks demonstrate that our framework significantly enhances in-context learning performance. Furthermore, we show the generalization ability of our framework to unseen tasks during training. An in-depth analysis reveals that our model improves performance by retrieving examples with similar patterns, and the gains are consistent across LLMs of varying sizes. The code and data are available at https://github.com/microsoft/LMOps/tree/main/llm_retriever .
研究动机与目标
- 激发并分析大型语言模型对上下文中示例的敏感性以及对高质量检索的需求。
- 提出一个迭代框架(LLM-R),利用 LLM 的反馈来学习一个密集检索器。
- 证明 LLM-R 在多样化任务和不同规模的 LLM 上提升上下文学习。
- 显示检索出的示例往往与测试用例共用输入模式或标签,并且能泛化到未见任务。
提出的方法
- 从任务混合池中使用 BM25 进行初始候选检索。
- 根据测试输入和候选项,按 LLM 的真实对数似然度排序候选项。
- 训练一个 cross-encoder 奖励模型,以使用真实标签和困难负样本来评估候选项的质量。
- 使用知识蒸馏来训练一个 bi-encoder 密集检索器,通过对困难负样本的 KL 散度以及 InfoNCE 对比损失来模仿奖励模型。
- 利用新检索到的正样本/负样本迭代重新训练密集检索器以提高质量。

实验结果
研究问题
- RQ1在 LLM 反馈引导下,学习得到的密集检索器是否能在选择上下文示例方面优于启发式基线?
- RQ2在多任务和不同规模的 LLM 上,使用奖励模型监督的迭代再训练是否能提升 ICL?
- RQ3该方法在未见任务和不同 LLM 上的泛化能力如何?
- RQ4哪些因素(任务类型、数据模式、任务难度)会影响检索到的上下文示例的有效性?
主要发现
- LLM-R 在 30 项任务上持续优于基线(random、k-means、BM25、E5、SBERT、EPR),迭代 1 次时平均为 65.7,迭代 2 次时为 66.5。
- 迭代训练在两次迭代后收益递减,表明收敛。
- 基于奖励模型的蒸馏显著提升性能,相比没有奖励模型的变体。
- LLM-R 能泛化到未见任务和不同的 LLM(GPT-Neo-2.7B、LLaMA-13B、GPT-3.5-turbo),在较小的 LLM 上尤其显著。
- 检索到的顶端示例往往与测试具有相同输入模式或相同标签,知识密集型任务的绝对收益较小。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。