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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: "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 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.
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
<img src="https://huggingface.co/datasets/Salesforce/dialogstudio/resolve/main/DialogStudio_Stats.jpg"
|
| 83 |
+
alt="drawing" width="700"/>
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
## Model Description
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
- **Model type:** Language model
|
| 91 |
+
- **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
|
| 92 |
+
- **License:** Apache 2.0
|
| 93 |
+
- **Related Models:** [All DialogStudio-T5 Checkpoints](https://huggingface.co/models?search=dialogstudio-t5)
|
| 94 |
+
- **Resources for more information:**
|
| 95 |
+
- [Research paper](https://arxiv.org/abs/2307.10172)
|
| 96 |
+
- [GitHub Repo](https://github.com/salesforce/DialogStudio)
|
| 97 |
+
- **Maximum model length:**:
|
| 98 |
+
- Maximum input length: 1200
|
| 99 |
+
- Maximum output length: 256
|
| 100 |
+
- **Training formats:**
|
| 101 |
+
- We process dialogue data into below input format :
|
| 102 |
+
- 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```
|
| 103 |
+
- Without instruction: ```<USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N <EXTERNAL KNOWLEDGE> your external knowledge```
|
| 104 |
+
- Without external knowledge: ```Instruction: your instruction <USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N```
|
| 105 |
+
- Without both: ```<USER> user utterance 1 <SYSTEM> system utterance 1 ... <USER> user utterance N```
|
| 106 |
+
- Note: output is final the system response; `<USER>`, `<SYSTEM>` and `<EXTERNAL KNOWLEDGE>` are special tokens
|
| 107 |
+
- For sampled FLAN data:
|
| 108 |
+
- We follow their original data format, i.e., we did not set special tokens to separate in-context learning examples.
|
| 109 |
+
- In summary:
|
| 110 |
+
- 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.
|
| 111 |
+
- 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.
|
| 112 |
+
# Usage
|
| 113 |
+
|
| 114 |
+
Find below some example scripts on how to use the model in `transformers`:
|
| 115 |
+
|
| 116 |
+
## Using the Pytorch model
|
| 117 |
+
|
| 118 |
+
### Running the model on a CPU
|
| 119 |
+
|
| 120 |
+
<details>
|
| 121 |
+
<summary> Click to expand </summary>
|
| 122 |
+
|
| 123 |
+
```python
|
| 124 |
+
|
| 125 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 126 |
+
|
| 127 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
|
| 128 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
|
| 129 |
+
|
| 130 |
+
input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
|
| 131 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
| 132 |
+
|
| 133 |
+
outputs = model.generate(input_ids, max_new_tokens=256)
|
| 134 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 135 |
+
```
|
| 136 |
+
|
| 137 |
+
</details>
|
| 138 |
+
|
| 139 |
+
### Running the model on a GPU
|
| 140 |
+
|
| 141 |
+
<details>
|
| 142 |
+
<summary> Click to expand </summary>
|
| 143 |
+
|
| 144 |
+
```python
|
| 145 |
+
# pip install accelerate
|
| 146 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 147 |
+
|
| 148 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
|
| 149 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0", device_map="auto")
|
| 150 |
+
|
| 151 |
+
input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
|
| 152 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
| 153 |
+
|
| 154 |
+
outputs = model.generate(input_ids, max_new_tokens=256)
|
| 155 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
</details>
|
| 159 |
+
|
| 160 |
+
### Running the model on a GPU using different precisions
|
| 161 |
+
|
| 162 |
+
#### FP16
|
| 163 |
+
|
| 164 |
+
<details>
|
| 165 |
+
<summary> Click to expand </summary>
|
| 166 |
+
|
| 167 |
+
```python
|
| 168 |
+
# pip install accelerate
|
| 169 |
+
import torch
|
| 170 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 171 |
+
|
| 172 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
|
| 173 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0", device_map="auto", torch_dtype=torch.float16)
|
| 174 |
+
|
| 175 |
+
input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
|
| 176 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
| 177 |
+
|
| 178 |
+
outputs = model.generate(input_ids, max_new_tokens=256)
|
| 179 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
</details>
|
| 183 |
+
|
| 184 |
+
#### INT8
|
| 185 |
+
|
| 186 |
+
<details>
|
| 187 |
+
<summary> Click to expand </summary>
|
| 188 |
+
|
| 189 |
+
```python
|
| 190 |
+
# pip install bitsandbytes accelerate
|
| 191 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 192 |
+
|
| 193 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0")
|
| 194 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/dialogstudio-t5-base-v1.0", device_map="auto", load_in_8bit=True)
|
| 195 |
+
|
| 196 |
+
input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write 200 words in a single tweet?"
|
| 197 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
| 198 |
+
|
| 199 |
+
outputs = model.generate(input_ids, max_new_tokens=256)
|
| 200 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
</details>
|
| 204 |
+
|
| 205 |
+
# Uses
|
| 206 |
+
|
| 207 |
+
## Direct Use and Downstream Use
|
| 208 |
+
|
| 209 |
+
<!-- The authors write in [the original paper's model card](https://arxiv.org/pdf/2210.11416.pdf) that: -->
|
| 210 |
+
|
| 211 |
+
> 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
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
## Out-of-Scope Use
|
| 215 |
+
|
| 216 |
+
More information needed.
|
| 217 |
+
|
| 218 |
+
# Bias, Risks, and Limitations
|
| 219 |
+
|
| 220 |
+
The information below in this section are copied and modified from Flan-T5's models card:
|
| 221 |
+
|
| 222 |
+
> 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.
|
| 223 |
+
|
| 224 |
+
## Ethical considerations and risks
|
| 225 |
+
|
| 226 |
+
> 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.
|
| 227 |
+
|
| 228 |
+
## Known Limitations
|
| 229 |
+
|
| 230 |
+
> DialogStudio-T5 has not been tested in real world applications.
|
| 231 |
+
|
| 232 |
+
## Sensitive Use:
|
| 233 |
+
|
| 234 |
+
> DialogStudio-T5 should not be applied for any unacceptable use cases, e.g., generation of abusive speech.
|
| 235 |
+
|
| 236 |
+
# Training Details
|
| 237 |
+
|
| 238 |
+
## Training Data
|
| 239 |
+
|
| 240 |
+
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).
|
| 241 |
+
|
| 242 |
+
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.
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
See above **Training formats:** for details of the training formats.
|
| 246 |
+
|
| 247 |
+
## Training Procedure
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
> 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.
|
| 251 |
+
|
| 252 |
+
The model has been trained on 16 A100 GPUs, each with 40G memory, using public [transformer](https://github.com/huggingface/transformers) codebase.
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
# Evaluation
|
| 256 |
+
|
| 257 |
+
## Testing Data, Factors & Metrics
|
| 258 |
+
|
| 259 |
+
The authors evaluated the model on several dialogue tasks and general tasks such as 0-shot/5-shot MMLU and 3-shot BBH.
|
| 260 |
+
|
| 261 |
+
## Results
|
| 262 |
+
|
| 263 |
+
For full results for DialogStudio, see the [research paper](https://arxiv.org/abs/2307.10172).
|
| 264 |
+
|
| 265 |
+
## Environmental Impact
|
| 266 |
+
More information needed.
|
| 267 |
+
|
| 268 |
+
# Citation
|
| 269 |
+
|
| 270 |
+
**BibTeX:**
|
| 271 |
+
|
| 272 |
+
```bibtex
|
| 273 |
+
@misc{zhang2023dialogstudio,
|
| 274 |
+
title={DialogStudio: Towards Richest and Most Diverse Unified Dataset Collection for Conversational AI},
|
| 275 |
+
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},
|
| 276 |
+
year={2023},
|
| 277 |
+
eprint={2307.10172},
|
| 278 |
+
archivePrefix={arXiv},
|
| 279 |
+
primaryClass={cs.CL}
|
| 280 |
+
}
|
| 281 |
+
```
|