younesbelkada commited on
Commit
7addbde
2 Parent(s): fed3861 29d278e

Merge branch 'main' of https://huggingface.co/ybelkada/flan_t5_large into main

Browse files
Files changed (2) hide show
  1. README.md +315 -0
  2. config.json +2 -2
README.md ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - sp
5
+ - ja
6
+ - pe
7
+ - hi
8
+ - fr
9
+ - ch
10
+ - be
11
+ - gu
12
+ - ge
13
+ - te
14
+ - it
15
+ - ar
16
+ - po
17
+ - ta
18
+ - ma
19
+ - ma
20
+ - or
21
+ - pa
22
+ - po
23
+ - ur
24
+ - ga
25
+ - he
26
+ - ko
27
+ - ca
28
+ - th
29
+ - du
30
+ - in
31
+ - vi
32
+ - bu
33
+ - fi
34
+ - ce
35
+ - la
36
+ - tu
37
+ - ru
38
+ - cr
39
+ - sw
40
+ - yo
41
+ - ku
42
+ - bu
43
+ - ma
44
+ - cz
45
+ - fi
46
+ - so
47
+ - ta
48
+ - sw
49
+ - si
50
+ - ka
51
+ - zh
52
+ - ig
53
+ - xh
54
+ - ro
55
+ - ha
56
+ - es
57
+ - sl
58
+ - li
59
+ - gr
60
+ - ne
61
+ - as
62
+ - no
63
+
64
+ tags:
65
+ - summarization
66
+ - translation
67
+ - text-generation
68
+
69
+ datasets:
70
+ - svakulenk0/qrecc
71
+ - taskmaster2
72
+ - djaym7/wiki_dialog
73
+ - deepmind/code_contests
74
+ - lambada
75
+ - gsm8k
76
+ - aqua_rat
77
+ - esnli
78
+ - quasc
79
+ - qed
80
+
81
+
82
+ license: apache-2.0
83
+ ---
84
+
85
+ # Model Card for FLAN-T5 large
86
+
87
+ ![model image](https://s3.amazonaws.com/moonup/production/uploads/1666363435475-62441d1d9fdefb55a0b7d12c.png)
88
+
89
+ # Table of Contents
90
+
91
+ 0. [TL;DR](#TL;DR)
92
+ 1. [Model Details](#model-details)
93
+ 2. [Usage](#usage)
94
+ 3. [Uses](#uses)
95
+ 4. [Bias, Risks, and Limitations](#bias-risks-and-limitations)
96
+ 5. [Training Details](#training-details)
97
+ 6. [Evaluation](#evaluation)
98
+ 7. [Environmental Impact](#environmental-impact)
99
+ 8. [Citation](#citation)
100
+ 9. [Model Card Authors](#model-card-authors)
101
+
102
+ # TL;DR
103
+
104
+ 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.
105
+ As mentioned in the first few lines of the abstract :
106
+ > 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.
107
+
108
+ **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).
109
+
110
+ # Model Details
111
+
112
+ ## Model Description
113
+
114
+
115
+ - **Model type:** Language model
116
+ - **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
117
+ - **License:** Apache 2.0
118
+ - **Related Models:** [All FLAN-T5 Checkpoints](https://huggingface.co/models?search=flan-t5)
119
+ - **Original Checkpoints:** [All Original FLAN-T5 Checkpoints](https://github.com/google-research/t5x/blob/main/docs/models.md#flan-t5-checkpoints)
120
+ - **Resources for more information:**
121
+ - [Research paper](https://arxiv.org/pdf/2210.11416.pdf)
122
+ - [GitHub Repo](https://github.com/google-research/t5x)
123
+ - [Hugging Face FLAN-T5 Docs (Similar to T5) ](https://huggingface.co/docs/transformers/model_doc/t5)
124
+
125
+ # Usage
126
+
127
+ Find below some example scripts on how to use the model in `transformers`:
128
+
129
+ ## Using the Pytorch model
130
+
131
+ ### Running the model on a CPU
132
+
133
+ <details>
134
+ <summary> Click to expand </summary>
135
+
136
+ ```python
137
+
138
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
139
+
140
+ tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
141
+ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
142
+
143
+ input_text = "translate English to German: How old are you?"
144
+ input_ids = tokenizer.encode(input_text, return_tensors="pt").input_ids
145
+
146
+ outputs = model.generate(input_ids)
147
+ print(tokenizer.decode(outputs[0]))
148
+ ```
149
+
150
+ </details>
151
+
152
+ ### Running the model on a GPU
153
+
154
+ <details>
155
+ <summary> Click to expand </summary>
156
+
157
+ ```python
158
+
159
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
160
+
161
+ tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
162
+ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto")
163
+
164
+ input_text = "translate English to German: How old are you?"
165
+ input_ids = tokenizer.encode(input_text, return_tensors="pt").input_ids.to("cuda")
166
+
167
+ outputs = model.generate(input_ids)
168
+ print(tokenizer.decode(outputs[0]))
169
+ ```
170
+
171
+ </details>
172
+
173
+ ### Running the model on a GPU using different precisions
174
+
175
+ #### FP16
176
+
177
+ <details>
178
+ <summary> Click to expand </summary>
179
+
180
+ ```python
181
+ import torch
182
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
183
+
184
+ tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
185
+ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto", torch_dtype=torch.float16)
186
+
187
+ input_text = "translate English to German: How old are you?"
188
+ input_ids = tokenizer.encode(input_text, return_tensors="pt").input_ids.to("cuda")
189
+
190
+ outputs = model.generate(input_ids)
191
+ print(tokenizer.decode(outputs[0]))
192
+ ```
193
+
194
+ </details>
195
+
196
+ #### INT8
197
+
198
+ <details>
199
+ <summary> Click to expand </summary>
200
+
201
+ ```python
202
+ # pip install bitsandbytes
203
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
204
+
205
+ tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
206
+ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto", load_in_8bit=True)
207
+
208
+ input_text = "translate English to German: How old are you?"
209
+ input_ids = tokenizer.encode(input_text, return_tensors="pt").input_ids.to("cuda")
210
+
211
+ outputs = model.generate(input_ids)
212
+ print(tokenizer.decode(outputs[0]))
213
+ ```
214
+
215
+ </details>
216
+
217
+ # Uses
218
+
219
+ ## Direct Use and Downstream Use
220
+
221
+ The authors write in [the original paper's model card](https://arxiv.org/pdf/2210.11416.pdf) that:
222
+
223
+ > 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
224
+
225
+ See the [research paper](https://arxiv.org/pdf/2210.11416.pdf) for further details.
226
+
227
+ ## Out-of-Scope Use
228
+
229
+ More information needed.
230
+
231
+ # Bias, Risks, and Limitations
232
+
233
+ The information below in this section are copied from the model's [official model card](https://arxiv.org/pdf/2210.11416.pdf):
234
+
235
+ > 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.
236
+
237
+ ## Ethical considerations and risks
238
+
239
+ > 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.
240
+
241
+ ## Known Limitations
242
+
243
+ > Flan-T5 has not been tested in real world applications.
244
+
245
+ ## Sensitive Use:
246
+
247
+ > Flan-T5 should not be applied for any unacceptable use cases, e.g., generation of abusive speech.
248
+
249
+ # Training Details
250
+
251
+ ## Training Data
252
+
253
+ The model was trained on a mixture of tasks, that includes the tasks described in the table below (from the original paper, figure 2):
254
+
255
+ ![table.png](https://s3.amazonaws.com/moonup/production/uploads/1666363265279-62441d1d9fdefb55a0b7d12c.png)
256
+
257
+
258
+ ## Training Procedure
259
+
260
+ According to the model card from the [original paper](https://arxiv.org/pdf/2210.11416.pdf):
261
+
262
+ > 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.
263
+
264
+ 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).
265
+
266
+
267
+ # Evaluation
268
+
269
+ ## Testing Data, Factors & Metrics
270
+
271
+ The authors evaluated the model on various tasks covering several languages (1836 in total). See the table below for some quantitative evaluation:
272
+ ![image.png](https://s3.amazonaws.com/moonup/production/uploads/1666361983550-62441d1d9fdefb55a0b7d12c.png)
273
+ For full details, please check the [research paper](https://arxiv.org/pdf/2210.11416.pdf).
274
+
275
+ ## Results
276
+
277
+ For full results for FLAN-T5-Large, see the [research paper](https://arxiv.org/pdf/2210.11416.pdf), Table 3.
278
+
279
+ # Environmental Impact
280
+
281
+ 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).
282
+
283
+ - **Hardware Type:** Google Cloud TPU Pods - TPU v3 or TPU v4 | Number of chips ≥ 4.
284
+ - **Hours used:** More information needed
285
+ - **Cloud Provider:** GCP
286
+ - **Compute Region:** More information needed
287
+ - **Carbon Emitted:** More information needed
288
+
289
+ # Citation
290
+
291
+ **BibTeX:**
292
+
293
+ ```bibtex
294
+ @misc{https://doi.org/10.48550/arxiv.2210.11416,
295
+ doi = {10.48550/ARXIV.2210.11416},
296
+
297
+ url = {https://arxiv.org/abs/2210.11416},
298
+
299
+ 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},
300
+
301
+ keywords = {Machine Learning (cs.LG), Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
302
+
303
+ title = {Scaling Instruction-Finetuned Language Models},
304
+
305
+ publisher = {arXiv},
306
+
307
+ year = {2022},
308
+
309
+ copyright = {Creative Commons Attribution 4.0 International}
310
+ }
311
+ ```
312
+
313
+ # Model Card Authors
314
+
315
+ This model card was written by the team at Hugging Face.
config.json CHANGED
@@ -6,10 +6,10 @@
6
  "d_kv": 64,
7
  "d_model": 1024,
8
  "decoder_start_token_id": 0,
9
- "dense_act_fn": "relu",
10
  "dropout_rate": 0.1,
11
  "eos_token_id": 1,
12
- "feed_forward_proj": "relu",
13
  "initializer_factor": 1.0,
14
  "is_encoder_decoder": true,
15
  "is_gated_act": true,
 
6
  "d_kv": 64,
7
  "d_model": 1024,
8
  "decoder_start_token_id": 0,
9
+ "dense_act_fn": "gelu",
10
  "dropout_rate": 0.1,
11
  "eos_token_id": 1,
12
+ "feed_forward_proj": "gelu",
13
  "initializer_factor": 1.0,
14
  "is_encoder_decoder": true,
15
  "is_gated_act": true,