Skip to main content
Zubnet AI › Learn › Wiki › T5
Models

T5

Also known as: Text-to-Text Transfer Transformer, Flan-T5
Google's encoder-decoder model that treats every language task as turning one piece of text into another, still widely used as a text encoder for image and video generators.

Why it matters

T5 matters for two reasons. Historically, it showed that a single model with a single training objective could handle nearly any NLP task, and its systematic paper became a reference for how to do transfer learning. Its instruction-tuned successor, Flan-T5, was for a while the best small open model for following instructions.

Practically, T5 is still running in an enormous number of systems, in a role its authors didn't plan: as the text encoder inside image and video generators. If you've used FLUX.1, Stable Diffusion 3 or many open video models, a T5 encoder read your prompt.

Deep Dive

T5, the Text-to-Text Transfer Transformer, was introduced by Google researchers in 2019. Its central idea was to stop building a different output layer for every task. Translation, summarization, classification and question answering were all cast in the same form: text goes in, text comes out. To tell the model what to do, you put a short prefix on the input, such as translate English to German: or summarize:.

That sounds obvious today, since it's how everyone uses LLMs. In 2019 it was a real shift, and T5 was one of the models that established it.

Architecture and Training

T5 uses the original Transformer layout with both an encoder, which reads the input with bidirectional attention, and a decoder, which generates the output token by token. That sets it apart from BERT (encoder only) and GPT (decoder only).

It was pre-trained on a large web-text corpus called C4 using span corruption: random spans of text are replaced with placeholder tokens, and the model learns to generate the missing spans. It's a cousin of BERT's masked language modeling, adapted to a model that outputs text. The original release came in five sizes, from T5-Small (60 million parameters) to T5-11B (11 billion).

The Family

  • mT5: a multilingual version covering about 100 languages.
  • ByT5: works directly on bytes instead of tokens, which makes it robust to misspellings and unusual scripts.
  • Flan-T5 (2022): T5 fine-tuned on more than a thousand tasks phrased as instructions. It could follow new instructions without task-specific training and remains popular for cheap classification and extraction.
  • T5Gemma (2025): Google's return to the encoder-decoder design, built by adapting Gemma models.

T5 has also been repurposed well beyond language. Amazon's Chronos time-series forecasting models were originally built on the T5 architecture, and T5-based models have been used for reranking search results and producing embeddings.

T5 in Image Generation

Google's Imagen paper (2022) made a surprising finding: a large frozen language model trained only on text, T5-XXL, was a better text encoder for image generation than CLIP, and scaling up the text encoder helped more than scaling up the image model. T5 embeddings capture word order, relationships and long descriptions in a way CLIP's don't, which improved prompt following and the rendering of text in images.

The approach spread. Stable Diffusion 3 and FLUX.1 use T5-XXL alongside CLIP, and many video models use T5 variants. This is the t5xxl file, several gigabytes in size, that you load in ComfyUI. Because the encoder alone has about 4.7 billion parameters, quantized versions are common. Newer image models increasingly replace T5 with modern LLMs as text encoders.

Why Decoder-Only Won for Chat

If encoder-decoders work so well, why are today's LLMs decoder-only? Mostly simplicity and scale. A decoder-only model treats everything, prompt and response alike, as one sequence, which makes it straightforward to train on raw text, to handle multi-turn conversation and to cache earlier computation. At large scale, it performed at least as well. Encoder-decoders keep their advantage where the input is fully known up front and must be understood deeply: translation, summarization, speech recognition (Whisper is an encoder-decoder) and conditioning signals for other models.

← All Terms
ESC