sam-mosaic commited on
Commit
848c6bf
1 Parent(s): 22bd597

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +209 -0
README.md ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ - Composer
22
+ - MosaicML
23
+ - llm-foundry
24
+ inference: false
25
+ ---
26
+
27
+ # MPT-30B-Chat
28
+
29
+ MPT-7B-8k-Chat is a chatbot-like model for dialogue generation.
30
+ It was built by finetuning [MPT-7B-8k](https://huggingface.co/mosaicml/mpt-7b-8k) on the [ShareGPT-Vicuna](https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered), [Camel-AI](https://huggingface.co/camel-ai),
31
+ [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.
32
+ * License: _CC-By-NC-SA-4.0_ (non-commercial use only)
33
+ * [Demo on Hugging Face Spaces](https://huggingface.co/spaces/mosaicml/mpt-7b-chat)
34
+
35
+
36
+ This model was trained by [MosaicML](https://www.mosaicml.com) and follows a modified decoder-only transformer architecture.
37
+
38
+ ## Model Date
39
+
40
+ June 29, 2023
41
+
42
+ ## Model License
43
+
44
+ _CC-By-NC-SA-4.0_ (non-commercial use only)
45
+
46
+ ## Documentation
47
+
48
+ * **TODO** Twitter thread link?
49
+ * [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
50
+ * Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
51
+
52
+ ## How to Use
53
+
54
+ This model is best used with the MosaicML [llm-foundry repository](https://github.com/mosaicml/llm-foundry) for training and finetuning.
55
+
56
+ ```python
57
+ import transformers
58
+ model = transformers.AutoModelForCausalLM.from_pretrained(
59
+ 'mosaicml/mpt-7b-8k-chat',
60
+ trust_remote_code=True
61
+ )
62
+ ```
63
+ Note: This model requires that `trust_remote_code=True` be passed to the `from_pretrained` method.
64
+ This is because we use a custom `MPT` model architecture that is not yet part of the Hugging Face `transformers` package.
65
+ `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.
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-7b-8k-chat'
73
+
74
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
75
+ config.attn_config['attn_impl'] = 'triton' # change this to use triton-based FlashAttention
76
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
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 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:
87
+
88
+ ```python
89
+ import transformers
90
+
91
+ name = 'mosaicml/mpt-7b-8k-chat'
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-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.
104
+
105
+ ```python
106
+ from transformers import AutoTokenizer
107
+ tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-7b-8k')
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
+ ## Model Description
132
+
133
+ The architecture is a modification of a standard decoder-only transformer.
134
+
135
+ The model has been modified from a standard transformer in the following ways:
136
+ * It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
137
+ * It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
138
+ * It does not use biases
139
+
140
+
141
+ | Hyperparameter | Value |
142
+ |----------------|-------|
143
+ |n_parameters | 6.7B |
144
+ |n_layers | 32 |
145
+ | n_heads | 32 |
146
+ | d_model | 4096 |
147
+ | vocab size | 50432 |
148
+ | sequence length | 2048 |
149
+
150
+ ## Data Mix
151
+
152
+ The model was trained on the following data mix:
153
+
154
+ | Data Source | Number of Tokens in Source | Proportion |
155
+ |-------------|----------------------------|------------|
156
+ | Airoboros/GPT4-1.2 | 26.4M | 1.71% |
157
+ | Baize | 55.0M | 3.57% |
158
+ | Camel | 301M | 19.54% |
159
+ | GPTeacher | 7.56M | 0.49% |
160
+ | Guanaco | 15.6M | 1.02% |
161
+ | LongCoversations | 18.4M | 1.19% |
162
+ | ShareGPT | 821M | 53.24% |
163
+ | WizardLM | 297M | 19.23% |
164
+
165
+ "LongConversations" is a GPT3.5/4-generated dataset, details of which will be released at a later date.
166
+
167
+ ### Training Configuration
168
+
169
+ **TODO FILL IN THESE DETAILS**
170
+ This model was trained on **NUMBER** H100s for about **NUMBER** hours using the [MosaicML Platform](https://www.mosaicml.com/platform).
171
+ The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the AdamW optimizer.
172
+
173
+ ## Limitations and Biases
174
+
175
+ _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
176
+
177
+ MPT-7B-8k-Chat can produce factually incorrect output, and should not be relied on to produce factually accurate information.
178
+ MPT-7B-8k-Chat was trained on various public datasets.
179
+ 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.
180
+
181
+ ## Acknowledgements
182
+
183
+ This model was finetuned by the MosaicML NLP team
184
+
185
+ ## Disclaimer
186
+
187
+ 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.
188
+
189
+
190
+ ## MosaicML Platform
191
+
192
+ 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).
193
+
194
+
195
+ ## Citation
196
+
197
+ Please cite this model using the following format:
198
+
199
+ ```
200
+ @online{MosaicML2023Introducing,
201
+ author = {MosaicML NLP Team},
202
+ title = {Introducing MPT-30B: Raising the bar
203
+ for open-source foundation models},
204
+ year = {2023},
205
+ url = {www.mosaicml.com/blog/mpt-30b},
206
+ note = {Accessed: 2023-06-22},
207
+ urldate = {2023-06-22}
208
+ }
209
+ ```