FlashPapers | T5 Deep Dive
JMLR 2020 Landmark Paper

Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer

Colin Raffel*, Noam Shazeer*, Adam Roberts*, Katherine Lee*, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu | Google Research | 2020

"By converting all text-based language problems into a unified text-to-text format, we systematically compare pre-training objectives, architectures, datasets, and scaling strategies. Combining these insights with our 750 GB 'Colossal Clean Crawled Corpus' (C4) and an 11-billion parameter model, we establish new state-of-the-art results across dozens of NLP benchmarks."

Unified Text-to-Text C4 Dataset Span Corruption 11 Billion Parameters

Why This Matters

Before T5, the field of Natural Language Processing (NLP) was highly fragmented. Transfer learning had proven extremely successful, but researchers were using a dizzying array of diverse pre-training objectives, model architectures (e.g., encoder-only vs. decoder-only), unlabeled datasets, and fine-tuning recipes.

This diversity made it nearly impossible to isolate which design choices actually drove performance. Was a new model better because of its novel attention mechanism, its cleaner training data, or simply because it was trained longer? T5 addresses this by providing a rigorous, controlled empirical comparison of the entire transfer learning landscape under a single, unified framework.

The Big Idea

Treat every text-based problem as a "text-to-text" task.

Instead of adding custom classification heads or span-extraction layers for different tasks (like BERT or RoBERTa do), T5 uses the exact same model, loss function, and decoding procedure for every task. Whether the goal is translation, sentiment analysis, document summarization, or even sentence similarity (regression), the model is fed a text string and trained to generate a target text string.

How It Works

1. The Unified Text-to-Text Format

To instruct the model on which task to perform, T5 appends a task-specific text prefix to the input. For example, to translate, the prefix is "translate English to German: ". For classification, the model literally generates the output text labels (e.g., "positive" or "negative").

Task Format Explorer

Click a task to see T5's input/output formulation
T5 Formatted Input (with Prefix)
translate English to German: That is good.
T5 Model
Target Output (Generated Tokens)
Das ist gut.

Translation is naturally text-to-text. The prefix specifies the target language.

2. Attention Masking Patterns

The paper systematically compares three main model structures: standard Encoder-Decoder, Decoder-only Language Models (LM), and Prefix LMs. The key differentiator is the self-attention mask which controls which tokens can attend to which other tokens.

Attention Mask Matrix

Output (y)
Input (x)
Fully-Visible Attention Mask

Allows a self-attention mechanism to attend to any entry of the input sequence at any timestep. This is used in standard encoders (like BERT) where context is fully visible.

Allowed Attention Path Masked (No Attention)

3. Denoising & Span Corruption

The paper systematically evaluates various pre-training objectives. The clear winner was a modified version of BERT's masked language model, called Span Corruption. Instead of masking individual tokens, T5 replaces entire consecutive spans of corrupted tokens with a single unique sentinel token (e.g., <X>).

Objective Transformation Simulator

Select an objective to see the input/target transformation
Original Sentence
Thank you for inviting me to your party last week.
Highlighted tokens are selected for corruption (15% rate).
Processed Model Input
Thank you <X> me to your party <Y> week.
Model Target Output
<X> for inviting <Y> last <Z>

Results & Scaling

By combining the optimal recipes from their systematic study (Encoder-Decoder architecture, Span Corruption pre-training, C4 dataset) and scaling the model up to 11 Billion Parameters, T5 achieved state-of-the-art results on 18 out of 24 benchmarks.

Benchmark Comparison Dashboard

Compare T5 variants against previous State-of-the-Art (SOTA)

Limitations & Open Questions

  • The Inconvenience of Large Models: Although T5-11B achieves stellar performance, deploying an 11-billion parameter model for real-time inference remains highly resource-intensive and impractical for edge devices.
  • English-centric Pre-training: The primary C4 dataset is English-only. Consequently, T5 struggled on multilingual translation benchmarks compared to specialized translation models that leverage backtranslation.
  • Inefficient Knowledge Extraction: Training a model to reconstruct missing words (denoising) might be a suboptimal way to teach general-purpose knowledge. More sample-efficient objectives are needed.

Glossary

Span Corruption

A pre-training objective where contiguous sequences of tokens are masked and replaced with unique sentinel tokens. The model is then tasked with predicting only the masked tokens, reducing computational costs.

C4 (Colossal Clean Crawled Corpus)

A massive, 750 GB dataset of clean English text scraped from the public web (Common Crawl) using aggressive cleaning heuristics to remove boilerplate, non-natural language, and offensive content.

Prefix LM

A variation of attention masking where a portion of the input sequence (the prefix) is fully visible (bidirectional attention), while the remaining generated tokens are causally masked.

Citation

@article{raffel2020exploring,
  title={Exploring the limits of transfer learning with a unified text-to-text transformer},
  author={Raffel, Colin and Shazeer, Noam and Roberts, Adam and Lee, Katherine and Narang, Sharan and Matena, Michael and Zhou, Yanqi and Li, Wei and Liu, Peter J},
  journal={Journal of Machine Learning Research},
  volume={21},
  number={140},
  pages={1--67},
  year={2020}
}
Made with Flash Papers — make your own