Paper · 2021-10-15 · cs.LG, cs.CL
Multitask Prompted Training Enables Zero-Shot Task Generalization
Fine-tunes T5 LM-adapted encoder-decoders (3B and 11B) on 62 NLP datasets, each written as several natural-language prompts, then tests zero-shot on held-out NLI, coreference, sentence completion and WSD. T0 matches or beats GPT-3 on 9 of 11 held-out datasets (author-reported).
Multi-task learningInstruction tuningZero-shot learningPrompt engineeringmultitask-learningpromptingzero-shotencoder-decodert5
arXivPDFCodeMarkdown11 min read
AI-compiled by claude-haiku-5-5 on 2026-10-19, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Large language models often handle tasks they were never trained on, if the task is described in the prompt. One explanation is that they pick up many tasks by accident while predicting text. The authors ask whether the same ability can be built on purpose, by training one model on many tasks at once, each phrased as a plain-language request.
They take a pretrained text-to-text model and fine-tune it on a large set of existing datasets. Each dataset is rewritten with several prompt wordings, so the model sees the same task in many forms. They then test it on kinds of tasks that were left out of training, such as deciding whether one sentence follows from another. The model does well on these held-out tasks even though it is much smaller than the language models it is compared with.
TL;DR
Sanh, Webson, Raffel and co-authors build a system that turns NLP datasets into prompted text pairs, and fine-tune an encoder-decoder T5 model on 62 datasets and 12 task types. Four task types are held out: natural language inference, coreference, sentence completion and word sense disambiguation. T0 (11B) matches or exceeds GPT-3 (up to 175B) on 9 of 11 held-out datasets, and the authors say it is about 16 times smaller (author-reported). Read this if you want to build multitask instruction data or check zero-shot claims. The Pitfalls section lists where the paper and its code disagree.
Problem
- Large language models show zero-shot generalization to new tasks, usually attributed to implicit multitask learning during pretraining §1.
- The question is whether explicit multitask training on prompted datasets induces zero-shot generalization directly §1.
- Earlier multitask work generalizes to held-out datasets, not held-out tasks, and single-prompt formats do not extend to new tasks §1 §2.
- Zero-shot ability depends on model size and is sensitive to prompt wording §1. Choosing a prompt by its validation score leaks evaluation information, so the authors do not select prompts this way §5.
- Tasks are a fuzzy partition of NLP datasets. The authors group by task format rather than by skill, and they hold out whole tasks §3.
Method
Partition. The authors collect 62 English datasets in 12 task types with publicly contributed prompts. The 11 held-out evaluation datasets are WSC, Winogrande, ANLI R1 to R3, CB, RTE, COPA, HellaSwag, StoryCloze and WiC §3 app. D.4, tab. 5. Held-out task types are NLI, coreference, sentence completion and word sense disambiguation §3. Datasets in the four held-out types are excluded from T0 and T0+. T0++ adds SuperGLUE WSC and WiC to its training data, which is why those two are greyed out in its results §5 tab. 5 tab. 7. LAMBADA is dropped from evaluation because GPT-3 used a different variant app. D.3.
Prompts. A prompt is an input template and a target template, plus metadata such as answer choices and the evaluation metric. Templates map a data example to text §4. Each dataset is written as several prompts, and the collection (P3) has 2073 prompts for 177 datasets, 11.7 per dataset on average §4. Prompt templates are written in Jinja in the PromptSource tool; an empty rendered prompt is skipped app. C. Prompts that are not the dataset's original task, for example generating a document from its summary, are used in training but not reported in evaluation §4.
Model. The model is a T5-style encoder-decoder. Input text goes to the encoder, and the decoder is trained by maximum likelihood to produce the target text. The model is never trained to generate its input §5. The starting point is the LM-adapted T5 of Lester et al., trained further on a language-model objective §5. Variants: T0 (11B), T0+ (also trains on GPT-3's evaluation datasets), T0++ (also trains on SuperGLUE except RTE and CB), and T0 (3B) §5.
# Build one prompted example from a raw example [§4] [app. C]
# Input: example (dict of fields), template (input and target templates)
# Output: (input_text, target_text), or None if the prompt is empty
def materialize(example, template):
# Fill the input template with the example's fields [§4]
input_text = render(template.input_template, example)
# Fill the target template; it is the text the model must produce [§4]
target_text = render(template.target_template, example)
# Skip examples where the template does not apply [app. C]
if input_text == "" or target_text == "":
return None
return input_text, target_text# Sampling cap per template in the training mixture [§5]
# Input: train_size (examples in the dataset), num_templates
# Output: number of examples drawn for each template
def template_cap(train_size, num_templates):
# Large datasets share a budget of 500,000 across their templates [§5]
if train_size > 500000:
return 500000 // num_templates
# Smaller datasets keep their full size for every template [code:
# t0/seqio_tasks/tasks.py#L205-L214]
return train_size# Training loss for one example [§5]
# Input: input_ids (encoder tokens), target_ids (decoder tokens)
# Output: scalar negative log-likelihood of the target
def training_loss(input_ids, target_ids):
# Score each target token given the input; only targets are scored [§5]
token_log_probs = decoder_log_probs(input_ids, target_ids)
# Sum vs mean over tokens is not stated in the paper [§5]
return -sum(token_log_probs)Training. All training examples are combined and shuffled, and the training mixture is sampled with the cap above §5 [code: t0/seqio_tasks/tasks.py#L205-L232]. Sequences are packed to the maximum length §5. Hyperparameters are in the next section.
Checkpoint. The checkpoint with the highest score on the validation splits of the training datasets is kept. No held-out data is used for this choice §5.
Evaluation. For multiple-choice tasks, rank classification: score every answer option by its log-likelihood under the model, pick the highest, and do not normalize by length §5. The metric is accuracy §5. For each dataset, the reported number is the median over all its prompts, with the interquartile range (Q3 minus Q1) as the robustness measure §5. Validation splits are used §5; ANLI uses its dev rounds tasks.py.
# Rank classification for a multiple-choice task [§5]
# Input: input_ids (encoder tokens), choices (list of token lists)
# Output: index of the chosen answer
def predict(input_ids, choices):
scores = []
for choice in choices:
# Log-probability of every token of this option [§5]
# [code: t0/model.py#L61-L64]
token_log_probs = score_tokens(input_ids, choice)
# Plain sum, no length normalization [§5]
scores.append(sum(token_log_probs))
return argmax(scores)Prompt robustness experiments. The main T0 model averages 8.03 prompts per dataset (the non-original prompts included). Ablations use 1 prompt per dataset, 5.7 original prompts per dataset, and no prompted training §6.2 fig. 6. The dataset-count ablation uses 39, 49 and 55 datasets for T0, T0+ and T0++ §6.2 fig. 7.
Hyperparameters
Hardware and compute: about 27 TPU v3-512 hours for one T0 run and about 270 hours for all experiments in the paper app. B.1 tab. 1.
| Name | Value | Where | Notes |
|---|---|---|---|
| Base model, main | T5+LM, 11B parameters | §5 | Used for T0, T0+, T0++ |
| Base model, small | T5+LM, 3B parameters | §5 | Used for T0 (3B) |
| Base checkpoint name | not stated in paper | §5 | Code initializes from t5.1.1.lm100k.xxl README.md |
| Input length | 1024 tokens | §5 | Truncation |
| Target length | 256 tokens | §5 | Truncation; see Pitfalls for eval code |
| Batch size | 1024 sequences = 2^20 input tokens | §5 | Code: tokens_per_batch=1048576 README.md |
| Packing | yes | §5 | Packs examples into full-length sequences, as in T5 |
| Optimizer | Adafactor | §5 | |
| Learning rate | 1e-3 | §5 | Code gin file name suggests a constant schedule README.md; the gin file is not in the repo |
| Dropout | 0.1 | §5 | Not in the repo |
| Training steps | not stated in paper | — | README uses 1,112,200 README.md |
| Sampling cap | 500,000 examples per dataset, divided by number of templates | §5 | tasks.py |
| Checkpoint selection | highest validation score on training datasets | §5 | Selected step not stated |
| Eval metric | accuracy | §5 | |
| Eval statistic | median over prompts, plus IQR | §5 | |
| Prompts per dataset (T0) | 8.03 average | §6.2 | |
| Prompts per dataset (P3) | 11.7 average over 177 datasets | §4 |
Results
Author-reported. Zero-shot evaluation on validation splits; per dataset, median over all its prompts §5. GPT-3 reports one prompt per dataset, while the T0 numbers cover all prompts §6.1. GPT-3 numbers appear only in fig. 4 and are not tabulated here.
- Held-out datasets: T0 matches or exceeds all GPT-3 models on 9 of 11 held-out datasets. Winogrande and HellaSwag are the two exceptions §6.1 §7.
- NLI: T0 outperforms GPT-3 on all NLI datasets, though the T5+LM baseline does not §6.1.
- Against the T5+LM baseline with the same architecture and prompts, T0 improves on every held-out dataset §6.1 fig. 4.
- BIG-bench subset: at least one T0 variant outperforms all baselines on all tasks except StrategyQA. The baselines are decoder-only models from the BIG-bench maintainers, each evaluated with one prompt per dataset §6.1 fig. 5.
- Prompt robustness, p=5.7 versus p=1: median improves on 8 of 11 datasets, and the IQR shrinks on 7 of 11 §6.2 fig. 6.
- Prompt robustness, all prompts versus 5.7: median rises on 9 of 11 datasets and the IQR shrinks on 8 of 11 §6.2.
- Datasets ablation: median rises for all 5 held-out datasets from 39 to 49 datasets, but the IQR shrinks on only 1 of 5 §6.2 fig. 7.
- GPT-3 robustness on RTE: 10 prompts, median 52.96%, IQR 1.28 §6.2. One of them reproduces GPT-3's reported prompt at 58.8%, below the 63.5% GPT-3 reports §6.2.
- Without instructions, the HellaSwag median rises from 33.65% to 57.93%. For Winogrande, FLAN's prompt without instructions gives 62.15%, with no large change §7.
Table 7 gives per-dataset medians for T5+LM and the T0 variants. Values are medians across prompts, as reported in tab. 7 app. F. An asterisk marks a cell the paper greys out as not zero-shot for that model, because the model trained on that dataset.
| Dataset | T5+LM | T0 (p=1) | T0 (p=5.7) | T0 (3B) | T0 | T0+ | T0++ |
|---|---|---|---|---|---|---|---|
| WSC | 57.69 | 56.25 | 63.46 | 64.42 | 64.42 | 64.42 | 69.71* |
| Winogrande (XL) | 50.71 | 57.22 | 58.80 | 50.51 | 60.46 | 61.72 | 66.54* |
| ANLI R1 | 32.85 | 40.05 | 43.20 | 33.65 | 44.70 | 45.80 | 49.80 |
| ANLI R2 | 32.90 | 38.20 | 38.60 | 33.40 | 39.40 | 41.10 | 44.50 |
| ANLI R3 | 33.75 | 39.33 | 38.58 | 33.33 | 42.42 | 41.17 | 46.42 |
| CB | 33.93 | 50.89 | 64.29 | 50.00 | 78.57 | 71.43 | 83.93 |
| RTE | 51.81 | 79.24 | 74.91 | 64.08 | 81.23 | 64.98 | 84.84 |
| COPA | 55.00 | 87.50 | 91.69 | 74.92 | 90.79 | 93.88 | 93.75* |
| HellaSwag | 27.73 | 33.27 | 35.20 | 27.51 | 33.65 | 85.79* | 85.65* |
| StoryCloze | 48.85 | 93.00 | 95.88 | 85.09 | 94.71 | 97.17* | 97.33* |
| WiC | 50.24 | 54.94 | 54.94 | 50.39 | 57.21 | 55.49 | 69.98* |
BIG-bench subset (accuracy, one BIG-bench prompt per dataset): tab. 8 app. F. Accuracies for T5+LM, T0, T0+ and T0++; baseline models appear only in fig. 5.
| Dataset | T5+LM | T0 | T0+ | T0++ |
|---|---|---|---|---|
| Code Description | 18.33 | 36.67 | 53.33 | 58.33 |
| Conceptual | 25.00 | 62.50 | 81.25 | 75.00 |
| Hindu Knowledge | 32.00 | 36.00 | 38.29 | 40.00 |
| Known Unknowns | 52.17 | 63.04 | 63.04 | 52.17 |
| Language ID | 16.71 | 20.68 | 20.80 | 22.17 |
| Logic Grid | 31.00 | 39.60 | 39.50 | 39.40 |
| Logical Deduction | 31.00 | 55.40 | 44.20 | 43.60 |
| Misconceptions | 51.60 | 52.51 | 52.97 | 54.79 |
| Movie Dialog | 50.19 | 53.83 | 54.05 | 53.97 |
| Novel Concepts | 9.38 | 15.62 | 31.25 | 28.12 |
| Strategy QA | 52.25 | 52.73 | 54.00 | 54.39 |
| Syllogisms | 50.04 | 51.79 | 50.53 | 50.31 |
| Vitamin C | 38.29 | 64.73 | 66.24 | 70.00 |
| Winowhy | 45.77 | 47.38 | 45.84 | 48.15 |
Bias and contamination (not in the headline numbers). On CrowS-Pairs and WinoGender, T0 mean accuracy is 59.2 and 84.2 respectively tab. 3 app. B.3. WinoBias pro-minus-anti gaps are reported in tab. 4. Contamination checks found 9.12% of HellaSwag examples and 5.2% of RTE hypotheses in C4 app. E tab. 6.
Paper vs code
Checked against the official repository at code_commit, which contains the
training and evaluation scripts and the mixture definitions. Discrepancies:
- Checkpoint selection. The paper selects the checkpoint by validation score on training datasets §5. The training README evaluates a fixed step, 1,112,200 README.md, and the repo contains no selection script.
- Sampling weight. The paper says the mixture samples each dataset in proportion to its number of examples, with the 500,000 cap for large datasets §5. The code sets a cap per template, so each template of a dataset under 500,000 examples contributes its full size [code: t0/seqio_tasks/tasks.py#L205-L232]. A dataset with several templates therefore gets more weight than its example count would give.
- Target length in evaluation. The paper truncates targets to 256 tokens
§5. The evaluation script defines
--target_max_length(default 256) run_eval.py, but the answer-choice tokenization usesmax_length(default 1024) instead [code: evaluation/run_eval.py#L268-L276]. - Special tokens in evaluation. Inputs are tokenized with
add_special_tokens=Falserun_eval.py. Answer options are not, so the end-of-sequence token of the tokenizer's default setting is scored as part of each option. This is a reading of the code, not a check of the output. - Training steps and optimizer details. The paper gives neither the number of steps nor the dropout's location. The repo supplies 1,112,200 steps README.md and a learning-rate gin file, but dropout, Adafactor and packing settings live in external T5 gin files that are not in this repo.
- Training code. The released training path is Mesh TensorFlow on TPUs. The README says the PyTorch replication is still a work in progress README.md.
- Hotpot QA. The paper recasts HotpotQA as closed-book QA fig. 2. The code drops the generative HotpotQA prompts because they exceed 1024 tokens tasks.py. The paper does not list the kept prompts.
- Mixture membership. The T0+ and T0++ additions match the paper's description tasks.py.
Pitfalls
- Zero-shot is only as clean as the held-out split. Tasks are a fuzzy partition §3, and the authors argue that NLI and paraphrase are distinct while holding out sentence completion as a precaution app. D.2. A reader who disagrees should treat the held-out numbers as one partition, not a fact.
- Contamination is partial. 9.12% of HellaSwag and 5.2% of RTE hypotheses appear in C4 app. E tab. 6. The search used exact matches on 16-token windows, and flagged matches were checked by hand app. E.
- Median over prompts is not GPT-3's protocol. GPT-3 reports one prompt per dataset, which the authors believe is a manually tuned best prompt §6.1 fn. 1. The T0 medians cover all prompts, so the comparison is not like for like.
- Validation splits, not test. Every number is on validation or dev splits §5. Compare with the same split.
- LAMBADA was dropped. The unprompted form gave T5+LM 6.2% and T0 18.7%; the cloze form gave T0 27.8%, and the GPT-3 variant gave 40.5% app. D.3.
- Answer scoring has no length normalization. Long options are penalized when the option is scored by its summed log-probability §5 [code: t0/model.py#L61-L67].
- fp16 is not safe at inference. The code's data collator warns that fp16 predictions can differ greatly from fp32 data_collator.py.
- Prompts are external. The 2073 prompts are in the P3 collection and the PromptSource repository, not in the paper text §4 app. G. Reproducing the mixture needs both.
- Bias. The authors report that T0++ produces biased or false answers, for example "yes" to "Is the earth flat?" app. B.3 tab. 2. The training data excluded forum and social-media sources, but the models are not bias-free.
- Compute cost. Training used about 270 TPU v3-512 hours across all experiments app. B.1 tab. 1. A reproduction needs that hardware class, and the repo's training command is for TPUs.
Lineage
- Builds on: the T5 encoder-decoder §5 and the LM-adapted T5 of Lester et al. §5. Prompting as the input format builds on GPT-3 §2.
- Compared against: GPT-3 §6.1; the BIG-bench baselines §6.1.
- Concurrent work: FLAN ("Finetuned Language Models Are Zero-Shot Learners"), which trains decoder-only models, one held-out task per model §7. The paper names no arXiv id for it.
- Superseded by: not stated in the paper.
Source and license
Adapted from “Multitask Prompted Training Enables Zero-Shot Task Generalization” by Victor Sanh, Albert Webson, Colin Raffel, Stephen H. Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, Manan Dey, M Saiful Bari, Canwen Xu, Urmish Thakker, Shanya Sharma Sharma, Eliza Szczechla, Taewoon Kim, Gunjan Chhablani, Nihal Nayak, Debajyoti Datta, Jonathan Chang, Mike Tian-Jian Jiang, Han Wang, Matteo Manica, Sheng Shen, Zheng Xin Yong, Harshit Pandey, Rachel Bawden, Thomas Wang, Trishala Neeraj, Jos Rozen, Abheesht Sharma, Andrea Santilli, Thibault Fevry, Jason Alan Fries, Ryan Teehan, Tali Bers, Stella Biderman, Leo Gao, Thomas Wolf, Alexander M. Rush (arXiv:2110.08207), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/bigscience-workshop/t-zero at commit 7a699e3ba15c (Apache-2.0). Any quoted code is shown under that license.