Large language models (LLMs) can adapt to new tasks through in-context learning (ICL) based on a few examples presented in dialogue history without any model parameter update. Despite such convenience, the performance of ICL heavily depends on the quality of the in-context examples presented, which makes the in-context example selection approach a critical choice. This paper proposes a novel Bayesian in-Context example Selection method (ByCS) for ICL. Extending the inference probability conditioned on in-context examples based on Bayes' theorem, ByCS focuses on the inverse inference conditioned on test input. Following the assumption that accurate inverse inference probability (likelihood) will result in accurate inference probability (posterior), in-context examples are selected based on their inverse inference results. Diverse and extensive cross-tasking and cross-modality experiments are performed with speech, text, and image examples. Experimental results show the efficacy and robustness of our ByCS method on various models, tasks and modalities.
翻译:大型语言模型(LLMs)能够通过上下文学习(ICL)适应新任务,仅需在对话历史中提供少量示例而无需更新模型参数。尽管这种方式十分便捷,但ICL的性能在很大程度上取决于所提供的上下文示例的质量,这使得上下文示例的选择方法成为关键决策。本文提出了一种新颖的贝叶斯上下文示例选择方法(ByCS)用于ICL。通过基于贝叶斯定理扩展以上下文示例为条件的推断概率,ByCS聚焦于以测试输入为条件的逆推断。依据准确的逆推断概率(似然)将产生准确推断概率(后验)的假设,上下文示例根据其逆推断结果进行选择。研究在语音、文本和图像示例上进行了多样且广泛的跨任务与跨模态实验。实验结果表明,我们的ByCS方法在不同模型、任务和模态上均表现出有效性和鲁棒性。