Pre-trained language models derive substantial linguistic and factual knowledge from the massive corpora on which they are trained, and prompt engineering seeks to align these models to specific tasks. Unfortunately, existing prompt engineering methods require significant amounts of labeled data, access to model parameters, or both. We introduce a new method for selecting prompt templates without labeled examples and without direct access to the model . Specifically, over a set of candidate templates, we choose the template that maximizes the mutual information between the input and the corresponding model output. Across 8 datasets representing 7 distinct NLP tasks, we show that when a template has high mutual information, it also has high accuracy on the task. On the largest model, selecting prompts with our method gets 90% of the way from the average prompt accuracy to the best prompt accuracy and requires no ground truth labels. It is well-known that large pre-trained language models (LMs) learn substantial linguistic (Liu et al., 2019; Amrami and Goldberg, 2018) and factual world knowledge (Petroni et al., 2020; Bosselut et al.; Bouraoui et al.; Zuo et al., 2018), achieving state-of-the-art performance on classic NLP tasks like closed-book question-answering, sentiment analysis, and many other tasks (Radford et al., 2019; Devlin et al., 2019; Raffel et al., 2019). The largest models can do this in a few-shot waythat is, being trained only with generic, semi-supervised objectives and taught tasks with just instructions and a few examples of the task provided via a natural language prompt in the context window (Brown et al., 2020). This suggests that pre-training equips them to potentially do many tasks that can be formulated as natural language generation, if only they can be primed in the right way. Such priming is not a trivial task. The few-shot learning breakthrough can give the impression that if the LM is given a sensible prompt, it will under-stand what is meant and perform well on the task if it has the capacity. However, LMs can generate substantially different output distributionsand thus textgiven two distinct prompts that appear semantically invariant (e.g., alternative orderings, lexical changes like capitalization, and general rephrasing (Zhao et al., 2021; Lu et al., 2021)). This can lead to surprisingly high variance in performance from prompt to prompt. Clearly, some prompts are better than others for aligning a model to a task. Prompt engineering is a nascent field that aims to find aligning prompts (Reynolds and McDonell, 2021). While prompt refers to any language passed to the model via the context window, a template refers to a natural language scaffolding filled in with raw data, resulting in a prompt. Thus, prompt engineering includes finding high-quality templates (i.e., those with high test accuracy). Generally, this is done by optimizing for accuracy over 819 a validation set: a template is chosen from a candidate set based on its performance on labeled examples. Such labeled examples can be challenging to procure for some tasks and impossible for others. Some recent methods optimize prompts using backpropagation, which requires access to model weights. In this paper, we propose a new method for selecting prompts by using mutual information, which allows prediction of a prompt's performance without labels or access to model parameters. Mutual information (MI) is a metric that quantifies the shared information between two random variables (see Section 3.2). We demonstrate that the mutual information between a prompt and a language model's output can serve as a useful surrogate for the test accuracy of a template. Specifically, for eight popular datasets representing seven classic NLP tasks, we generate a diverse set of 20 templates for each and show that template mutual information and template accuracy are highly correlated. These results are strongest on the largest models we study, for which our method chooses prompts that, on average, get 90% of the way from mean accuracy to maximum accuracy and even selects the best prompt on three of eight datasets. This suggests that, across a variety of NLP tasks, mutual information can be used to select one of the best prompts from a set of candidate prompts, even without making use of model weights or ground truth labels. In the following pages, we outline each step of our general method for generating and evaluating templates so that it can easily be ported to any other task. Code is available online. 1 2 Related Work The promise of language models and the challenge of aligning them has given rise to the field of prompt engineering, which seeks to construct the best prompt given a task and a language model (Liu et al., 2021a). The best performance on prompt engineering is often achieved using backpropaga-tion in continuous prompt embedding space (Lester et al., 2021; Li and Liang, 2021; Gu et al., 2021; Liu et al., 2021b; Zhang et al., 2021) in contrast to generating a discrete set of prompts by hand and testing them. While optimizing in continuous prompt space via backprop allows for similar performance to model-tuning (at least at higher model sizes) (Lester et al., 2021), not all models are publicly available. Thus, these methods are 1 github.com/BYU-PCCL/information-theoretic-prompts only feasible for those who have direct access to the model and can perform backprop on it. Prompts optimized in continuous space are also not interpretable in natural language, making it harder to transfer insights from prompts that work well for one task to another task. Additionally, these methods require labeled examples, while ours does not. Other selection protocols not based on gradient descent can include cross-validation or minimum description length, as in (Perez et al., 2021). These methods yield prompts that perform marginally better than average in terms of test accuracy. Mutual information has been used in n-gram clustering, part-of-speech tagging, probing classifiers, and LM training objective reframing (Brown et al., 1992; Stratos, 2019; Voita and Titov, 2020; Kong et al., 2019). Ours is the first work of which we are aware to apply MI to prompt engineering. (Lu et al., 2021) make use of entropy statistics to determine performant orderings for few-shot examples in prompts. Our work is focused on selecting high quality templates with no special focus on example ordering or need for multiple examples to order (the few-shot case). Our method uses no artificial probing set, making our prompt selection much cheaper, and we also explore open-ended tasks. While the GlobalE and LocalE statistics they use are similar (and in the case of LocalE identical) to the two parts of our MI calculation (see 3.2), we use the two statistics jointly and choose prompts by minimizing, rather than maximizing, LocalE. At the most abstract, our method is as follows (see Appendix A for a more thorough description): 1. Generate a set of K prompt templatizing functions. 2. Playground a couple of examples to ensure that templates give roughly expected output. 3. Estimate mutual information for each template given a set of inputs x 1 , x 2 , ..., x N where x i  X,  i . 4. Choose template(s) based on mutual information and perform inference. Section 3.1. We also justify our use of mutual information as a surrogate for prompt quality and specify how we estimate it in Section 3.2. In order to demonstrate our method's widespread applicability and general effectiveness, we validate it across many datasets and tasks. This requires us to estimate MI and accuracy, and this is most straightforward in the case where, given a context, a language model produces just one probability distribution P ( t n | context = t 1 , t 2 , ..., t n  1 ) . This is in contrast to other experimental setups that use multi-token sampling methods (e.g., beam search), although our method is easily tractable in such setups. 2 Any NLP task is tractable in this framework so long as the output space consists of a set of options that each start with a unique token. In this case, the language model can give an answer by assigning probability to tokens that begin giving each of these answers (invariant to lexical variation like capitalization and leading/trailing spaces). While, for open-ended tasks, this method might artificially inflate accuracy if the model starts to 2 The only difference: For each considered answer, simply calculate its unnormalized probability by multiplying the probabilities of the decisions taken at each branch in the sequence of tokens, then normalize the resulting probability scores. give a wrong answer that happens to start with the same token as the correct one, we find that this difference is small and does not affect our results. 3 Irrelevant tokens (with which none of the desired answers begin) are ignored, and the resulting collapsed probabilities are normalized. We term this approach One-token Response (OTR). Although our method isn't limited to OTR tasks, we choose tasks that can be cast as OTR tasks for simplicity and to reduce computational expense. Many NLP tasks fit within this framework, although a few do not (e.g., machine translation and summarization). This basic approach is in common use (Brown et al., 2020), but we formalize it for clarity below. Generally, the OTR framework casts a natural language task as a classification problem with raw data input x i  X and output P ( Y | x i ) , a probability distribution over targets. In order to use a language model  for this task, a templatizing function f  : X  L is needed to map raw data 3 Our open-ended datasets are SQuAD, LAMBADA, and ROCStories, and none of these seemed more likely than ROCStories to exhibit this issue. We reran our experiment on ROCStories by sampling with temperature 0 until reaching a space, and only counted responses as accurate if they exactly matched the corresponding ground truth labels. Results were virtually unchanged: accuracy decreased by only 0.03 on average, and the correlation between mutual information and test accuracy increased by 0.04, from 0.68 to 0.72. into natural language prompts. g  : L  T  maps prompts to a probability distribution over T  , the token set represented by the model tokenizer. Finally, a collapsing function c  : T   P ( Y | x , ,  ) (see Appendix A) yields an estimate of P ( Y | X ) : P ( Y | x , ,  ) = c  ( g  ( f  ( x ))) , x  X (1) We also refer to P ( Y | x , ,  ) as P ( Y | f  ( x )) . The above pipeline can be specified in many ways using different  and  (see Figure 2), which will result in different accuracies. Our ultimate aim is to select the best  given  . Whereas past prompt engineering methods rely on scores calculated by comparing model answers and ground truth, our method selects  by maximizing mutual information, which requires no ground truth labels. Mutual information is a measure of the amount of shared information between two random variables (Cover and Thomas, 2006); in other words, it is the reduction in entropy that is observed in one random variable when the other random variable is known. We expect MI to serve as a good criterion for comparing prompts. Previous work has shown that large networks trained with cross-entropy loss are calibrated (e.g., a 60% confidence corresponds to a 60% chance of the model being correct) when in the early-stopped (  1 epoch) regime (Ji et al., 2021), but become miscalibrated in the overfit regime (Nakkiran and Bansal, 2020). According to (Brown et al., 2020), GPT-3 was trained for a different number of epochs on each corpus in its training data. We calculate it was trained for an average of 1.57 epochs, so we have reason to believe that GPT-3 is generally well-calibrated. Thus, we postulate that a prompt that elicits a very confident response (high MI) from the language model is more likely than a less confident prompt to score well. We denote the mutual information between random variables X and Y as I ( X ; Y ) and the entropy of X as H ( X ) =  (cid:82) x  XP ( x ) log ( P ( x )) d x . The mutual information between X and Y is defined as DKL ( P ( X,Y ) || PX  PY ) , and can be rewritten as H ( Y )  H ( Y | X ) (the reduction in entropy in Y given knowledge of X ). Using the OTR framework, we fix a model  and generate a diverse set of K prompt templatizing functions f  1 , f  2 , ..., f  K along with their corresponding collapsing functions c  k (see Appendix A). Treating f  ( X ) := { f  ( x ) , x  X } as a random variable, we can calculate I ( f  ( X ); Y ) and use it as a criterion for selecting prompt templatizing functions with which to do inference. We hypothesize that a  i with higher mutual information will align a language model to a task better than a  j with lower mutual information. Formally, we select   = argmax  { I ( f  ( X ); Y ) } . Mutual information is estimated as: I ( f  ( X ); Y ) = H ( Y )  H ( Y | f  ( X )) (2) where each term is estimated in expectation using draws x i  X and Equation 1 as follows: H ( Y )  H (cid:32) 1 NN (cid:88) i =1 P ( Y | f  ( x i )) (cid:33) (3) H ( Y | f  ( X ))  1 NN (cid:88) i =1 H ( P ( Y | f  ( x i )))) (4) The marginal entropy H ( Y ) is the entropy of the mean of the conditional distributions, and the conditional entropy H ( Y | f  ( X )) is the mean of entropies of the individual conditional distributions. This definition gives us another reason to expect that mutual information will work well. Since mutual information is the marginal entropy minus the conditional entropy, maximizing mutual information is equivalent to maximizing marginal entropy and minimizing conditional entropy. Thus, MI is high for templates that are, on average, less biased towards any given answer (high marginal entropy) and templates with outputs the model is confident about (low conditional entropy). These attributes are desirable in constructing prompts, and we postulate that maximizing mutual information will yield a well-aligned template. Looking at it another way, by the data processing inequality (Cover and Thomas, 2006), I ( f  ( X ); Y )  I ( X ; Y ) . Thus, I ( f  ( X ); Y ) gives a lower bound for I ( X ; Y ) , and the highest mutual information is the tightest lower bound. The prompt corresponding to this lower bound preserves the most information between X and Y . We validate the efficacy of our prompt engineering method with experiments on eight well-known NLP datasets 4 SQuAD2.0 (Rajpurkar et al., 2018), LAMBADA (Paperno et al., 2016), ROCStories (Mostafazadeh et al., 2016), CommonsenseQA (CoQA) (Talmor et al., 2018), IMDB (Maas et al., 2011), BoolQ (Clark et al., 2019), COPA (Gor-don et al., 2012), and WiC (Pilehvar and Camacho-Collados, 2018))that span seven unique NLP tasks (see Table 1). We used a random sample of N = 500 samples from each dataset for our experiments. 5 For ROCStories, which consists of a set of five sentence stories, we randomly masked a word from each story in order to use the data for masked word prediction (cloze). We made minor changes to two of the datasets in 5 We sampled from the train sets of CoQA and SQuAD; the train and validation sets of WIC, COPA, and BoolQ; the full datasets of ROCStories and IMDB; and the test set for LAMBADA. order to cast the associated tasks into OTR. For the SQuAD dataset, we dropped all questions that did not have a one word answer. For the CoQA dataset we dropped all questions with answer choices that started with a shared first word (e.g, the dog, the cat, the monkey). Both changes were to decrease ambiguity about which option the model was choosing given its output distribution for a single token. We assess our method on eight models ranging from 124 million to 175 billion parameters : These include GPT-2 124M & 1.5B (Radford et al., 2019), GPT-Neo 2.7B (Black et al., 2021), GPT-J (6B) (Wang and Komatsuzaki, 2021), and (Ada, Babbage, Curie, & Davinci) GPT-3 (Brown et al., 2020). We assume (per (Perez et al., 2021)) these models to correspond, respectively, to the 2.7B, 6.7B, 13B, and 175B models in (Brown et al., 2020). Each is a causal language model, and although we do not include masked language models, this is a promising area for future work. In this section, we analyze our experiments. First, we look at our method's ability to select high-accuracy prompts across models and datasets (Sec-tion 5.1). Next, we correlate template mutual information and accuracy in Section 5.2. After that, we compare our method and template selection using labeled examples in Section 5.3. In Section 5.4, we 823 GPT3 : 175 BGPT3 : 13 BGPT3 : 6 . explore the robustness of MI and use ensembling to improve it. Finally, we compare the tranferability of prompt templates selected with MI from model to model in Section 5.5. We first define baselines against which we compare our approach. Other prompt engineering methods generally require either access to model weights, labeled data (validation set selection), or both (back-prop/continuous prompt embedding methods). Our method does not require these, so we instead compare to random and oracle baselines. A random template selection method would give us the average accuracy of our template set (in expectation), while an oracle selection method would give us the best accuracy every time. To understand how our MI method compares to these two baselines for each dataset, refer to Figure 1, where we analyze performance on GPT-3 175B. On each of the eight datasets, mutual information selects a prompt template that outperforms both the mean and median accuracies (random baseline performance). In three of the eight datasets, mutual information selects the best (highest accuracy) template from the 20 proposed (equivalent to oracle performance). Given our method's promising performance with GPT-3 175B, it is natural to ask how it performs with smaller models. Figure 3 shows the accuracy distributions over prompt templates for each dataset/model pair. With every model, MI gives above-average performance on several datasets. Although MI is more likely to select a high ac-3 4 5 0.4 0.6 0.8 A cc u r ac y SQuAD 2 4 0.4 0.6 0.8 LAMBADA 2 4 0.2 0.4 A cc u r ac y ROCStories 0.0 0.5 0.3 0.4 0.5 0.6 CoQA 0.1 0.2 0.3 0.6 0.8 1.0 A cc u r ac y IMDB 0.0250.0500.075 0.5 0.6 0.7 0.8 BoolQ 0.000 0.025 0.5 0.6 0.7 A cc u r ac y COPA 0.01 0.02 0.03 0.450 0.475 0.500 WiC 0.0 0.2 0.4 0.6 0.8 1.0 Mutual Information (nats) 0.0 0.2 0.4 0.6 0.8 1.0 Mutual Information vs. Accuracy with GPT-3 175B Figure 5: Each dot represents a template and its average mutual information and accuracy over N = 500 task instances. curacy template for larger models, it is a good criterion even for smaller models on all but two datasets, COPA and WiC. Note that, for these two datasets, none of the templates do significantly better than chance (  50%) besides the largest model on COPA, which is in line with previous work. 6 Thus, we observe that mutual information performs best when there is a high-signal prompt to select, and worse when all prompts are low-signal. When considering all other datasets, MI selects an above average prompt 83% of the time for all models; for the largest two models, MI selects an above average template 100% of the time. In Section 5.1, we see how the mutual information selected template does in terms of accuracy compared to all other templates. We have not dis-6 Our template's best accuracy is 54% for WiC, and 78.2% for COPA, which is similar to previous work (WiC: (Brown et al., 2020) 49.4%, (Perez et al., 2021) 54.1%; COPA: (Brown et al., 2020) 92.0%, (Perez et al., 2021) 84.8%). cussed, however, how generally MI and accuracy are correlated, except that the highest MI template tends to have anomalously high accuracy. Here, we establish that their correlation is high across all templates for the largest LMs. Each of the K = 20 templates has two corresponding measures: average accuracy and average MI. We can use these pairs to correlate MI and accuracy via Pearson's R. We see in Figure 4 that the correlations are surprisingly high for the majority of models and datasets. For SQuAD, LAMBADA, ROCStories, and CoQA, this pattern holds across all model sizes; for the remainder, results are good on larger models and are much less reliable on smaller models. Overall, this is evidence that as mutual information increases, so does accuracy. In other words, mutual information can be used to make an educated guess about accuracy without having to use any ground truth labels, especially on larger models. Next, we ask: How does our method compare to selecting a template based on the accuracy of a few-labeled examples? Also, how many unlabeled examples does MI need to be able to perform well? Results with the largest model are reported in Figure 6. Note that with as few as N = 2 instances, MI selects a far better than average template, allowing performance gains even in the low-data, unlabeled regime. Additionally, for low N and across all eight datasets, MI even selects a better template on average than selecting based on labeled train set accuracy. This suggests that, even with labeled examples, selecting based off of MI may be preferable to test accuracy with few examples. Selecting by labeled train set accuracy often begins to perform better at higher N , but at the cost of requiring labeled data, while our method needs no labels. To explore our method's robustness we consider the question: what if we had included a different subset of templates, especially not including the top MI template? Figure 5 shows average MI/accuracy data for all K = 20 prompt templates on GPT-3 175B (similar plots for other models are found in Appendix B.1). For six of eight datasets, the results are robust; the top few prompt templates (by MI) are all high performers. The performance for COPA and WiC is more brittle; excluding the top-MI template would have resulted in a large drop in accuracy. This attests to the utility of generating a diverse slate of templates as recommended in Appendix A and also to the risk that outliers could compromise our method's effectiveness. an important concern. Considering the strength of MI/accuracy correlations, one simple approach is to ensemble the top 5 MI templates. To compare this principled top-5 ensemble to other possible ensembles of templates, we take all (cid:0) 205 (cid:1) subsets of 5 templates from all 20 templates and calculate the accuracy of each ensemble. For each dataset, we plot this distribution's kernel density estimate, which models the p.d.e. of the random variable accuracy of 5 random templates ensembled together. We then compare the top-5 MI ensemble to other possible ensembles. The results are shown in Figure 7. We found that the top-5 MI ensemble does at least as well as the top-20 ensemble in all but one case. Two reasons to use MI are, then, that 1) the MI ensemble gets as good or better a result as ensembling all prompt templates and 2) at a fourth of the experimental cost. In short, ensembling by MI is a cheap and effective way to guard against anomalous high MI/low accuracy templates. Finally, we explore how well-chosen templates generalize between models. Concretely, we choose templates by maximizing either test accuracy (or-acle) or mutual information (our method) using a selection model  s , and then calculate test accuracy using a different inference model  i . We calculate absolute test accuracy and then normalize it such that 0 and 100 correspond to the average and maximum scores across templates for a model/dataset pair. We average our results across datasets and present the results in Figure 8. Prompt transfer for 826 each dataset can be found in Appendix B.2. MI performance is best when the largest model (GPT-3 175B) is used as both the selection and inference model: on average, MI scores 90% on this normalized scale. Additionally, performance is most consistently high when the largest models are used either for selection or inference. But almost all transfer scores are well above 0 (only one negative average gain out of 64 transfer permutations), suggesting that transfer is often effective. Overall, we have observed that prompt selection by mutual information is surprisingly effective across a variety of datasets and model sizes. This method works best on larger models and for tasks that the LM is capable of performing. Given the high diversity of tasks that we have explored, we expect this method to transfer well to many other NLP tasks, including regimes with little labeled data. In this paper, we introduce a method for selecting prompts that effectively align language models to NLP tasks. Over a set of candidate prompts, our method selects the template that maximizes the mutual information between the input and the model output. We demonstrate that 1) mutual information is highly correlated with test accuracy and 2) selecting a prompt based on mutual information leads to significant accuracy gains over random choice, approaching oracle performance on GPT-3 175B, and it does so across model sizes and tasks. Whereas other methods rely on ground truth labels and/or direct model access, ours requires neither. Many applications characterized by lack of computational resources, limited model access (e.g., inference only), and lack of ground truth data prohibiting testing of candidate prompts become feasible with our method. There are many ways to prompt a language model poorly, and there still seem to be NLP tasks which are beyond alignment regardless of model size or prompt quality. This method cannot align a LM to a task if the entire set of prompts is poor or, obviously, if the model cannot be aligned. High mutual information does not necessarily imply high accuracy despite the strong correlation we found. Thus, our method should only be employed on a task if there is some understanding of how high MI needs to be on a domain or set of templates to imply a sufficiently high accuracy for safe use. Otherwise, we introduce no model, dataset, or other contribution that might warrant ethical concern. We thank the anonymous reviewers for their helpful feedback. This material is based upon work supported by the National Science Foundation under Grant No. RI 2141680.
abstain abstain objective method result abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain objective abstain objective result result abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain objective abstain method objective result method abstain abstain abstain abstain abstain method method method method abstain abstain abstain method abstain method method abstain method abstain method method abstain abstain abstain method abstain method method abstain method abstain abstain method method method abstain method method method method other method abstain abstain method abstain abstain abstain method abstain method method method abstain method method abstain method method method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain other abstain abstain result abstain result abstain abstain abstain abstain result abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain method abstain abstain method method method result abstain abstain abstain abstain abstain result abstain abstain abstain result abstain abstain abstain abstain objective abstain abstain abstain abstain abstain method abstain other other other