Prompt-free and Efficient Few-shot Learning with Language Models (2022)

Abstract: Current methods for few-shot fine-tuning of pretrained masked language models (PLMs) require carefully engineered prompts and verbalizers for each new task to convert examples into a cloze-format that the PLM can score. In this work, we propose Perfect, a simple and efficient method for few-shot fine-tuning of PLMs without relying on any such handcrafting, which is highly effective given as few as 32 data points. Perfect makes two key design choices: First, we show that manually engineered task prompts can be replaced with task-specific adapters that enable sample-efficient fine-tuning and reduce memory and storage costs by roughly factors of 5 and 100, respectively. Second, instead of using handcrafted verbalizers, we learn new multi-token label embeddings during fine-tuning, which are not tied to the model vocabulary and which allow us to avoid complex auto-regressive decoding. These embeddings are not only learnable from limited data but also enable nearly 100x faster training and inference. Experiments on a wide range of few shot NLP tasks demonstrate that Perfect, while being simple and efficient, also outperforms existing state-of-the-art few-shot learning methods. Our code is publicly available at https://github.com/rabeehk/perfect .

## introduction recent methods for few-shot language model tuning obtain impressive performance but require careful engineering of prompts and verbalizers to convert inputs to a cloze-format @xcite that can be scored with pre-trained language models (plms) @xcite @xcite . for example, as figure 1 shows, a sentiment classifier can be designed by inserting the input text x in a prompt template "x it was [mask]" where verbalizers (e.g., 'great' and 'terrible') are substituted for the @xcite to score target task labels ('positive' or 'negative'). in this paper, we show that such engineering is not needed for few-shot learning and instead can be replaced with simple methods for data-efficient fine-tuning with as few as 32 end-task examples. more specifically, we propose perfect, a prompt-free and efficient paradigm for few-shot cloze-based fine-tuning. to remove handcrafted patterns, perfect uses task-specific adapter layers @xcite ) ( §3.1). freezing the underlying plm with millions or billions of parameters @xcite , and only tuning adapters with very few new parameters saves on memory and storage costs ( §4.2), while allowing very sample-efficient tuning ( §4). it also stabilizes the training by increasing the worst-case performance and decreasing variance across the choice of examples in the few shot training sets ( §4.3). to remove handcrafted verbalizers (with variable token lengths), we introduce a new multi-token fixed-length classifier scheme that learns task label embeddings which are independent from the language model vocabulary during fine-tuning ( §3.2). we show ( §4) that this approach is sample efficient and outperforms carefully engineered verbalizers from random initialization ( §4). it also allows us to avoid previously used expensive auto-regressive decoding schemes @xcite , by leveraging prototypical networks @xcite over multiple tokens. overall, these changes enable up to 100x faster learning and inference ( §4.2). perfect has several advantages: it avoids engineering patterns and verbalizers for each new task, which can be cumbersome. recent work has shown that even some intentionally irrelevant or misleading prompts can perform as well as more interpretable ones @xcite . unlike the zero-shot or extreme few-shot case, where prompting might be essential, we argue in this paper that all you need is tens of training examples to avoid these challenges by adopting perfect or a similar data-efficient learning method. experiments on a wide variety of nlp tasks demonstrate that perfect outperforms state-of-the-art prompt-based methods while being significantly more efficient in inference and training time, storage, and memory usage ( §4.2). to the best of our knowledge, we are the first to propose a few-shot learning method using the mlm objective in plms that provide state-of-the-art results while removing all per-task manual engineering. ## method we propose perfect, a verbalizer and pattern free few-shot learning method. we design perfect to be close to the pre-training phase, similar to the pet family of models @xcite , while replacing handcrafted patterns and verbalizers with new components that are designed to describe the task and learn the labels. as shown in figure 3 , we first convert each input x input to its masked language modeling (mlm) input containing m mask tokens [mask] foot_0 with no added patterns, denoted as x @xmath0. foot_1 perfect then trains a classifier per-token and optimizes the average multi-class hinge loss over each mask position. three main components play a role in the success of perfect: a) a pattern-free task description, where we use task-specific adapters to efficiently tell the model about the given task, replacing previously manually engineered patterns ( §3.1), b) multi-token label-embedding as an efficient mechanism to learn the label representations, removing manually designed verbalizers ( §3.2). c) an efficient inference strategy building on top of the idea of prototypical networks @xcite ( §3.4), which replaces prior iterative autoregressive decoding methods @xcite . as shown in figure 3 , we fix the underlying plm model and only optimize the new parameters that we add (green boxes). this includes the task-specific adapters to adapt the representations for a given task and the multi-token label representations. we detail each of these components below. ## experiments we conduct extensive experiments on a variety of nlp datasets to evaluate the performance of perfect and compare it with state-of-the-art few-shot learning. datasets: we consider 7 tasks and 12 datasets: 1) the sentiment analysis datasets sst-2 @xcite , sst-5 @xcite , mr @xcite , and cr @xcite , 2) the subjectivity classification dataset subj @xcite , 3) the question classification dataset trec (voorhees and tice, 2000), 4) the natural language inference datasets cb @xcite and rte @xcite , 5) the question answering dataset qnli @xcite , 6) the word sense disambiguation dataset wic (pilehvar and camacho-collados, 2019), 7) the paraphrase detection datasets mrpc @xcite and qqp. 4 see datasets statistics in appendix a. for mr, cr, sst-5, subj, and trec, we test on the original test sets, while for other datasets, since test sets are not publicly available, we test on the original validation set. we sample 16 instances per label from the training set to form training and validation sets. baselines we compare with the state-of-the-art few-shot learning of pet and fine-tuning: pet @xcite is the stateof-the-art few-shot learning method that employs carefully crafted verbalizers and patterns. we report the best (pet-best) and average (pet-average) results among all patterns and verbalizers. 5 finetune the standard fine-tuning @xcite , with adding a classifier on top of the [cls] token and fine-tuning all parameters. our method we study the performance of perfect and perform an extensive ablation study to show the effectiveness of our design choices: perfect-rand we randomly initialize the label embedding l from a normal distribution n (0,σ) with σ = 10 -4 (chosen based on validation performance, see appendix d) without relying on any handcrafted patterns and verbalizers. as an ablation, we study the following two variants: perfect-init we initialize the label embedding with the token embeddings of manually designed verbalizers in the plm's vocabulary to study the impact of engineered verbalizers. logan iv et al. (2021) following logan iv et al. (2021), we remove patterns and tune the biases in the pet. ## conclusion we proposed perfect, a simple and efficient method for few-shot learning with pre-trained language models without relying on handcrafted patterns and verbalizers. perfect employs task-specific adapters to learn task descriptions implicitly, replacing previous handcrafted patterns, and a continuous multi-token label embedding to represent the output classes. through extensive experiments over 12 nlp benchmarks, we demonstrate that perfect, despite being far simpler and more efficient than recent few-shot learning methods, produces state-of-the-art results. overall, the simplicity and effectiveness of perfect make it a promising approach for few-shot learning with plms.