Pre-trained language models (PLMs) have exhibited remarkable few-shot learning capabilities when provided a few examples in a natural language prompt as demonstrations of test instances, i.e., in-context learning. However, the performance of in-context learning is susceptible to the choice of prompt format, training examples and the ordering of the training examples. In this paper, we propose a novel nearest-neighbor calibration framework for in-context learning to ease this issue. It is inspired by a phenomenon that the in-context learning paradigm produces incorrect labels when inferring training instances, which provides a useful supervised signal to calibrate predictions. Thus, our method directly augments the predictions with a $k$-nearest-neighbor ($k$NN) classifier over a datastore of cached few-shot instance representations obtained by PLMs and their corresponding labels. Then adaptive neighbor selection and feature regularization modules are introduced to make full use of a few support instances to reduce the $k$NN retrieval noise. Experiments on various few-shot text classification tasks demonstrate that our method significantly improves in-context learning, while even achieving comparable performance with state-of-the-art tuning-based approaches in some sentiment analysis tasks.
翻译:培训前语言模型(PLMS)在以自然语言作为测试实例的演示(即文字内学习)提供一些实例时,表现出了惊人的微小学习能力。但是,文中学习的成绩很容易被选择迅速的格式、培训范例和训练实例的顺序所决定。在本文中,我们建议为文字内学习提供一个新的近邻校准框架,以方便这一问题。它受到一种现象的启发,即文中学习模式在推断培训实例时产生错误的标签,为校准预测提供了有用的监督信号。因此,我们的方法直接用美元-最近邻(kNNNN)的分类器来补充预测,取代了由PLMS及其相应标签获得的少量实例演示的数据存储器。然后引入了适应性邻居选择和特征校正模块,以便充分利用少数支持性实例来减少以美元为基础的检索噪音。对几张文本分类的实验表明,我们的方法大大改进了感官的学习方法,同时实现了某种可比较性的工作。