In-Context learning is the paradigm that adapts large language models to downstream tasks by providing a few examples. Few-shot selection -- selecting appropriate examples for each test instance separately -- is important for in-context learning. In this paper, we propose Skill-KNN, a skill-based few-shot selection method for in-context learning. The key advantages of Skill-KNN include: (1) it addresses the problem that existing methods based on pre-trained embeddings can be easily biased by surface natural language features that are not important for the target task; (2) it does not require training or fine-tuning of any models, making it suitable for frequently expanding or changing example banks. The key insight is to optimize the inputs fed into the embedding model, rather than tuning the model itself. Technically, Skill-KNN generates the skill-based representations for each test case and candidate example by utilizing a pre-processing few-shot prompting, thus eliminating unimportant surface features. Experimental results across four cross-domain semantic parsing tasks and four backbone models show that Skill-KNN significantly outperforms existing methods.
翻译:上下文学习是一种通过提供少量示例使大型语言模型适应下游任务的范式。少样本选取——即为每个测试实例单独选取合适的示例——对于上下文学习至关重要。本文提出Skill-KNN,一种基于技能的少样本选取方法。其主要优势包括:(1)解决了现有基于预训练嵌入的方法易受对目标任务不重要的表层自然语言特征影响的偏差问题;(2)无需对任何模型进行训练或微调,适用于示例库频繁扩展或更新的场景。核心思路是优化输入到嵌入模型的数据而非调整模型本身。技术上,Skill-KNN通过预处理的少样本提示为每个测试用例和候选示例生成基于技能的表示,从而消除不重要的表层特征。在四个跨领域语义解析任务和四种骨干模型上的实验结果表明,Skill-KNN显著优于现有方法。