Danivilanova commited on
Commit
3544572
1 Parent(s): e2f4085

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +235 -0
README.md ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
26
+
27
+ This model was trained by [MosaicML](https://www.mosaicml.com) and follows a modified decoder-only transformer architecture.
28
+
29
+ ## Model Date
30
+
31
+ June 22, 2023
32
+
33
+ ## Model License
34
+
35
+ CC-By-SA-3.0
36
+
37
+ ## Documentation
38
+
39
+ * [Blog post: Raising the bar for open-source foundation models](https://www.mosaicml.com/blog/mpt-30b)
40
+ * [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
41
+ * Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
42
+
43
+ ### Example Question/Instruction
44
+
45
+ **Bespokenizer46**
46
+ > I need to convince my friend, Phyllis, that she should train a custom LLM for her Fortune 500 company using the MosaicML Platform.
47
+ > Please write an email that explains why MosaicML's emphasis on cutting edge methodology, data privacy, and efficiency are so important.
48
+ > End the email with a friendly inquiry about Phyllis's family.
49
+
50
+ **MPT-30B-Instruct**:
51
+ > Phyllis -
52
+ > I know you're always looking for ways to improve efficiency at work and I think I've found a solution that you'll be very interested in.
53
+ > LLMs are only as good as the data they're trained on and the training process can be very time consuming and resource intensive. MosaicML uses cutting edge methodology to efficiently train high quality models without compromising data privacy.
54
+ > They also provide tools to easily connect to and use the model in your daily workflow.
55
+ > I think you'd really enjoy speaking with their founder, we can set up a call if you're interested.
56
+ > Also, I know it's been a tough year for your family, how are things?
57
+
58
+ > Best,
59
+ > Your Friend
60
+
61
+ ## How to Use
62
+
63
+ 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.
64
+
65
+ 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.
66
+
67
+ ```python
68
+ import transformers
69
+ model = transformers.AutoModelForCausalLM.from_pretrained(
70
+ 'mosaicml/mpt-30b-instruct',
71
+ trust_remote_code=True
72
+ )
73
+ ```
74
+
75
+ 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:
76
+ ```python
77
+ import torch
78
+ import transformers
79
+
80
+ name = 'mosaicml/mpt-30b-instruct'
81
+
82
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
83
+ config.attn_config['attn_impl'] = 'triton' # change this to use triton-based FlashAttention
84
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
85
+
86
+ model = transformers.AutoModelForCausalLM.from_pretrained(
87
+ name,
88
+ config=config,
89
+ torch_dtype=torch.bfloat16, # Load model weights in bfloat16
90
+ trust_remote_code=True
91
+ )
92
+ ```
93
+
94
+ The model was trained initially on a sequence length of 2048. 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:
95
+
96
+ ```python
97
+ import transformers
98
+
99
+ name = 'mosaicml/mpt-30b-instruct'
100
+
101
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
102
+ config.max_seq_len = 16384 # (input + output) tokens can now be up to 16384
103
+
104
+ model = transformers.AutoModelForCausalLM.from_pretrained(
105
+ name,
106
+ config=config,
107
+ trust_remote_code=True
108
+ )
109
+ ```
110
+
111
+ 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.
112
+
113
+ ```python
114
+ from transformers import AutoTokenizer
115
+ tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-30b')
116
+ ```
117
+
118
+ The model can then be used, for example, within a text-generation pipeline.
119
+ 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).
120
+
121
+ ```python
122
+ from transformers import pipeline
123
+
124
+ with torch.autocast('cuda', dtype=torch.bfloat16):
125
+ inputs = tokenizer('Here is a recipe for vegan banana bread:\n', return_tensors="pt").to('cuda')
126
+ outputs = model.generate(**inputs, max_new_tokens=100)
127
+ print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
128
+
129
+ # or using the HF pipeline
130
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
131
+ with torch.autocast('cuda', dtype=torch.bfloat16):
132
+ print(
133
+ pipe('Here is a recipe for vegan banana bread:\n',
134
+ max_new_tokens=100,
135
+ do_sample=True,
136
+ use_cache=True))
137
+ ```
138
+
139
+ ### Formatting
140
+
141
+ This model was trained on data formatted as follows:
142
+
143
+ ```python
144
+ def format_prompt(instruction):
145
+ 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"
146
+ return template.format(instruction=instruction)
147
+
148
+ example = "Tell me a funny joke.\nDon't make it too funny though."
149
+ fmt_ex = format_prompt(instruction=example)
150
+ ```
151
+
152
+ In the above example, `fmt_ex` is ready to be tokenized and sent through the model.
153
+
154
+ ## Model Description
155
+
156
+ The architecture is a modification of a standard decoder-only transformer.
157
+
158
+ The model has been modified from a standard transformer in the following ways:
159
+ * It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
160
+ * It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
161
+ * It does not use biases
162
+
163
+
164
+ | Hyperparameter | Value |
165
+ |----------------|-------|
166
+ |n_parameters | 29.95B |
167
+ |n_layers | 48 |
168
+ | n_heads | 64 |
169
+ | d_model | 7168 |
170
+ | vocab size | 50432 |
171
+ | sequence length | 8192 |
172
+
173
+ ## Data Mix
174
+
175
+ The model was trained on the following data mix:
176
+
177
+ | Data Source | Number of Tokens in Source | Proportion |
178
+ |-------------|----------------------------|------------|
179
+ | competition_math | 1.6 M | 3.66% |
180
+ | cot_gsm8k | 3.36 M | 7.67% |
181
+ | dialogsum | 0.1 M | 0.23% |
182
+ | dolly_hhrlhf | 5.89 M | 13.43% |
183
+ | duorc | 7.8 M | 17.80% |
184
+ | qasper | 8.72 M | 19.90% |
185
+ | quality | 11.29 M | 25.78% |
186
+ | scrolls/summ_screen_fd | 4.97 M | 11.33% |
187
+ | spider | 0.089 M | 0.20% |
188
+
189
+ ## PreTraining Data
190
+
191
+ For more details on the pretraining process, see [MPT-30B](https://huggingface.co/mosaicml/mpt-30b).
192
+
193
+ The data was tokenized using the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer.
194
+
195
+ ### Training Configuration
196
+
197
+ This model was trained on 72 A100 40GB GPUs for 8 hours using the [MosaicML Platform](https://www.mosaicml.com/platform).
198
+ The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the AdamW optimizer.
199
+
200
+ ## Limitations and Biases
201
+
202
+ _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
203
+
204
+ MPT-30B-Instruct can produce factually incorrect output, and should not be relied on to produce factually accurate information.
205
+ MPT-30B-Instruct was trained on various public datasets.
206
+ 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.
207
+
208
+
209
+ ## Acknowledgements
210
+
211
+ This model was finetuned by Sam Havens, Alex Trott, and the MosaicML NLP team
212
+
213
+ ## MosaicML Platform
214
+
215
+ 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).
216
+
217
+ ## Disclaimer
218
+
219
+ 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 consult an attorney before using this model for commercial purposes.
220
+
221
+ ## Citation
222
+
223
+ Please cite this model using the following format:
224
+
225
+ ```
226
+ @online{MosaicML2023Introducing,
227
+ author = {MosaicML NLP Team},
228
+ title = {Introducing MPT-30B: Raising the bar
229
+ for open-source foundation models},
230
+ year = {2023},
231
+ url = {www.mosaicml.com/blog/mpt-30b},
232
+ note = {Accessed: 2023-06-22},
233
+ urldate = {2023-06-22}
234
+ }
235
+ ```