[Paper Review] Improving Few-Shot Performance of Language Models via Nearest Neighbor Calibration
This paper proposes a nearest-neighbor calibration framework that improves few-shot in-context learning in pre-trained language models by dynamically retrieving and calibrating predictions using k-nearest neighbors of cached support instance representations. The method significantly boosts performance—achieving a 12.8% average accuracy gain on single-sentence tasks and matching tuning-based SOTA methods in sentiment analysis—by reducing sensitivity to prompt design through adaptive neighbor selection and feature regularization.
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.
Motivation & Objective
- To address the high sensitivity of in-context learning to prompt templates, example order, and verbalizer choice.
- To exploit the inconsistency in in-context learning predictions on support instances as a supervisory signal for calibration.
- To improve few-shot text classification performance without fine-tuning by enhancing PLM predictions with instance-based retrieval.
- To reduce noise in k-NN retrieval through adaptive neighbor selection and feature regularization.
- To close the performance gap between in-context learning and parameter-tuning-based methods in few-shot settings.
Proposed method
- The method augments in-context learning predictions with a k-nearest-neighbor (k-NN) classifier over a datastore of cached PLM representations of few-shot support instances and their labels.
- It uses a lightweight feature regularization module to separate instances with similar representations but different labels, reducing retrieval noise.
- An adaptive neighbor selection module dynamically determines the optimal number of neighbors per input based on local representation similarity.
- The k-NN classifier retrieves the most similar few-shot examples to refine the original PLM prediction distribution.
- The framework operates on top of BERT and GPT-style PLMs, using their final hidden states as instance representations.
- The method is end-to-end differentiable and does not require any parameter updates to the base PLM.
Experimental results
Research questions
- RQ1Can the inconsistency in in-context learning predictions on support instances be leveraged as a supervisory signal to improve model calibration?
- RQ2How can k-NN retrieval of few-shot support instances improve the robustness and accuracy of in-context learning?
- RQ3To what extent can a retrieval-augmented approach match or exceed fine-tuning-based methods in few-shot text classification?
- RQ4How do adaptive neighbor selection and feature regularization reduce k-NN retrieval noise in few-shot settings?
- RQ5Does the proposed method reduce variance in performance due to prompt engineering choices?
Key findings
- The proposed k-NN calibration method achieves a 12.8% absolute average accuracy improvement over standard in-context learning on single-sentence text classification tasks.
- On the SST-2 dataset, the method improves accuracy from 81.2% (ICL) to 88.3% (KNN-C-ICL), with a worst-case accuracy gain of 1.8%.
- On sentiment analysis tasks like SST-2 and SST-5, the method achieves performance comparable to state-of-the-art fine-tuning approaches.
- The method reduces standard deviation in performance across different prompt configurations, indicating lower sensitivity to prompt design.
- The feature regularization module reduces retrieval noise, particularly in cases where similar representations have conflicting labels.
- The adaptive neighbor selection mechanism improves robustness by dynamically adjusting the number of neighbors based on input similarity.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.