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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
- fr
|
5 |
+
- ro
|
6 |
+
- de
|
7 |
+
- multilingual
|
8 |
+
|
9 |
+
widget:
|
10 |
+
- text: "Translate to German: My name is Arthur"
|
11 |
+
example_title: "Translation"
|
12 |
+
- text: "Please answer to the following question. Who is going to be the next Ballon d'or?"
|
13 |
+
example_title: "Question Answering"
|
14 |
+
- text: "Q: Can Geoffrey Hinton have a conversation with George Washington? Give the rationale before answering."
|
15 |
+
example_title: "Logical reasoning"
|
16 |
+
- text: "Please answer the following question. What is the boiling point of Nitrogen?"
|
17 |
+
example_title: "Scientific knowledge"
|
18 |
+
- text: "Answer the following yes/no question. Can you write a whole Haiku in a single tweet?"
|
19 |
+
example_title: "Yes/no question"
|
20 |
+
- text: "Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?"
|
21 |
+
example_title: "Reasoning task"
|
22 |
+
- text: "Q: ( False or not False or False ) is? A: Let's think step by step"
|
23 |
+
example_title: "Boolean Expressions"
|
24 |
+
- text: "The square root of x is the cube root of y. What is y to the power of 2, if x = 4?"
|
25 |
+
example_title: "Math reasoning"
|
26 |
+
- text: "Premise: At my age you will probably have learnt one lesson. Hypothesis: It's not certain how many lessons you'll learn by your thirties. Does the premise entail the hypothesis?"
|
27 |
+
example_title: "Premise and hypothesis"
|
28 |
+
|
29 |
+
tags:
|
30 |
+
- text2text-generation
|
31 |
+
|
32 |
+
datasets:
|
33 |
+
- svakulenk0/qrecc
|
34 |
+
- taskmaster2
|
35 |
+
- djaym7/wiki_dialog
|
36 |
+
- deepmind/code_contests
|
37 |
+
- lambada
|
38 |
+
- gsm8k
|
39 |
+
- aqua_rat
|
40 |
+
- esnli
|
41 |
+
- quasc
|
42 |
+
- qed
|
43 |
+
|
44 |
+
|
45 |
license: apache-2.0
|
46 |
---
|
47 |
+
|
48 |
+
# Model Card for FLAN-T5 large
|
49 |
+
|
50 |
+
![model image](https://s3.amazonaws.com/moonup/production/uploads/1666363435475-62441d1d9fdefb55a0b7d12c.png)
|
51 |
+
|
52 |
+
# Table of Contents
|
53 |
+
|
54 |
+
0. [TL;DR](#TL;DR)
|
55 |
+
1. [Model Details](#model-details)
|
56 |
+
2. [Usage](#usage)
|
57 |
+
3. [Uses](#uses)
|
58 |
+
4. [Bias, Risks, and Limitations](#bias-risks-and-limitations)
|
59 |
+
5. [Training Details](#training-details)
|
60 |
+
6. [Evaluation](#evaluation)
|
61 |
+
7. [Environmental Impact](#environmental-impact)
|
62 |
+
8. [Citation](#citation)
|
63 |
+
9. [Model Card Authors](#model-card-authors)
|
64 |
+
|
65 |
+
# TL;DR
|
66 |
+
|
67 |
+
If you already know T5, FLAN-T5 is just better at everything. For the same number of parameters, these models have been fine-tuned on more than 1000 additional tasks covering also more languages.
|
68 |
+
As mentioned in the first few lines of the abstract :
|
69 |
+
> Flan-PaLM 540B achieves state-of-the-art performance on several benchmarks, such as 75.2% on five-shot MMLU. We also publicly release Flan-T5 checkpoints,1 which achieve strong few-shot performance even compared to much larger models, such as PaLM 62B. Overall, instruction finetuning is a general method for improving the performance and usability of pretrained language models.
|
70 |
+
|
71 |
+
**Disclaimer**: Content from **this** model card has been written by the Hugging Face team, and parts of it were copy pasted from the [T5 model card](https://huggingface.co/t5-large).
|
72 |
+
|
73 |
+
# Model Details
|
74 |
+
|
75 |
+
## Model Description
|
76 |
+
|
77 |
+
|
78 |
+
- **Model type:** Language model
|
79 |
+
- **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
|
80 |
+
- **License:** Apache 2.0
|
81 |
+
- **Related Models:** [All FLAN-T5 Checkpoints](https://huggingface.co/models?search=flan-t5)
|
82 |
+
- **Original Checkpoints:** [All Original FLAN-T5 Checkpoints](https://github.com/google-research/t5x/blob/main/docs/models.md#flan-t5-checkpoints)
|
83 |
+
- **Resources for more information:**
|
84 |
+
- [Research paper](https://arxiv.org/pdf/2210.11416.pdf)
|
85 |
+
- [GitHub Repo](https://github.com/google-research/t5x)
|
86 |
+
- [Hugging Face FLAN-T5 Docs (Similar to T5) ](https://huggingface.co/docs/transformers/model_doc/t5)
|
87 |
+
|
88 |
+
# Usage
|
89 |
+
|
90 |
+
Find below some example scripts on how to use the model in `transformers`:
|
91 |
+
|
92 |
+
## Using the Pytorch model
|
93 |
+
|
94 |
+
### Running the model on a CPU
|
95 |
+
|
96 |
+
<details>
|
97 |
+
<summary> Click to expand </summary>
|
98 |
+
|
99 |
+
```python
|
100 |
+
|
101 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
102 |
+
|
103 |
+
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
|
104 |
+
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
|
105 |
+
|
106 |
+
input_text = "translate English to German: How old are you?"
|
107 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
108 |
+
|
109 |
+
outputs = model.generate(input_ids)
|
110 |
+
print(tokenizer.decode(outputs[0]))
|
111 |
+
```
|
112 |
+
|
113 |
+
</details>
|
114 |
+
|
115 |
+
### Running the model on a GPU
|
116 |
+
|
117 |
+
<details>
|
118 |
+
<summary> Click to expand </summary>
|
119 |
+
|
120 |
+
```python
|
121 |
+
# pip install accelerate
|
122 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
123 |
+
|
124 |
+
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
|
125 |
+
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto")
|
126 |
+
|
127 |
+
input_text = "translate English to German: How old are you?"
|
128 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
129 |
+
|
130 |
+
outputs = model.generate(input_ids)
|
131 |
+
print(tokenizer.decode(outputs[0]))
|
132 |
+
```
|
133 |
+
|
134 |
+
</details>
|
135 |
+
|
136 |
+
### Running the model on a GPU using different precisions
|
137 |
+
|
138 |
+
#### FP16
|
139 |
+
|
140 |
+
<details>
|
141 |
+
<summary> Click to expand </summary>
|
142 |
+
|
143 |
+
```python
|
144 |
+
# pip install accelerate
|
145 |
+
import torch
|
146 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
147 |
+
|
148 |
+
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
|
149 |
+
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto", torch_dtype=torch.float16)
|
150 |
+
|
151 |
+
input_text = "translate English to German: How old are you?"
|
152 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
153 |
+
|
154 |
+
outputs = model.generate(input_ids)
|
155 |
+
print(tokenizer.decode(outputs[0]))
|
156 |
+
```
|
157 |
+
|
158 |
+
</details>
|
159 |
+
|
160 |
+
#### INT8
|
161 |
+
|
162 |
+
<details>
|
163 |
+
<summary> Click to expand </summary>
|
164 |
+
|
165 |
+
```python
|
166 |
+
# pip install bitsandbytes accelerate
|
167 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
168 |
+
|
169 |
+
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
|
170 |
+
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto", load_in_8bit=True)
|
171 |
+
|
172 |
+
input_text = "translate English to German: How old are you?"
|
173 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
174 |
+
|
175 |
+
outputs = model.generate(input_ids)
|
176 |
+
print(tokenizer.decode(outputs[0]))
|
177 |
+
```
|
178 |
+
|
179 |
+
</details>
|
180 |
+
|
181 |
+
# Uses
|
182 |
+
|
183 |
+
## Direct Use and Downstream Use
|
184 |
+
|
185 |
+
The authors write in [the original paper's model card](https://arxiv.org/pdf/2210.11416.pdf) that:
|
186 |
+
|
187 |
+
> 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
|
188 |
+
|
189 |
+
See the [research paper](https://arxiv.org/pdf/2210.11416.pdf) for further details.
|
190 |
+
|
191 |
+
## Out-of-Scope Use
|
192 |
+
|
193 |
+
More information needed.
|
194 |
+
|
195 |
+
# Bias, Risks, and Limitations
|
196 |
+
|
197 |
+
The information below in this section are copied from the model's [official model card](https://arxiv.org/pdf/2210.11416.pdf):
|
198 |
+
|
199 |
+
> 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.
|
200 |
+
|
201 |
+
## Ethical considerations and risks
|
202 |
+
|
203 |
+
> 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.
|
204 |
+
|
205 |
+
## Known Limitations
|
206 |
+
|
207 |
+
> Flan-T5 has not been tested in real world applications.
|
208 |
+
|
209 |
+
## Sensitive Use:
|
210 |
+
|
211 |
+
> Flan-T5 should not be applied for any unacceptable use cases, e.g., generation of abusive speech.
|
212 |
+
|
213 |
+
# Training Details
|
214 |
+
|
215 |
+
## Training Data
|
216 |
+
|
217 |
+
The model was trained on a mixture of tasks, that includes the tasks described in the table below (from the original paper, figure 2):
|
218 |
+
|
219 |
+
![table.png](https://s3.amazonaws.com/moonup/production/uploads/1666363265279-62441d1d9fdefb55a0b7d12c.png)
|
220 |
+
|
221 |
+
|
222 |
+
## Training Procedure
|
223 |
+
|
224 |
+
According to the model card from the [original paper](https://arxiv.org/pdf/2210.11416.pdf):
|
225 |
+
|
226 |
+
> 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.
|
227 |
+
|
228 |
+
The model has been trained on TPU v3 or TPU v4 pods, using [`t5x`](https://github.com/google-research/t5x) codebase together with [`jax`](https://github.com/google/jax).
|
229 |
+
|
230 |
+
|
231 |
+
# Evaluation
|
232 |
+
|
233 |
+
## Testing Data, Factors & Metrics
|
234 |
+
|
235 |
+
The authors evaluated the model on various tasks covering several languages (1836 in total). See the table below for some quantitative evaluation:
|
236 |
+
![image.png](https://s3.amazonaws.com/moonup/production/uploads/1668072995230-62441d1d9fdefb55a0b7d12c.png)
|
237 |
+
For full details, please check the [research paper](https://arxiv.org/pdf/2210.11416.pdf).
|
238 |
+
|
239 |
+
## Results
|
240 |
+
|
241 |
+
For full results for FLAN-T5-Large, see the [research paper](https://arxiv.org/pdf/2210.11416.pdf), Table 3.
|
242 |
+
|
243 |
+
# Environmental Impact
|
244 |
+
|
245 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
246 |
+
|
247 |
+
- **Hardware Type:** Google Cloud TPU Pods - TPU v3 or TPU v4 | Number of chips ≥ 4.
|
248 |
+
- **Hours used:** More information needed
|
249 |
+
- **Cloud Provider:** GCP
|
250 |
+
- **Compute Region:** More information needed
|
251 |
+
- **Carbon Emitted:** More information needed
|
252 |
+
|
253 |
+
# Citation
|
254 |
+
|
255 |
+
**BibTeX:**
|
256 |
+
|
257 |
+
```bibtex
|
258 |
+
@misc{https://doi.org/10.48550/arxiv.2210.11416,
|
259 |
+
doi = {10.48550/ARXIV.2210.11416},
|
260 |
+
|
261 |
+
url = {https://arxiv.org/abs/2210.11416},
|
262 |
+
|
263 |
+
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},
|
264 |
+
|
265 |
+
keywords = {Machine Learning (cs.LG), Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
266 |
+
|
267 |
+
title = {Scaling Instruction-Finetuned Language Models},
|
268 |
+
|
269 |
+
publisher = {arXiv},
|
270 |
+
|
271 |
+
year = {2022},
|
272 |
+
|
273 |
+
copyright = {Creative Commons Attribution 4.0 International}
|
274 |
+
}
|
275 |
+
```
|