michaelfeil commited on
Commit
b2bfa61
1 Parent(s): 213cf98

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

Browse files
.gitattributes CHANGED
@@ -25,7 +25,6 @@
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
  *.tflite filter=lfs diff=lfs merge=lfs -text
30
  *.tgz filter=lfs diff=lfs merge=lfs -text
31
  *.wasm filter=lfs diff=lfs merge=lfs -text
 
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
 
28
  *.tflite filter=lfs diff=lfs merge=lfs -text
29
  *.tgz filter=lfs diff=lfs merge=lfs -text
30
  *.wasm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-sa-4.0
3
+ datasets:
4
+ - camel-ai/code
5
+ - ehartford/wizard_vicuna_70k_unfiltered
6
+ - anon8231489123/ShareGPT_Vicuna_unfiltered
7
+ - teknium1/GPTeacher/roleplay-instruct-v2-final
8
+ - teknium1/GPTeacher/codegen-isntruct
9
+ - timdettmers/openassistant-guanaco
10
+ - camel-ai/math
11
+ - project-baize/baize-chatbot/medical_chat_data
12
+ - project-baize/baize-chatbot/quora_chat_data
13
+ - project-baize/baize-chatbot/stackoverflow_chat_data
14
+ - camel-ai/biology
15
+ - camel-ai/chemistry
16
+ - camel-ai/ai_society
17
+ - jondurbin/airoboros-gpt4-1.2
18
+ - LongConversations
19
+ - camel-ai/physics
20
+ tags:
21
+ - ctranslate2
22
+ - int8
23
+ - float16
24
+ - Composer
25
+ - MosaicML
26
+ - llm-foundry
27
+ inference: false
28
+ ---
29
+ # # Fast-Inference with Ctranslate2
30
+ Speedup inference while reducing memory by 2x-4x using int8 inference in C++ on CPU or GPU.
31
+
32
+ quantized version of [mosaicml/mpt-30b-chat](https://huggingface.co/mosaicml/mpt-30b-chat)
33
+ ```bash
34
+ pip install hf-hub-ctranslate2>=2.12.0 ctranslate2>=3.16.0
35
+ ```
36
+
37
+ ```python
38
+ # from transformers import AutoTokenizer
39
+ model_name = "michaelfeil/ct2fast-mpt-30b-chat"
40
+
41
+
42
+ from hf_hub_ctranslate2 import GeneratorCT2fromHfHub
43
+ model = GeneratorCT2fromHfHub(
44
+ # load in int8 on CUDA
45
+ model_name_or_path=model_name,
46
+ device="cuda",
47
+ compute_type="int8_float16",
48
+ # tokenizer=AutoTokenizer.from_pretrained("{ORG}/{NAME}")
49
+ )
50
+ outputs = model.generate(
51
+ text=["def fibonnaci(", "User: How are you doing? Bot:"],
52
+ max_length=64,
53
+ include_prompt_in_result=False
54
+ )
55
+ print(outputs)
56
+ ```
57
+
58
+ Checkpoint compatible to [ctranslate2>=3.16.0](https://github.com/OpenNMT/CTranslate2)
59
+ and [hf-hub-ctranslate2>=2.12.0](https://github.com/michaelfeil/hf-hub-ctranslate2)
60
+ - `compute_type=int8_float16` for `device="cuda"`
61
+ - `compute_type=int8` for `device="cpu"`
62
+
63
+ Converted on 2023-06-23 using
64
+ ```
65
+ ct2-transformers-converter --model mosaicml/mpt-30b-chat --output_dir ~/tmp-ct2fast-mpt-30b-chat --force --copy_files tokenizer.json README.md tokenizer_config.json generation_config.json special_tokens_map.json .gitattributes --quantization int8_float16 --trust_remote_code
66
+ ```
67
+
68
+ # Licence and other remarks:
69
+ This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.
70
+
71
+ # Original description
72
+
73
+
74
+ # MPT-30B-Chat
75
+
76
+ MPT-30B-Chat is a chatbot-like model for dialogue generation.
77
+ It was built by finetuning [MPT-30B](https://huggingface.co/mosaicml/mpt-30b) on the [ShareGPT-Vicuna](https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered), [Camel-AI](https://huggingface.co/camel-ai),
78
+ [GPTeacher](https://github.com/teknium1/GPTeacher), [Guanaco](https://huggingface.co/datasets/timdettmers/openassistant-guanaco), [Baize](https://github.com/project-baize/baize-chatbot) and some generated datasets.
79
+ * License: _CC-By-NC-SA-4.0_ (non-commercial use only)
80
+ * [Demo on Hugging Face Spaces](https://huggingface.co/spaces/mosaicml/mpt-30b-chat)
81
+
82
+
83
+ This model was trained by [MosaicML](https://www.mosaicml.com) and follows a modified decoder-only transformer architecture.
84
+
85
+ ## Model Date
86
+
87
+ June 22, 2023
88
+
89
+ ## Model License
90
+
91
+ _CC-By-NC-SA-4.0_ (non-commercial use only)
92
+
93
+ ## Documentation
94
+
95
+ * [Blog post: Raising the bar for open-source foundation models](https://www.mosaicml.com/blog/mpt-30b)
96
+ * [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
97
+ * Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
98
+
99
+ ### Example Dialogue
100
+
101
+ **ksreenivasan**:
102
+ > I want you to come up with a tweet based on this summary of the article:
103
+ >
104
+ > We are excited to extend the MosaicML Foundation Series with MPT-30B, a new commercially licensed open-source model that is significantly more powerful, and outperforms the
105
+ > original GPT-3. In addition, we are releasing two fine-tuned models, MPT-30B-Instruct and MPT-30B-Chat, that are built on top of MPT-30B and excel at short-form instruction
106
+ > following and multi-turn conversations, respectively.
107
+ > All MPT-30B models come with special features that differentiate them from other LLMs, including an 8k token context window (which can be further extended via finetuning;
108
+ > see MPT-7B-StoryWriter), support for context-length extrapolation via ALiBi, and efficient inference + training performance via FlashAttention. It also has strong coding
109
+ > abilities thanks to its pretraining data mixture.
110
+
111
+
112
+
113
+ **MPT-30B-Chat**:
114
+ > "Revolutionize your AI capabilities with MosaicML's latest addition, MPT-30B! Outperforming GPT-3, this open-source model is significantly more powerful and comes with
115
+ > finely-tuned models for exceptional instruction following and multi-turn conversations. Unleash the potential of an 8k token context window, ALiBi support, and FlashAttention.
116
+ > Experience the future of AI with MosaicML! #AI #ML #innovation"
117
+
118
+ **ksreenivasan**:
119
+ > Is there anything you want to say to MosaicML about this exciting news?
120
+
121
+ **MPT-30B-Chat**:
122
+ > As your AI marketing assistant, I would say that this is truly exciting news for the AI community! MosaicML's latest addition, MPT-30B, is poised to revolutionize the industry with its powerful open-source capabilities and finely-tuned models for instruction following and multi-turn conversations.
123
+ > The special features, including the 8k token context window, ALiBi support, and FlashAttention, are sure to set MosaicML's MPT-30B apart from other LLMs.
124
+ > Congratulations to the MosaicML team on this incredible achievement!
125
+
126
+ ## How to Use
127
+
128
+ This model is best used with the MosaicML [llm-foundry repository](https://github.com/mosaicml/llm-foundry) for training and finetuning.
129
+
130
+ ```python
131
+ import transformers
132
+ model = transformers.AutoModelForCausalLM.from_pretrained(
133
+ 'mosaicml/mpt-30b-chat',
134
+ trust_remote_code=True
135
+ )
136
+ ```
137
+ Note: This model requires that `trust_remote_code=True` be passed to the `from_pretrained` method.
138
+ This is because we use a custom `MPT` model architecture that is not yet part of the Hugging Face `transformers` package.
139
+ `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.
140
+
141
+ 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:
142
+ ```python
143
+ import torch
144
+ import transformers
145
+
146
+ name = 'mosaicml/mpt-30b-chat'
147
+
148
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
149
+ config.attn_config['attn_impl'] = 'triton' # change this to use triton-based FlashAttention
150
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
151
+
152
+ model = transformers.AutoModelForCausalLM.from_pretrained(
153
+ name,
154
+ config=config,
155
+ torch_dtype=torch.bfloat16, # Load model weights in bfloat16
156
+ trust_remote_code=True
157
+ )
158
+ ```
159
+
160
+ The model was trained initially with a sequence length of 4096 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:
161
+
162
+ ```python
163
+ import transformers
164
+
165
+ name = 'mosaicml/mpt-30b-chat'
166
+
167
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
168
+ config.max_seq_len = 16384 # (input + output) tokens can now be up to 16384
169
+
170
+ model = transformers.AutoModelForCausalLM.from_pretrained(
171
+ name,
172
+ config=config,
173
+ trust_remote_code=True
174
+ )
175
+ ```
176
+
177
+ 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.
178
+
179
+ ```python
180
+ from transformers import AutoTokenizer
181
+ tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-30b')
182
+ ```
183
+
184
+ The model can then be used, for example, within a text-generation pipeline.
185
+ 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).
186
+
187
+ ```python
188
+ from transformers import pipeline
189
+
190
+ with torch.autocast('cuda', dtype=torch.bfloat16):
191
+ inputs = tokenizer('Here is a recipe for vegan banana bread:\n', return_tensors="pt").to('cuda')
192
+ outputs = model.generate(**inputs, max_new_tokens=100)
193
+ print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
194
+
195
+ # or using the HF pipeline
196
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
197
+ with torch.autocast('cuda', dtype=torch.bfloat16):
198
+ print(
199
+ pipe('Here is a recipe for vegan banana bread:\n',
200
+ max_new_tokens=100,
201
+ do_sample=True,
202
+ use_cache=True))
203
+ ```
204
+
205
+ ## Model Description
206
+
207
+ The architecture is a modification of a standard decoder-only transformer.
208
+
209
+ The model has been modified from a standard transformer in the following ways:
210
+ * It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
211
+ * It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
212
+ * It does not use biases
213
+
214
+
215
+ | Hyperparameter | Value |
216
+ |----------------|-------|
217
+ |n_parameters | 29.95B |
218
+ |n_layers | 48 |
219
+ | n_heads | 64 |
220
+ | d_model | 7168 |
221
+ | vocab size | 50432 |
222
+ | sequence length | 8192 |
223
+
224
+ ## Data Mix
225
+
226
+ The model was trained on the following data mix:
227
+
228
+ | Data Source | Number of Tokens in Source | Proportion |
229
+ |-------------|----------------------------|------------|
230
+ | Airoboros/GPT4 | 26.4M | 1.71% |
231
+ | Baize | 55.0M | 3.57% |
232
+ | Camel | 301M | 19.54% |
233
+ | GPTeacher | 7.56M | 0.49% |
234
+ | Guanaco | 15.6M | 1.02% |
235
+ | LongCoversations | 18.4M | 1.19% |
236
+ | ShareGPT | 821M | 53.24% |
237
+ | WizardLM | 297M | 19.23% |
238
+
239
+ "LongConversations" is a GPT3.5/4-generated dataset, details of which will be released at a later date.
240
+
241
+ ### Training Configuration
242
+
243
+ This model was trained on 64 H100s for about 7.6 hours using the [MosaicML Platform](https://www.mosaicml.com/platform).
244
+ The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the AdamW optimizer.
245
+
246
+ ## Limitations and Biases
247
+
248
+ _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
249
+
250
+ MPT-30B-Chat can produce factually incorrect output, and should not be relied on to produce factually accurate information.
251
+ MPT-30B-Chat was trained on various public datasets.
252
+ 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.
253
+
254
+ ## Acknowledgements
255
+
256
+ This model was finetuned by Sam Havens and the MosaicML NLP team
257
+
258
+ ## Disclaimer
259
+
260
+ 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.
261
+
262
+
263
+ ## MosaicML Platform
264
+
265
+ 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).
266
+
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": "sam-mosaic/gpt-neox-20b-chatml",
47
+ "torch_dtype": "bfloat16",
48
+ "transformers_version": "4.30.2",
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.30.2",
4
+ "use_cache": false
5
+ }
model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c63c1de64f18b04783aed6c99e29328dea1c5998abf62195d4765c2efe70e494
3
+ size 29970535088
special_tokens_map.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>"
5
+ ],
6
+ "bos_token": "<|endoftext|>",
7
+ "eos_token": "<|endoftext|>",
8
+ "pad_token": "<|endoftext|>",
9
+ "unk_token": "<|endoftext|>"
10
+ }
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