An Information-theoretic Approach to Prompt Engineering Without Ground Truth Labels (2022)

Abstract: 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.

## introduction it is well-known that large pre-trained language models (lms) learn substantial linguistic @xcite and factual world knowledge @xcite @xcite , achieving state-of-the-art performance on classic nlp tasks like closed-book question-answering, sentiment analysis, and many other tasks @xcite @xcite . the largest models can do this in a few-shot way-that 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 @xcite . 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 "understand" what is meant and perform well on the task if it has the capacity. however, lms can generate substantially different output distributions-and thus text-given two distinct prompts that appear semantically invariant (e.g., alternative orderings, lexical changes like capitalization, and general rephrasing @xcite ). 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. ## 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 @xcite . the best performance on prompt engineering is often achieved using backpropagation in continuous prompt embedding space @xcite @xcite @xcite 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) @xcite , 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 @xcite . 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 @xcite @xcite . ours is the first work of which we are aware to apply mi to prompt engineering. @xcite ) 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. ## methods at the most abstract, our method is as follows (see appendix a for a more thorough description): we find it useful to unify all the tasks we study within a single framework, which we describe in given the following questions and choices, pick the choice that corresponds best to the question. "i'm crossing the river, my feet are wet but my body is dry, where am i?", "bridge, waterfall, valley, pebble, mountain", -> "valley" "in what spanish speaking north american country can you get a great cup of coffee?", "mexico, mildred's coffee shop, diner, kitchen, canteen", -> "mexico" "<@xmath0, "<a>, <b>, <c>, <d>, <@xmath1, choices, answers "what is france?", "[state,city,country,continent, mountain range]", country "<@xmath2, "[<a>, <b>, <c>, <d>, <@xmath3, if asked the question '<@xmath4, and given the choices '<@xmath5, '<@xmath6, '<@xmath7, '<@xmath8, and '<@xmath9, i would say ..... @xmath10. we pass this prompt through the language model via g ϕ , yielding a probability distribution over the model's tokens t ϕ . the collapsing function c θ sums the weight given to each token corresponding to each possible answer @xmath11, giving a probability distribution p (y |x i ), which we can use to estimate mutual information or obtain a guess for y i . 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. ## results in this section, we analyze our experiments. first, we look at our method's ability to select highaccuracy prompts across models and datasets (section 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 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. ## conclusion 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.