When primed with only a handful of training samples, very large, pretrained language models such as GPT-3 have shown competitive results when compared to fully-supervised, fine-tuned, large, pretrained language models. We demonstrate that the order in which the samples are provided can make the difference between near state-of-the-art and random guess performance: essentially some permutations are fantastic and some not. We analyse this phenomenon in detail, establishing that: it is present across model sizes (even for the largest current models), it is not related to a specific subset of samples, and that a given good permutation for one model is not transferable to another. While one could use a development set to determine which permutations are performant, this would deviate from the true few-shot setting as it requires additional annotated data. Instead, we use the generative nature of language models to construct an artificial development set and based on entropy statistics of the candidate permutations on this set, we identify performant prompts. Our method yields a 13% relative improvement for GPT-family models across eleven different established text classification tasks. Large pretrained language models (PLMs, Devlin et al., 2019; Peters et al., 2018; Raffel et al., 2020; Liu et al., 2019; Yang et al., 2019; Radford et al., 2019) have shown remarkable performance when conditioned with an appropriate textual context (Petroni et al., 2019, 2020; Jiang et al., 2020; Shin et al., 2020; Davison et al., 2019). For example, when conditioned on a long document and a TL;DR: token, they can generate a summary of said document, and when provided a partial question (The theory of relativity was developed by __), they can generate the correct answer. Perhaps most strikingly, when primed with a context consisting of very few training examples, they produce 0.1 0.3 0.8 1.5 2.7 6.7 13 175 Model Parameters (Billion) 50 60 70 80 90 100 SST2 A cc u r a c y ( % ) 0.1 0.3 0.8 1.5 2.7 6.7 13 175 Model Parameters (Billion) 50 60 70 80 90 100 S u b j A cc u r a c y ( % ) Figure 1: Four-shot performance for 24 different sample orders across different sizes of GPT-family models (GPT-2 and GPT-3) for the SST-2 and Subj datasets. text classification results that can match those of fully supervised models. This type of few shot setting, is commonly referred to as In-context Learn-ing (Brown et al., 2020). A core component of in-context learning is the text-based prompt that serves as the context. Composing a prompt requires: (i) text linearisation using a template; and (ii) training sample concatenation (See Table 1 for an example). It has been established that the structure of the template has a large impact on performance (Shin et al., 2020; Gao et al., 2020; Schick and Schtze, 2020; Jiang et al., 2020). However, to the best of our knowledge, no work has studied the effect of the sample ordering on In-context Learning performance. Perhaps counter-intuitively, we find that the right sample order can make as much of a difference as 8086 Example trainingset (thegreatestmusicians,1)(redundantconcept,0) linearization Review: thegreatestmusicians. the right template. As can be seen in Figure 1, some permutations have comparable performance (over 85% accuracy) to supervised training for sentiment classification, while others perform close to random (around 50%). This order sensitivity is universal across models, and although increasing the model size somewhat addresses it, the problem is still present for some text classification tasks (Subj in Figure 1) for models with billions of parameters. In our analysis, we find no common denominator between performant sample orders and that they are not transferable across different model sizes and tasks. In a fully-supervised setting, we could rely on a development set to select among sample orders. However, this is not desirable in a few-shot setting where the size of the development set is very limited, even unavailable (Perez et al., 2021) . Instead, we use the generative nature of language models to construct an unlabelled artificial development set and refer to it as a probing set . As the probing set is unlabelled, we use the predicted label distribution statistics and propose entropy-based metrics to measure the quality of candidate prompts.Experimental results show that we can achieve on average 13% relative improvement across eleven different established text classification tasks across all different sizes (four orders of magnitude) of PLMs. To summarise, our contributions are as follows: 1. We study order sensitivity for In-context Learning, which we show is crucial for the success of pretrained language models for few-shot learning. 2. We propose a simple, generation-based probing method to identify performant prompts without requiring additional data. 3. Our probing method is universally applicable and effective across different sizes of pretrained language models and for different types of datasets  achieving on average a Figure 2: Training sample permutations for the In-context Learning setting. In this section, we study the relationship between permutation performance and various factors. For the ease of visualisation, we use a fixed random subset of four samples with a balanced label distribution from the SST-2 dataset and consider all 24 possible sample order permutations. This setup is illustrated in Figure 2. We also test five randomly-selected sets of examples and summarised variance statistics in the experiment section (Section 5). Although beneficial, increasing model size does not guarantee low variance We evaluate the order permutations for four different sizes of GPT-2 (0.1B1.5B) 1 and GPT-3 (2.7B175B). As we can observe in Figure 1, models can obtain remarkable few-shot performance. We see that the GPT2-XL (1.5B) model can even surpass 90% accuracy given just four samples. This result is comparable to those of supervised models trained on more than 60,000 samples. However, the performance variation of different permutations remain a big issue, especially for smaller models. 2 The same model can exhibit nearly perfect behaviour given one sample order, but then fall back to be on par with a random baseline for another. While increasing the model size (by a few order of magnitudes) can sometimes alleviate the issue, it still cannot resolve it entirely (especially if we consider tasks other than SST-2). In contrast, different initialisations of supervised fine-tuning approaches typically result in less than 1% standard deviation for their test set performance (Gao et al., 2020). Adding training samples does not significantly reduce variance To further explore the order sensitivity of few-shot prompts, we increase the number of training samples and then sample a subset of at most 24 different orderings. 3 We use the GPT2 family models for this experiment. In Figure 3, we can observe that increasing the number of training samples leads to increases in performance. However, a high level of variance remains, even with a large number of samples and can even increase. Based on this, we draw the conclusion that order sensitivity is likely to be a fundamental issue of In-context Learning regardless of the number of training samples. Performant prompts are not transferable across models We find that a specific permuta-tion's performance may drop from 88.7% to 51.6% by changing the underlying model from GPT2-XL (1.5B) to GPT2-Large (0.8B). This suggests that a particular permutation working well for one model does not imply that it will provide good results for another model. To validate this hypothesis, we use all possible order permutations of the four samples as prompts  24 in total. We then perform prediction conditioned on each of these prompts for different models and calculate the pairwise Spearman's rank correlation coefficient between the scores. These results are shown in Figure 4. If there is a common pattern for performant prompts, we should then be able to observe high correlation across models. However, the behaviour of permutations is seemingly random even across 3 Bounded at the lower limit by the total number of samples given, and at the upper limit as there can be up to 64! possible orders. different sizes of the same model. For example, the 175B and 2.7B model only has a correlation of 0.05, this means a good permutation for the 2.7B model is in no way guaranteed that it will also yield good performance for the 175B model. across models In addition to training example ordering, we also explore label ordering for training prompts. We use all patterns of the abovementioned full permutations  six different label patterns. 4 We then compute the pairwise Spearman correlation across different models as described in the previous paragraph. As shown in Figure 5, the behaviour of label orderings is once again seemingly random across different sizes of the same model. It is thus not possible to identify a label 4 NNPP, NPNP, NPPN, PNNP, PNPN, PPNN, where P/N respectively denotes positive/negative 8088 51.6 85.2 SST-2 Accuracy(%) 0 50 100 150 200 250 N u m b e r o f E x a m p l e s positivenegative orginal calibrated 55 60 65 70 75 80 85 SST2 A cc u r a c y ( % ) Figure 6: Left: Predicted SST-2 label distribution under different prompts. Degenerate behaviour of bad prompts We perform error analysis across performant and non-performant prompts and observe that the majority of failing prompts suffer from highly unbalanced predicted label distributions (Figure 6, left). An intuitive way to address this would be by calibrating the output distribution, along the lines of Zhao et al. (2021). However, we find that although calibration leads to much higher performance, the variance remains high (Figure 6, right). The previous section demonstrates that prompt order can have a substantial effect on performance, with some orderings of the same prompts for the same model providing random performance, and other better orderings providing performance competitive with supervised approaches. This suggests that there could be various ways of selecting prompt orders to achieve better performance, but the challenge is to do so automatically and without the need for additional labels (e.g., a development set). Hence, in this section, we explore the question of: How can we automatically generate a prob-ing set' to find performant prompt orderings? We approach this by: (i) for a randomly-selected set of training samples, we use every possible ordering permutation of this set as candidates; (ii) constructing a probing set by querying the language model using all candidate prompts as context; and (iii) use this probing set to identify the best ordering by ranking them using a probing metric. We propose a simple methodology to automatically construct a probing set, by directly sampling sampling from the language model itself. This approach makes it possible to generate probing sets automatically, without access to any additional data. Concretely, given a set of training samples S = { ( x i , y i ) } , i = 1 ,    , n , where x i and y i denote the sentence and label of the i th training sample. We then define a transformation T , mapping each sample into natural language space, such that t i = T ( x i , y i ) . t i is therefore a text sequence of the i th training sample using the template defined by T . In this work, we use a simple transformation function T such that T ( x i , y i ) = input: x i type: y i . This transforms each sample into a standard format sentence, which linearises each element in the set into natural language space defined as S (cid:48) = { t i } , i = 1 ,    , n . We then define a full permutation function group of n training samples, F = { f m } , m = 1 ,    , n ! , where each function f m takes S (cid:48) as input and outputs c m : the concatenation of a unique permutation. In our case, sampling four training samples at random gives up to 24 possible ordering permutations of the transformed samples. For each prompt candidate c m , we then sample from the language model to obtain the probing sequence g m  P ( | c m ;  ) , where  denotes the parameters of the pretrained language model. We stop decoding from the language model upon generating the special end-of-sentence token defined by a template, or reach the generation length limit. Our probing set construction method is illustrated in Figure 7, where the objective is to generate a probing set that shares a similar distribution to the training samples. We run this sampling process for all possible prompt ordering permutations and extract probing samples from them ( T  1 ( g ) ). Then gather extracted samples together to form the probing set D = T  1 ( g 1 )  ... T  1 ( g n ! ) . Although the probing set contains predicted label for each sentence, there is no guarantee on the validity of these labels. Therefore, we discard them from the probing set as we are only interested in sampling probes from the language model corresponding to the input distribution. Once we have constructed a probing set for a given set of samples, we can now use that probing set to identify the best possible prompt ordering for that particular sample set. Here, we explore two 8089 Figure 7: Our probing set construction method, showing the various possible ordering permutations of the randomly selected training samples, the resulting generation for each permutation, and the concatenation of each into a probing set. Global Entropy (GlobalE) The motivation behind GlobalE is to identify prompts of specific sample orderings that avoid the issue of extremely unbalanced predictions (as we have previously established it as key problem for non-performant prompts). We compute the predicted label  y i for data point ( x (cid:48) i , y (cid:48) i ) under context c m as follows:  y i,m = argmax v  VP ( v | c m  T ( x (cid:48) i );  ) (1) For each label v  V (where V denotes the target label set), we compute the label probability over the probing set as: p vm = (cid:80) i 1 {  y i,m = v } | D | (2) We then use the predicted category label entropy as the GlobalE score for c m as follows: GlobalE m = (cid:88) v  V  p vm log p vm (3) Local Entropy (LocalE) The motivation behind LocalE is that if a model is overly confident for all probing inputs, then it is likely that the model is not behaving as desired. At the very least, it is poorly calibrated, which could also be an indication of a poor capability to appropriately differentiate between classes. Similar to the GlobalE computation, we calculate the prediction probability of a data point ( x (cid:48) i , y (cid:48) i ) over the target labels v  V under context c m , as follows: p vi,m = P ( x (cid:48) i ,y (cid:48) i )  D ( v | c m  T ( x (cid:48) i );  ) , v  V (4) We then calculate the average prediction entropy per data point as the LocalE score: LocalE m = (cid:80) i (cid:80) v  V  p vi,m log p vi,m | D | (5) As we now have a way to score each prompt ordering, based on its effect against the probing set, we can rank each prompt ordering by performance as measured by GlobalE or LocalE respectively. We use four different sizes of GPT-2 (Radford et al., 2019) (with 0.1B, 0.3B, 0.8B, and 1.5B parame-teers) and two sizes of GPT-3 (Brown et al., 2020) (with 2.7B, and 175B parameters). Due to limited context window size (up to 1024 word-pieces for the GPT-2 series of models), we use a 4-shot setting for all datasets except AGNews and DBPedia. Our experiments are based on the open-source checkpoints of GPT-2 models and access to the OpenAI GPT-3 API. 5 For probing set generation, we restrict the maximum generation length to 128. We also use sampling with a temperature, t , of 2, and we also make use of block n -gram repetitions (Paulus et al., 2018) to encourage diverse generation. We use 24 different permutations for each set of randomly selected training samples and use 5 different sets (except for GPT-3 with 175B parameters, where we only do two sets with 12 different permutation due to the high monetary cost) for each experiment, giving a total of 120 runs. We report the mean and standard deviation of the corresponding evaluation metric over 5 different sets. For performant prompt selection, we rank candidate prompts using the LocalE and GlobalE prob-5 https://openai.com/api/ 8090 SST-2 SST-5 DBPedia MR CR MPQA Subj TREC AGNews RTE CB Majority 50.9 23.1 9.4 50.0 50.0 50.0 50.0 18.8 25.0 52.7 51.8 Finetuning (Full) 95.0 58.7 99.3 90.8 89.4 87.8 97.0 97.4 94.7 80.9 90.5 GPT-2 0.1B 58 . ing metrics over the automatically generated probing set. We then select top k samples ranked by highest entropy values, where k = 4 in our experiments, of the available 24 permutations as performant prompts. Finally, we use these performant prompts to evaluate performance on various datasets and demonstrate both better performance and reduced variance. We also provide results for a majority baseline, which always predicts the majority label in the dataset, as a lower-bound of performance. We also provide an oracle to show the upper-bound of performance by selecting the top four performant orderings based on prompt performance on the validation set. Similar to previous work (Gao et al., 2020; Zhao et al., 2021), we use eleven text classification datasets ranging from sentiment classification to textual entailment. Further details of the datasets are provided in the Appendix. For evaluation, we sub-sample 256 samples of the validation sets for all datasets to control for the GPT-3 inference costs as it requires the usage of a monetary paid-for API. We report experimental results in Table 2 and observe consistent improvements for both LocalE and GlobalE across all tasks. Entropy-based probing is effective for performant prompt selection regardless of model size We find that GlobalE achieves, on average, a 13% relative improvement across the eleven different sentence classification tasks in comparison to prompts that do not make use of probing. LocalE provides results slightly inferior to GlobalE, with an average 9.6% relative improvement over the baseline model. Our selected performant prompts also demonstrate considerably lower variance than using all candidate prompts. In Figure 8, we visualise the average performance when varying K for the top K prompt selection. K = 24 corresponds to using all sampled prompt orders, which is equivalent to the baseline model performance in Table 2. We can observe that the slope of curves are negative for all datasets, suggesting that our method can rank performant prompts effectively. Though K = 1 can provide good performance for most cases, in our experiments, we use K = 4 as preliminary experiments indicated that it yielded stable performance across datasets. Entropy-based probing is effective across templates We evaluate Entropy-based probing for four different templates similar to Gao et al. (2020) and Zhao et al. (2021) (Table 4) for the SST-2 dataset. Experimental results in Table 3 indicate that Entropy-based probing is valid for different templates. We also observe that the randomness across different templates is similar to Section 2. These findings suggest that Entropy-based probing is not sensitive to specific templates, as it consistently provides improvements for all cases. Performant permutation selection is a safe option for In-context Learning We find that for models that suffer from high prompt variance, our prompt selection process can show large improvements  up to 30% relative improvement. Furthermore, for tasks with low initial prompt performance variance, our method does not negatively impact performance. Our prompt selection provides marginal improvement at worse and on average a 13% relative improvement in the most cases. Sentence-pair tasks remain challenging for smaller-sized models even with performant permutation selection For the CB and RTE datasets, Template 1 Template 2 Template 3 Template 4 GPT-2 0.1B 58.9 7 . the performance of GPT-2 models is not significantly different from that of a random baseline. Despite this, we find that our method for identifying performant prompts can still provide minimal performance gains, although these are still within the levels of a random guess or majority vote. One reason for this could be that, for these particular sizes of models on these tasks, no good prompt exists. As such, optimising the prompt is not particularly effective in this setting. This is further supported by the observation that prompt selection can considerably improve performance on both CB and RTE at larger model sizes (particularly so for the GPT-3 175B parameter model). In fact, we find that prompt selection using GlobalE improves performance by 4.9% for GPT-3 175B on CB. This indicates that our method is widely applicable to all model sizes, and across all tasks, as long as they already possess some existing classification ability that can be improved through prompt design. Entropy-based probing outperforms using subsets of the training data for tuning If one was not to rely on generation, an alternative approach to prompt selection could be to split the (limited) training data to form a validation set. To compare 8092 GPT-2 0.1B GPT-2 0.3B GPT-2 0.8B GPT-2 1.5B Baseline 58 . against this approach, we split the 4-shot training samples (same setting as in Table 2) in half. We then select the top four performing prompts using validation set performance. As can be seen in Table 5, this approach consistently outperforms the baseline. However, both Entropy-based probing methods consistently provides better performance across all model sizes. Unified Interface Design for NLP Most previous work focuses on shared-parameters models, pretrain on some tasks, then fine-tune for different tasks, e.g. ELMo (Peters et al., 2018), BERT (De-vlin et al., 2019), etc. Eventually, leading to multiple task-specific models. There has for some time been attempts to design a unified interface for NLP tasks (Kumar et al., 2016; Raffel et al., 2020).In parallel with these works, GPT-2 (Radford et al., 2019) shows that appending trigger tokens (e.g. TL;DR) at the end of language model input can cause language models to behave like summarisation models. The zero-shot capability of language models shows the potential to unify NLP tasks into a language modelling framework where fine-tuning is not necessary to achieve good performance. Furthermore, GPT-3 (Brown et al., 2020) shows that task-agnostic, few-shot performance can be improved by scaling up language models. It can sometimes even become competitive with prior state-of-the-art fine-tuning approaches. Prompt Design for PLMs The core challenge of prompt design is to convert training data (if it exists) into a text sequence. Most work on prompt design focuses on how to make prompts more compatible with language models. Petroni et al. (2019) uses human effort to design natural language sentences and then perform token prediction given the input context. However, hand-crafted templates require significant human effort and is likely to end up with sub-optimal performance. Recent work has explored automatic template construction: Schick and Schtze (2020) uses cloze-style tasks to construct templates, Gao et al. (2020) uses an external language model to generate templates, and Shin et al. (2020) uses gradient-guided search to find templates that maximise performance. Jiang et al. (2020) uses a mining-based method to create multiple diverse templates automatically. Order Sensitivity of Prompt Design Gao et al. (2020) demonstrated that finetuning-based approaches are not as order sensitive as In-context Learning. Making use of a standard-size training set, Liu et al. (2021) used nearest neighbour search to retrieve the most relevant training samples for a specific test sample. They were successful in retrieving relevant samples and concluded that after retrieving them the order in which they are provided in the prompt has little to no effect on performance. While our study is fundamentally different from theirs in that we do not make use of a standard-size training set, we do come to the opposite conclusion. All previous work on prompt design focuses on the textual quality of the prompt and, to the best of our knowledge, none has studied order sensitivity in detail. True Few-shot Learning Perez et al. (2021) evaluated few-shot capability of LMs when a held-out validation set is not available. Experimental result suggested that previous work overestimate the few-shot ability of LMs in this (true few-shot learning) setting. Our work instead use the generative nature of language models to construct a probing set without relying on held-out examples. We show that our probing method is better than relying on held out examples (Figure 5) and thus enables true few-shot learning. We have shown that few-shot prompts suffer from order sensitivity, in that for the same prompt the order in which samples are provided can make the difference between state-of-the-art and random performance. In our analysis of the problem, we established that it is present across tasks, model sizes, prompt templates, samples, and number of training samples. To alleviate this problem, we introduced a novel probing method that exploits the generative nature of language models to construct an artificial development set. We were able to identity performant permutations using entropy-based statistics over this set, leading to an on average 13% improvement across eleven text classification tasks.
abstain objective method abstain method method other abstain other abstain abstain abstain abstain abstain abstain abstain method result abstain abstain abstain result abstain abstain method objective objective objective result method method abstain method abstain abstain abstain abstain abstain method abstain abstain method abstain abstain abstain abstain abstain method method abstain abstain abstain abstain abstain abstain method method abstain other abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain method abstain method abstain method abstain method abstain method abstain method abstain abstain method method abstain abstain other abstain method method method method method method method method other abstain method method method method method abstain method result result abstain abstain abstain abstain method method abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method method abstain abstain other other other other other other other other other other other other other other other other abstain method other other method abstain result method objective method