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.
翻译:大语言模型(LLM)可通过对话历史中的少量示例进行上下文学习(ICL)来适应新任务,且无需更新模型参数。尽管具有这种便捷性,ICL的性能在很大程度上取决于所提供上下文示例的质量,这使得上下文示例选择方法成为关键环节。本文提出一种面向ICL的新型贝叶斯上下文示例选择方法(ByCS)。基于贝叶斯定理对以上下文示例为条件的推断概率进行扩展,ByCS聚焦于以测试输入为条件的逆推断。遵循"准确的逆推断概率(似然)将产生准确推断概率(后验)"的假设,该方法依据示例的逆推断结果来选择上下文示例。我们采用语音、文本和图像示例进行了多样化且广泛的跨任务与跨模态实验。实验结果表明,ByCS方法在多种模型、任务和模态上均展现出优异的有效性和鲁棒性。