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 $\texttt{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 $\texttt{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 $\texttt{Se}^2$'s exceptional stability and adaptability across various scenarios. Our code will be released to facilitate future research.
翻译:大型语言模型(LLM)在上下文学习(ICL)中的卓越能力需要通过示范示例来激活。先前研究广泛探索了ICL示例的选择问题,但多遵循"先选择后组织"范式,这类方法往往忽视示例间的内在关联,并存在训练与推理阶段的不一致性。本文将问题形式化为序列化选择问题,提出$\texttt{Se}^2$——一种序列感知方法,通过利用LLM对不同上下文设置的反馈,辅助捕捉示例间的相互关系和序列信息,显著增强ICL提示的上下文关联性和相关性。同时,我们采用束搜索来寻找并构建示例序列,从而提升质量与多样性。在涵盖8个类别23项NLP任务的广泛实验中,$\texttt{Se}^2$显著超越多个强基线方法,相较于随机选择实现42%的相对性能提升。深入分析进一步验证了所提策略的有效性,突显了$\texttt{Se}^2$在不同场景下卓越的稳定性和适应性。我们将公开代码以促进后续研究。