AlexWortega commited on
Commit
805f015
1 Parent(s): 65d742c

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +258 -0
README.md ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - ru
5
+ - multilingual
6
+
7
+ tags:
8
+ - text2text-generation
9
+
10
+ widget:
11
+ - text: "Translate to German: My name is Arthur"
12
+ example_title: "Translation"
13
+ - text: "Please answer to the following question. Who is going to be the next Ballon d'or?"
14
+ example_title: "Question Answering"
15
+ - text: "Q: Can Geoffrey Hinton have a conversation with George Washington? Give the rationale before answering."
16
+ example_title: "Logical reasoning"
17
+ - text: "Please answer the following question. What is the boiling point of Nitrogen?"
18
+ example_title: "Scientific knowledge"
19
+ - text: "Answer the following yes/no question. Can you write a whole Haiku in a single tweet?"
20
+ example_title: "Yes/no question"
21
+ - text: "Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?"
22
+ example_title: "Reasoning task"
23
+ - text: "Q: ( False or not False or False ) is? A: Let's think step by step"
24
+ example_title: "Boolean Expressions"
25
+ - text: "The square root of x is the cube root of y. What is y to the power of 2, if x = 4?"
26
+ example_title: "Math reasoning"
27
+ - 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?"
28
+ example_title: "Premise and hypothesis"
29
+
30
+ datasets:
31
+ - svakulenk0/qrecc
32
+ - taskmaster2
33
+ - djaym7/wiki_dialog
34
+ - deepmind/code_contests
35
+ - lambada
36
+ - gsm8k
37
+ - aqua_rat
38
+ - esnli
39
+ - quasc
40
+ - qed
41
+
42
+
43
+ license: apache-2.0
44
+ ---
45
+
46
+ # Model Card for FLAN-T5 base
47
+
48
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/flan2_architecture.jpg"
49
+ alt="drawing" width="600"/>
50
+
51
+ # Table of Contents
52
+
53
+ 0. [TL;DR](#TL;DR)
54
+ 1. [Model Details](#model-details)
55
+ 2. [Usage](#usage)
56
+ 3. [Uses](#uses)
57
+ 4. [Bias, Risks, and Limitations](#bias-risks-and-limitations)
58
+ 5. [Training Details](#training-details)
59
+ 6. [Evaluation](#evaluation)
60
+ 7. [Environmental Impact](#environmental-impact)
61
+ 8. [Citation](#citation)
62
+ 9. [Model Card Authors](#model-card-authors)
63
+
64
+ # TL;DR
65
+
66
+ 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.
67
+ As mentioned in the first few lines of the abstract :
68
+ > 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.
69
+
70
+ **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).
71
+
72
+ # Model Details
73
+
74
+ ## Model Description
75
+
76
+
77
+ - **Model type:** Language model
78
+ - **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
79
+ - **License:** Apache 2.0
80
+ - **Related Models:** [All FLAN-T5 Checkpoints](https://huggingface.co/models?search=flan-t5)
81
+ - **Original Checkpoints:** [All Original FLAN-T5 Checkpoints](https://github.com/google-research/t5x/blob/main/docs/models.md#flan-t5-checkpoints)
82
+ - **Resources for more information:**
83
+ - [Research paper](https://arxiv.org/pdf/2210.11416.pdf)
84
+ - [GitHub Repo](https://github.com/google-research/t5x)
85
+ - [Hugging Face FLAN-T5 Docs (Similar to T5) ](https://huggingface.co/docs/transformers/model_doc/t5)
86
+
87
+ # Usage
88
+
89
+ Find below some example scripts on how to use the model in `transformers`:
90
+
91
+ ## Using the Pytorch model
92
+
93
+ ### Running the model on a CPU
94
+
95
+ <details>
96
+ <summary> Click to expand </summary>
97
+
98
+ ```python
99
+
100
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
101
+
102
+ tokenizer = T5Tokenizer.from_pretrained("AlexWortega/Flan_base_translated")
103
+ model = T5ForConditionalGeneration.from_pretrained("AlexWortega/Flan_base_translated")
104
+
105
+ input_text = "translate English to German: How old are you?"
106
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids
107
+
108
+ outputs = model.generate(input_ids)
109
+ print(tokenizer.decode(outputs[0]))
110
+ ```
111
+
112
+ </details>
113
+
114
+ ### Running the model on a GPU
115
+
116
+ <details>
117
+ <summary> Click to expand </summary>
118
+
119
+ ```python
120
+ # pip install accelerate
121
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
122
+
123
+ tokenizer = T5Tokenizer.from_pretrained("AlexWortega/Flan_base_translated")
124
+ model = T5ForConditionalGeneration.from_pretrained("AlexWortega/Flan_base_translated", device_map="auto")
125
+
126
+ input_text = "translate English to German: How old are you?"
127
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
128
+
129
+ outputs = model.generate(input_ids)
130
+ print(tokenizer.decode(outputs[0]))
131
+ ```
132
+
133
+ </details>
134
+
135
+ ### Running the model on a GPU using different precisions
136
+
137
+ #### FP16
138
+
139
+ <details>
140
+ <summary> Click to expand </summary>
141
+
142
+ ```python
143
+ # pip install accelerate
144
+ import torch
145
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
146
+
147
+ tokenizer = T5Tokenizer.from_pretrained("AlexWortega/Flan_base_translated")
148
+ model = T5ForConditionalGeneration.from_pretrained("AlexWortega/Flan_base_translated", device_map="auto", torch_dtype=torch.float16)
149
+
150
+ input_text = "translate English to German: How old are you?"
151
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
152
+
153
+ outputs = model.generate(input_ids)
154
+ print(tokenizer.decode(outputs[0]))
155
+ ```
156
+
157
+ </details>
158
+
159
+ #### INT8
160
+
161
+ <details>
162
+ <summary> Click to expand </summary>
163
+
164
+ ```python
165
+ # pip install bitsandbytes accelerate
166
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
167
+
168
+ tokenizer = T5Tokenizer.from_pretrained("AlexWortega/Flan_base_translated")
169
+ model = T5ForConditionalGeneration.from_pretrained("AlexWortega/Flan_base_translated", device_map="auto", load_in_8bit=True)
170
+
171
+ input_text = "translate English to German: How old are you?"
172
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
173
+
174
+ outputs = model.generate(input_ids)
175
+ print(tokenizer.decode(outputs[0]))
176
+ ```
177
+
178
+ </details>
179
+
180
+ # Uses
181
+
182
+ ## Direct Use and Downstream Use
183
+
184
+ The authors write in [the original paper's model card](https://arxiv.org/pdf/2210.11416.pdf) that:
185
+
186
+ > 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
187
+
188
+ See the [research paper](https://arxiv.org/pdf/2210.11416.pdf) for further details.
189
+
190
+ ## Out-of-Scope Use
191
+
192
+ More information needed.
193
+
194
+ # Bias, Risks, and Limitations
195
+
196
+ The information below in this section are copied from the model's [official model card](https://arxiv.org/pdf/2210.11416.pdf):
197
+
198
+ > 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.
199
+
200
+ ## Ethical considerations and risks
201
+
202
+ > 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.
203
+
204
+ ## Known Limitations
205
+
206
+ > Flan-T5 has not been tested in real world applications.
207
+
208
+ ## Sensitive Use:
209
+
210
+ > Flan-T5 should not be applied for any unacceptable use cases, e.g., generation of abusive speech.
211
+
212
+ # Training Details
213
+
214
+ ## Training Data
215
+
216
+ ## Training Procedure
217
+
218
+
219
+ # Evaluation
220
+
221
+ ## Testing Data, Factors & Metrics
222
+
223
+
224
+
225
+ **BibTeX:**
226
+
227
+ ```bibtex
228
+ @misc{https://doi.org/10.48550/arxiv.2210.11416,
229
+ doi = {10.48550/ARXIV.2210.11416},
230
+
231
+ url = {https://arxiv.org/abs/2210.11416},
232
+
233
+ 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},
234
+
235
+ keywords = {Machine Learning (cs.LG), Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
236
+
237
+ title = {Scaling Instruction-Finetuned Language Models},
238
+
239
+ publisher = {arXiv},
240
+
241
+ year = {2022},
242
+
243
+ copyright = {Creative Commons Attribution 4.0 International}
244
+ }
245
+ ```
246
+ ## Model Recycling
247
+
248
+ [Evaluation on 36 datasets](https://ibm.github.io/model-recycling/model_gain_chart?avg=9.16&mnli_lp=nan&20_newsgroup=3.34&ag_news=1.49&amazon_reviews_multi=0.21&anli=13.91&boolq=16.75&cb=23.12&cola=9.97&copa=34.50&dbpedia=6.90&esnli=5.37&financial_phrasebank=18.66&imdb=0.33&isear=1.37&mnli=11.74&mrpc=16.63&multirc=6.24&poem_sentiment=14.62&qnli=3.41&qqp=6.18&rotten_tomatoes=2.98&rte=24.26&sst2=0.67&sst_5bins=5.44&stsb=20.68&trec_coarse=3.95&trec_fine=10.73&tweet_ev_emoji=13.39&tweet_ev_emotion=4.62&tweet_ev_hate=3.46&tweet_ev_irony=9.04&tweet_ev_offensive=1.69&tweet_ev_sentiment=0.75&wic=14.22&wnli=9.44&wsc=5.53&yahoo_answers=4.14&model_name=google%2Fflan-t5-base&base_name=google%2Ft5-v1_1-base) using AlexWortega/Flan_base_translated as a base model yields average score of 77.98 in comparison to 68.82 by google/t5-v1_1-base.
249
+
250
+ The model is ranked 1st among all tested models for the google/t5-v1_1-base architecture as of 06/02/2023
251
+ Results:
252
+
253
+ | 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 |
254
+ |---------------:|----------:|-----------------------:|--------:|--------:|--------:|--------:|-------:|----------:|--------:|-----------------------:|-------:|--------:|--------:|--------:|----------:|-----------------:|--------:|--------:|------------------:|--------:|--------:|------------:|--------:|--------------:|------------:|-----------------:|-------------------:|----------------:|-----------------:|---------------------:|---------------------:|--------:|-------:|--------:|----------------:|
255
+ | 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.6923 | 92.7878 | 89.7724 | 89.0244 | 84.8375 | 94.3807 | 57.2851 | 89.4759 | 97.2 | 92.8 | 46.848 | 80.2252 | 54.9832 | 76.6582 | 84.3023 | 70.6366 | 70.0627 | 56.338 | 53.8462 | 73.4 |
256
+
257
+
258
+ For more information, see: [Model Recycling](https://ibm.github.io/model-recycling/)