kartikmosaicml
commited on
Commit
•
5a1cae6
1
Parent(s):
9a14fb7
Create README.md with model card.
Browse files
README.md
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: cc-by-sa-3.0
|
3 |
+
datasets:
|
4 |
+
- competition_math
|
5 |
+
- conceptofmind/cot_submix_original/cot_gsm8k
|
6 |
+
- knkarthick/dialogsum
|
7 |
+
- mosaicml/dolly_hhrlhf
|
8 |
+
- duorc
|
9 |
+
- tau/scrolls/qasper
|
10 |
+
- emozilla/quality
|
11 |
+
- scrolls/summ_screen_fd
|
12 |
+
- spider
|
13 |
+
tags:
|
14 |
+
- Composer
|
15 |
+
- MosaicML
|
16 |
+
- llm-foundry
|
17 |
+
inference: false
|
18 |
+
---
|
19 |
+
|
20 |
+
# MPT-30B-Instruct
|
21 |
+
|
22 |
+
MPT-30B-Instruct is a model for short-form instruction following.
|
23 |
+
It is built by finetuning [MPT-30B](https://huggingface.co/mosaicml/mpt-30b) on [Dolly HHRLHF](https://huggingface.co/datasets/mosaicml/dolly_hhrlhf) derived from the [Databricks Dolly-15k](https://huggingface.co/datasets/databricks/databricks-dolly-15k) and the [Anthropic Helpful and Harmless (HH-RLHF)](https://huggingface.co/datasets/Anthropic/hh-rlhf) datasets. It is also trained on [Competition Math](https://huggingface.co/datasets/competition_math), [Duorc](https://huggingface.co/datasets/duorc), [CoT GSM8k](https://huggingface.co/datasets/conceptofmind/cot_submix_original), [Qasper](https://huggingface.co/datasets/allenai/qasper), [Quality](https://huggingface.co/datasets/emozilla/quality), [Summ Screen FD](https://huggingface.co/datasets/tau/scrolls) and [Spider](https://huggingface.co/datasets/spider).
|
24 |
+
* License: _CC-By-SA-3.0_
|
25 |
+
* [Demo on Hugging Face Spaces](https://huggingface.co/spaces/mosaicml/mpt-30b-instruct)
|
26 |
+
|
27 |
+
|
28 |
+
This model was trained by [MosaicML](https://www.mosaicml.com) and follows a modified decoder-only transformer architecture.
|
29 |
+
|
30 |
+
## Model Date
|
31 |
+
|
32 |
+
June 22, 2023
|
33 |
+
|
34 |
+
## Model License
|
35 |
+
|
36 |
+
CC-By-SA-3.0
|
37 |
+
|
38 |
+
## Documentation
|
39 |
+
|
40 |
+
* [Blog post: Introducing MPT-30B: Raising the bar for open-source commercial foundation models](https://www.mosaicml.com/blog/mpt-30b)
|
41 |
+
* [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
|
42 |
+
* Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
|
43 |
+
|
44 |
+
### Example Question/Instruction
|
45 |
+
|
46 |
+
**Bespokenizer**:
|
47 |
+
> What is a quoll?
|
48 |
+
|
49 |
+
**MPT-30B-Instruct**:
|
50 |
+
TBD (update these)
|
51 |
+
>A Quoll (pronounced “cool”) is one of Australia’s native carnivorous marsupial mammals, which are also known as macropods or wallabies in other parts around Asia and South America
|
52 |
+
|
53 |
+
## How to Use
|
54 |
+
|
55 |
+
Note: This model requires that `trust_remote_code=True` be passed to the `from_pretrained` method. This is because we use a custom model architecture that is not yet part of the `transformers` package.
|
56 |
+
|
57 |
+
It includes options for many training efficiency features such as [FlashAttention (Dao et al. 2022)](https://arxiv.org/pdf/2205.14135.pdf), [ALiBi](https://arxiv.org/abs/2108.12409), QK LayerNorm, and more.
|
58 |
+
|
59 |
+
```python
|
60 |
+
import transformers
|
61 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(
|
62 |
+
'mosaicml/mpt-30b-instruct',
|
63 |
+
trust_remote_code=True
|
64 |
+
)
|
65 |
+
```
|
66 |
+
|
67 |
+
To use the optimized [triton implementation](https://github.com/openai/triton) of FlashAttention, you can load the model on GPU (`cuda:0`) with `attn_impl='triton'` and with `bfloat16` precision:
|
68 |
+
```python
|
69 |
+
import torch
|
70 |
+
import transformers
|
71 |
+
|
72 |
+
name = 'mosaicml/mpt-30b-instruct'
|
73 |
+
|
74 |
+
config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
|
75 |
+
config.attn_config['attn_impl'] = 'torch' # change this to use triton
|
76 |
+
config.init_device = 'cpu' # For fast initialization directly on GPU! (if you have enough memory)
|
77 |
+
|
78 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(
|
79 |
+
name,
|
80 |
+
config=config,
|
81 |
+
torch_dtype=torch.bfloat16, # Load model weights in bfloat16
|
82 |
+
trust_remote_code=True
|
83 |
+
)
|
84 |
+
```
|
85 |
+
|
86 |
+
The model was trained first on 2048, and then an additional pre-training phase was included for sequence length adaptation to 8192. However, ALiBi further enables users to increase the maximum sequence length during finetuning and/or inference. For example:
|
87 |
+
|
88 |
+
```python
|
89 |
+
import transformers
|
90 |
+
|
91 |
+
name = 'mosaicml/mpt-30b-instruct'
|
92 |
+
|
93 |
+
config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
|
94 |
+
config.max_seq_len = 16384 # (input + output) tokens can now be up to 16384
|
95 |
+
|
96 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(
|
97 |
+
name,
|
98 |
+
config=config,
|
99 |
+
trust_remote_code=True
|
100 |
+
)
|
101 |
+
```
|
102 |
+
|
103 |
+
This model was trained with the MPT-30B tokenizer which is based on the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer and includes additional padding and eos tokens.
|
104 |
+
|
105 |
+
```python
|
106 |
+
from transformers import AutoTokenizer
|
107 |
+
tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-30b')
|
108 |
+
```
|
109 |
+
|
110 |
+
The model can then be used, for example, within a text-generation pipeline.
|
111 |
+
Note: when running Torch modules in lower precision, it is best practice to use the [torch.autocast context manager](https://pytorch.org/docs/stable/amp.html).
|
112 |
+
|
113 |
+
```python
|
114 |
+
from transformers import pipeline
|
115 |
+
|
116 |
+
with torch.autocast('cuda', dtype=torch.bfloat16):
|
117 |
+
inputs = tokenizer('Here is a recipe for vegan banana bread:\n', return_tensors="pt").to('cuda')
|
118 |
+
outputs = model.generate(**inputs, max_new_tokens=100)
|
119 |
+
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
|
120 |
+
|
121 |
+
# or using the HF pipeline
|
122 |
+
pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
|
123 |
+
with torch.autocast('cuda', dtype=torch.bfloat16):
|
124 |
+
print(
|
125 |
+
pipe('Here is a recipe for vegan banana bread:\n',
|
126 |
+
max_new_tokens=100,
|
127 |
+
do_sample=True,
|
128 |
+
use_cache=True))
|
129 |
+
```
|
130 |
+
|
131 |
+
### Formatting
|
132 |
+
|
133 |
+
This model was trained on data formatted as follows:
|
134 |
+
|
135 |
+
```python
|
136 |
+
def format_prompt(instruction):
|
137 |
+
template = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n###Instruction\n{instruction}\n\n### Response\n"
|
138 |
+
return template.format(instruction=instruction)
|
139 |
+
)
|
140 |
+
|
141 |
+
example = "Tell me a funny joke.\nDon't make it too funny though."
|
142 |
+
fmt_ex = format_prompt(instruction=example)
|
143 |
+
```
|
144 |
+
|
145 |
+
In the above example, `fmt_ex` is ready to be tokenized and sent through the model.
|
146 |
+
|
147 |
+
## Model Description
|
148 |
+
|
149 |
+
The architecture is a modification of a standard decoder-only transformer.
|
150 |
+
|
151 |
+
The model has been modified from a standard transformer in the following ways:
|
152 |
+
* It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
|
153 |
+
* It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
|
154 |
+
* It does not use biases
|
155 |
+
|
156 |
+
|
157 |
+
| Hyperparameter | Value |
|
158 |
+
|----------------|-------|
|
159 |
+
|n_parameters | 29.95B |
|
160 |
+
|n_layers | 48 |
|
161 |
+
| n_heads | 64 |
|
162 |
+
| d_model | 7168 |
|
163 |
+
| vocab size | 50432 |
|
164 |
+
| sequence length | 8192 |
|
165 |
+
|
166 |
+
## PreTraining Data
|
167 |
+
|
168 |
+
For more details on the pretraining process, see [MPT-30B](https://huggingface.co/mosaicml/mpt-30b).
|
169 |
+
|
170 |
+
The data was tokenized using the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer.
|
171 |
+
|
172 |
+
### Training Configuration
|
173 |
+
|
174 |
+
TODO: this needs to be changed
|
175 |
+
This model was trained using the [MosaicML Platform](https://www.mosaicml.com/platform).
|
176 |
+
The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the AdamW optimizer.
|
177 |
+
|
178 |
+
## Limitations and Biases
|
179 |
+
|
180 |
+
_The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
|
181 |
+
|
182 |
+
MPT-30B-Instruct can produce factually incorrect output, and should not be relied on to produce factually accurate information.
|
183 |
+
MPT-30B-Instruct was trained on various public datasets.
|
184 |
+
While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
|
185 |
+
|
186 |
+
|
187 |
+
## Acknowledgements
|
188 |
+
|
189 |
+
This model was finetuned by Sam Havens and the MosaicML NLP team
|
190 |
+
|
191 |
+
## MosaicML Platform
|
192 |
+
|
193 |
+
If you're interested in [training](https://www.mosaicml.com/training) and [deploying](https://www.mosaicml.com/inference) your own MPT or LLMs on the MosaicML Platform, [sign up here](https://forms.mosaicml.com/demo?utm_source=huggingface&utm_medium=referral&utm_campaign=mpt-30b).
|
194 |
+
|
195 |
+
## Disclaimer
|
196 |
+
|
197 |
+
The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please cosult an attorney before using this model for commercial purposes.
|
198 |
+
|
199 |
+
## Citation
|
200 |
+
|
201 |
+
Please cite this model using the following format:
|
202 |
+
|
203 |
+
```
|
204 |
+
@online{MosaicML2023Introducing,
|
205 |
+
author = {MosaicML NLP Team},
|
206 |
+
title = {Introducing MPT-30B: Raising the bar for open-source commercial foundation models},
|
207 |
+
year = {2023},
|
208 |
+
url = {www.mosaicml.com/blog/mpt-30b},
|
209 |
+
note = {Accessed: 2023-06-22},
|
210 |
+
urldate = {2023-06-22}
|
211 |
+
}
|
212 |
+
```
|