Skip to main content
QUICK REVIEW

[论文解读] In-Context Learning with Iterative Demonstration Selection

Chengwei Qin, Aston Zhang|arXiv (Cornell University)|Oct 15, 2023
Topic Modeling被引用 6
一句话总结

本文提出迭代演示选择(IDS),一种通过零样本思维链(Zero-shot-CoT)推理,迭代选择多样化且语义相关演示的方法,用于上下文学习(ICL)。通过在多轮迭代中生成测试样本的推理路径,并选择与这些路径语义相似的演示,IDS 在多个 NLP 任务上持续优于现有基线方法,表现优于仅依赖相似性或多样性的方法。

ABSTRACT

Spurred by advancements in scale, large language models (LLMs) have demonstrated strong few-shot learning ability via in-context learning (ICL). However, the performance of ICL has been shown to be highly sensitive to the selection of few-shot demonstrations. Selecting the most suitable examples as context remains an ongoing challenge and an open problem. Existing literature has highlighted the importance of selecting examples that are diverse or semantically similar to the test sample while ignoring the fact that the optimal selection dimension, i.e., diversity or similarity, is task-specific. Based on how the test sample is answered, we propose Iterative Demonstration Selection (IDS) to leverage the merits of both dimensions. Using zero-shot chain-of-thought reasoning (Zero-shot-CoT), IDS iteratively selects examples that are diverse but still strongly correlated with the test sample as ICL demonstrations. Specifically, IDS applies Zero-shot-CoT to the test sample before demonstration selection. The output reasoning path is then used to choose demonstrations that are prepended to the test sample for inference. The generated answer is followed by its corresponding reasoning path for extracting a new set of demonstrations in the next iteration. After several iterations, IDS adopts majority voting to obtain the final result. Through extensive experiments on tasks including reasoning, question answering, and topic classification, we demonstrate that IDS can consistently outperform existing ICL demonstration selection methods.

研究动机与目标

  • 为解决上下文学习(ICL)对演示选择的敏感性问题,该问题显著影响性能。
  • 识别出最优演示选择策略(多样性 vs. 相似性)是任务特定的,挑战了单一维度普遍优于另一维度的假设。
  • 提出一种统一方法,通过零样本思维链推理的迭代优化,同时利用多样性和相似性。
  • 在无需模型微调或访问模型参数的情况下提升 ICL 性能,使其适用于冻结的大规模语言模型。
  • 在多种 NLP 任务和大规模语言模型架构上展示方法的鲁棒性与一致性能提升。

提出的方法

  • 首先对测试样本应用零样本思维链提示(例如:'让我们一步步思考。'),以生成推理路径。
  • 然后选择与该推理路径在语义上最相似的训练样本作为初始演示,并将其附加到测试输入前用于推理。
  • 模型从推理中生成新的答案及其对应的推理路径,作为下一轮迭代中选择新演示集的基础。
  • 该迭代过程持续固定步数,每轮均基于不断演化的推理路径对演示集进行优化。
  • 经过多轮迭代后,通过所有迭代输出的多数投票获得最终预测结果。
  • 使用 Sentence-BERT 嵌入计算推理路径与演示之间的语义相似度,以指导选择。
Figure 1: Illustration of in-context learning (ICL) on sentiment analysis. A frozen large language model directly generates the sentiment ‘Positive’ for the test sample ‘I like this movie.’ by taking the demonstrations and the test sample as input.
Figure 1: Illustration of in-context learning (ICL) on sentiment analysis. A frozen large language model directly generates the sentiment ‘Positive’ for the test sample ‘I like this movie.’ by taking the demonstrations and the test sample as input.

实验结果

研究问题

  • RQ1在不同 NLP 任务中,多样性或相似性是否作为选择上下文学习演示的主要标准具有持续优势?
  • RQ2能否通过在演示选择中结合多样性与相似性,使上下文学习性能超越当前最先进方法?
  • RQ3使用零样本思维链推理进行迭代优化,是否能实现逐步改进的演示选择与最终预测?
  • RQ4该方法对演示数量、迭代次数及底层 LLM 架构的变化是否具有鲁棒性?
  • RQ5该方法能否在无需参数更新或访问内部模型统计信息的情况下,有效应用于冻结的大规模语言模型?

主要发现

  • IDS 在六个不同 NLP 数据集上持续优于现有的 ICL 演示选择方法,包括 Top-k-Consistency-CoT 和 Random-Voting-CoT。
  • 在所有评估数据集上,IDS 平均比 Top-k-Consistency-CoT 提高 0.9% 的绝对准确率,单个任务上的提升范围为 0.4% 至 1.2%。
  • 在使用四个演示时,IDS 在基准测试中达到 90.9% 的准确率,而 Top-k-Consistency-CoT 为 90.0%,表明在不同演示集大小下均保持一致优势。
  • IDS 在不同迭代次数下均保持良好性能,峰值性能出现在三轮迭代,且更多轮次未导致性能持续下降,表明对超参数选择具有鲁棒性。
  • 在 GPT-4 上评估时,IDS 达到 93.6% 的准确率,而 Top-k-Consistency-CoT 为 92.8%,证实其在不同 LLM 架构下的鲁棒性。
  • IDS 中测试样本与所选演示之间的平均语义相似度为 0.46,低于 Top-k-Consistency-CoT 的 0.69,表明 IDS 在保持与测试输入强相关性的同时,成功选择了更多样化的样本。
Figure 2: Illustration of our proposed Iterative Demonstration Selection (IDS). IDS first applies Zero-shot-CoT to the test sample to obtain a reasoning path, which is then used to select few-shot demonstrations from training examples through KNN. The selected demonstration examples are prepended to
Figure 2: Illustration of our proposed Iterative Demonstration Selection (IDS). IDS first applies Zero-shot-CoT to the test sample to obtain a reasoning path, which is then used to select few-shot demonstrations from training examples through KNN. The selected demonstration examples are prepended to

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。