Cutting Down on Prompts and Parameters: Simple Few-Shot Learning with Language Models (2022)

Abstract: Prompting language models (LMs) with training examples and task descriptions has been seen as critical to recent successes in few-shot learning. In this work, we show that finetuning LMs in the few-shot setting can considerably reduce the need for prompt engineering. In fact, one can use null prompts, prompts that contain neither task-specific templates nor training examples, and achieve competitive accuracy to manually-tuned prompts across a wide range of tasks. While finetuning LMs does introduce new parameters for each downstream task, we show that this memory overhead can be substantially reduced: finetuning only the bias terms can achieve comparable or better accuracy than standard finetuning while only updating 0.1% of the parameters. All in all, we recommend finetuning LMs for few-shot learning as it is more accurate, robust to different prompts, and can be made nearly as efficient as using frozen LMs.

## introduction few-shot learning-the ability to learn tasks with limited examples-is an important academic and practical challenge @xcite . in stateof-the-art nlp, few-shot learning is performed by reformulating tasks as natural language "prompts" and completing those prompts with pre-trained language models @xcite . prompts that are well-designed can substantially improve accuracy @xcite . however, finding these prompts is difficult: it requires a non-trivial combinatorial search over the prompt's wording (a.k.a. its pattern or template), whether and how to include training examples, and how to convert language model probabilities into class predictions. consequently, prompts are often designed using human * work done while an intern at facebook ai research. in this work, we seek to mitigate prompt engineering by identifying a class of simple prompts that are effective across many tasks for masked language models (lms). we find that, when using prompt-based finetuning @xcite , the prompt requires less optimization than previously thought; in fact, the pattern and training examples can be completely cut out (e.g., figure 1 , right). these null prompts-simple concatenations of the inputs and the [mask] token-achieve comparable accuracy to manually-written patterns while drastically simplifying prompt design: users only need to decide the label names (a.k.a. the verbalizer) and where to place the [mask] token. the effectiveness of null prompts also challenges the common wisdom that the success of few-shot learning is due to inductive biases present in the prompt. a key drawback of prompt-based finetuning is that it has large memory requirements for each new downstream task at inference time (figure 1 , left). in contrast, in-context learning @xcite allows reusing the large-scale lm across tasks, but it requires significant prompt engineering. to determine whether memory efficiency and simple prompt selection can be simultaneously achieved, we experiment with either: (1) making prompts for in-context learning similarly easy to create, or (2) making prompt-based finetuning more memory efficient. for (1), we simplify prompt engineering for in-context learning by automatically tuning the prompt's tokens or embeddings, an approach that has been successful in the non-few-shot setting @xcite . for (2), we study lightweight finetuning alternatives that update a smaller set of parameters: bitfit @xcite , adapters @xcite , and calibration layers @xcite . ## prompting language models we use masked lms for few-shot learning. following schick and schütze (2021a), we have: • a pre-trained masked lm, with t denoting its vocabulary and t * the set of all token sequences. ## simplifying prompt engineering in this section, we run prompt-based finetuning and ablate different elements of the prompt. we consider the following ablations: in all cases, we finetune all of the masked lm parameters. we show the accuracy of the above prompts as well as traditional finetuning (using a [cls] token and a classification head) in figure 3 . 2 manual prompts perform best the manuallywritten prompts from prior work perform best on average for both models. on the other hand, our manual prompts (w/o engineering) are noticeably worse than the ones from prior work and are outperformed by many other methods. null prompts are competitive in many cases, prompt tuning and null prompts perform comparably to manually-written prompts, especially for roberta. for instance, both of these methods outperform manual prompts (w/o engineering) in b o o l q c b m n l i -m m n l i -m m m r p c q n l i q q p r t e s s t -2 0 25 50 75 100 roberta (large) # wins 0 5 b o o l q c b m n l i -m m n l i -m m m r p c q n l i q q p r t e s s t -2 0 25 50 75 100 albert (xxlarge-v2) # wins 0 2 4 manual prompt (prior) manual prompt (w/o engineering) prompt tuning null prompt null verbalizer null prompt + verbalizer the only decision to make when using null prompts is which order to concatenate the mask token and the input fields. one can choose the best option using a tiny held-out development set. we show the results for mnli, with the few-shot development set accuracy on the x-axis. null prompts or prompt tuning? both null prompts and prompt tuning achieve competitive results without resorting to manual prompt design. we advocate for using null prompts over prompt tuning because they are easier to use. null prompts only require choosing which order to concatenate the input fields and the [mask] token. prompt tuning requires choosing the number of embeddings, their placement, their initialization, etc. null prompts simplify prompt search one complication that arises in standard prompt-based finetuning is that prompts become a hyperparameter of the finetuning procedure, and have a combinatorially large search space. on the other hand, determining the concatenation order for null prompts is trivial by just trying all of the few possible options and choosing which one works best on the validation set. to see this, in figure 4 we plot the accuracy on the few-shot development set and the full test set for different concatenation orders for roberta on mnli. 3 the development and test accuracy is strongly correlated (r 2 = 79.05), which demonstrates that tuning the concatenation order is easy even when validation data is scarce. ## achieving simplicity and efficiency thus far, we have shown that prompt-based finetuning can simplify prompt engineering at the cost of memory inefficiency-a new set of parameters must be learned for each task. this is in contrast to in-context learning, which holds all model weights fixed but is heavily influenced by small prompt modifications @xcite . in this section, we investigate how to achieve both memory efficiency and simple prompts. concretely, in section 5.1 we try to simplify prompt engineering for in-context learning by tuning the prompt, and in section 5.2, we reduce the number of learned parameters for prompt-based finetuning. ## conclusion and future work two high-level methods exist in few-shot prompting: using a frozen lm (in-context learning) and finetuning the lm on the few training examples (prompt-based finetuning). in this work, we demonstrate two new advantages of prompt-based finetuning. first, we show that it performs comparably across different prompt choices. in fact, there is a simple class of prompts-null prompts-that can be flexibly applied to different tasks without degrading performance relative to manually-written and learned prompts. second, we demonstrate that prompt-based finetuning can be made memory efficient: finetuning only the bias terms (bitfit) achieves comparable or better accuracy than finetuning all the parameters while being 1000x more memory efficient. taken together, using null patterns with bitfit is an approach that is efficient, simple-to-tune, and competitive in accuracy. code and instructions for reproducing our results is available at: https://github.com/ucinlp/null-prompts . our results motivate future analysis of few-shot learning methods. concretely, we show that the success of prompt-based finetuning is not solely explained by carefully-chosen patterns or verbalizers. this suggests that the gains from promptbased finetuning are partially due to its low-level setup, i.e., predicting on a [mask] token with a pre-trained mlm head. more generally, we hope to further analyze why and how small changes to different few-shot learning methods can lead to wildly different accuracies. we also hope to extend our findings to both very large and left-to-right lms, as our current results are for masked lms that are relatively small by modern standards. dataset pattern verbalizer boolq {passage}. question: {question}? answer: [mask]. true: "yes" false: "no" cb {premise}? [sep] [mask], {hypothesis} entailment: "yes" contradiction: "no" neutral: "maybe" mnli {sentence1}? [sep] [mask], {sentence2} entailment: "yes" contradiction: "no" neutral: "maybe" mnli-mm {sentence1}? [sep] [mask], {sentence2} entailment: "yes" contradiction: "no" neutral: "maybe" mrpc {sentence1} and {sentence2} have [mask] meanings. 0: "different" 1: "similar" qnli {question}? [sep] [mask], {sentence} entailment: "yes" not_entailment: "no" qqp {question1} and {question2} have [mask] meanings. 0: "different" 1: "similar" rte {sentence1}? [sep] [mask], {sentence2} entailment: "yes" not_entailment: "no" sst-2 {sentence} it was [mask] . 0: "terrible" 1: "great" table a1 : prompts denoted as "manual prompts (prior)". we use prompts inspired from past work @xcite . the fields between curly brackets indicate dataset-specific inputs. predictions are made on the [mask] token in each prompt. for prompt tuning, we tune the tokens in the pattern.