sam-mosaic commited on
Commit
14fd0a4
1 Parent(s): e913229

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +200 -0
README.md ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-7B-Instruct-8k
21
+
22
+ MPT-7B-Instruct-8k is a model for short-form instruction following.
23
+ It is built by finetuning [MPT-7B-8k](https://huggingface.co/mosaicml/mpt-7b-8k) 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-7b-instruct-8k)
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
+ July X, 2023
33
+
34
+ ## Model License
35
+
36
+ _CC-By-SA-3.0_
37
+
38
+ ## Documentation
39
+
40
+ * **TODO** Twitter thread link?
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
+ ## How to Use
45
+
46
+ This model is best used with the MosaicML [llm-foundry repository](https://github.com/mosaicml/llm-foundry) for training and finetuning.
47
+
48
+ ```python
49
+ import transformers
50
+ model = transformers.AutoModelForCausalLM.from_pretrained(
51
+ 'mosaicml/mpt-7b-instruct-8k',
52
+ trust_remote_code=True
53
+ )
54
+ ```
55
+ Note: This model requires that `trust_remote_code=True` be passed to the `from_pretrained` method.
56
+ This is because we use a custom `MPT` model architecture that is not yet part of the Hugging Face `transformers` package.
57
+ `MPT` includes options for many training efficiency features such as [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf), [ALiBi](https://arxiv.org/abs/2108.12409), [QK LayerNorm](https://arxiv.org/abs/2010.04245), and more.
58
+
59
+ 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:
60
+ ```python
61
+ import torch
62
+ import transformers
63
+
64
+ name = 'mosaicml/mpt-7b-instruct-8k'
65
+
66
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
67
+ config.attn_config['attn_impl'] = 'triton' # change this to use triton-based FlashAttention
68
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
69
+
70
+ model = transformers.AutoModelForCausalLM.from_pretrained(
71
+ name,
72
+ config=config,
73
+ torch_dtype=torch.bfloat16, # Load model weights in bfloat16
74
+ trust_remote_code=True
75
+ )
76
+ ```
77
+
78
+ The model was trained initially with a sequence length of 2048 with an additional pretraining stage for sequence length adapation up to 8192. However, ALiBi enables users to increase the maximum sequence length even further during finetuning and/or inference. For example:
79
+
80
+ ```python
81
+ import transformers
82
+
83
+ name = 'mosaicml/mpt-7b-instruct-8k'
84
+
85
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
86
+ config.max_seq_len = 16384 # (input + output) tokens can now be up to 16384
87
+
88
+ model = transformers.AutoModelForCausalLM.from_pretrained(
89
+ name,
90
+ config=config,
91
+ trust_remote_code=True
92
+ )
93
+ ```
94
+
95
+ This model was trained with the MPT-7B-chat tokenizer which is based on the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer and includes additional ChatML tokens.
96
+
97
+ ```python
98
+ from transformers import AutoTokenizer
99
+ tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-7b-8k')
100
+ ```
101
+
102
+ The model can then be used, for example, within a text-generation pipeline.
103
+ 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).
104
+
105
+ ```python
106
+ from transformers import pipeline
107
+
108
+ with torch.autocast('cuda', dtype=torch.bfloat16):
109
+ inputs = tokenizer('Here is a recipe for vegan banana bread:\n', return_tensors="pt").to('cuda')
110
+ outputs = model.generate(**inputs, max_new_tokens=100)
111
+ print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
112
+
113
+ # or using the HF pipeline
114
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
115
+ with torch.autocast('cuda', dtype=torch.bfloat16):
116
+ print(
117
+ pipe('Here is a recipe for vegan banana bread:\n',
118
+ max_new_tokens=100,
119
+ do_sample=True,
120
+ use_cache=True))
121
+ ```
122
+
123
+ ## Model Description
124
+
125
+ The architecture is a modification of a standard decoder-only transformer.
126
+
127
+ The model has been modified from a standard transformer in the following ways:
128
+ * It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
129
+ * It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
130
+ * It does not use biases
131
+
132
+
133
+ | Hyperparameter | Value |
134
+ |----------------|-------|
135
+ |n_parameters | 6.7B |
136
+ |n_layers | 32 |
137
+ | n_heads | 32 |
138
+ | d_model | 4096 |
139
+ | vocab size | 50432 |
140
+ | sequence length | 2048 |
141
+
142
+ ## Data Mix
143
+
144
+ The model was trained on the following data mix:
145
+
146
+ | Data Source | Number of Tokens in Source | Proportion |
147
+ |-------------|----------------------------|------------|
148
+ | Airoboros/GPT4-1.2 | 26.4M | 1.71% |
149
+ | Baize | 55.0M | 3.57% |
150
+ | Camel | 301M | 19.54% |
151
+ | GPTeacher | 7.56M | 0.49% |
152
+ | Guanaco | 15.6M | 1.02% |
153
+ | LongCoversations | 18.4M | 1.19% |
154
+ | ShareGPT | 821M | 53.24% |
155
+ | WizardLM | 297M | 19.23% |
156
+
157
+ "LongConversations" is a GPT3.5/4-generated dataset, details of which will be released at a later date.
158
+
159
+ ### Training Configuration
160
+
161
+ This model was trained on 8 80GB A100s for about 6.3 hours using the [MosaicML Platform](https://www.mosaicml.com/platform).
162
+ The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the AdamW optimizer.
163
+
164
+ ## Limitations and Biases
165
+
166
+ _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
167
+
168
+ MPT-7B-Instruct-8k can produce factually incorrect output, and should not be relied on to produce factually accurate information.
169
+ MPT-7B-Instruct-8k was trained on various public datasets.
170
+ 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.
171
+
172
+ ## Acknowledgements
173
+
174
+ This model was finetuned by the MosaicML NLP team.
175
+
176
+ ## Disclaimer
177
+
178
+ 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.
179
+
180
+
181
+ ## MosaicML Platform
182
+
183
+ 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-7b).
184
+
185
+
186
+ ## Citation
187
+
188
+ Please cite this model using the following format:
189
+
190
+ ```
191
+ @online{MosaicML2023Introducing,
192
+ author = {MosaicML NLP Team},
193
+ title = {Introducing MPT-30B: Raising the bar
194
+ for open-source foundation models},
195
+ year = {2023},
196
+ url = {www.mosaicml.com/blog/mpt-30b},
197
+ note = {Accessed: 2023-06-22},
198
+ urldate = {2023-06-22}
199
+ }
200
+ ```