Citation and evidence

Flan-T5

16 min full readUpdated 25 references

This article's verification

Report a problem with this article

Edit article
More

Cite this article

Flan-T5 is a family of five instruction-tuned encoder-decoder language models released by Google in October 2022, ranging from about 80 million to 11 billion parameters.[1] The models were made by taking T5 checkpoints and fine-tuning them on a mixture of 1,836 tasks phrased as natural-language instructions (later called the "Flan 2022" collection), a procedure described in the paper "Scaling Instruction-Finetuned Language Models" by Hyung Won Chung and 34 co-authors.[1][3][13] The paper's public release consisted of the Flan-T5 checkpoints, which are distributed under the Apache License 2.0.[1][4] Google's T5X documentation recommends Flan-T5 over the plain T5 checkpoints as a general-purpose starting point for few-shot prompting and fine-tuning.[3]

Researchers have used Flan-T5 as the frozen language model in vision-language models such as BLIP-2 and InstructBLIP, as the text encoder of the Tango text-to-audio system, and as a fine-tuned backbone for web agents in Mind2Web.[19][20][21][22]

Background

T5 (Text-to-Text Transfer Transformer), introduced by Colin Raffel and colleagues at Google in 2019, casts every language task as feeding text into an encoder and generating text from a decoder, and was pre-trained on the Colossal Clean Crawled Corpus (C4).[6] Google later published improved "T5 1.1" checkpoints, pre-trained on C4 alone without the downstream tasks that the original T5 mixed in, and "LM-adapted" versions of them that were trained for an additional 100,000 steps on a language-modeling objective; the T5X documentation says the adaptation makes the models better suited to prompt tuning.[3]

Instruction tuning had been introduced by Jason Wei and colleagues in the 2021 FLAN paper ("Finetuned Language Models Are Zero-Shot Learners"), which fine-tuned a 137-billion-parameter pretrained model on more than 60 NLP datasets written as instructions and found that it surpassed zero-shot 175B GPT-3 on 20 of the 25 datasets evaluated.[7] The 2022 follow-up asked how this kind of fine-tuning scales with the number of tasks and the size of the model, and whether adding chain-of-thought training data helps reasoning.[1] The authors use "Flan" for the fine-tuning procedure and "FLAN" for the 2021 model, and prefix every resulting model with "Flan" (Flan-PaLM, Flan-U-PaLM, Flan-T5).[1]

Development and release

The paper "Scaling Instruction-Finetuned Language Models" was first posted to arXiv on 20 October 2022 and revised four times through 6 December 2022.[1] The paper lists Google as the authors' affiliation, with Hyung Won Chung, Le Hou, Shayne Longpre, Barret Zoph and Yi Tay as the first five listed and Jason Wei last; Quoc Le, Jeff Dean, Jacob Devlin, Ed H. Chi and Denny Zhou were among the research advisors named in the contributions statement.[1] The paper was later published in the Journal of Machine Learning Research in 2024 (volume 25, paper 70).[2]

Most of the paper is about Flan-PaLM, instruction-tuned versions of PaLM at 8B, 62B and 540B parameters; the 540B model reached 75.2% on five-shot MMLU using chain-of-thought prompting with self-consistency.[1] Flan-T5 was the part of the work that outsiders could download. The abstract states that the authors "publicly release Flan-T5 checkpoints, which achieve strong few-shot performance even compared to much larger models, such as PaLM 62B."[1] The original T5X checkpoints were posted to a public Google Cloud Storage bucket and are listed in the T5X model documentation, and Hugging Face repositories for all five sizes appeared under the google organization on 21 October 2022, the day after the first arXiv version.[3][5]

Training data

The paper scaled instruction tuning to 1,836 tasks (drawn from 473 datasets and 146 task categories) by combining four existing or newly assembled mixtures.[1] A "task" is a pairing of a dataset with a task category, so one dataset such as SQuAD can contribute several tasks (question answering, question generation, and so on).[1]

MixtureTasksDatasetsContents
Muffin8069Tasks from the 2021 FLAN paper plus new dialogue and program-synthesis data
T0-SF19355Tasks from BigScience's T0 that do not overlap with Muffin ("sans Flan")
Natural Instructions v2 (NIV2)1,554372Tasks from Super-Natural Instructions, with 44 MMLU-related tasks removed
Chain-of-thought (CoT)99Datasets with human-written reasoning annotations, such as arithmetic and multi-hop reasoning

Expanded article table

Sources for the table: Chung et al. 2022, Figure 2 and section 2.1.[1]

For Muffin, T0-SF and NIV2 the authors used the instruction templates written by the creators of those collections; for the nine CoT datasets they wrote about ten templates each.[1] Training examples were formatted with and without few-shot exemplars and with and without chain-of-thought, and some examples carried exemplars only.[1] Because a few datasets were far larger than others, each task's sampling weight was its example count up to a cap: 30,000 examples for Muffin, 20,000 for T0-SF, 100,000 for CoT and 5,000 for NIV2.[1]

The paper reported that adding the nine CoT datasets mattered: earlier instruction-tuning mixtures without CoT data hurt performance on chain-of-thought evaluations, while the combined mixture improved every evaluation.[1] In its Flan-PaLM scaling experiments, most of the benefit from adding tasks came within the first 282 tasks; as one of two possible explanations, the authors suggested that much of the gain comes from the model learning to better express knowledge it already had from pre-training (the other being that the additional tasks were not diverse enough).[1]

Fine-tuning procedure

Each Flan-T5 model was initialized from the corresponding T5 1.1 LM-adapted checkpoint and fine-tuned with the Adafactor optimizer and a constant learning rate.[1][3] Several training examples were packed into each sequence, with masking so that tokens could not attend across example boundaries.[1] Training used Google's JAX-based T5X framework on TPU v3 or v4 hardware.[1] For each model the authors kept a single checkpoint, chosen by periodic evaluation on the held-out tasks.[1]

All five sizes used the same global batch size (64), dropout (0.05) and learning rate (5e-4); only the number of steps differed.[1] Instruction tuning was cheap relative to pre-training: the paper's Table 2 puts the fine-tuning cost of Flan-T5 between 0.2% and 1.6% of the pre-training FLOPs, depending on size.[1]

Model sizes

ModelParametersEncoder / decoder layersd_modeld_ffAttention headsFine-tuning stepsFine-tuning compute (% of pre-training)
Flan-T5-Small80M8 / 85121024698k1.6%
Flan-T5-Base250M12 / 1276820481284k1.4%
Flan-T5-Large780M24 / 24102428161664k1.1%
Flan-T5-XL3B24 / 24204851203238k0.6%
Flan-T5-XXL11B24 / 244096102406414k0.2%

Expanded article table

Parameter counts, steps and compute share are from the paper; layer and width figures are from the config.json files published with the Hugging Face weights.[1][8][9][10][11][12] The paper's own model card gives the small model as 77 million weights rather than 80 million.[1] Every size uses a gated-GELU feed-forward layer, separate (untied) input and output embeddings and a 32,128-entry vocabulary, following the T5 1.1 design.[3][8][9][10][11][12] The paper notes that T5 is not multilingual.[1]

Evaluation

Google Research compares two models across five evaluations as the number of training steps increases.
Google Research compares two models across five evaluations as the number of training steps increases. Google Research.

The paper evaluated on benchmarks held out from fine-tuning: MMLU (57 exam-style tasks, five-shot), BIG-Bench Hard (BBH, 23 hard BIG-Bench tasks, three-shot), TyDiQA (question answering in 8 languages, one-shot) and MGSM (grade-school math in 10 languages, eight-shot, chain-of-thought only).[1] Its summary "normalized average" rescales each score against a random-guessing baseline, so a model can score below zero.[1] The non-finetuned T5 baselines in the comparison are the LM-adapted checkpoints.[1]

ModelNormalized averageMMLU directMMLU CoTBBH directBBH CoTTyDiQAMGSM
T5-XXL (LM-adapted, 11B)-2.925.918.729.519.30.01.0
Flan-T5-Small-3.128.712.129.119.21.10.2
Flan-T5-Base6.535.933.731.327.94.10.4
Flan-T5-Large13.845.140.537.531.512.30.7
Flan-T5-XL19.152.445.541.035.216.61.9
Flan-T5-XXL23.755.148.645.341.419.04.9
PaLM 62B (not instruction-tuned)28.455.149.037.443.040.518.2

Expanded article table

Source: Chung et al. 2022, Table 5 (scores in %).[1]

Instruction tuning raised the normalized average of every T5 size, by 6.1 points for Small and 26.6 points for XXL.[1] The authors attributed the size of these gains partly to the difficulty of the benchmarks and to T5 not being multilingual.[1] The paper highlighted two comparisons: Flan-T5-XL, with 3 billion parameters, scored 52.4% on MMLU against 43.9% for 175B GPT-3, and Flan-T5-XXL beat the much larger PaLM 62B on direct-prompted BBH.[1][3] The table also shows the limits: PaLM 62B still had the higher normalized average, and no Flan-T5 model reached 5% on the multilingual math benchmark MGSM.[1]

The Flan Collection

In January 2023 Shayne Longpre and colleagues published "The Flan Collection: Designing Data and Methods for Effective Instruction Tuning", which broke down the design choices behind the Flan 2022 mixture and released it.[13] The paper appeared at the International Conference on Machine Learning (ICML) 2023.[14] Its experiments held the base model fixed (T5-XL, 3 billion parameters) and swapped the instruction-tuning collection, comparing Flan 2022 with Flan 2021, T0++ and Super-Natural Instructions.[13]

The authors reported that Flan-T5 outperformed models tuned on those earlier public collections by 3% to 17% or more across evaluation settings.[13] They identified several inexpensive techniques as responsible:

  • training on a mix of zero-shot, few-shot and chain-of-thought prompts, which improved results in all three settings (adding just 10% few-shot prompts improved zero-shot results by 2% or more);[13]
  • "input inversion", which creates extra tasks by swapping a dataset's inputs and outputs;[13]
  • balancing the proportions of the different source collections.[13]

The paper also tested Flan-T5 as a starting checkpoint for ordinary single-task fine-tuning. Fine-tuning Flan-T5 gave better results than fine-tuning T5 directly on both held-in and held-out tasks, converged in fewer steps, and in some low-data cases Flan-T5 without any extra fine-tuning beat a task-fine-tuned T5.[13] A Google Research blog post by Longpre and Adam Roberts argued that this makes instruction-tuned models a cheaper base for the many fine-tuning runs done downstream.[15] The Flan Collection paper also noted that the authors of OPT-IML (Iyer et al., 2022) had reported Flan-T5-XL and Flan-T5-XXL outperforming the 175-billion-parameter OPT-IML-Max on MMLU and BBH, while cautioning that pre-training, architecture and tuning details could all explain the gap.[13] The data-generation code for Flan 2022 is in Google's FLAN repository on GitHub, which is licensed under Apache 2.0.[13][16]

Flan-UL2

In March 2023, Yi Tay, a co-author of both the UL2 paper and the Flan-T5 paper, announced Flan-UL2, a 20-billion-parameter model that applied the same Flan instruction tuning to the UL2 20B encoder-decoder checkpoint.[1][17][18] Before tuning, the team continued training UL2 for an extra 100,000 steps so that it no longer needed UL2's "mode tokens", and Flan-UL2 used a receptive field of 2,048 tokens rather than the original UL2's 512, to make few-shot prompting more practical.[17][18] Tay reported that Flan-UL2 improved on Flan-T5-XXL on all four reported setups (MMLU and BBH, direct and chain-of-thought), by 3.2% overall in relative terms, with most of the gain in the chain-of-thought settings.[17] Flan-UL2 was also released under Apache 2.0.[18]

Safety evaluations and model card

The paper's responsible-AI appendix measured toxic continuations with the Real Toxicity Prompts dataset and the Perspective API.[1] The probability that Flan-T5-XXL produced at least one toxic continuation out of 25 was 0.06 for non-toxic prompts and 0.26 for toxic prompts, lower than the figures for Flan-PaLM.[1] However, the authors observed that at high prompt toxicity Flan-T5-XXL behaved differently from the Flan-PaLM models, sometimes producing continuations more toxic than the human baselines, and left the cause to future work.[1]

The model card published with the paper lists research on language models as the primary intended use and states that Flan-T5 "should not be used directly in any application, without a prior assessment of safety and fairness concerns specific to the application."[1] It adds that the fine-tuning data "was not filtered for explicit content or assessed for existing biases" and that the models had not been tested in real-world applications.[1] Hugging Face's model card repeats these passages and notes that its own text was written by the Hugging Face team.[4]

Availability

The weights are distributed in two forms: the original T5X checkpoints listed in the T5X documentation, and PyTorch-compatible copies on Hugging Face (google/flan-t5-small, -base, -large, -xl and -xxl) tagged with the Apache 2.0 license.[3][4] Because Flan-T5 keeps the T5 architecture, it runs with the standard T5 classes of the Hugging Face Transformers library, and the model card's examples load it with T5ForConditionalGeneration on CPU, on GPU, and in FP16 or INT8 precision.[4]

Use in later research

Flan-T5 appears as a component or baseline in many later research projects, including the following:

WorkYearHow Flan-T5 was used
BLIP-2 (Salesforce)2023Frozen encoder-decoder language model connected to a frozen image encoder; versions built on FlanT5-XL and FlanT5-XXL[19]
InstructBLIP (Salesforce)2023One of two language-model families (with Vicuna) in an instruction-tuned vision-language model[20]
Tango2023Frozen Flan-T5-Large (780M) as the text encoder for a latent-diffusion text-to-audio model[21]
Mind2Web2023Flan-T5 Base, Large and XL fine-tuned as action-prediction models for the MindAct web agent[22]
VQAScore and GenAI-Bench2024CLIP-FlanT5, a CLIP vision encoder joined to Flan-T5, used to score image-text alignment[23]
Garden-path sentence study2024One of four models (with GPT-2, Llama 2 and RoBERTa) compared with human sentence processing[24]

Expanded article table

The Tango authors chose Flan-T5 because, unlike older text encoders such as T5 or RoBERTa, it had been instruction-tuned, and they credited it in part for outperforming AudioLDM on most metrics despite training on a much smaller dataset.[21] In Mind2Web, GPT-4 and GPT-3.5 were tested in-context, while the Flan-T5 models were fine-tuned on the full training split; a Flan-T5-XL used zero-shot, without that fine-tuning, scored about 8% to 12% in the paper's zero-shot element-selection comparison, against about 39% to 52% for the fine-tuned model, which the authors described as failing to perform the task without fine-tuning.[22] The VQAScore authors built on Flan-T5 because its bidirectional encoder lets image features depend on the question being asked.[23]

Reception and limitations

The INSTRUCTEVAL benchmark study (Chia et al., 2023) found that OPT-IML and the Flan-T5 family showed the largest improvements over their base models among the instruction-tuned models it tested, which it linked to their large collections of human-annotated tasks.[25] In its scaling analysis, the smallest Flan-T5 model outperformed the largest T5 base model, which the authors read as evidence that better instruction data can matter more than model size.[25] The study also found that Flan-Alpaca, a T5-based model tuned on synthetic Alpaca instructions generated with GPT-3, wrote considerably better than Flan-T5 despite weaker problem-solving.[25]

Yi Tay's Flan-UL2 announcement described the main limitation of the Flan models: they were instruction-tuned mostly on academic NLP tasks whose outputs are typically short, which he summarized as "academic tasks for academic tasks."[17] The same post described the Flan series as a compact family of models that is relatively cheap to deploy and serve, and noted its unrestrictive license.[17] The paper notes that T5 is not multilingual, and Flan-T5's scores on the multilingual TyDiQA and MGSM benchmarks were far below those of the PaLM models.[1]

Continue reading

More from See also

More to read

Topics:GoogleLarge Language ModelsNatural Language ProcessingOpen Source AI

References

  1. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10 ^11 ^12 ^13 ^14 ^15 ^16 ^17 ^18 ^19 ^20 ^21 ^22 ^23 ^24 ^25 ^26 ^27 ^28 ^29 ^30 ^31 ^32 ^33 ^34 ^35 ^36 ^37 ^38 ^39 ^40 ^41Chung, Hyung Won; Hou, Le; Longpre, Shayne; Zoph, Barret; Tay, Yi; Fedus, William; et al. (35 authors). "Scaling Instruction-Finetuned Language Models". arXiv:2210.11416, 20 October 2022 (v5, 6 December 2022). arxiv.org/...2210.11416
  2. ^Chung, Hyung Won; Hou, Le; Longpre, Shayne; et al. "Scaling Instruction-Finetuned Language Models". Journal of Machine Learning Research, 25(70):1-53, 2024. jmlr.org/...23-0870
  3. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8Google Research. "Models" (T5X documentation, including "Flan-T5 Checkpoints", "T5 1.1 Checkpoints" and "T5 1.1 LM-Adapted Checkpoints"). GitHub, google-research/t5x. github.com/...models.md
  4. ^1 ^2 ^3 ^4Hugging Face. "Model Card for FLAN-T5 XXL" (google/flan-t5-xxl). Hugging Face Hub. huggingface.co/...flan-t5-xxl
  5. ^Hugging Face. Hub API listing of google/flan-t5 model repositories (creation dates). Hugging Face Hub. huggingface.co/...models
  6. ^Raffel, Colin; Shazeer, Noam; Roberts, Adam; Lee, Katherine; Narang, Sharan; Matena, Michael; Zhou, Yanqi; Li, Wei; Liu, Peter J. "Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer". arXiv:1910.10683, October 2019. arxiv.org/...1910.10683
  7. ^Wei, Jason; Bosma, Maarten; Zhao, Vincent Y.; Guu, Kelvin; Yu, Adams Wei; Lester, Brian; Du, Nan; Dai, Andrew M.; Le, Quoc V. "Finetuned Language Models Are Zero-Shot Learners". arXiv:2109.01652, September 2021. arxiv.org/...2109.01652
  8. ^1 ^2Google. "config.json", google/flan-t5-small. Hugging Face Hub. huggingface.co/...config.json
  9. ^1 ^2Google. "config.json", google/flan-t5-base. Hugging Face Hub. huggingface.co/...config.json
  10. ^1 ^2Google. "config.json", google/flan-t5-large. Hugging Face Hub. huggingface.co/...config.json
  11. ^1 ^2Google. "config.json", google/flan-t5-xl. Hugging Face Hub. huggingface.co/...config.json
  12. ^1 ^2Google. "config.json", google/flan-t5-xxl. Hugging Face Hub. huggingface.co/...config.json
  13. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10Longpre, Shayne; Hou, Le; Vu, Tu; Webson, Albert; Chung, Hyung Won; Tay, Yi; Zhou, Denny; Le, Quoc V.; Zoph, Barret; Wei, Jason; Roberts, Adam. "The Flan Collection: Designing Data and Methods for Effective Instruction Tuning". arXiv:2301.13688, 31 January 2023. arxiv.org/...2301.13688
  14. ^Longpre, Shayne; et al. "The Flan Collection: Designing Data and Methods for Effective Instruction Tuning". Proceedings of the 40th International Conference on Machine Learning, PMLR 202:22631-22648, 2023. proceedings.mlr.press/...longpre23a
  15. ^Longpre, Shayne; Roberts, Adam. "The Flan Collection: Advancing open source methods for instruction tuning". Google Research Blog, 1 February 2023. research.google/...-methods-for-instruction-tuning
  16. ^Google Research. "FLAN" repository (Apache License 2.0). GitHub. github.com/...FLAN
  17. ^1 ^2 ^3 ^4 ^5Tay, Yi. "A New Open Source Flan 20B with UL2". yitay.net, March 2023. yitay.net/...flan-ul2-20b
  18. ^1 ^2 ^3Hugging Face. "Model card for Flan-UL2" (google/flan-ul2). Hugging Face Hub. huggingface.co/...flan-ul2
  19. ^1 ^2Li, Junnan; Li, Dongxu; Savarese, Silvio; Hoi, Steven. "BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models". arXiv:2301.12597, January 2023. arxiv.org/...2301.12597
  20. ^1 ^2Dai, Wenliang; Li, Junnan; Li, Dongxu; Tiong, Anthony Meng Huat; Zhao, Junqi; Wang, Weisheng; Li, Boyang; Fung, Pascale; Hoi, Steven. "InstructBLIP: Towards General-purpose Vision-Language Models with Instruction Tuning". arXiv:2305.06500, May 2023. arxiv.org/...2305.06500
  21. ^1 ^2 ^3Ghosal, Deepanway; Majumder, Navonil; Mehrish, Ambuj; Poria, Soujanya. "Text-to-Audio Generation using Instruction-Tuned LLM and Latent Diffusion Model". arXiv:2304.13731, April 2023. arxiv.org/...2304.13731
  22. ^1 ^2 ^3Deng, Xiang; Gu, Yu; Zheng, Boyuan; Chen, Shijie; Stevens, Samuel; Wang, Boshi; Sun, Huan; Su, Yu. "Mind2Web: Towards a Generalist Agent for the Web". arXiv:2306.06070, June 2023 (NeurIPS 2023). arxiv.org/...2306.06070
  23. ^1 ^2Lin, Zhiqiu; Pathak, Deepak; Li, Baiqi; Li, Jiayao; Xia, Xide; Neubig, Graham; Zhang, Pengchuan; Ramanan, Deva. "Evaluating Text-to-Visual Generation with Image-to-Text Generation". arXiv:2404.01291, April 2024. arxiv.org/...2404.01291
  24. ^Li, Andrew; Feng, Xianle; Narang, Siddhant; Peng, Austin; Cai, Tianle; Shah, Raj Sanjay; Varma, Sashank. "Incremental Comprehension of Garden-Path Sentences by Large Language Models: Semantic Interpretation, Syntactic Re-Analysis, and Attention". arXiv:2405.16042, May 2024 (CogSci 2024). arxiv.org/...2405.16042
  25. ^1 ^2 ^3Chia, Yew Ken; Hong, Pengfei; Bing, Lidong; Poria, Soujanya. "INSTRUCTEVAL: Towards Holistic Evaluation of Instruction-Tuned Large Language Models". arXiv:2306.04757, June 2023. arxiv.org/...2306.04757

Improve this article

Add missing citations, update stale details, or write a clearer explanation. Anyone can edit: changes go live when you publish, and every edit is checked by an editor.

2 revisions · v2 · 3,229 words · full history

Fact-checks are independent of edits: a reviewer re-verifies the article against its sources and stamps the date. How we verify

Research and drafting on this wiki are AI-assisted, under named human editorial standards. How AI is used here

Reviewer note: Independent fact-check before publication on November 18, 2026: 96 claims checked against 24 cited and independent sources; 0 material and 6 minor corrections applied before publication.

Cite this page: AI Wiki. "Flan-T5." aiwiki.ai, updated 5 Dec 2026, fact-checked 18 Nov 2026. CC BY 4.0. https://aiwiki.ai/wiki/flan_t5

Edit article