mohamedemam commited on
Commit
64482dc
1 Parent(s): 21226b5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +230 -1
README.md CHANGED
@@ -11,4 +11,233 @@ tags:
11
  - generate text
12
  - nlp
13
  - dataset maker
14
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  - generate text
12
  - nlp
13
  - dataset maker
14
+ ---
15
+ # Model Card for FLAN-T5 large
16
+
17
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/flan2_architecture.jpg"
18
+ alt="drawing" width="600"/>
19
+
20
+ # Table of Contents
21
+
22
+ 0. [TL;DR](#TL;DR)
23
+ 1. [Model Details](#model-details)
24
+ 2. [Usage](#usage)
25
+ 3. [Uses](#uses)
26
+ 4. [Bias, Risks, and Limitations](#bias-risks-and-limitations)
27
+ 5. [Training Details](#training-details)
28
+ 6. [Evaluation](#evaluation)
29
+ 7. [Environmental Impact](#environmental-impact)
30
+ 8. [Citation](#citation)
31
+ 9. [Model Card Authors](#model-card-authors)
32
+
33
+ # TL;DR
34
+
35
+ 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.
36
+ As mentioned in the first few lines of the abstract :
37
+ > 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.
38
+
39
+ **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).
40
+
41
+ # Model Details
42
+
43
+ ## Model Description
44
+
45
+
46
+ - **Model type:** Language model
47
+ - **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
48
+ - **License:** Apache 2.0
49
+ - **Related Models:** [All FLAN-T5 Checkpoints](https://huggingface.co/models?search=flan-t5)
50
+ - **Original Checkpoints:** [All Original FLAN-T5 Checkpoints](https://github.com/google-research/t5x/blob/main/docs/models.md#flan-t5-checkpoints)
51
+ - **Resources for more information:**
52
+ - [Research paper](https://arxiv.org/pdf/2210.11416.pdf)
53
+ - [GitHub Repo](https://github.com/google-research/t5x)
54
+ - [Hugging Face FLAN-T5 Docs (Similar to T5) ](https://huggingface.co/docs/transformers/model_doc/t5)
55
+
56
+ # Usage
57
+
58
+ Find below some example scripts on how to use the model in `transformers`:
59
+
60
+ ## Using the Pytorch model
61
+
62
+ ### Running the model on a CPU
63
+
64
+ <details>
65
+ <summary> Click to expand </summary>
66
+
67
+ ```python
68
+
69
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
70
+
71
+ tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
72
+ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
73
+
74
+ input_text = "translate English to German: How old are you?"
75
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids
76
+
77
+ outputs = model.generate(input_ids)
78
+ print(tokenizer.decode(outputs[0]))
79
+ ```
80
+
81
+ </details>
82
+
83
+ ### Running the model on a GPU
84
+
85
+ <details>
86
+ <summary> Click to expand </summary>
87
+
88
+ ```python
89
+ # pip install accelerate
90
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
91
+
92
+ tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
93
+ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto")
94
+
95
+ input_text = "translate English to German: How old are you?"
96
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
97
+
98
+ outputs = model.generate(input_ids)
99
+ print(tokenizer.decode(outputs[0]))
100
+ ```
101
+
102
+ </details>
103
+
104
+ ### Running the model on a GPU using different precisions
105
+
106
+ #### FP16
107
+
108
+ <details>
109
+ <summary> Click to expand </summary>
110
+
111
+ ```python
112
+ # pip install accelerate
113
+ import torch
114
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
115
+
116
+ tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
117
+ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto", torch_dtype=torch.float16)
118
+
119
+ input_text = "translate English to German: How old are you?"
120
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
121
+
122
+ outputs = model.generate(input_ids)
123
+ print(tokenizer.decode(outputs[0]))
124
+ ```
125
+
126
+ </details>
127
+
128
+ #### INT8
129
+
130
+ <details>
131
+ <summary> Click to expand </summary>
132
+
133
+ ```python
134
+ # pip install bitsandbytes accelerate
135
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
136
+
137
+ tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
138
+ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto", load_in_8bit=True)
139
+
140
+ input_text = "translate English to German: How old are you?"
141
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
142
+
143
+ outputs = model.generate(input_ids)
144
+ print(tokenizer.decode(outputs[0]))
145
+ ```
146
+
147
+ </details>
148
+
149
+ # Uses
150
+
151
+ ## Direct Use and Downstream Use
152
+
153
+ The authors write in [the original paper's model card](https://arxiv.org/pdf/2210.11416.pdf) that:
154
+
155
+ > 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
156
+
157
+ See the [research paper](https://arxiv.org/pdf/2210.11416.pdf) for further details.
158
+
159
+ ## Out-of-Scope Use
160
+
161
+ More information needed.
162
+
163
+ # Bias, Risks, and Limitations
164
+
165
+ The information below in this section are copied from the model's [official model card](https://arxiv.org/pdf/2210.11416.pdf):
166
+
167
+ > 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.
168
+
169
+ ## Ethical considerations and risks
170
+
171
+ > 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.
172
+
173
+ ## Known Limitations
174
+
175
+ > Flan-T5 has not been tested in real world applications.
176
+
177
+ ## Sensitive Use:
178
+
179
+ > Flan-T5 should not be applied for any unacceptable use cases, e.g., generation of abusive speech.
180
+
181
+ # Training Details
182
+
183
+ ## Training Data
184
+
185
+ The model was trained on a mixture of tasks, that includes the tasks described in the table below (from the original paper, figure 2):
186
+
187
+ ![table.png](https://s3.amazonaws.com/moonup/production/uploads/1666363265279-62441d1d9fdefb55a0b7d12c.png)
188
+
189
+
190
+ ## Training Procedure
191
+
192
+ According to the model card from the [original paper](https://arxiv.org/pdf/2210.11416.pdf):
193
+
194
+ > 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.
195
+
196
+ 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).
197
+
198
+
199
+ # Evaluation
200
+
201
+ ## Testing Data, Factors & Metrics
202
+
203
+ The authors evaluated the model on various tasks covering several languages (1836 in total). See the table below for some quantitative evaluation:
204
+ ![image.png](https://s3.amazonaws.com/moonup/production/uploads/1668072995230-62441d1d9fdefb55a0b7d12c.png)
205
+ For full details, please check the [research paper](https://arxiv.org/pdf/2210.11416.pdf).
206
+
207
+ ## Results
208
+
209
+ For full results for FLAN-T5-Large, see the [research paper](https://arxiv.org/pdf/2210.11416.pdf), Table 3.
210
+
211
+ # Environmental Impact
212
+
213
+ 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).
214
+
215
+ - **Hardware Type:** Google Cloud TPU Pods - TPU v3 or TPU v4 | Number of chips ≥ 4.
216
+ - **Hours used:** More information needed
217
+ - **Cloud Provider:** GCP
218
+ - **Compute Region:** More information needed
219
+ - **Carbon Emitted:** More information needed
220
+
221
+ # Citation
222
+
223
+ **BibTeX:**
224
+
225
+ ```bibtex
226
+ @misc{https://doi.org/10.48550/arxiv.2210.11416,
227
+ doi = {10.48550/ARXIV.2210.11416},
228
+
229
+ url = {https://arxiv.org/abs/2210.11416},
230
+
231
+ 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},
232
+
233
+ keywords = {Machine Learning (cs.LG), Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
234
+
235
+ title = {Scaling Instruction-Finetuned Language Models},
236
+
237
+ publisher = {arXiv},
238
+
239
+ year = {2022},
240
+
241
+ copyright = {Creative Commons Attribution 4.0 International}
242
+ }
243
+ ```