Distinguishability Calibration to In-Context Learning (2023)

Abstract: Recent years have witnessed increasing interests in prompt-based learning in which models can be trained on only a few annotated instances, making them suitable in low-resource settings. It is even challenging in fine-grained classification as the pre-trained language models tend to generate similar output embedding which makes it difficult to discriminate for the prompt-based classifier. In this work, we alleviate this information diffusion issue by proposing a calibration method based on a transformation which rotates the embedding feature into a new metric space where we adapt the ratio of each dimension to a uniform distribution to guarantee the distinguishability of learned embeddings. Furthermore, we take the advantage of hyperbolic embedding to capture the relation between dimensions by a coarse-fine metric learning strategy to enhance interpretability. Extensive experiments on the three datasets under various settings demonstrate the effectiveness of our approach.

## introduction large pre-trained language models (plms) @xcite @xcite have been achieved state-of-the-art performance in many natural language processing (nlp) downstream tasks. more recently, the plms with prompt learning demonstrate surprising capabilities in numerous in an emotion classification task shown in however, as in-context learning does not require updating plm parameters, there arises the problem of distribution mismatch between the data used for lm pre-training and the test samples used in in-context learning, which hinders the full exploitation of the knowledge encoded in plms @xcite @xcite . to alleviate the context shift, existing methods rely on prior knowledge to increase the overlapping between the two distributions. for example, ptr @xcite appends domain-agnostic tokens to prompts to discriminate the domains, such as "sports", "politics". another line of studies designs sophisticated handcrafted verbalizers to map the test samples onto the label word space derived from plms @xcite . although the gradient-optimized verbalizers @xcite are proposed to ease the human effort and can be adapted to different downstream tasks via training, it is still consid-ered inferior to the manual verbalizers, especially in both the few-shot and zero-shot settings where training data are scarce. in this paper, we first show that plms have an inherent information diffusion issue in their generated output token embeddings, which share a large proportion of similar information after going through a stack of transformer layers @xcite . such token embeddings occupy a narrow cone, leading to largely overlapped output distributions when applied to in-context learning. next, we elaborate that the overlapped output distributions would violate the distinguishability condition @xcite under in-context learning. to this end, we propose to flatten the singular value distributions of the output embeddings generated from plms to shape the space spanned by the singular values to a desirable manifold. on the one hand, we apply an orthogonal and a scaling constraints to the weight matrix applied to the output embeddings, which can avoid exploding and vanishing values in the feature matrix @xcite , leading to better discriminative features when trained with limited labelled data. on the other hand, we leverage hyperbolic embeddings to capture the hierarchical relations among fine-grained class labels of training examples to further enhance the distinguishability of output embeddings. our proposed framework has been implemented on top of existing prompt-based few-shot learning methods and it demonstrates an average 5.86% performance improvement of f1-measure on three classification tasks under 100-shot learning. we also verify that the improvement stems from a more balanced singular value distribution for the output features and the learnt hierarchical feature space. in summary, our contributions include: ## related works information diffusion in plms. in a typical l-layer transformer-based plm, assuming the prompt is a concatenation of a few training examples and a test input x test , consisting of m tokens in total, the goal of in-context learning is to predict the output distribution over the masked token at the t-th position, @xcite . it is formally defined by the following equation: although we have limited knowledge of the output distribution p(o t |x test ) over token @xcite , many existing studies analyzed the geometry properties of the last layer feature h l , and examined its effects in downstream tasks @xcite . due to the softmax bottleneck @xcite and the likelihood loss in language generation tasks @xcite , the output feature distribution in plms tends to be anisotropic and rank-deficient, which limits the expressiveness of the generated representations. @xcite discussed the information diffusion issue among tokens within a sentence that feeding the tokens in different positions for classification only resulted in a 1.2% variance in classification accuracy. @xcite explored the information diffusion among different sentences via singular value decomposing and they found that the singular value distributions are skewed especially in deeper plm layers, i.e., larger singular values become more predominant compared to the smaller ones. context shift in in-context learning. many researchers studied the distribution shift (aka. domain shift) between the pretraining corpora and test samples and proposed solutions to decrease the performance variance in prompt-based few-shot learning @xcite @xcite @xcite . on the one hand, some in-context learning methods incorporated domain-specific words or learnable tokens in the prompt to discriminate different context. @xcite proposed to first generate the name of the domain and then generate domain-related features (drfs) conditioned on the domain in a supervised manner. both the generated domain name and drfs were used as the prompt fed to the model. on the other hand, the sophisticated verbalizers contributed to minimising the distance between the two distributions @xcite @xcite . to broaden the coverage of single-choice verbalizer, knowledge prompt tuning (kpt) @xcite used the knowledge graph to extract more topic-related words as label words and then refine the label word candidates. to incorporate prior knowledge to calibrate the context shift, xie et al. ( 2022 ) simplified a language model as the hidden markov model, where the observed tokens are sampled from a family of concepts and proposed the distinguishability condition to measure context shift as the kullback-leibler (kl) divergence. ## contextual calibration for output distribution many existing methods calibrate the probabilities of the generated tokens in a language model in order to improve the generation quality. in promptbased learning, we want to find out if the output distribution p(o t |x test ) or the output feature h [mask] , which is a part of the hidden representation from the last layer of a plm, h ℓ , suffers from the information diffusion issue and occupies a narrow cone. we take roberta-based prompt learning as an example and derive the value of h [mask] from 1,500 randomly selected test samples from an emotion classification dataset, goemotions @xcite , and visualise the results in a 2d plane in figure 1 @xcite . for comparison, we select the predicted token with the largest probability on each [mask] and map their corresponding vectors from word2vec @xcite to a 2d plane in 1(b). it is clear that the word embeddings learned from word2vec has a more uniform distribution around the origin. in contrast, the representations derived by roberta degenerate into a narrow cone, which implies limited expressiveness. inspired by the approach proposed in @xcite , we display the singular value distribution of h [mask] and calculate the distribution statistics, i.e., the matrix moment and the average cosine similarity between every [mask] pair in figure 1(c ). from the empirical results, we can see that the value of the hidden representation for [mask] in different samples share much similar information with the token uniformity value @xcite (tokenuni in figure 1(c )) of 0.939. this shows that most h [mask] concentrates at very few singular values, which implies a severe information diffusion issue. ## conclusion in this paper, to address the information diffusion issue in prompt-based few-shot learning, we propose a calibration method based on featuretransformation which first rotates output embeddings into a new metric space, and then scales the ratio of each dimension to a uniform distribution to guarantee the distinguishability of the transformed embeddings. on the other hand, we utilise hyperbolic embeddings to capture the hierarchical relations between class labels to guide the metric learning strategy to enhance the interpretability of the learned output embeddings. extensive experiments on the three multi-class classification tasks under various settings demonstrate the effectiveness of our approach with an average 5.9% performance improvement on the f1-measure.