The remarkable capability of large language models (LLMs) for in-context learning (ICL) needs to be activated by demonstration examples. Prior work has extensively explored the selection of examples for ICL, predominantly following the "select then organize" paradigm, such approaches often neglect the internal relationships between examples and exist an inconsistency between the training and inference. In this paper, we formulate the problem as a $\textit{se}$quential $\textit{se}$lection problem and introduce $Se^2$, a sequential-aware method that leverages the LLM's feedback on varying context, aiding in capturing inter-relationships and sequential information among examples, significantly enriching the contextuality and relevance of ICL prompts. Meanwhile, we utilize beam search to seek and construct example sequences, enhancing both quality and diversity. Extensive experiments across 23 NLP tasks from 8 distinct categories illustrate that $Se^2$ markedly surpasses competitive baselines and achieves 42% relative improvement over random selection. Further in-depth analysis show the effectiveness of proposed strategies, highlighting $Se^2$'s exceptional stability and adaptability across various scenarios. Our code will be released to facilitate future research.
翻译:大语言模型(LLMs)在上下文学习(ICL)中展现的卓越能力需要通过示范示例来激活。以往研究广泛探索了ICL的示例选择方法,主要遵循"先选择后组织"的范式,这类方法往往忽略了示例间的内在关联性,且存在训练与推理阶段不一致的问题。本文将问题形式化为一个序贯选择问题,提出$Se^2$这一具备序贯感知能力的方法。该方法利用大语言模型对动态上下文的反馈,有效捕捉示例间的相互关系与序列信息,显著增强了ICL提示的上下文关联性与相关性。同时,我们采用束搜索算法来寻找并构建示例序列,提升了序列质量与多样性。在涵盖8个类别共23项NLP任务的广泛实验中,$Se^2$显著超越多个强基线方法,相较随机选择实现了42%的相对性能提升。进一步的深度分析验证了所提策略的有效性,凸显了$Se^2$在不同场景中卓越的稳定性与适应性。我们将公开代码以促进后续研究。