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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: "Q: Can Geoffrey Hinton have a conversation with George Washington? Give the rationale before answering."
|
17 |
+
example_title: "Logical reasoning"
|
18 |
+
- text: "Please answer the following question. What is the boiling point of Nitrogen?"
|
19 |
+
example_title: "Scientific knowledge"
|
20 |
+
- text: "Answer the following yes/no question. Can you write 200 words in a single tweet?"
|
21 |
+
example_title: "Yes/no question"
|
22 |
+
- text: "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
|
23 |
+
example_title: "Reasoning task"
|
24 |
+
- 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"
|
25 |
+
example_title: "Boolean Expressions"
|
26 |
+
- text: "The square root of x is the cube root of y. What is y to the power of 2, if x = 4?"
|
27 |
+
example_title: "Math reasoning"
|
28 |
+
- 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?"
|
29 |
+
example_title: "Premise and hypothesis"
|
30 |
+
|
31 |
+
inference:
|
32 |
+
parameters:
|
33 |
+
max_length: 256
|
34 |
+
|
35 |
+
tags:
|
36 |
+
- text2text-generation
|
37 |
+
- dialog
|
38 |
+
|
39 |
+
datasets:
|
40 |
+
- Salesforce/dialogstudio
|
41 |
+
- flan
|
42 |
+
|
43 |
+
|
44 |
+
license: apache-2.0
|
45 |
+
---
|
46 |
+
|
47 |
+
# Model Card for DialogStudio-T5 large
|
48 |
+
|
49 |
+
<img src="https://huggingface.co/datasets/Salesforce/dialogstudio/resolve/main/logo.png"
|
50 |
+
alt="drawing" width="510"/>
|
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 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.
|
68 |
+
|
69 |
+
|
70 |
+
**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).
|
71 |
+
|
72 |
+
|
73 |
+
**Follow the [DialogStudio](https://github.com/salesforce/DialogStudio) GitHub repository for latest information.**
|
74 |
+
|
75 |
+
|
76 |
+
# Model Details
|
77 |
+
## Data
|
78 |
+
|
79 |
+
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).
|
80 |
+
|
81 |
+
Note that 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.
|
82 |
+
|
83 |
+
|
84 |
+
<img src="https://huggingface.co/datasets/Salesforce/dialogstudio/resolve/main/DialogStudio_Stats.jpg"
|
85 |
+
alt="drawing" width="700"/>
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
## Model Description
|
90 |
+
|
91 |
+
|
92 |
+
- **Model type:** Language model
|
93 |
+
- **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
|
94 |
+
- **License:** Apache 2.0
|
95 |
+
- **Related Models:** [All DialogStudio-T5 Checkpoints](https://huggingface.co/models?search=dialogstudio-t5)
|
96 |
+
- **Resources for more information:**
|
97 |
+
- [Research paper](https://arxiv.org/abs/2307.10172)
|
98 |
+
- [GitHub Repo](https://github.com/salesforce/DialogStudio)
|
99 |
+
- **Maximum model length:**:
|
100 |
+
- Maximum input length: 1200
|
101 |
+
- Maximum output length: 256
|
102 |
+
- **Training formats:**
|
103 |
+
- We process dialogue data into below input format :
|
104 |
+
- 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```
|
105 |
+
- Without instruction: ```<USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N <EXTERNAL KNOWLEDGE> your external knowledge```
|
106 |
+
- Without external knowledge: ```Instruction: your instruction <USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N```
|
107 |
+
- Without both: ```<USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N```
|
108 |
+
- Note: output is final the system response; `<USER>`, `<SYSTEM>` and `<EXTERNAL KNOWLEDGE>` are special tokens
|
109 |
+
- For sampled FLAN data:
|
110 |
+
- We follow their original data format, i.e., we did not set special tokens to separate in-context learning examples.
|
111 |
+
- In summary:
|
112 |
+
- 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 observe random behavios.
|
113 |
+
- 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.
|
114 |
+
# Usage
|
115 |
+
|
116 |
+
Find below some example scripts on how to use the model in `transformers`:
|
117 |
+
|
118 |
+
## Using the Pytorch model
|
119 |
+
|
120 |
+
### Running the model on a CPU
|
121 |
+
|
122 |
+
<details>
|
123 |
+
<summary> Click to expand </summary>
|
124 |
+
|
125 |
+
```python
|
126 |
+
|
127 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
128 |
+
|
129 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-large-v1.0")
|
130 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-large-v1.0")
|
131 |
+
|
132 |
+
input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
|
133 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
134 |
+
|
135 |
+
outputs = model.generate(input_ids, max_new_tokens=256)
|
136 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
137 |
+
```
|
138 |
+
|
139 |
+
</details>
|
140 |
+
|
141 |
+
### Running the model on a GPU
|
142 |
+
|
143 |
+
<details>
|
144 |
+
<summary> Click to expand </summary>
|
145 |
+
|
146 |
+
```python
|
147 |
+
# pip install accelerate
|
148 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
149 |
+
|
150 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-large-v1.0")
|
151 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-large-v1.0", device_map="auto")
|
152 |
+
|
153 |
+
input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
|
154 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
155 |
+
|
156 |
+
outputs = model.generate(input_ids, max_new_tokens=256)
|
157 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
158 |
+
```
|
159 |
+
|
160 |
+
</details>
|
161 |
+
|
162 |
+
### Running the model on a GPU using different precisions
|
163 |
+
|
164 |
+
#### FP16
|
165 |
+
|
166 |
+
<details>
|
167 |
+
<summary> Click to expand </summary>
|
168 |
+
|
169 |
+
```python
|
170 |
+
# pip install accelerate
|
171 |
+
import torch
|
172 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
173 |
+
|
174 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-large-v1.0")
|
175 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-large-v1.0", device_map="auto", torch_dtype=torch.float16)
|
176 |
+
|
177 |
+
input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
|
178 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
179 |
+
|
180 |
+
outputs = model.generate(input_ids, max_new_tokens=256)
|
181 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
182 |
+
```
|
183 |
+
|
184 |
+
</details>
|
185 |
+
|
186 |
+
#### INT8
|
187 |
+
|
188 |
+
<details>
|
189 |
+
<summary> Click to expand </summary>
|
190 |
+
|
191 |
+
```python
|
192 |
+
# pip install bitsandbytes accelerate
|
193 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
194 |
+
|
195 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-large-v1.0")
|
196 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-large-v1.0", device_map="auto", load_in_8bit=True)
|
197 |
+
|
198 |
+
input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
|
199 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
200 |
+
|
201 |
+
outputs = model.generate(input_ids, max_new_tokens=256)
|
202 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
203 |
+
```
|
204 |
+
|
205 |
+
</details>
|
206 |
+
|
207 |
+
# Uses
|
208 |
+
|
209 |
+
## Direct Use and Downstream Use
|
210 |
+
|
211 |
+
<!-- The authors write in [the original paper's model card](https://arxiv.org/pdf/2210.11416.pdf) that: -->
|
212 |
+
|
213 |
+
> 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
|
214 |
+
|
215 |
+
|
216 |
+
## Out-of-Scope Use
|
217 |
+
|
218 |
+
More information needed.
|
219 |
+
|
220 |
+
# Bias, Risks, and Limitations
|
221 |
+
|
222 |
+
The information below in this section are copied and modified from Flan-T5's models card:
|
223 |
+
|
224 |
+
> 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.
|
225 |
+
|
226 |
+
## Ethical considerations and risks
|
227 |
+
|
228 |
+
> 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.
|
229 |
+
|
230 |
+
## Known Limitations
|
231 |
+
|
232 |
+
> DialogStudio-T5 has not been tested in real world applications.
|
233 |
+
|
234 |
+
## Sensitive Use:
|
235 |
+
|
236 |
+
> DialogStudio-T5 should not be applied for any unacceptable use cases, e.g., generation of abusive speech.
|
237 |
+
|
238 |
+
# Training Details
|
239 |
+
|
240 |
+
## Training Data
|
241 |
+
|
242 |
+
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).
|
243 |
+
|
244 |
+
Note that 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.
|
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 |
+
```
|