Introduction
Pretrained language models (LMs) like BERT and RoBERTa contain vast amounts of knowledge. Traditionally, accessing this knowledge for specific tasks requires "finetuning," which alters the model's weights. This process makes it difficult to distinguish between knowledge the model already possessed and knowledge acquired during finetuning. An alternative is "prompting"—querying the model with natural language templates. However, LMs are notoriously sensitive to prompt phrasing, and manual prompt engineering is often a suboptimal process of trial and error.
AUTOPROMPT is an automated, gradient-based method for discovering optimal prompts (trigger tokens) to elicit specific knowledge from LMs without changing their parameters. By finding the "magic words" that best trigger a model's internal representations, AUTOPROMPT reveals that these models possess significant inherent capabilities for sentiment analysis, natural language inference, and fact retrieval.
Methods: Gradient-Guided Prompt Search
The AUTOPROMPT method automates the creation of prompts through a gradient-guided search for "trigger tokens." Unlike human-written prompts, these tokens are optimized to maximize the probability of a correct model output for a given task.
The process involves three main components:
- Templates: A fixed structure is defined, such as
{sentence} [T] [T] [T] [P], where[T]represents slots for trigger tokens and[P]is the prediction (mask) token. - Gradient-Based Search: The algorithm identifies vocabulary words that, when placed in the trigger slots, most significantly increase the likelihood of the target output. This is done iteratively by swapping tokens based on model gradients, a technique adapted from adversarial attack literature.
- Automated Label Selection: For classification tasks, the method automatically identifies "label tokens" (e.g., "marvelous" for positive sentiment) that the model naturally associates with specific classes, further reducing the need for manual intervention.
Key Results
The researchers evaluated AUTOPROMPT across several benchmarks, including sentiment analysis (SST-2), natural language inference (SICK-E), and factual knowledge retrieval (LAMA).
A key finding is that AUTOPROMPT is particularly effective in "low-data regimes." When only 10 to 1,000 labeled examples are available, prompting often outperforms traditional finetuning, which can be unstable on small datasets. For instance, on the SST-2 sentiment task, a prompted RoBERTa model achieved 91.4% accuracy without any weight updates, surpassing a finetuned ELMo model. In fact retrieval (LAMA), AUTOPROMPT reached 43.3% Precision-at-1, significantly outperforming previous manual or mined prompting techniques.
Discussion and Insights
The "optimal" prompts discovered by AUTOPROMPT are frequently ungrammatical strings that appear as gibberish to humans (e.g., atmosphere alot dialogue Clone totally for sentiment). This suggests that LMs "speak" a different internal language than humans, and automated methods are necessary to fully unlock their potential.
Furthermore, the results indicate that Masked Language Models (MLMs) have a much stronger inherent grasp of logic and sentiment than previously assumed. However, the method also revealed limitations: in relation extraction, models often rely on their internal "encyclopedic" knowledge rather than the provided context, making it difficult for them to process counterfactual information.
While AUTOPROMPT requires some labeled data for its gradient search—meaning it is not strictly "zero-shot"—it provides a powerful, parameter-free way to probe and utilize the latent knowledge within large-scale pretrained models.
Summary updated