Source-linked AI summary
AutoPrompt: Eliciting Knowledge from Language Models with Automatically Generated Prompts
Taylor Shin, Yasaman Razeghi, Robert L. Logan, Eric Wallace, Sameer Singh
TL;DR
Pretrained language models contain knowledge whose origin is difficult to assess, while manually designed prompts are costly and sensitive to phrasing. AutoPrompt uses gradient-guided search to generate prompts for masked language models. It achieves strong performance without finetuning and improves factual retrieval over manual prompts, while remaining one probing tool among several.
Problem
Evaluating knowledge acquired during pretraining is difficult, and manually crafting effective prompts requires substantial effort because models are sensitive to context.
Method
AutoPrompt automatically combines task inputs with shared trigger tokens learned by gradient-based search and maps masked-token predictions to classes using label-token sets.
Results
AutoPrompt performs well across sentiment analysis, natural language inference, fact retrieval, and relation extraction, including 43.3% precision-at-1 on LAMA versus 34.1% for the best single-prompt result.
Takeaways & Limitations
Automatically generated prompts can be a parameter-free alternative to manual prompting and can be more effective than finetuning in some data-scarce settings.
Takeaways & Limitations
Prompting remains unsuitable for some phenomena: on QQP and RTE, manual and automatically generated prompts performed little better than chance, and AutoPrompt is only one interpretability tool.
Abstract
from arXiv · showhide
The remarkable success of pretrained language models has motivated the study of what kinds of knowledge these models learn during pretraining. Reformulating tasks as fill-in-the-blanks problems (e.g., cloze tests) is a natural approach for gauging such knowledge, however, its usage is limited by the manual effort and guesswork required to write suitable prompts. To address this, we develop AutoPrompt, an automated method to create prompts for a diverse set of tasks, based on a gradient-guided search. Using AutoPrompt, we show that masked language models (MLMs) have an inherent capability to perform sentiment analysis and natural language inference without additional parameters or finetuning, sometimes achieving performance on par with recent state-of-the-art supervised models. We also show that our prompts elicit more accurate factual knowledge from MLMs than the manually created prompts on the LAMA benchmark, and that MLMs can be used as relation extractors more effectively than supervised relation extraction models. These results demonstrate that automatically generated prompts are a viable parameter-free alternative to existing probing methods, and as pretrained LMs become more sophisticated and capable, potentially a replacement for finetuning.
1 Introduction
AutoPrompt addresses the difficulty of manually designing prompts for directly evaluating pretrained language models’ knowledge. It automatically generates prompts and shows that masked language models can perform several tasks effectively without finetuning.
- Motivation: Manual prompts are time-consuming, unintuitive for some tasks, and sensitive to phrasing, which can artificially lower performance.Existing probing methods can also require additional parameters or fail to evaluate knowledge beyond simple classification tasks.
- Method: AutoPrompt combines task inputs with shared trigger tokens learned through gradient-based search and converts masked-token predictions into class probabilities using label tokens.Label tokens may be learned or specified in advance.
- Results: Without finetuning, masked language models perform well on sentiment analysis and natural language inference, with prompted RoBERTa reaching 91% accuracy on SST-2 and 69% on balanced SICK-E.The reported SST-2 result exceeds a finetuned ELMo model.
- Results: AutoPrompt achieves 43.3% precision-at-1 on LAMA, compared with 34.1% for the best single-prompt result, and masked language models can outperform relation-extraction models with real factual context.The models struggle when context sentences are artificially falsified.
- Practical implications: Prompting achieves higher average- and worst-case accuracy than finetuning in low-data regimes and avoids storing separate model checkpoints for each task.A discovered prompt can run on an off-the-shelf pretrained model, which is beneficial for serving multiple tasks.
2 Overview of AUTOPROMPT
AutoPrompt reformulates tasks as masked-language-model predictions and automatically searches for task- and model-specific prompts. Its procedure learns trigger tokens and label-token sets, then evaluates the resulting prompts across several probing tasks.
- Overview: AutoPrompt constructs customized prompts because manually chosen phrasing is time-consuming, model-sensitive, and not reliably optimal for eliciting desired knowledge.The method maps one or more task-input sequences into a prompt containing a special prediction token.
- Background and notation: For classification, the masked-token distribution is converted into a class probability by summing probabilities over the label-token set associated with each class.This supports labels represented by multiple vocabulary tokens.
- Extensions: The framework extends to autoregressive language models by placing the prediction token at the end of the prompt.This is the only adjustment specified for that extension.
- Gradient-based prompt search: Trigger tokens are shared across prompts, initialized as [MASK] tokens, and iteratively updated to maximize label likelihood over batches of examples.At each iteration, candidate replacements are estimated from gradients and the best prompt is retained using separate evaluation data.
- Automating label-token selection: Label-token selection trains a logistic classifier on the contextualized [MASK] embedding, then scores vocabulary words against the learned label representation.The highest-scoring words form the label-token sets.
- Experiments: The experiments apply AutoPrompt to sentiment analysis, natural language inference, fact retrieval, and relation extraction using pretrained BERT and RoBERTa models.The implementation supports prompt generation for pretrained HuggingFace transformer models on arbitrary datasets.
3 Sentiment Analysis
This section evaluates AUTOPROMPT for sentiment analysis, finding that pretrained masked language models can perform the task without finetuning and that automatically generated prompts outperform manual prompts. In low-data settings, AUTOPROMPT can also compare favorably with finetuning.
- AUTOPROMPT automatically constructs prompts for sentiment classification using searched trigger tokens and selected label tokens.The sentiment setup searches over candidate-token, label-token, and trigger-token set sizes.
- Without finetuning, BERT performs comparably to a supervised BiLSTM, while RoBERTa achieves accuracy on-par with finetuned BERT and ELMo models.
- Automatically constructed prompts are more effective than manual prompts, despite being difficult to design using human intuition.The best RoBERTa template includes seemingly unintuitive trigger tokens.
- Accuracy in Low-Data Settings: AUTOPROMPT achieves higher average- and worst-case accuracy than finetuning in low-data regimes.The comparison uses random subsets of 10, 100, and 1000 training instances and repeated runs.
- Accuracy in Low-Data Settings: Finetuning outperforms AUTOPROMPT on sentiment analysis, while AUTOPROMPT elicits better average performance from BERT and RoBERTa given only 10 training examples.RoBERTa results are more stable across sample sizes, whereas finetuning can produce failed runs.
4 Natural Language Inference
This section tests AUTOPROMPT on natural language inference using SICK-E and its balanced variants. AUTOPROMPT outperforms majority baselines, can match supervised systems in some settings, and performs strongly in low-data evaluation.
- The evaluation uses SICK-E sentence pairs labeled as entailment, contradiction, or neutral, including unbiased 2-way and 3-way variants.The standard dataset is biased toward the neutral class, which represents 56.7% of instances.
- AUTOPROMPT considerably outperforms the majority baseline in all natural language inference experiments.On the 2-way SICK-E dataset, it is comparable to a supervised finetuned BERT.
- AUTOPROMPT has comparable or higher accuracy than linear probes while avoiding the additional learned classifiers used by those probes.The paper notes that linear probes are susceptible to false positives.
- Low-Data Evaluation: AUTOPROMPT performs on par with finetuned BERT and significantly better than finetuned RoBERTa on unbiased 3-way SICK-E in low-data settings.
- MLMs Excel on Contradiction: On balanced 3-way SICK-E, BERT precision is 74.9% for contradiction, 54.4% for entailment, and 36.8% for neutral.RoBERTa precision is 84.9%, 65.1%, and 57.3% for the same labels, respectively.
5 Fact Retrieval
AUTOPROMPT generates relation-specific prompts for fact retrieval and improves factual knowledge elicitation over manual and mined prompts. Its advantages are strongest for relations that are difficult to express naturally, while model comparisons require caution because prompting provides only a lower bound on knowledge.
- Setup: The fact-retrieval setup maps each (sub, rel, obj) triple to a template containing relation-specific trigger tokens, with the object represented by the label token.Training facts come primarily from T-REx, with Wikidata supplying additional examples for underrepresented relations.
- Results: AUTOPROMPT improves P@1 by up to 12 points over manual and mined prompting methods on factual retrieval.It also outperforms LPAQA’s ensemble of up to 30 prompts by approximately 4 points.
- Relation Breakdown: AUTOPROMPT performs especially well on relations that are difficult to specify with natural-language prompts, whereas manual prompts remain competitive for easy relations.The paper illustrates this contrast with PLACE OF BIRTH and POSITION PLAYED ON TEAM.
- BERT versus RoBERTa: BERT slightly outperforms RoBERTa on a shared single-token LAMA subset, while RoBERTa-generated prompts contain more irrelevant words.The comparison uses AUTOPROMPT with five trigger tokens and excludes examples whose objects are not single tokens for both models.
- BERT versus RoBERTa: Lower relative performance does not establish that a model knows less because prompting is only a lower bound on the model’s knowledge.The paper identifies the BERT–RoBERTa result as warranting further investigation.
6 Relation Extraction
AUTOPROMPT applies relation-specific prompts to extract objects from sentences, and pretrained MLMs outperform the supervised RE baseline. Perturbed-sentence results show that MLM performance partly reflects stored factual knowledge rather than relation extraction alone.
- Method: AUTOPROMPT constructs relation-specific prompts that combine a sentence, subject, trigger tokens, and a label token representing the object.The approach adapts the fact-retrieval prompting setup to relation extraction.
- Evaluation: The evaluation compares AUTOPROMPT with LAMA, LPAQA, and a supervised relation-extraction model using T-REx context sentences.The supervised baseline is evaluated with a modified object-prediction protocol.
- Results: MLMs extract relational information more effectively than the supervised RE model, with AUTOPROMPT providing up to a 33% increase.RoBERTa also outperforms the supervised model, although it performs worse than BERT.
- Perturbed Sentence Evaluation: Replacing test objects with random objects significantly decreases MLM accuracy but does not significantly change the supervised model’s accuracy.This perturbation separates memorized factual knowledge from extracting the relation expressed in the sentence.
- Perturbed Sentence Evaluation: AUTOPROMPT prompts for BERT outperform corresponding LAMA and LPAQA prompts, providing further evidence that the method produces better probes.The perturbed-data experiment therefore preserves an advantage for automatically generated prompts even as MLM accuracy falls.
- Results: Table 5 reports mean precision-at-1 for MLMs and the supervised LSTM baseline on ordinary and factually edited sentences.MLM accuracy drops on edited sentences, indicating that high performance stems from factual knowledge.
7 Discussion
Prompting can offer practical advantages over finetuning, especially in low-data and multi-task settings, but it remains a limited interpretability tool. AUTOPROMPT also requires labeled data, can be hard to interpret, struggles with imbalance, and may be brittle.
- Prompting as an Alternative to Finetuning: AUTOPROMPT can achieve higher accuracy than finetuning in the low-data regime.This advantage is reported for prompting experiments described earlier in the paper.
- Prompting as an Alternative to Finetuning: Prompting reduces multi-task deployment cost and complexity by storing task-specific prompts while reusing one pretrained model.Finetuning instead requires separate checkpoints and simultaneous deployment of multiple models.
- Limitations of Prompting: Prompts generated manually and with AUTOPROMPT perform near chance on preliminary QQP and RTE evaluations.The authors caution that these results do not establish that BERT lacks paraphrasing or entailment knowledge.
- Limitations of AUTOPROMPT: AUTOPROMPT requires labeled training data, unlike manual prompts that rely on domain and language insights.Generated prompts also lack the interpretability of human-designed prompts.
- Limitations of AUTOPROMPT: Class imbalance can make AUTOPROMPT increase the likelihood of the majority label, while greedy search over discrete phrases can make it brittle.Rebalancing the training data can mitigate the imbalance problem.
8 Conclusion
The paper introduces AUTOPROMPT for automatically constructing prompts that elicit knowledge from pretrained masked language models across tasks. It reports that these prompts outperform manual prompts with less human effort and can be advantageous over finetuning in some data-scarce settings.
- Conclusion: AUTOPROMPT automatically constructs prompts to elicit knowledge from pretrained masked language models across a variety of tasks.The method is presented as an approach for developing automatically constructed prompts.
- Conclusion: AUTOPROMPT prompts outperform manual prompts while requiring less human effort.The conclusion summarizes this result across the paper’s evaluations.
- Conclusion: In some data-scarce settings, prompting language models may be more effective than finetuning for sentiment analysis and textual entailment.The conclusion limits this comparison to the reported tasks and data conditions.
- Conclusion: Although the paper focuses on masked language models, AUTOPROMPT can be trivially extended to standard language models.The authors suggest this may support constructing inputs for models such as GPT-3.
A Effect of Hyperparameters on Sentiment Analysis
The appendix examines how label-set size and trigger-token count affect sentiment-analysis performance. Increasing the label set improves accuracy, whereas trigger length generally has little effect.
- Setup: Figure 3 varies label-set size and trigger-token count while fixing the candidate replacement count at |Vcand| = 100.Similar trends are observed when |Vcand| = 10.
- Label Set Size: Increasing the label set from 1 to 3 raises accuracy by approximately +5% for BERT and +10% for RoBERTa.The appendix reports a substantial increase associated with the larger label set.
- Trigger Set Size: Varying the number of trigger tokens generally has little effect on sentiment-analysis accuracy.The figure caption likewise reports little impact from changing trigger length.
- Label Set Size: RoBERTa’s learned label sets associate “marvelous” and “philanthrop” with positive sentiment and “worse” and “incompetence” with negative sentiment.The authors describe these associations as intuitive results.
C Additional Fact Retrieval Results
This section presents additional fact-retrieval results, including a breakdown of relations and comparisons between manually designed and automatically generated prompts.
- Fact Retrieval: Table 6 breaks down fact-retrieval relations on the original Petroni et al. (2019) dataset using P@1.It compares prompts from LAMA, LPAQA, and AutoPrompt with five prompt tokens.
- Fact Retrieval: The fact-retrieval material compares prompt designs across manually created and automatically generated formulations.
- Fact Retrieval: Table 7 gives examples of manual prompts alongside prompts generated via AutoPrompt.The manual examples are shown with BERT’s P@1.
D Additional Relation Extraction Results
This section provides additional relation-extraction examples and an augmented evaluation that replaces original objects with new objects.
- Relation Extraction: Table 8 presents examples of prompts generated using AutoPrompt for relation extraction.
- Relation Extraction: Underlined words in the examples represent the gold object.
- Relation Extraction: The augmented evaluation replaces original objects with new objects, shown as crossed-out words.