AI Logic

Datasets and Benchmarks

GLUE

Updated:

GLUE tasks and how the score is computed. Left: the nine tasks grouped into single-sentence tasks, similarity and paraphrase tasks, and inference tasks, with what each predicts, its training-set size, and its metric. Right: the flow in which a model predicts on the test inputs, the predictions are sent to the evaluation server, and the per-task scores are averaged into the GLUE score, plus the diagnostic dataset reported separately

Overview

GLUE (General Language Understanding Evaluation) is a benchmark that bundles nine English sentence-understanding tasks and compares models with a single score. Wang et al. released it in 2018 (ICLR 2019). It consists of tasks such as sentiment classification, paraphrase detection for sentence pairs, and inference between two sentences (recognizing textual entailment), and it was widely used as the standard benchmark for comparing pretrained language models such as BERT and GPT.

Its goal is to measure general language understanding that is not tied to a single task or domain. The paper points out that many models are built for a specific task and struggle with data from other domains. GLUE is therefore designed as follows.

  • Reuse existing datasets: all nine tasks are built from existing datasets that researchers already regarded as hard and interesting.
  • Include low-resource tasks: some tasks have only a few thousand examples, which favors models that share knowledge across tasks (pretrained or multi-task models).
  • Model-agnostic: any model can be evaluated as long as it takes one or two sentences and returns a prediction.
  • Hidden test labels: predictions are scored by an evaluation server.

A diagnostic dataset is also provided for probing which linguistic phenomena trip up a model.

The GLUE score is a simple average of the nine task scores. The tasks use different metrics (accuracy, F1, correlation coefficients, and so on), and small and large tasks get the same weight in the average.

Contents: the nine tasks and the diagnostic dataset

The nine tasks fall into three groups according to their input and what they ask. All of them are classification over one or two sentences, except STS-B, which is a regression task. MNLI has three classes, and the other classification tasks have two.

TypeTaskSource dataWhat to predictTrainTestMetric
Single sentenceCoLAExample sentences from linguistics books and papersWhether the sentence is grammatical English8.5k1kMatthews correlation coefficient
Single sentenceSST-2Movie review sentencesPositive or negative67k1.8kAccuracy
Similarity & paraphraseMRPCSentence pairs automatically collected from newsWhether the two sentences mean the same3.7k1.7kAccuracy and F1
Similarity & paraphraseSTS-BNews headlines, image and video captions, etc.Similarity of the two sentences (1–5)7k1.4kPearson and Spearman correlation
Similarity & paraphraseQQPQuestion pairs from the Q&A site QuoraWhether the two questions mean the same364k391kAccuracy and F1
InferenceMNLITen sources, including transcribed speech, fiction, and government reportsWhether the premise implies the hypothesis (entailment, contradiction, neutral)393k20kMatched and mismatched accuracy
InferenceQNLISQuAD (Wikipedia paragraphs and questions)Whether the sentence contains the answer to the question105k5.4kAccuracy
InferenceRTETextual entailment challenges (news, Wikipedia)Whether the first sentence implies the second2.5k3kAccuracy
InferenceWNLIWinograd Schema Challenge (sentences from fiction)Whether the sentence with the pronoun replaced by a candidate follows from the original634146Accuracy

Several tasks recast the original dataset into a form suited to GLUE.

  • QNLI: each question from SQuAD is paired with each sentence of its paragraph, giving a two-class task of whether the sentence contains the answer. Pairs with little word overlap between question and sentence are removed.
  • RTE: data from the RTE1, 2, 3, and 5 challenges are merged, and the three-class data are collapsed to two classes by merging "contradiction" and "neutral" into "not entailment".
  • WNLI: the task of choosing a pronoun's referent is turned into a sentence-pair classification of whether the sentence with the pronoun replaced by a candidate word follows from the original sentence.

The MNLI test set is split into sentences from the same domains as the training set (matched) and from domains not in the training set (mismatched), and accuracy is reported for both. GLUE also recommends SNLI (550k inference examples) as auxiliary training data. The test labels of four tasks, CoLA, QQP, MNLI, and WNLI, have never been released.

The diagnostic dataset consists of 1,100 hand-crafted inference sentence pairs containing phenomena chosen from a linguistic perspective. Sentences from news, Reddit, Wikipedia, and papers are minimally edited to create pairs that share almost the same words and structure but differ in their entailment relation. The phenomena fall into four broad categories.

CategoryExample phenomena
Lexical semanticsHypernymy and hyponymy, morphological negation, quantifiers, named entities
Predicate-argument structureActive and passive voice, relative clauses, prepositional phrases, anaphora
LogicNegation, double negation, conditionals, universals and existentials, numeric ranges, monotonicity
KnowledgeCommon sense, world knowledge

Evaluation rules

GLUE evaluation follows these steps.

  1. Produce the model's predictions for the test inputs of all nine tasks.
  2. Submit the predictions to the evaluation server (gluebenchmark.com) for scoring. To prevent overfitting to the test set, submissions are limited to two per day.
  3. For tasks with two metrics (accuracy and F1 for MRPC and QQP, the two correlations for STS-B, matched and mismatched for MNLI), the two values are averaged without weighting to give the task score.
  4. The simple (macro) average of the nine task scores is the GLUE score. Leaderboard rankings are based on this value.

The CoLA metric, the Matthews correlation coefficient, is computed from the four counts of the confusion matrix of a binary classifier.

MCC=TP⋅TN−FP⋅FN(TP+FP)(TP+FN)(TN+FP)(TN+FN)\mathrm{MCC} = \frac{\mathrm{TP}\cdot\mathrm{TN} - \mathrm{FP}\cdot\mathrm{FN}}{\sqrt{(\mathrm{TP}+\mathrm{FP})(\mathrm{TP}+\mathrm{FN})(\mathrm{TN}+\mathrm{FP})(\mathrm{TN}+\mathrm{FN})}}

It ranges from −1-1 to 11, and random guessing gives 00. Following the CoLA authors, the paper uses it as a metric that measures performance even for binary classification with imbalanced classes. MRPC (68% "same meaning") and QQP (63% "different meaning") are also imbalanced, so both accuracy and F1 are reported.

The diagnostic dataset is solved directly by a classifier trained on MNLI and evaluated with R3R_3, a three-class extension of the Matthews correlation coefficient. It is not included in the GLUE score and is reported separately. In the paper, six NLP researchers who solved it achieved an average R3R_3 of 0.80.

The diagnostic dataset is a tool for probing a model's weaknesses phenomenon by phenomenon. The paper itself states that diagnostic results do not reflect performance in real applications, and that they can be used to compare models but not to compare categories (for example, "Logic" versus "Knowledge").

Usage and historical significance

GLUE became the central benchmark in the trend of comparing pretrained language models by fine-tuning them on many tasks.

At release, the best model was a bidirectional LSTM trained only on the GLUE tasks, with attention and ELMo (word representations pretrained with a language model) added and all nine tasks trained jointly; it reached a GLUE score of 70.0. On WNLI, no model beat the 65.1% obtained by always predicting the majority class, and the paper concluded that "solving GLUE is beyond the capabilities of current models and methods".

The GLUE score then rose quickly.

PaperModelGLUE score (test)
Wang et al. (2018)BiLSTM + attention + ELMo (joint training on nine tasks)70.0
Devlin et al. (2018)GPT (official leaderboard at the time of the BERT paper)72.8
Devlin et al. (2018)BERT-Large80.5
Wang et al. (2019, SuperGLUE paper)XLNet (Yang et al. 2019)88.4
Wang et al. (2019, SuperGLUE paper)Human (Nangia & Bowman 2019)87.1

According to the SuperGLUE paper, by early July 2019 the best model's GLUE score (88.4) exceeded human performance (87.1) by 1.3 points. With little headroom left to measure differences on GLUE, the same authors built SuperGLUE, a collection of harder tasks. SuperGLUE keeps the two hardest GLUE tasks and adds tasks in formats other than sentence-pair classification, such as coreference resolution and question answering.

Caveats

License: GLUE is not newly created data but a collection of existing datasets. Each original dataset's license must be followed.

There is no single license covering all of GLUE. The Hugging Face dataset card also asks users to consult the original license of each dataset and to cite every dataset they use. For example, QQP is based on Quora questions and SST-2 on movie review sentences. Before commercial use, check the terms of the original dataset for each task.

Handle WNLI with care: the WNLI validation set contains examples that reuse hypothesis sentences from the training set, so models that memorize training examples tend to get them wrong on validation. In addition, 65% of the test set is "not entailment", a distribution different from the training set. The BERT paper reports its average excluding WNLI, whose problems are noted in the GLUE FAQ. Always state whether the reported average includes WNLI.

Some tasks have different train and test distributions: the paper notes that the QQP test set has a different label ratio from the training set. Validation performance does not necessarily carry over to the test set.

QNLI versions: the first released version of QNLI had an issue that made it easier to solve than intended, and a fixed version was released. Scores on the old version are not comparable.

Tune on validation; only submit test predictions: test labels are not released. Choose hyperparameters on the validation set. The BERT paper notes that the learning rate was chosen on the validation set, and that fine-tuning BERT-Large was sometimes unstable on small datasets, so it ran several random restarts and selected the best model on the validation set. When comparing scores on small tasks, also watch for such differences in model selection.

Beating humans ≠ understanding language: even when a GLUE score surpasses human performance, a model can still be weak on the logic and knowledge phenomena of the diagnostic dataset. To measure general language understanding, look at other benchmarks such as SuperGLUE as well.

Comparison with similar benchmarks

Language-understanding benchmarks compared along the same dimensions:

BenchmarkNumber and format of tasksWhat it measuresHow it is evaluatedBest suited for
GLUE9; all single- or two-sentence classification (STS-B is regression)Sentence understanding such as sentiment, paraphrase, and inferenceTest predictions scored on a server; average of nine tasksComparing fine-tuned pretrained models (papers from around 2018–2019)
SuperGLUE8; classification plus coreference resolution and question answeringInference and reading comprehension harder than GLUETest predictions scored on a server; average of tasksComparing models that GLUE can no longer separate
SQuAD1; extract the answer span from a paragraphReading comprehension and question answeringExact match and F1Comparisons focused on reading comprehension and QA

(The SuperGLUE details follow the SuperGLUE paper.)

Rough guidelines for choosing:

  • To compare under the same conditions as classic pretrained models from BERT onward, report per-task validation scores on GLUE and the test GLUE score.
  • To see differences between newer or larger models, use SuperGLUE or similar, since GLUE barely separates them.
  • To check only a specific ability (inference, paraphrase, and so on), look at the relevant GLUE tasks and the per-category R3R_3 on the diagnostic dataset.

PyTorch example

Show code
python
import numpy as np
import torch
from datasets import load_dataset
from torch.utils.data import DataLoader

"""
Load GLUE tasks with Hugging Face datasets and compute validation scores with the official metrics
Task names: 'cola' 'sst2' 'mrpc' 'qqp' 'stsb' 'mnli' 'qnli' 'rte' 'wnli' (diagnostic dataset: 'ax')
Test labels are not released (the label field holds no real values). Test scores are obtained by submitting predictions to gluebenchmark.com
"""

TASK_KEYS = {  # input column names per task (None as the second for single-sentence tasks)
  'cola': ('sentence', None), 'sst2': ('sentence', None),
  'mrpc': ('sentence1', 'sentence2'), 'stsb': ('sentence1', 'sentence2'),
  'qqp': ('question1', 'question2'), 'mnli': ('premise', 'hypothesis'),
  'qnli': ('question', 'sentence'), 'rte': ('sentence1', 'sentence2'), 'wnli': ('sentence1', 'sentence2'),
}

ds = load_dataset('nyu-mll/glue', 'rte')
print(ds)   # train 2490 / validation 277 / test 3000
print(ds['train'][0])  # {'sentence1': ..., 'sentence2': ..., 'label': 0 or 1, 'idx': ...}
# MNLI has two validation splits: 'validation_matched' and 'validation_mismatched'


def matthews_corr(pred, gold):
  """CoLA metric. Computed from the four counts of the binary confusion matrix (-1 to 1, 0 for random)"""
  tp = np.sum((pred == 1) & (gold == 1)); tn = np.sum((pred == 0) & (gold == 0))
  fp = np.sum((pred == 1) & (gold == 0)); fn = np.sum((pred == 0) & (gold == 1))
  denom = np.sqrt(float((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn)))
  return 0.0 if denom == 0 else (tp * tn - fp * fn) / denom


def f1(pred, gold):
  tp = np.sum((pred == 1) & (gold == 1))
  precision = tp / max(np.sum(pred == 1), 1); recall = tp / max(np.sum(gold == 1), 1)
  return 0.0 if precision + recall == 0 else 2 * precision * recall / (precision + recall)


def task_score(task, pred, gold):
  """Task score. Tasks with two metrics are averaged without weighting (same as the GLUE score)"""
  if task == 'cola':
    return matthews_corr(pred, gold)
  if task in ('mrpc', 'qqp'):
    return (np.mean(pred == gold) + f1(pred, gold)) / 2
  if task == 'stsb':                                   # regression: mean of Pearson and Spearman correlation
    from scipy.stats import pearsonr, spearmanr
    return (pearsonr(pred, gold)[0] + spearmanr(pred, gold)[0]) / 2
  return np.mean(pred == gold)                         # accuracy for the rest


# Validation evaluation (model is a task classifier, tokenizer is the pretrained model's)
# model.eval()                                          # disable Dropout
# key1, key2 = TASK_KEYS['rte']
# preds, golds = [], []
# with torch.no_grad():
#   for batch in DataLoader(ds['validation'], batch_size=32):
#     enc = tokenizer(batch[key1], batch[key2], padding=True, truncation=True, return_tensors='pt')
#     preds.append(model(**enc).logits.argmax(-1).numpy())
#     golds.append(batch['label'].numpy())
# print('RTE validation accuracy', task_score('rte', np.concatenate(preds), np.concatenate(golds)))
# GLUE score = simple average of task_score over the nine tasks (MNLI: mean of matched and mismatched). Always state whether WNLI is included

FAQ

Q. How is the GLUE score computed?
A.

A score is computed for each of the nine tasks, and these are averaged with equal weight. For tasks with two metrics, such as MRPC and QQP (accuracy and F1), STS-B (two correlations), and MNLI (matched and mismatched), the two are first averaged to give the task score. Test scores are computed by the evaluation server.

Q. Why does the "GLUE average" in a paper's table sometimes differ from the official GLUE score?
A.

Some papers average without WNLI or average validation scores. For example, the table in the BERT paper shows an average that excludes WNLI, separate from the official leaderboard value (80.5 for BERT-Large). When comparing, make sure the same tasks and splits are averaged.

Q. Should I use GLUE or SuperGLUE?
A.

GLUE is used for comparisons with models up to around 2019 (BERT, GPT, and so on). Because models surpassed humans on GLUE and differences became hard to see, use SuperGLUE, a collection of harder tasks, to compare newer models.

References

  1. Wang, A., Singh, A., Michael, J., Hill, F., Levy, O., & Bowman, S. R. (2018). GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding. ICLR 2019.
  2. Wang, A., Pruksachatkun, Y., Nangia, N., Singh, A., Michael, J., Hill, F., Levy, O., & Bowman, S. R. (2019). SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems. NeurIPS 2019.
  3. Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2018). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. NAACL 2019.
  4. nyu-mll/glue (Hugging Face dataset card).
  5. GLUE Benchmark (official site and leaderboard).