michaelfeil commited on
Commit
4a3f3af
1 Parent(s): ca1aaf5

Upload mosaicml/mpt-30b-instruct ctranslate fp16 weights

Browse files
README.md ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ - ctranslate2
15
+ - int8
16
+ - float16
17
+ - Composer
18
+ - MosaicML
19
+ - llm-foundry
20
+ inference: false
21
+ ---
22
+ # # Fast-Inference with Ctranslate2
23
+ Speedup inference while reducing memory by 2x-4x using int8 inference in C++ on CPU or GPU.
24
+
25
+ quantized version of [mosaicml/mpt-30b-instruct](https://huggingface.co/mosaicml/mpt-30b-instruct)
26
+ ```bash
27
+ pip install hf-hub-ctranslate2>=2.12.0 ctranslate2>=3.16.0
28
+ ```
29
+
30
+ ```python
31
+ # from transformers import AutoTokenizer
32
+ model_name = "michaelfeil/ct2fast-mpt-30b-instruct"
33
+
34
+
35
+ from hf_hub_ctranslate2 import GeneratorCT2fromHfHub
36
+ model = GeneratorCT2fromHfHub(
37
+ # load in int8 on CUDA
38
+ model_name_or_path=model_name,
39
+ device="cuda",
40
+ compute_type="int8_float16",
41
+ # tokenizer=AutoTokenizer.from_pretrained("{ORG}/{NAME}")
42
+ )
43
+ outputs = model.generate(
44
+ text=["def fibonnaci(", "User: How are you doing? Bot:"],
45
+ max_length=64,
46
+ include_prompt_in_result=False
47
+ )
48
+ print(outputs)
49
+ ```
50
+
51
+ Checkpoint compatible to [ctranslate2>=3.16.0](https://github.com/OpenNMT/CTranslate2)
52
+ and [hf-hub-ctranslate2>=2.12.0](https://github.com/michaelfeil/hf-hub-ctranslate2)
53
+ - `compute_type=int8_float16` for `device="cuda"`
54
+ - `compute_type=int8` for `device="cpu"`
55
+
56
+ Converted on 2023-06-23 using
57
+ ```
58
+ ct2-transformers-converter --model mosaicml/mpt-30b-instruct --output_dir ~/tmp-ct2fast-mpt-30b-instruct --force --copy_files tokenizer.json README.md tokenizer_config.json generation_config.json special_tokens_map.json .gitattributes --quantization int8_float16 --trust_remote_code
59
+ ```
60
+
61
+ # Licence and other remarks:
62
+ This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.
63
+
64
+ # Original description
65
+
66
+
67
+ # MPT-30B-Instruct
68
+
69
+ MPT-30B-Instruct is a model for short-form instruction following.
70
+ 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).
71
+ * License: _CC-By-SA-3.0_
72
+
73
+
74
+ This model was trained by [MosaicML](https://www.mosaicml.com) and follows a modified decoder-only transformer architecture.
75
+
76
+ ## Model Date
77
+
78
+ June 22, 2023
79
+
80
+ ## Model License
81
+
82
+ CC-By-SA-3.0
83
+
84
+ ## Documentation
85
+
86
+ * [Blog post: Raising the bar for open-source foundation models](https://www.mosaicml.com/blog/mpt-30b)
87
+ * [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
88
+ * Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
89
+
90
+ ### Example Question/Instruction
91
+
92
+ **Bespokenizer46**
93
+ > I need to convince my friend, Phyllis, that she should train a custom LLM for her Fortune 500 company using the MosaicML Platform.
94
+ > Please write an email that explains why MosaicML's emphasis on cutting edge methodology, data privacy, and efficiency are so important.
95
+ > End the email with a friendly inquiry about Phyllis's family.
96
+
97
+ **MPT-30B-Instruct**:
98
+ > Phyllis -
99
+ > 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.
100
+ > 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.
101
+ > They also provide tools to easily connect to and use the model in your daily workflow.
102
+ > I think you'd really enjoy speaking with their founder, we can set up a call if you're interested.
103
+ > Also, I know it's been a tough year for your family, how are things?
104
+
105
+ > Best,
106
+ > Your Friend
107
+
108
+ ## How to Use
109
+
110
+ 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.
111
+
112
+ 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.
113
+
114
+ ```python
115
+ import transformers
116
+ model = transformers.AutoModelForCausalLM.from_pretrained(
117
+ 'mosaicml/mpt-30b-instruct',
118
+ trust_remote_code=True
119
+ )
120
+ ```
121
+
122
+ 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:
123
+ ```python
124
+ import torch
125
+ import transformers
126
+
127
+ name = 'mosaicml/mpt-30b-instruct'
128
+
129
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
130
+ config.attn_config['attn_impl'] = 'triton' # change this to use triton-based FlashAttention
131
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
132
+
133
+ model = transformers.AutoModelForCausalLM.from_pretrained(
134
+ name,
135
+ config=config,
136
+ torch_dtype=torch.bfloat16, # Load model weights in bfloat16
137
+ trust_remote_code=True
138
+ )
139
+ ```
140
+
141
+ 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:
142
+
143
+ ```python
144
+ import transformers
145
+
146
+ name = 'mosaicml/mpt-30b-instruct'
147
+
148
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
149
+ config.max_seq_len = 16384 # (input + output) tokens can now be up to 16384
150
+
151
+ model = transformers.AutoModelForCausalLM.from_pretrained(
152
+ name,
153
+ config=config,
154
+ trust_remote_code=True
155
+ )
156
+ ```
157
+
158
+ 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.
159
+
160
+ ```python
161
+ from transformers import AutoTokenizer
162
+ tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-30b')
163
+ ```
164
+
165
+ The model can then be used, for example, within a text-generation pipeline.
166
+ 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).
167
+
168
+ ```python
169
+ from transformers import pipeline
170
+
171
+ with torch.autocast('cuda', dtype=torch.bfloat16):
172
+ inputs = tokenizer('Here is a recipe for vegan banana bread:\n', return_tensors="pt").to('cuda')
173
+ outputs = model.generate(**inputs, max_new_tokens=100)
174
+ print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
175
+
176
+ # or using the HF pipeline
177
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
178
+ with torch.autocast('cuda', dtype=torch.bfloat16):
179
+ print(
180
+ pipe('Here is a recipe for vegan banana bread:\n',
181
+ max_new_tokens=100,
182
+ do_sample=True,
183
+ use_cache=True))
184
+ ```
185
+
186
+ ### Formatting
187
+
188
+ This model was trained on data formatted as follows:
189
+
190
+ ```python
191
+ def format_prompt(instruction):
192
+ 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"
193
+ return template.format(instruction=instruction)
194
+
195
+ example = "Tell me a funny joke.\nDon't make it too funny though."
196
+ fmt_ex = format_prompt(instruction=example)
197
+ ```
198
+
199
+ In the above example, `fmt_ex` is ready to be tokenized and sent through the model.
200
+
201
+ ## Model Description
202
+
203
+ The architecture is a modification of a standard decoder-only transformer.
204
+
205
+ The model has been modified from a standard transformer in the following ways:
206
+ * It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
207
+ * It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
208
+ * It does not use biases
209
+
210
+
211
+ | Hyperparameter | Value |
212
+ |----------------|-------|
213
+ |n_parameters | 29.95B |
214
+ |n_layers | 48 |
215
+ | n_heads | 64 |
216
+ | d_model | 7168 |
217
+ | vocab size | 50432 |
218
+ | sequence length | 8192 |
219
+
220
+ ## Data Mix
221
+
222
+ The model was trained on the following data mix:
223
+
224
+ | Data Source | Number of Tokens in Source | Proportion |
225
+ |-------------|----------------------------|------------|
226
+ | competition_math | 1.6 M | 3.01% |
227
+ | cot_gsm8k | 3.36 M | 6.32% |
228
+ | dialogsum | 0.1 M | 0.19% |
229
+ | dolly_hhrlhf | 5.89 M | 11.07% |
230
+ | duorc | 8.2 M | 15.51% |
231
+ | qasper | 10.97 M | 20.63% |
232
+ | quality | 11.31 M | 21.28% |
233
+ | scrolls/summ_screen_fd | 11.56 M | 21.82% |
234
+ | spider | 0.089 M | 0.16% |
235
+
236
+ ## PreTraining Data
237
+
238
+ For more details on the pretraining process, see [MPT-30B](https://huggingface.co/mosaicml/mpt-30b).
239
+
240
+ The data was tokenized using the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer.
241
+
242
+ ### Training Configuration
243
+
244
+ This model was trained on 72 A100 40GB GPUs for 8 hours using the [MosaicML Platform](https://www.mosaicml.com/platform).
245
+ The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the AdamW optimizer.
246
+
247
+ ## Limitations and Biases
248
+
249
+ _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
250
+
251
+ MPT-30B-Instruct can produce factually incorrect output, and should not be relied on to produce factually accurate information.
252
+ MPT-30B-Instruct was trained on various public datasets.
253
+ 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.
254
+
255
+
256
+ ## Acknowledgements
257
+
258
+ This model was finetuned by Sam Havens, Alex Trott, and the MosaicML NLP team
259
+
260
+ ## MosaicML Platform
261
+
262
+ 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).
263
+
264
+ ## Disclaimer
265
+
266
+ 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.
267
+
268
+ ## Citation
269
+
270
+ Please cite this model using the following format:
271
+
272
+ ```
273
+ @online{MosaicML2023Introducing,
274
+ author = {MosaicML NLP Team},
275
+ title = {Introducing MPT-30B: Raising the bar
276
+ for open-source foundation models},
277
+ year = {2023},
278
+ url = {www.mosaicml.com/blog/mpt-30b},
279
+ note = {Accessed: 2023-06-22},
280
+ urldate = {2023-06-22}
281
+ }
282
+ ```
config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "MPTForCausalLM"
4
+ ],
5
+ "attn_config": {
6
+ "alibi": true,
7
+ "alibi_bias_max": 8,
8
+ "attn_impl": "torch",
9
+ "attn_pdrop": 0,
10
+ "attn_type": "multihead_attention",
11
+ "attn_uses_sequence_id": false,
12
+ "clip_qkv": null,
13
+ "prefix_lm": false,
14
+ "qk_ln": false,
15
+ "softmax_scale": null
16
+ },
17
+ "auto_map": {
18
+ "AutoConfig": "configuration_mpt.MPTConfig",
19
+ "AutoModelForCausalLM": "modeling_mpt.MPTForCausalLM"
20
+ },
21
+ "d_model": 7168,
22
+ "emb_pdrop": 0,
23
+ "embedding_fraction": 1.0,
24
+ "expansion_ratio": 4,
25
+ "init_config": {
26
+ "emb_init_std": null,
27
+ "emb_init_uniform_lim": null,
28
+ "fan_mode": "fan_in",
29
+ "init_div_is_residual": true,
30
+ "init_gain": 0.0,
31
+ "init_nonlinearity": "relu",
32
+ "init_std": null,
33
+ "name": "kaiming_normal_",
34
+ "verbose": 0
35
+ },
36
+ "init_device": "cpu",
37
+ "learned_pos_emb": true,
38
+ "logit_scale": null,
39
+ "max_seq_len": 8192,
40
+ "model_type": "mpt",
41
+ "n_heads": 64,
42
+ "n_layers": 48,
43
+ "no_bias": true,
44
+ "norm_type": "low_precision_layernorm",
45
+ "resid_pdrop": 0,
46
+ "tokenizer_name": "EleutherAI/gpt-neox-20b",
47
+ "torch_dtype": "bfloat16",
48
+ "transformers_version": "4.28.1",
49
+ "use_cache": false,
50
+ "verbose": 0,
51
+ "vocab_size": 50432,
52
+ "bos_token": "<|endoftext|>",
53
+ "eos_token": "<|endoftext|>",
54
+ "layer_norm_epsilon": null,
55
+ "unk_token": "<|endoftext|>"
56
+ }
generation_config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.28.1",
4
+ "use_cache": false
5
+ }
model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:992a79c800728d5c6dc891e56e34ce7357b97d84b365fc8b4372d4fb5024c169
3
+ size 29970535088
special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "pad_token": "<|endoftext|>",
5
+ "unk_token": "<|endoftext|>"
6
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "bos_token": "<|endoftext|>",
4
+ "clean_up_tokenization_spaces": true,
5
+ "eos_token": "<|endoftext|>",
6
+ "model_max_length": 8192,
7
+ "tokenizer_class": "GPTNeoXTokenizer",
8
+ "unk_token": "<|endoftext|>"
9
+ }
vocabulary.json ADDED
The diff for this file is too large to render. See raw diff