Text2Text Generation
Transformers
dialog
Inference Endpoints
jncraton commited on
Commit
3165445
1 Parent(s): 7d01938

Upload 6 files

Browse files
README.md ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - fr
5
+ - ro
6
+ - de
7
+ - multilingual
8
+
9
+ widget:
10
+ - text: "Continue the dialogue as a task-oriented dialogue system called SYSTEM. The answer of SYSTEM should follow the ACTION provided next while answering the USER's last utterance: \n<USER> Hello, I am looking for a restaurant in Cambridge. I believe it is called Golden Wok. \n<EXTERNAL KNOWLEDGE> ACTION: {'Restaurant-Inform': [['address', '191 Histon Road Chesterton']]}"
11
+ example_title: "Dialog Act to Response Generation"
12
+ - text: "Translate to German: My name is Arthur"
13
+ example_title: "Translation"
14
+ - text: "Please answer to the following question. Who is going to be the next Ballon d'or?"
15
+ example_title: "Question Answering"
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 200 words 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 200 words in a single tweet?"
21
+ example_title: "Reasoning task"
22
+ - text: "Q: Is the statement ( `Jianguo is a research scientist at Salesforce AI` and `Jianguo is a student at UIC` ) True or Flase? 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
+ inference:
30
+ parameters:
31
+ max_length: 256
32
+
33
+ tags:
34
+ - text2text-generation
35
+ - dialog
36
+
37
+ datasets:
38
+ - Salesforce/dialogstudio
39
+ - flan
40
+
41
+
42
+ license: apache-2.0
43
+ ---
44
+
45
+ # Model Card for DialogStudio-T5 base
46
+
47
+ <img src="https://huggingface.co/datasets/Salesforce/dialogstudio/resolve/main/logo.png"
48
+ alt="drawing" width="510"/>
49
+
50
+ # Table of Contents
51
+
52
+ 0. [TL;DR](#TL;DR)
53
+ 1. [Model Details](#model-details)
54
+ 2. [Usage](#usage)
55
+ 3. [Uses](#uses)
56
+ 4. [Bias, Risks, and Limitations](#bias-risks-and-limitations)
57
+ 5. [Training Details](#training-details)
58
+ 6. [Evaluation](#evaluation)
59
+ 7. [Environmental Impact](#environmental-impact)
60
+ 8. [Citation](#citation)
61
+ 9. [Model Card Authors](#model-card-authors)
62
+
63
+ # TL;DR
64
+
65
+ If you already know T5 and Flan-T5, DialogStudio-T5 is better at many things. With the same number of parameters, the models are fine-tuned from a selected amount of dialogues from [DialogStudio](https://github.com/salesforce/DialogStudio) and also 1000 additional tasks.
66
+
67
+
68
+ **Disclaimer**: Content from **this** model card are modified from contents written by the Hugging Face team, and parts of it were copy pasted from the [T5 model card](https://huggingface.co/t5-large) and [Flan-T5 model card](https://huggingface.co/google/flan-t5-large).
69
+
70
+
71
+ **Follow the [DialogStudio](https://github.com/salesforce/DialogStudio) GitHub repository for latest information.**
72
+
73
+
74
+ # Model Details
75
+ ## Data
76
+
77
+ We sample a small amount of dialogues from each commercial supported dataset under three categories of [DialogStudio](https://huggingface.co/datasets/Salesforce/dialogstudio), i.e., KG-Dial, TOD and Open-Domain dialogues. Additionally, we sample at most 150 examples for each non-translation task from [FLAN](https://github.com/google-research/FLAN/tree/main/flan/v2).
78
+
79
+ **Note** that this model version 1.0 does not incorporate datasets utilized for training large-scale models (>=7B) like Alpaca, ShareGPT, GPT4ALL, UltraChat from OpenAI's 'GPT-3.5/4', or other datasets such as OASST1 and WizardCoder.
80
+
81
+ <img src="https://huggingface.co/datasets/Salesforce/dialogstudio/resolve/main/DialogStudio_Stats.jpg"
82
+ alt="drawing" width="700"/>
83
+
84
+
85
+
86
+ ## Model Description
87
+
88
+
89
+ - **Model type:** Language model
90
+ - **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
91
+ - **License:** Apache 2.0
92
+ - **Related Models:** [All DialogStudio-T5 Checkpoints](https://huggingface.co/models?search=dialogstudio-t5)
93
+ - **Resources for more information:**
94
+ - [Research paper](https://arxiv.org/abs/2307.10172)
95
+ - [GitHub Repo](https://github.com/salesforce/DialogStudio)
96
+ - **Maximum model length:**:
97
+ - Maximum input length: 1200
98
+ - Maximum output length: 256
99
+ - **Training formats:**
100
+ - We process dialogue data into below input format :
101
+ - With instruction and external knowledge: ```Instruction: your instruction <USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N <EXTERNAL KNOWLEDGE> your external knowledge```
102
+ - Without instruction: ```<USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N <EXTERNAL KNOWLEDGE> your external knowledge```
103
+ - Without external knowledge: ```Instruction: your instruction <USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N```
104
+ - Without both: ```<USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N```
105
+ - Note: output is final the system response; `<USER>`, `<SYSTEM>` and `<EXTERNAL KNOWLEDGE>` are special tokens
106
+ - For sampled FLAN data:
107
+ - We follow their original data format, i.e., we did not set special tokens to separate in-context learning examples.
108
+ - In summary:
109
+ - We recommend you use our format and add our special tokens (such as `<USER>` and `<SYSTEM>` ) to get better performance. However, you may not necessary need to exactly follow our format if you do not observe random behavios.
110
+ - We found that T5 model series such as Flan-t5 and DialogStudio-T5 may generate repetitive tokens during inference. If you find such repetition issues, you can set the `repetition_penalty` in model.generate(), such as 1.5, to mitigate them. Note that `repetition_penalty=1.0` by default.
111
+ # Usage
112
+
113
+ Find below some example scripts on how to use the model in `transformers`:
114
+
115
+ ## Using the Pytorch model
116
+
117
+ ### Running the model on a CPU
118
+
119
+ <details>
120
+ <summary> Click to expand </summary>
121
+
122
+ ```python
123
+
124
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
125
+
126
+ tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
127
+ model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
128
+
129
+ input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
130
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids
131
+
132
+ outputs = model.generate(input_ids, max_new_tokens=256)
133
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
134
+ ```
135
+
136
+ </details>
137
+
138
+ ### Running the model on a GPU
139
+
140
+ <details>
141
+ <summary> Click to expand </summary>
142
+
143
+ ```python
144
+ # pip install accelerate
145
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
146
+
147
+ tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
148
+ model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0", device_map="auto")
149
+
150
+ input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
151
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
152
+
153
+ outputs = model.generate(input_ids, max_new_tokens=256)
154
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
155
+ ```
156
+
157
+ </details>
158
+
159
+ ### Running the model on a GPU using different precisions
160
+
161
+ #### FP16
162
+
163
+ <details>
164
+ <summary> Click to expand </summary>
165
+
166
+ ```python
167
+ # pip install accelerate
168
+ import torch
169
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
170
+
171
+ tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
172
+ model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0", device_map="auto", torch_dtype=torch.float16)
173
+
174
+ input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
175
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
176
+
177
+ outputs = model.generate(input_ids, max_new_tokens=256)
178
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
179
+ ```
180
+
181
+ </details>
182
+
183
+ #### INT8
184
+
185
+ <details>
186
+ <summary> Click to expand </summary>
187
+
188
+ ```python
189
+ # pip install bitsandbytes accelerate
190
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
191
+
192
+ tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
193
+ model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0", device_map="auto", load_in_8bit=True)
194
+
195
+ input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
196
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
197
+
198
+ outputs = model.generate(input_ids, max_new_tokens=256)
199
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
200
+ ```
201
+
202
+ </details>
203
+
204
+ # Uses
205
+
206
+ ## Direct Use and Downstream Use
207
+
208
+ <!-- The authors write in [the original paper's model card](https://arxiv.org/pdf/2210.11416.pdf) that: -->
209
+
210
+ > 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 dialogue response generation, reasoning, and question answering; advancing fairness and safety research, and understanding limitations of current large language models
211
+
212
+
213
+ ## Out-of-Scope Use
214
+
215
+ More information needed.
216
+
217
+ # Bias, Risks, and Limitations
218
+
219
+ The information below in this section are copied and modified from Flan-T5's models card:
220
+
221
+ > Language models, including DialogStudio-T5, can potentially be used for language generation in a harmful way, according to Rae et al. (2021). DialogStudio-T5 should not be used directly in any application, without a prior assessment of safety and fairness concerns specific to the application.
222
+
223
+ ## Ethical considerations and risks
224
+
225
+ > DialogStudio-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.
226
+
227
+ ## Known Limitations
228
+
229
+ > DialogStudio-T5 has not been tested in real world applications.
230
+
231
+ ## Sensitive Use:
232
+
233
+ > DialogStudio-T5 should not be applied for any unacceptable use cases, e.g., generation of abusive speech.
234
+
235
+ # Training Details
236
+
237
+ ## Training Data
238
+
239
+ We sample a small amount of dialogues from each commercial supported dataset under three categories of [DialogStudio](https://huggingface.co/datasets/Salesforce/dialogstudio), i.e., KG-Dial, TOD and Open-Domain dialogues. Additionally, we sample at most 150 examples for each non-translation task from [FLAN](https://github.com/google-research/FLAN/tree/main/flan/v2).
240
+
241
+
242
+ **Note:**
243
+
244
+ Model Version 1.0 is built on small-scale pre-trained models, this version does not incorporate datasets utilized for training large-scale models (>=7B) like Alpaca, ShareGPT, GPT4ALL, UltraChat from OpenAI's 'GPT-3.5/4', or other datasets such as OASST1 and WizardCoder. As a result, it has certain limitations in terms of writing and creative capabilities. Our initial focus is to update the model versions to enhance existing abilities. Further improvements, including expansion of other capabilities, are part of our roadmap and will be responsive to community requests.
245
+
246
+
247
+ See above **Training formats:** for details of the training formats.
248
+
249
+ ## Training Procedure
250
+
251
+
252
+ > These models are based on Flan-T5 and are fine-tuned with instructions for better zero-shot and few-shot performance. There is one fine-tuned DialogStudio model per T5 model size.
253
+
254
+ The model has been trained on 16 A100 GPUs, each with 40G memory, using public [transformer](https://github.com/huggingface/transformers) codebase.
255
+
256
+
257
+ # Evaluation
258
+
259
+ ## Testing Data, Factors & Metrics
260
+
261
+ The authors evaluated the model on several dialogue tasks and general tasks such as 0-shot/5-shot MMLU and 3-shot BBH.
262
+
263
+ ## Results
264
+
265
+ For full results for DialogStudio, see the [research paper](https://arxiv.org/abs/2307.10172).
266
+
267
+ ## Environmental Impact
268
+ More information needed.
269
+
270
+ # Citation
271
+
272
+ **BibTeX:**
273
+
274
+ ```bibtex
275
+ @misc{zhang2023dialogstudio,
276
+ title={DialogStudio: Towards Richest and Most Diverse Unified Dataset Collection for Conversational AI},
277
+ author={Jianguo Zhang and Kun Qian and Zhiwei Liu and Shelby Heinecke and Rui Meng and Ye Liu and Zhou Yu and and Huan Wang and Silvio Savarese and Caiming Xiong},
278
+ year={2023},
279
+ eprint={2307.10172},
280
+ archivePrefix={arXiv},
281
+ primaryClass={cs.CL}
282
+ }
283
+ ```
config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_source_bos": false,
3
+ "add_source_eos": false,
4
+ "bos_token": "<pad>",
5
+ "decoder_start_token": "<pad>",
6
+ "eos_token": "</s>",
7
+ "layer_norm_epsilon": null,
8
+ "unk_token": "<unk>"
9
+ }
shared_vocabulary.json ADDED
The diff for this file is too large to render. See raw diff
 
special_tokens_map.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<USER>",
4
+ "<SYSTEM>",
5
+ "<EXTERNAL KNOWLEDGE>"
6
+ ],
7
+ "eos_token": "</s>",
8
+ "pad_token": "<pad>",
9
+ "unk_token": "<unk>"
10
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<extra_id_0>",
4
+ "<extra_id_1>",
5
+ "<extra_id_2>",
6
+ "<extra_id_3>",
7
+ "<extra_id_4>",
8
+ "<extra_id_5>",
9
+ "<extra_id_6>",
10
+ "<extra_id_7>",
11
+ "<extra_id_8>",
12
+ "<extra_id_9>",
13
+ "<extra_id_10>",
14
+ "<extra_id_11>",
15
+ "<extra_id_12>",
16
+ "<extra_id_13>",
17
+ "<extra_id_14>",
18
+ "<extra_id_15>",
19
+ "<extra_id_16>",
20
+ "<extra_id_17>",
21
+ "<extra_id_18>",
22
+ "<extra_id_19>",
23
+ "<extra_id_20>",
24
+ "<extra_id_21>",
25
+ "<extra_id_22>",
26
+ "<extra_id_23>",
27
+ "<extra_id_24>",
28
+ "<extra_id_25>",
29
+ "<extra_id_26>",
30
+ "<extra_id_27>",
31
+ "<extra_id_28>",
32
+ "<extra_id_29>",
33
+ "<extra_id_30>",
34
+ "<extra_id_31>",
35
+ "<extra_id_32>",
36
+ "<extra_id_33>",
37
+ "<extra_id_34>",
38
+ "<extra_id_35>",
39
+ "<extra_id_36>",
40
+ "<extra_id_37>",
41
+ "<extra_id_38>",
42
+ "<extra_id_39>",
43
+ "<extra_id_40>",
44
+ "<extra_id_41>",
45
+ "<extra_id_42>",
46
+ "<extra_id_43>",
47
+ "<extra_id_44>",
48
+ "<extra_id_45>",
49
+ "<extra_id_46>",
50
+ "<extra_id_47>",
51
+ "<extra_id_48>",
52
+ "<extra_id_49>",
53
+ "<extra_id_50>",
54
+ "<extra_id_51>",
55
+ "<extra_id_52>",
56
+ "<extra_id_53>",
57
+ "<extra_id_54>",
58
+ "<extra_id_55>",
59
+ "<extra_id_56>",
60
+ "<extra_id_57>",
61
+ "<extra_id_58>",
62
+ "<extra_id_59>",
63
+ "<extra_id_60>",
64
+ "<extra_id_61>",
65
+ "<extra_id_62>",
66
+ "<extra_id_63>",
67
+ "<extra_id_64>",
68
+ "<extra_id_65>",
69
+ "<extra_id_66>",
70
+ "<extra_id_67>",
71
+ "<extra_id_68>",
72
+ "<extra_id_69>",
73
+ "<extra_id_70>",
74
+ "<extra_id_71>",
75
+ "<extra_id_72>",
76
+ "<extra_id_73>",
77
+ "<extra_id_74>",
78
+ "<extra_id_75>",
79
+ "<extra_id_76>",
80
+ "<extra_id_77>",
81
+ "<extra_id_78>",
82
+ "<extra_id_79>",
83
+ "<extra_id_80>",
84
+ "<extra_id_81>",
85
+ "<extra_id_82>",
86
+ "<extra_id_83>",
87
+ "<extra_id_84>",
88
+ "<extra_id_85>",
89
+ "<extra_id_86>",
90
+ "<extra_id_87>",
91
+ "<extra_id_88>",
92
+ "<extra_id_89>",
93
+ "<extra_id_90>",
94
+ "<extra_id_91>",
95
+ "<extra_id_92>",
96
+ "<extra_id_93>",
97
+ "<extra_id_94>",
98
+ "<extra_id_95>",
99
+ "<extra_id_96>",
100
+ "<extra_id_97>",
101
+ "<extra_id_98>",
102
+ "<extra_id_99>"
103
+ ],
104
+ "clean_up_tokenization_spaces": true,
105
+ "eos_token": "</s>",
106
+ "extra_ids": 100,
107
+ "model_max_length": 512,
108
+ "pad_token": "<pad>",
109
+ "sp_model_kwargs": {},
110
+ "tokenizer_class": "T5Tokenizer",
111
+ "unk_token": "<unk>"
112
+ }