[Paper Review] How to Query Language Models?
This paper proposes querying large language models (LMs) by providing few-shot demonstrations in the input context to disambiguate ambiguous factual queries, significantly improving performance on knowledge probing tasks. By adding just 10 exemplars—e.g., 'Ronaldo plays for Portugal. Neuer plays for [MASK]'—BERT-large achieves a 37.8% relative improvement on T-REx over baseline cloze queries, outperforming even ensembles of 40 paraphrased prompts with a single forward pass.
Large pre-trained language models (LMs) are capable of not only recovering linguistic but also factual and commonsense knowledge. To access the knowledge stored in mask-based LMs, we can use cloze-style questions and let the model fill in the blank. The flexibility advantage over structured knowledge bases comes with the drawback of finding the right query for a certain information need. Inspired by human behavior to disambiguate a question, we propose to query LMs by example. To clarify the ambivalent question "Who does Neuer play for?", a successful strategy is to demonstrate the relation using another subject, e.g., "Ronaldo plays for Portugal. Who does Neuer play for?". We apply this approach of querying by example to the LAMA probe and obtain substantial improvements of up to 37.8% for BERT-large on the T-REx data when providing only 10 demonstrations--even outperforming a baseline that queries the model with up to 40 paraphrases of the question. The examples are provided through the model's context and thus require neither fine-tuning nor an additional forward pass. This suggests that LMs contain more factual and commonsense knowledge than previously assumed--if we query the model in the right way.
Motivation & Objective
- To address the challenge of ambiguous or suboptimal prompt design when querying pre-trained language models for factual knowledge.
- To investigate whether providing contextual examples can improve the accuracy of knowledge probing in masked language models.
- To evaluate if demonstration-based prompting can surpass traditional methods like paraphrase ensembling without fine-tuning or multiple forward passes.
- To assess the effectiveness of this approach across diverse knowledge probing benchmarks, including T-REx, ConceptNet, and BATS.
Proposed method
- The method involves augmenting a cloze-style query with one or more few-shot demonstrations of the same relation in natural language, e.g., 'Ronaldo plays for Portugal. Neuer plays for [MASK]'.
- Demonstrations are injected directly into the model’s context, requiring no fine-tuning or additional forward passes.
- The approach leverages the model’s ability to recognize and transfer relational patterns from examples to new queries.
- Performance is evaluated using standard benchmarks: LAMA probe (T-REx, Google-RE, ConceptNet), BATS for word analogies, and TBG for commonsense reasoning.
- For each query, the model predicts the masked token, and performance is measured via P@1 (precision at top-1) and relative improvement over baselines.
- The method is compared against state-of-the-art baselines, including paraphrase ensembling (Jiang et al., 2020) and context-augmented probing (Petroni et al., 2020).
Experimental results
Research questions
- RQ1Can providing a few natural language examples in the input context significantly improve the accuracy of factual knowledge retrieval in pre-trained language models?
- RQ2How does demonstration-based prompting compare to using an ensemble of 40 paraphrased prompts for probing factual knowledge?
- RQ3Does the performance gain from demonstrations saturate with increasing numbers of examples, and at what point is the benefit negligible?
- RQ4To what extent can this method generalize across different knowledge probing benchmarks, including factual, commonsense, and analogical reasoning tasks?
Key findings
- Providing only 10 demonstrations improved BERT-large’s P@1 performance on the T-REx dataset by 37.8% compared to the standard cloze prompt baseline.
- The few-shot demonstration approach outperformed an ensemble of up to 40 paraphrased prompts, achieving higher accuracy with a single forward pass.
- On ConceptNet’s commonsense relations, Albert-xxlarge achieved a 25% relative performance improvement with 10 demonstrations, outperforming GloVe baselines on solvable analogies.
- Performance gains from demonstrations diminished beyond 10 examples, indicating a saturation point where additional examples yield minimal improvement.
- The method was effective even in highly ambiguous cases, such as when the relation was expressed via an arrow operator (e.g., [s] => [o]), where just a few examples clarified the intended relation.
- The approach demonstrated strong generalization across diverse knowledge types, including factual, commonsense, and morphological relations, as validated on T-REx, BATS, and TBG benchmarks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.