AutoPrompt: Eliciting Knowledge from Language Models with Automatically Generated Prompts
- Publication
- EMNLP 2020Conference
- First submitted to arXiv
- arXiv:2010.15980
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{modeltuningautoprompt2020,
title = {{AutoPrompt: Eliciting Knowledge from Language Models with Automatically Generated Prompts}},
author = {Taylor Shin and Yasaman Razeghi and Robert L. Logan and Eric Wallace and Sameer Singh},
year = {2020},
eprint = {2010.15980},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2010.15980}
}
As language models grow larger and more complex, training or fine-tuning them becomes beyond the reach of most people. Consequently, prompt engineering, a new research direction, has emerged: how to design effective prompts that enable large language models to answer specific questions.
But writing prompts is a hassle!
Problem Definition
Manually Crafting Prompts is Time-Consuming and Tedious
Every time you create a prompt for a new task, it's like playing a puzzle game that requires repeated trial and error, consuming a lot of time.
Crafting these prompts is not straightforward; you need to deeply understand the model and the task to write effective prompts, which isn't intuitive for most people.
The Model is Highly Sensitive to Inputs
Models have stringent requirements for prompts; even slight changes can significantly degrade their performance.
A small mistake while writing a prompt can lead to disastrous results.
Lack of Expertise
Manually writing prompts is not only tiring but also requires specialized knowledge. Without expertise, you might not ask the core questions, and the model can only respond with superficial answers.
New Model, New Prompts
After facing the previous challenges, you spend months perfecting prompts that fully leverage the model's potential.
But then the model gets upgraded!
And you have to start all over again.
Solution
Model Architecture Design
To address these issues, the paper proposes a new method: AutoPrompt.
The idea is simple: if I do not know which prompt works, let the model's gradients help find one. A search algorithm selects discrete trigger tokens from its vocabulary; this work studies masked language models such as BERT and RoBERTa.
The entire architecture is clearly illustrated in the figure above:
- Original Input: This is the original input .
- [MASK]: This is the position where the masked language model predicts a token, not the known answer supplied as input. In the paper's template, [P] marks this position and is realized as [MASK]. Candidate label tokens correspond to classes such as positive and negative.
In this case, the task is sentiment analysis, so is a sentiment label, either positive or negative.
The [T] positions in the middle are the focus of AutoPrompt: the trigger slots where it searches for prompt tokens.
Prompt search uses labeled training examples to evaluate candidates. At inference, the input contains the example and selected prompt, not the correct label.
Gradient-Based Prompt Search
Table 3 gives prompts found for different tasks; it does not depict the gradient-search algorithm itself. Tasks can use different templates, while the triggers found for a task are shared across its input examples.
In this part, AutoPrompt uses a gradient-based search strategy to automatically generate prompts.
The trigger positions [T] are initialized with [MASK]. At each step, gradients estimate which vocabulary replacements would improve label likelihood; the top-k candidates are then inserted into the template and evaluated to retain the better prompt.
The model weights stay frozen. Gradients rank candidate tokens, whose replacements are then evaluated. Discrete words are not updated by ordinary continuous gradient descent, and the search still requires labeled data and computation.
Discussion
Sentiment Analysis Experiment
Research results show:
- AutoPrompt elicits sentiment classification performance from BERT and RoBERTa on the evaluated benchmark.
- Without fine-tuning, BERT + AutoPrompt scores 82.3% on the SST-2 test set, close to a supervised BiLSTM's 82.8% but below fine-tuned BERT's 93.5%.
- RoBERTa + AutoPrompt scores 91.4%, above BiLSTM + ELMo's 89.3%, but below fine-tuned BERT's 93.5% and fine-tuned RoBERTa's 96.7%.
Additionally, the authors observed that automatically constructed prompts are more effective than manually created ones, and these prompts are challenging to construct using human intuition:
- On the SST-2 test set, BERT's automatic prompt scores 19.1 percentage points above its manual prompt (82.3% versus 63.2%); RoBERTa's gain is 6.2 points (91.4% versus 85.2%). These are the compared templates on this task, not a fixed gain across tasks.
- The paper's best RoBERTa template is “{sentence} atmosphere alot dialogue Clone totally [P].”.
Fact Retrieval
The authors also conducted experiments on fact retrieval. They used the LAMA benchmark and compared with LPAQA prompts to see whether pretrained MLMs (such as BERT and RoBERTa) could retrieve real-world facts. In this task, they mapped triples with the template "{sub}[T]...[T][P]": the trigger tokens are specific to the relation, and the correct object is the label token.
-
Data Collection and Processing
- For each LAMA relation, collected up to 1,000 facts from T-REx, supplementing relations with fewer facts directly from Wikidata, to search for relation-specific prompts.
- Ensured that collected T-REx triples did not appear in the LAMA test set and split the collected data 80:20 into training and development sets. A separate same-distribution T-REx evaluation uses a 60:20:20 train/development/test split.
-
Performance Evaluation
- Used standard ranking metrics such as Mean Reciprocal Rank (MRR), Precision at 1 (P@1), and Precision at 10 (P@10) to evaluate the model.
- On the Original LAMA test set, single-prompt LPAQA scores 34.10% P@1, versus 42.94% with five AutoPrompt triggers and 43.34% with seven. The separate T-REx column reports 31.16%/45.40%/45.57%, respectively; the two test columns should not be merged.
-
Comparison of BERT and RoBERTa:
- On the LAMA subset whose answers are single tokens for both models, using five triggers, BERT scores 45.23% P@1 and RoBERTa 40.01%. Some RoBERTa triggers look less relevant.
Under these prompts and datasets, AutoPrompt elicits more measurable fact-retrieval answers than the compared manual and corpus-mined prompts. This does not verify which facts are internally stored in a model.
Surprisingly, on that comparable subset RoBERTa did not outperform BERT, warranting further investigation in future work.
Conclusion
As mentioned by the authors:
- The paper's best RoBERTa template is “{sentence} atmosphere alot dialogue Clone totally [P].”.
Although language models are trained on human language, perhaps they have picked up patterns from that training data that amount to a kind of “model language” only they can use effectively.
Deep networks can abstract complex semantic and contextual patterns. I wonder whether these apparently disorderly word combinations are one way the model uses those patterns to process information. That is an interpretation of the prompts, not a mechanism established by this paper: a natural-sounding prompt simply need not maximize a frozen model’s target probabilities on this task.
This phenomenon is quite interesting and opens up numerous lines of thought:
- Is human language too inefficient?
- Should the differences between model language and human language be eliminated? Is it even possible?
- We often criticize models for their lack of transparency, but does the existence of "model language" make them even harder to interpret?
- Do different models have similarities in their "model languages"? After all, they are all learned from human language?
Let's continue to explore subsequent research to see if there are more answers to these questions.