Model Overview
Model Features
Model Capabilities
Use Cases
đ FLAN-T5 base Model Card
This is a model card for FLAN-T5 base. It's a language model that has been fine - tuned on a wide range of tasks and multiple languages, offering better zero - shot and few - shot performance compared to its base counterparts.
đ Quick Start
You can start using the FLAN - T5 base model in the transformers
library with the following steps. Here are some example scripts to get you going.
đģ Usage Examples
Basic Usage
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-base")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base")
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
Advanced Usage
There are different ways to run the model on a GPU with various precisions.
FP16
# pip install accelerate
import torch
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-base")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base", device_map="auto", torch_dtype=torch.float16)
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
INT8
# pip install bitsandbytes accelerate
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-base")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base", device_map="auto", load_in_8bit=True)
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
⨠Features
- Multilingual Support: Supports a wide range of languages including English, Spanish, Japanese, Persian, and many others.
- Fine - Tuned for Tasks: Fine - tuned on over 1000 additional tasks, covering areas like zero - shot NLP tasks, in - context few - shot learning NLP tasks such as reasoning and question answering.
đĻ Installation
No specific installation steps are provided in the original document. However, you need to have the transformers
library installed. You can install it using pip install transformers
.
đ Documentation
Model Details
Model Description
Property | Details |
---|---|
Model Type | Language model |
Language(s) (NLP) | English, Spanish, Japanese, Persian, Hindi, French, Chinese, Bengali, Gujarati, German, Telugu, Italian, Arabic, Polish, Tamil, Marathi, Malayalam, Oriya, Panjabi, Portuguese, Urdu, Galician, Hebrew, Korean, Catalan, Thai, Dutch, Indonesian, Vietnamese, Bulgarian, Filipino, Central Khmer, Lao, Turkish, Russian, Croatian, Swedish, Yoruba, Kurdish, Burmese, Malay, Czech, Finnish, Somali, Tagalog, Swahili, Sinhala, Kannada, Zhuang, Igbo, Xhosa, Romanian, Haitian, Estonian, Slovak, Lithuanian, Greek, Nepali, Assamese, Norwegian |
License | Apache 2.0 |
Related Models | [All FLAN - T5 Checkpoints](https://huggingface.co/models?search=flan - t5) |
Original Checkpoints | [All Original FLAN - T5 Checkpoints](https://github.com/google - research/t5x/blob/main/docs/models.md#flan - t5 - checkpoints) |
Resources for more information | Research paper, [GitHub Repo](https://github.com/google - research/t5x), Hugging Face FLAN - T5 Docs (Similar to T5) |
Uses
Direct Use and Downstream Use
The primary use is research on language models, including research on zero - shot NLP tasks and in - context few - shot learning NLP tasks, such as reasoning and question answering; advancing fairness and safety research, and understanding limitations of current large language models. See the research paper for further details.
Out - of - Scope Use
More information needed.
Bias, Risks, and Limitations
â ī¸ Important Note
Language models, including Flan - T5, can potentially be used for language generation in a harmful way, according to Rae et al. (2021). Flan - T5 should not be used directly in any application, without a prior assessment of safety and fairness concerns specific to the application.
đĄ Usage Tip
Flan - T5 is fine - tuned on a large corpus of text data that was not filtered for explicit content or assessed for existing biases. As a result, the model itself is potentially vulnerable to generating equivalently inappropriate content or replicating inherent biases in the underlying data.
- Known Limitations: Flan - T5 has not been tested in real - world applications.
- Sensitive Use: Flan - T5 should not be applied for any unacceptable use cases, e.g., generation of abusive speech.
Training Details
Training Data
The model was trained on a mixture of tasks, that includes the tasks described in the table below (from the original paper, figure 2):

Training Procedure
These models are based on pretrained T5 (Raffel et al., 2020) and fine - tuned with instructions for better zero - shot and few - shot performance. There is one fine - tuned Flan model per T5 model size. The model has been trained on TPU v3 or TPU v4 pods, using the [t5x
](https://github.com/google - research/t5x) codebase together with jax
.
Evaluation
Testing Data, Factors & Metrics
The authors evaluated the model on various tasks covering several languages (1836 in total). See the table below for some quantitative evaluation:  For full details, please check the research paper.
Results
For full results for FLAN - T5 - Base, see the research paper, Table 3.
Environmental Impact
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
- Hardware Type: Google Cloud TPU Pods - TPU v3 or TPU v4 | Number of chips âĨ 4.
- Hours used: More information needed
- Cloud Provider: GCP
- Compute Region: More information needed
- Carbon Emitted: More information needed
Citation
@misc{https://doi.org/10.48550/arxiv.2210.11416,
doi = {10.48550/ARXIV.2210.11416},
url = {https://arxiv.org/abs/2210.11416},
author = {Chung, Hyung Won and Hou, Le and Longpre, Shayne and Zoph, Barret and Tay, Yi and Fedus, William and Li, Eric and Wang, Xuezhi and Dehghani, Mostafa and Brahma, Siddhartha and Webson, Albert and Gu, Shixiang Shane and Dai, Zhuyun and Suzgun, Mirac and Chen, Xinyun and Chowdhery, Aakanksha and Narang, Sharan and Mishra, Gaurav and Yu, Adams and Zhao, Vincent and Huang, Yanping and Dai, Andrew and Yu, Hongkun and Petrov, Slav and Chi, Ed H. and Dean, Jeff and Devlin, Jacob and Roberts, Adam and Zhou, Denny and Le, Quoc V. and Wei, Jason},
keywords = {Machine Learning (cs.LG), Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Scaling Instruction-Finetuned Language Models},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}
Model Recycling
Evaluation on 36 datasets using google/flan - t5 - base as a base model yields an average score of 77.98 in comparison to 68.82 by google/t5 - v1_1 - base.
The model is ranked 1st among all tested models for the google/t5 - v1_1 - base architecture as of 06/02/2023. Results:
20_newsgroup | ag_news | amazon_reviews_multi | anli | boolq | cb | cola | copa | dbpedia | esnli | financial_phrasebank | imdb | isear | mnli | mrpc | multirc | poem_sentiment | qnli | qqp | rotten_tomatoes | rte | sst2 | sst_5bins | stsb | trec_coarse | trec_fine | tweet_ev_emoji | tweet_ev_emotion | tweet_ev_hate | tweet_ev_irony | tweet_ev_offensive | tweet_ev_sentiment | wic | wnli | wsc | yahoo_answers |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
86.2188 | 89.6667 | 67.12 | 51.9688 | 82.3242 | 78.5714 | 80.1534 | 75 | 77.6667 | 90.9507 | 85.4 | 93.324 | 72.425 | 87.2457 | 89.4608 | 62.3762 | 82.692 | 81.9231 | 79.2617 | 94.1538 | 82.8571 | 95.2381 | 74.4444 | 92.8571 | 84.6154 | 87.5 | 88.4615 | 82.7273 | 80 | 83.3333 | 80 | 81.8182 | 85.7143 | 80 | 76 | 80 |
đ License
This model is licensed under the Apache 2.0 license.

