Towards Informative Few-Shot Prompt with Maximum Information Gain for In-Context Learning (2023)

Abstract: Large Language models (LLMs) possess the capability to engage In-context Learning (ICL) by leveraging a few demonstrations pertaining to a new downstream task as conditions. However, this particular learning paradigm suffers from high instability stemming from substantial variances induced by factors such as the input distribution of selected examples, their ordering, and prompt formats. In this work, we demonstrate that even when all these factors are held constant, the random selection of examples still results in high variance. Consequently, we aim to explore the informative ability of data examples by quantifying the Information Gain (IG) obtained in prediction after observing a given example candidate. Then we propose to sample those with maximum IG. Additionally, we identify the presence of template bias, which can lead to unfair evaluations of IG during the sampling process. To mitigate this bias, we introduce Calibration Before Sampling strategy. The experimental results illustrate that our proposed method can yield an average relative improvement of 14.3% across six classification tasks using three LLMs.

## introduction these days the in-context learning (icl) ability of pre-trained large language models (llms) has garnered significant attention in the community. icl represents a new paradigm for few-shot learning, which entails performing new downstream tasks based on prompts. these prompts consist of a few input-output pairs, commonly referred to as demonstrations. such prompts serve as explicit task descriptions for the llm. llms have showcased the formidable capacity of icl and achieved remarkable performances across various downstream tasks @xcite . in comparison to approaches that involve fine-tuning llms on downstream tasks @xcite , icl obviates the need for parameter updates, figure 1 : four-shot icl performance on sst-2 using gpt-2 xl and gpt-j. each boxplot summarizes the results of 10 randomly selected prompts for a specific sample order. for a given sample order, the input distribution, demonstration ordering, and prompt formats remain constant. for instance, the sample order [p p n n] denotes the sequence of two positive examples followed by two negative ones. thereby allowing higher efficiency in adapting to new tasks and easier deployment. however, icl tends to suffer from substantial variance in performance. existing studies attribute it to factors including the input distribution of demonstrations, their ordering, and the prompt formats employed during prompt construction @xcite @xcite . our investigation reveals that even when the input distribution, the ordering of demonstrations, and prompt formats remain fixed, the random selection of different demonstrations still leads to significant variance, as shown in figure 1 . this observation indicates that data samples within the same category can offer distinct information and contribute differently to the icl performance. we refer to the ability of a data sample to provide valuable information as its informative ability. to the best of our knowledge, there has been no prior study exploring this aspect in the existing literature. in this paper, we examine the informative ability of data examples from the perspective of information theory and investigate its correlation with the icl performance. specifically, we assess the contribution of individual data samples to the specific downstream tasks by quantitatively measuring their informative ability. to accomplish this, we propose to evaluate the information gain (ig) of prediction, which quantifies the amount of information gained after observing one example candidate in the context. we construct a prompt for each example candidate and utilize the llm to obtain the corresponding output distribution, thus enabling the evaluation of ig. furthermore, we uncover the presence of template bias, which can lead to biased evaluations of ig. to address this issue, we introduce a calibration before sampling strategy to ensure a fair assessment of ig. subsequently, we select the example candidates with maximum ig and annotate them as demonstrations for enhancing icl. to validate the effectiveness of our method, we conduct empirical evaluations across six classification datasets across three llms of varying model sizes. the experimental results demonstrate an average relative improvement of 14.3% on oneshot learning. it is important to emphasize that our proposed method is orthogonal to existing methods such as calibration @xcite and reordering methods @xcite . moreover, we demonstrate that our method can be combined with these approaches to achieve further improvements. additionally, we analyze the relationship between data informative ability with the correctness of target labels and find that data examples with high ig tend to rely more on the accuracy of target labels. in summary, our contributions can be summarized as follows: ## conclusion in this study, we have highlighted the significance of the data informative ability in icl. we have demonstrated that data samples with varying informative abilities, even when subjected to the same input distribution, order and prompt formats, make distinct contributions to the overall performance of icl. to address this, we draw inspiration from information theory and proposed to quantify the informative ability by evaluating the information gain of data samples. moreover, we identify the presence of template bias, which could introduce unfairness in the evaluation of ig. to mitigate this bias, we introduce the calibration before sampling strategy. through extensive experiments, we have validated the effectiveness of the proposed maximum information gain sampling strategy and calibration before sampling strategy. this validation underscores the reliability of measuring informative ability based on information gain. furthermore, our experimental findings illustrate that our method is orthogonal to existing approaches and can synergistically collaborate with them to achieve further performance improvements. we hope that our work can provide valuable guidance for the development of data-efficient methods and facilitate the exploration of enhanced data-centric approaches for icl in the future.