Exploiting Cloze Questions for Few Shot Text Classification and Natural Language Inference
Paper · Note reference · Code · EACL 2021
Abstract
This paper introduces Pattern-Exploiting Training (PET), a semi-supervised training procedure that reformulates input examples as cloze-style phrases to help language models understand a given task.
These phrases are then used to assign soft labels to a large set of unlabeled examples. Finally, standard supervised training is performed on the resulting training set.
PET outperforms supervised training and strong semi-supervised approaches in low-resource settings by a large margin.
Introduction
Before this paper, applying standard supervised learning to small training sets often performed poorly.
For instance, assume the model is given the following pieces of text:
- : This was the best pizza I’ve ever had.
- : You can get better sushi for half the price.
And the labels of and are and .
If the model is asked to infer the correct label for :
- : Pizza was average. Not worth the price.
The task becomes easier if the model knows that the underlying task is to identify whether the text says anything about prices.
This work shows that providing task descriptions can be successfully combined with standard supervised learning in few-shot settings. It is called Pattern-Exploiting Training (PET), a semi-supervised training procedure that uses natural language patterns to reformulate input examples into cloze-style phrases.

PET works in three steps:
- For each pattern, a separate PLM is fine-tuned on a small training set .
- The ensemble of all models annotates a large unlabeled dataset with soft labels.
- A standard classifier is trained on the soft-labeled dataset.
The authors also devise iPET, an iterative variant of PET in which this process is repeated with increasing training-set sizes.
Related Work
- Zero-shot learning of challenging tasks such as question answering and reading comprehension, which requires a semantic parser.
- Cloze-style phrases to probe the knowledge that PLMs acquire during pretraining.
- Few-shot learning in NLP, including exploiting examples from related tasks and data augmentation.
The idea behind iPET is to train multiple generations of models on data labeled by previous generations.
Pattern-Exploiting Training
- : masked language model with vocabulary .
- A mask token (also written as ).
- : a set of labels for target classification task .
An input for task is a sequence of phrases , with .
For example, if is textual inference with two input sentences.
They define a pattern as a function that takes as input and outputs a phrase or sentence that contains exactly one mask token. Its output can be viewed as a cloze question.
Furthermore, they define a verbalizer as an injective function that maps each label to a word from ‘s vocabulary.
The pair is a pattern-verbalizer pair (PVP).
- creates a expression from .
- defines the relation ; for example, positive great.
How PET solves task using a PVP
Given an input , apply to obtain . Then use to determine the label for which is the most likely substitute for the mask.
PVP Training and Inference
Given an input , define the score for label as:
Obtain a probability distribution over labels using softmax:
Auxiliary Language Modeling
The paper faces the problem that few training examples are available and catastrophic forgetting can occur. Therefore, it uses language modeling as an auxiliary task.
The final loss combines cross-entropy and language-modeling loss , where :
Combining PVPs
To handle differences in PVP performance, the authors use a strategy similar to knowledge distillation:
-
Define a set of PVPs that intuitively make sense for a given task .
-
Fine-tune a separate language model for each .
-
Use the ensemble to annotate examples from . The unnormalized class scores for each example are combined as:
where . The weighting term is either:
- for all ; or
- is the accuracy obtained using on the training set before training.
-
Fine-tune a PLM with a standard sequence-classification head on .

Iterative PET (iPET)
iPET trains several generations of models on datasets of increasing size. This avoids the issue that some patterns may perform much worse than others, which could otherwise cause the final model’s training set to contain many mislabeled examples.
- Enlarge the original dataset by labeling selected examples from using a random subset of trained PET models.
- Train a new generation of PET models on the enlarged dataset repeatedly.
- is the initial set of PET models fine-tuned on .
- Each is trained for PVP on its own training set .
- In each iteration, the training-set size is multiplied by a fixed constant .
To maintain the label ratio of the original dataset:
-
Obtain by randomly choosing models from the previous generation, with .
-
Use the subset to create a labeled dataset:
To avoid training future generations on mislabeled data, choose examples for which the ensemble is confident in its prediction. When drawing from , set the probability of each proportional to .
-
Combine the new dataset as:
-
After training generations of PET models, use to create and train as in basic PET.
Experiments
The paper evaluates four English datasets: Yelp Reviews, AG’s News, Yahoo Questions, and MNLI. It uses x-stance to investigate how well PET works for other languages.
RoBERTa large is used as the language model; for x-stance, XLM-R is used.
Sentiment Analysis Type Tasks
- Yelp
| Patterns | Verbalizer |
|---|---|
![]() |
![]() |
Thematic Classification Tasks
- AGNews / Yahoo
| Patterns | Verbalizer |
|---|---|
![]() |
Maps categories 1–4 to “World”, “Sports”, “Business”, and “Tech”. |
![]() |
Maps categories 1–10 to “Society”, “Science”, “Health”, “Education”, “Computer”, “Sports”, “Business”, “Entertainment”, “Relationship”, and “Politics”. |
Sentence Pair Type Task
- MNLI
| Patterns | Verbalizer |
|---|---|
![]() |
![]() |


X-Stance
Multilingual stance-detection dataset with German, French, and Italian examples.
| Patterns | Verbalizer |
|---|---|
![]() |
Maps 0 to “Yes” and 1 to “No”. |

Analysis
Combining PVPs

Auxiliary Language Modeling

Iterative PET

In-Domain Pretraining

Conclusion
PET consists of defining pairs of cloze-question patterns and verbalizers that help leverage the knowledge contained within pretrained language models for downstream tasks.
When the initial amount of training data is limited, PET gives large improvements over standard supervised training and strong semi-supervised approaches.





