TheBloke commited on
Commit
f1e6ad8
1 Parent(s): d837295

Initial GGML model commit

Browse files
Files changed (1) hide show
  1. README.md +477 -0
README.md ADDED
@@ -0,0 +1,477 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ inference: false
3
+ license: other
4
+ ---
5
+
6
+ <!-- header start -->
7
+ <div style="width: 100%;">
8
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
9
+ </div>
10
+ <div style="display: flex; justify-content: space-between; width: 100%;">
11
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
12
+ <p><a href="https://discord.gg/Jq4vkcDakD">Chat & support: my new Discord server</a></p>
13
+ </div>
14
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
15
+ <p><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
16
+ </div>
17
+ </div>
18
+ <!-- header end -->
19
+
20
+ # OpenAccess AI Collective's Minotaur MPT 7B GGML
21
+
22
+ These files are GGML format model files for [OpenAccess AI Collective's Minotaur MPT 7B](https://huggingface.co/openaccess-ai-collective/minotaur-mpt-7b).
23
+
24
+ GGML files are for CPU + GPU inference using [llama.cpp](https://github.com/ggerganov/llama.cpp) and libraries and UIs which support this format, such as:
25
+ * [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
26
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp)
27
+ * [ParisNeo/GPT4All-UI](https://github.com/ParisNeo/gpt4all-ui)
28
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python)
29
+ * [ctransformers](https://github.com/marella/ctransformers)
30
+
31
+ ## Repositories available
32
+
33
+ * [4-bit GPTQ models for GPU inference](https://huggingface.co/none)
34
+ * [2, 3, 4, 5, 6 and 8-bit GGML models for CPU+GPU inference](https://huggingface.co/TheBloke/minotaur-mpt-7B-GGML)
35
+ * [Unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/openaccess-ai-collective/minotaur-mpt-7b)
36
+
37
+ <!-- compatibility_ggml start -->
38
+ ## Compatibility
39
+
40
+ ### Original llama.cpp quant methods: `q4_0, q4_1, q5_0, q5_1, q8_0`
41
+
42
+ I have quantized these 'original' quantisation methods using an older version of llama.cpp so that they remain compatible with llama.cpp as of May 19th, commit `2d5db48`.
43
+
44
+ They should be compatible with all current UIs and libraries that use llama.cpp, such as those listed at the top of this README.
45
+
46
+ ### New k-quant methods: `q2_K, q3_K_S, q3_K_M, q3_K_L, q4_K_S, q4_K_M, q5_K_S, q6_K`
47
+
48
+ These new quantisation methods are only compatible with llama.cpp as of June 6th, commit `2d43387`.
49
+
50
+ They will NOT be compatible with koboldcpp, text-generation-ui, and other UIs and libraries yet. Support is expected to come over the next few days.
51
+
52
+ ## Explanation of the new k-quant methods
53
+
54
+ The new methods available are:
55
+ * GGML_TYPE_Q2_K - "type-1" 2-bit quantization in super-blocks containing 16 blocks, each block having 16 weight. Block scales and mins are quantized with 4 bits. This ends up effectively using 2.5625 bits per weight (bpw)
56
+ * GGML_TYPE_Q3_K - "type-0" 3-bit quantization in super-blocks containing 16 blocks, each block having 16 weights. Scales are quantized with 6 bits. This end up using 3.4375 bpw.
57
+ * GGML_TYPE_Q4_K - "type-1" 4-bit quantization in super-blocks containing 8 blocks, each block having 32 weights. Scales and mins are quantized with 6 bits. This ends up using 4.5 bpw.
58
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
59
+ * GGML_TYPE_Q6_K - "type-0" 6-bit quantization. Super-blocks with 16 blocks, each block having 16 weights. Scales are quantized with 8 bits. This ends up using 6.5625 bpw
60
+ * GGML_TYPE_Q8_K - "type-0" 8-bit quantization. Only used for quantizing intermediate results. The difference to the existing Q8_0 is that the block size is 256. All 2-6 bit dot products are implemented for this quantization type.
61
+
62
+ Refer to the Provided Files table below to see what files use which methods, and how.
63
+ <!-- compatibility_ggml end -->
64
+
65
+ ## Provided files
66
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
67
+ | ---- | ---- | ---- | ---- | ---- | ----- |
68
+ | minotaur-mpt-7b.ggmlv3.q4_0.bin | q4_0 | 4 | 3.74 GB | 6.24 GB | Original llama.cpp quant method, 4-bit. |
69
+ | minotaur-mpt-7b.ggmlv3.q4_1.bin | q4_1 | 4 | 4.16 GB | 6.66 GB | Original llama.cpp quant method, 4-bit. Higher accuracy than q4_0 but not as high as q5_0. However has quicker inference than q5 models. |
70
+ | minotaur-mpt-7b.ggmlv3.q5_0.bin | q5_0 | 5 | 4.57 GB | 7.07 GB | Original llama.cpp quant method, 5-bit. Higher accuracy, higher resource usage and slower inference. |
71
+ | minotaur-mpt-7b.ggmlv3.q5_1.bin | q5_1 | 5 | 4.99 GB | 7.49 GB | Original llama.cpp quant method, 5-bit. Even higher accuracy, resource usage and slower inference. |
72
+ | minotaur-mpt-7b.ggmlv3.q8_0.bin | q8_0 | 8 | 7.07 GB | 9.57 GB | Original llama.cpp quant method, 8-bit. Almost indistinguishable from float16. High resource use and slow. Not recommended for most users. |
73
+
74
+
75
+ **Note**: the above RAM figures assume no GPU offloading. If layers are offloaded to the GPU, this will reduce RAM usage and use VRAM instead.
76
+
77
+ ## How to run in `llama.cpp`
78
+
79
+ I use the following command line; adjust for your tastes and needs:
80
+
81
+ ```
82
+ ./main -t 10 -ngl 32 -m minotaur-mpt-7b.ggmlv3.q5_0.bin --color -c 2048 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "### Instruction: Write a story about llamas\n### Response:"
83
+ ```
84
+ Change `-t 10` to the number of physical CPU cores you have. For example if your system has 8 cores/16 threads, use `-t 8`.
85
+
86
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
87
+
88
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
89
+
90
+ ## How to run in `text-generation-webui`
91
+
92
+ Further instructions here: [text-generation-webui/docs/llama.cpp-models.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/llama.cpp-models.md).
93
+
94
+ <!-- footer start -->
95
+ ## Discord
96
+
97
+ For further support, and discussions on these models and AI in general, join us at:
98
+
99
+ [TheBloke AI's Discord server](https://discord.gg/Jq4vkcDakD)
100
+
101
+ ## Thanks, and how to contribute.
102
+
103
+ Thanks to the [chirper.ai](https://chirper.ai) team!
104
+
105
+ I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
106
+
107
+ If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
108
+
109
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
110
+
111
+ * Patreon: https://patreon.com/TheBlokeAI
112
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
113
+
114
+ **Special thanks to**: Luke from CarbonQuill, Aemon Algiz, Dmitriy Samsonov.
115
+
116
+ **Patreon special mentions**: Ajan Kanaga, Kalila, Derek Yates, Sean Connelly, Luke, Nathan LeClaire, Trenton Dambrowitz, Mano Prime, David Flickinger, vamX, Nikolai Manek, senxiiz, Khalefa Al-Ahmad, Illia Dulskyi, trip7s trip, Jonathan Leane, Talal Aujan, Artur Olbinski, Cory Kujawski, Joseph William Delisle, Pyrater, Oscar Rangel, Lone Striker, Luke Pendergrass, Eugene Pentland, Johann-Peter Hartmann.
117
+
118
+ Thank you to all my generous patrons and donaters!
119
+
120
+ <!-- footer end -->
121
+
122
+ # Original model card: OpenAccess AI Collective's Minotaur MPT 7B
123
+
124
+
125
+ [<img src="https://raw.githubusercontent.com/OpenAccess-AI-Collective/axolotl/main/image/axolotl-badge-web.png" alt="Built with Axolotl" width="200" height="32"/>](https://github.com/OpenAccess-AI-Collective/axolotl)
126
+ **[💵 Donate to OpenAccess AI Collective](https://github.com/sponsors/OpenAccess-AI-Collective) to help us keep building great tools and models!**
127
+
128
+ # Minotaur MPT 7B
129
+
130
+ Minotaur 7B is an instruct fine-tuned model on top of MPT-7B. Minotaur 7B is fine-tuned **on only completely open datasets** making this model reproducible by anyone.
131
+
132
+ Questions, comments, feedback, looking to donate, or want to help? Reach out on our [Discord](https://discord.gg/PugNNHAF5r) or email [wing@openaccessaicollective.org](mailto:wing@openaccessaicollective.org)
133
+
134
+ # Prompts
135
+ Chat only style prompts using `USER:`,`ASSISTANT:`.
136
+
137
+ # Training Datasets
138
+
139
+ Minotaur 7B model is fine-tuned on the following datasets:
140
+
141
+ - [WizardLM](https://huggingface.co/datasets/ehartford/WizardLM_alpaca_evol_instruct_70k_unfiltered)
142
+ - [subset of QingyiSi/Alpaca-CoT for roleplay and CoT](https://huggingface.co/QingyiSi/Alpaca-CoT)
143
+ - [GPTeacher-General-Instruct](https://huggingface.co/datasets/teknium/GPTeacher-General-Instruct)
144
+ - [metaeval/ScienceQA_text_only](https://huggingface.co/datasets/metaeval/ScienceQA_text_only) - instruct for concise responses
145
+ - [openai/summarize_from_feedback](https://huggingface.co/datasets/openai/summarize_from_feedback) - instruct augmented tl;dr summarization
146
+ - [camel-ai/math](https://huggingface.co/datasets/camel-ai/math)
147
+ - [camel-ai/physics](https://huggingface.co/datasets/camel-ai/physics)
148
+ - [camel-ai/chemistry](https://huggingface.co/datasets/camel-ai/chemistry)
149
+ - [camel-ai/biology](https://huggingface.co/datasets/camel-ai/biology)
150
+ - [winglian/evals](https://huggingface.co/datasets/winglian/evals)
151
+ - custom sysnthetic datasets around misconceptions, in-context qa, jokes, N-tasks problems, and context-insensitivity
152
+ - ARC-Easy & ARC-Challenge - instruct augmented for detailed responses, derived from the `train` split
153
+ - [hellaswag](https://huggingface.co/datasets/hellaswag) - 30K+ rows of instruct augmented for detailed explanations w 30K+ rows, derived from the `train` split
154
+ - [riddle_sense](https://huggingface.co/datasets/riddle_sense) - instruct augmented
155
+ - [gsm8k](https://huggingface.co/datasets/gsm8k) - instruct augmented
156
+
157
+ # Shoutouts
158
+
159
+ Special thanks to Nanobit for helping with Axolotl and TheBloke for quantizing these models are more accessible to all.
160
+
161
+ # Demo
162
+
163
+ HF Demo in Spaces coming soon.
164
+
165
+ ## Release Notes
166
+
167
+ - https://wandb.ai/wing-lian/mpt-7b-4k-minotaur/runs/i4zib0j4
168
+
169
+ ## Build
170
+
171
+ Minotaur was built with [Axolotl](https://github.com/OpenAccess-AI-Collective/axolotl) on 7xA100 80GB
172
+ - 3 epochs taking approximately 6 hours
173
+
174
+ ## Bias, Risks, and Limitations
175
+ Minotaur has not been aligned to human preferences with techniques like RLHF or deployed with in-the-loop filtering of responses like ChatGPT, so the model can produce problematic outputs (especially when prompted to do so).
176
+ Minotaur was fine-tuned from the base model MPT-7B, please refer to its model card's Limitations Section for relevant information. (included below)
177
+
178
+ ## Examples - results may vary based on temperature and other settings
179
+
180
+ ```
181
+ USER: your have 3 apples. you eat 2 pears. how many apples do you have left?
182
+ ASSISTANT:To find the quantity of apples, we can subtract the number of pears from the number of apples.
183
+
184
+ In this case, there are 3 apples and 2 pears. This means there are 3 apples left.
185
+ ```
186
+ wut?
187
+
188
+
189
+ ```
190
+ USER: your have 3 apples. you eat 2 pears. how many apples do you have left?
191
+ ASSISTANT:You don't have any apples left. You had 3 and after eating 2 pears, it is 2. You ate the other apple.
192
+ ```
193
+ 🤣
194
+
195
+
196
+ ```
197
+ A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
198
+ USER: your have 3 apples. you eat 2 pears. how many apples do you have left? Use multi-step reasoning.
199
+ ASSISTANT: I understand. You have three apples, two pears, and you ate two of the pears. You have three apples left.
200
+ ```
201
+ 👌 looks like you need the system prompt
202
+
203
+ ```
204
+ A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
205
+ USER: Solve for x: 5x = 3x + 10
206
+ ASSISTANT: To find the value of x, you can solve this equation by first adding both sides of the equation, as follows:
207
+ 5x = 3x + 10
208
+ Now, simplify the equation to get:
209
+ x = 2.5
210
+ ```
211
+ yup, it still sucks at math
212
+
213
+ ```
214
+ USER: tell me a joke. then explain why it's funny.
215
+
216
+ ASSISTANT: What did the blind man say to the man eating steak?
217
+ He said, "Is that a cow or a sandwich?"
218
+ ```
219
+
220
+ ```
221
+ USER: write a sonnet about doves
222
+
223
+ ASSISTANT:Doves are a beautiful bird, and you can write a sonnet about them to express your love for them. This sonnet can include imagery of doves, including the sound of their wings as they fly, the softness of their feathers, and the peacefulness they bring to their surroundings. The structure of this sonnet can be similar to the Shakespearean sonnets, with 14 lines divided into three groups of rhyming couplets. In the first stanza, you can express your love for doves as they are a symbol of peace and tranquility. The second stanza can describe the beauty of the dove's plumage and the softness of their feathers. The third stanza can be about the peacefulness that they bring to their surroundings, such as in a garden or park. You can end the sonnet with a final line that encapsulates your feelings about doves.
224
+
225
+ Here is the sonnet for your reference:
226
+
227
+ > Doves are a symbol of peace and tranquility,
228
+ > A gentle song that soothes the soul.
229
+ > Their soft feathers and sweet voices bring a sense of warmth and calm to their surroundings,
230
+ > And they are a welcome sight in any landscape.
231
+ >
232
+ > Their grace and beauty are a reminder of the simple pleasures in life,
233
+ > And their peaceful presence is a welcome respite from the stresses of everyday life.
234
+ >
235
+ > Doves are a symbol of love and friendship,
236
+ > And their companionship is a gift we can all cherish.
237
+ >
238
+ > Let us embrace the beauty and serenity of doves,
239
+ > And let us cherish the gift of their presence in our lives.
240
+ >
241
+ > May we always find beauty and serenity in the simple pleasures of life,
242
+ > And may we cherish the gift of friendship and love.
243
+ >
244
+ > Doves are a symbol of peace and tranquility,
245
+ > A gentle song that soothes the soul.
246
+ > Their soft feathers and sweet voices bring a sense of warmth and calm to their surroundings,
247
+ > And they are a welcome sight in any landscape.
248
+ >
249
+ > Their grace and beauty are a reminder of the simple pleasures in life,
250
+ > And their peaceful presence is a welcome respite from the stresses of everyday life.
251
+ >
252
+ > Doves are a symbol of love and friendship,
253
+ > And their companionship is a gift we can all cherish.
254
+ >
255
+ > Let us embrace the beauty and serenity of doves,
256
+ > And let us cherish the gift of their presence in our lives.
257
+ >
258
+ > May we always find beauty and serenity in the simple pleasures of life,
259
+ > And may we cherish the gift of friendship and love.
260
+ ```
261
+
262
+ # MPT-7B
263
+
264
+ MPT-7B is a decoder-style transformer pretrained from scratch on 1T tokens of English text and code.
265
+ This model was trained by [MosaicML](https://www.mosaicml.com).
266
+
267
+ MPT-7B is part of the family of MosaicPretrainedTransformer (MPT) models, which use a modified transformer architecture optimized for efficient training and inference.
268
+
269
+ These architectural changes include performance-optimized layer implementations and the elimination of context length limits by replacing
270
+ positional embeddings with Attention with Linear Biases ([ALiBi](https://arxiv.org/abs/2108.12409)).
271
+ Thanks to these modifications, MPT models can be trained with high throughput efficiency and stable convergence.
272
+ MPT models can also be served efficiently with both standard HuggingFace pipelines and NVIDIA's [FasterTransformer](https://github.com/NVIDIA/FasterTransformer).
273
+
274
+ This model uses the MosaicML LLM codebase, which can be found in the [llm-foundry repository](https://github.com/mosaicml/llm-foundry). It was trained by MosaicML’s NLP team on the [MosaicML platform](https://www.mosaicml.com/training) for LLM pretraining, finetuning, and inference.
275
+
276
+ ### How is this model different?
277
+
278
+ MPT-7B is
279
+
280
+ * **Licensed for the possibility of commercial use** (unlike [LLaMA](https://arxiv.org/abs/2302.13971)).
281
+ * **Trained on a large amount of data** (1T tokens like [LLaMA](https://arxiv.org/abs/2302.13971) vs. 300B for [Pythia](https://github.com/EleutherAI/pythia), 300B for [OpenLLaMA](https://github.com/openlm-research/open_llama), and 800B for [StableLM](https://github.com/Stability-AI/StableLM)).
282
+ * **Prepared to handle extremely long inputs** thanks to [ALiBi](https://arxiv.org/abs/2108.12409) (we finetuned [MPT-7B-StoryWriter-65k+](https://huggingface.co/mosaicml/mpt-7b-storywriter) on up to 65k inputs and can handle up to 84k vs. 2k-4k for other open source models).
283
+ * **Capable of fast training and inference** (via [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf) and [FasterTransformer](https://github.com/NVIDIA/FasterTransformer))
284
+ * **Equipped with highly efficient open-source training code** via the [llm-foundry repository](https://github.com/mosaicml/llm-foundry)
285
+
286
+ ### Models finetuned off MPT-7B:
287
+
288
+ The following models are finetuned on MPT-7B:
289
+
290
+ * [MPT-7B-StoryWriter-65k+](https://huggingface.co/mosaicml/mpt-7b-storywriter): a model designed to read and write fictional stories with super long context lengths.
291
+ Built by finetuning MPT-7B with a context length of 65k tokens on a filtered fiction subset of the [books3 dataset](https://huggingface.co/datasets/the_pile_books3).
292
+ At inference time, thanks to [ALiBi](https://arxiv.org/abs/2108.12409), MPT-7B-StoryWriter-65k+ can extrapolate even beyond 65k tokens.
293
+ We demonstrate generations as long as 80k tokens on a single A100-80GB GPU in our [blogpost](www.mosaicml.com/blog/mpt-7b).
294
+ * License: Apache 2.0
295
+
296
+ * [MPT-7B-Instruct](https://huggingface.co/mosaicml/mpt-7b-instruct): a model for short-form instruction following.
297
+ Built by finetuning MPT-7B on a [dataset](https://huggingface.co/datasets/mosaicml/dolly_hhrlhf) we also release, 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.
298
+ * License: _CC-By-SA-3.0_
299
+ * [Demo on Hugging Face Spaces](https://huggingface.co/spaces/mosaicml/mpt-7b-instruct)
300
+
301
+ * [MPT-7B-Chat](https://huggingface.co/mosaicml/mpt-7b-chat): a chatbot-like model for dialogue generation.
302
+ Built by finetuning MPT-7B on the [ShareGPT-Vicuna](https://huggingface.co/datasets/jeffwan/sharegpt_vicuna), [HC3](https://huggingface.co/datasets/Hello-SimpleAI/HC3),
303
+ [Alpaca](https://huggingface.co/datasets/tatsu-lab/alpaca), [HH-RLHF](https://huggingface.co/datasets/Anthropic/hh-rlhf), and [Evol-Instruct](https://huggingface.co/datasets/victor123/evol_instruct_70k) datasets.
304
+ * License: _CC-By-NC-SA-4.0_
305
+ * [Demo on Hugging Face Spaces](https://huggingface.co/spaces/mosaicml/mpt-7b-chat)
306
+
307
+ ## Model Date
308
+
309
+ May 5, 2023
310
+
311
+ ## Model License
312
+
313
+ Apache-2.0
314
+
315
+ ## Documentation
316
+
317
+ * [Blog post: Introducing MPT-7B: A New Standard for Open-Source, Commercially Usable LLMs](https://www.mosaicml.com/blog/mpt-7b)
318
+ * [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
319
+ * Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
320
+
321
+
322
+ ## How to Use
323
+
324
+ This model is best used with the MosaicML [llm-foundry repository](https://github.com/mosaicml/llm-foundry) for training and finetuning.
325
+
326
+ ```python
327
+ import transformers
328
+ model = transformers.AutoModelForCausalLM.from_pretrained(
329
+ 'mosaicml/mpt-7b',
330
+ trust_remote_code=True
331
+ )
332
+ ```
333
+ Note: This model requires that `trust_remote_code=True` be passed to the `from_pretrained` method.
334
+ This is because we use a custom `MPT` model architecture that is not yet part of the Hugging Face `transformers` package.
335
+ `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.
336
+
337
+ 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:
338
+ ```python
339
+ import torch
340
+ import transformers
341
+
342
+ name = 'mosaicml/mpt-7b'
343
+
344
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
345
+ config.attn_config['attn_impl'] = 'triton'
346
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
347
+
348
+ model = transformers.AutoModelForCausalLM.from_pretrained(
349
+ name,
350
+ config=config,
351
+ torch_dtype=torch.bfloat16, # Load model weights in bfloat16
352
+ trust_remote_code=True
353
+ )
354
+ ```
355
+
356
+ Although the model was trained with a sequence length of 2048, ALiBi enables users to increase the maximum sequence length during finetuning and/or inference. For example:
357
+
358
+ ```python
359
+ import transformers
360
+
361
+ name = 'mosaicml/mpt-7b'
362
+
363
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
364
+ config.max_seq_len = 4096 # (input + output) tokens can now be up to 4096
365
+
366
+ model = transformers.AutoModelForCausalLM.from_pretrained(
367
+ name,
368
+ config=config,
369
+ trust_remote_code=True
370
+ )
371
+ ```
372
+
373
+ This model was trained with the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer.
374
+
375
+ ```python
376
+ from transformers import AutoTokenizer
377
+ tokenizer = AutoTokenizer.from_pretrained('EleutherAI/gpt-neox-20b')
378
+ ```
379
+
380
+ ## Model Description
381
+
382
+ The architecture is a modification of a standard decoder-only transformer.
383
+
384
+ The model has been modified from a standard transformer in the following ways:
385
+ * It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
386
+ * It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
387
+ * It does not use biases
388
+
389
+
390
+ | Hyperparameter | Value |
391
+ |----------------|-------|
392
+ |n_parameters | 6.7B |
393
+ |n_layers | 32 |
394
+ | n_heads | 32 |
395
+ | d_model | 4096 |
396
+ | vocab size | 50432 |
397
+ | sequence length | 2048 |
398
+
399
+
400
+
401
+ ## Training Data
402
+
403
+ ### Streaming Datasets
404
+
405
+ Data was formatted using the MosaicML [StreamingDataset](https://github.com/mosaicml/streaming) library to host our data in object storage and efficiently stream it to our compute cluster during training.
406
+ StreamingDataset obviates the need to download the whole dataset before starting training, and allows instant resumption of training from any point in the dataset.
407
+
408
+
409
+ ### Data Mix
410
+
411
+ The model was trained for 1T tokens (with batch size 1760 and sequence length 2048). It was trained on the following data mix:
412
+
413
+
414
+ | Data Source | Number of Tokens in Source | Proportion | Effective Number of Tokens | Epochs |
415
+ |-------------|----------------------------|------------|----------------------------|--------|
416
+ | mC4 3.1.0 - English | 417.99 B | 0.33 | 330 B | 0.14 |
417
+ | C4 - English - SemDedup 80% | 100.42 B | 0.299 | 299 B | 2.98 |
418
+ | RedPajama - CommonCrawl | 878.45 B | 0.1 | 100 B | 0.11 |
419
+ | The Stack - Selected Languages | 463.78 B | 0.1 | 100 B | 0.22 |
420
+ | RedPajama - Wikipedia - En | 4.87 B | 0.04 | 40 B | 8.21 |
421
+ | The Stack - Markdown | 107.07 B | 0.035 | 35 B | 0.33 |
422
+ | S2ORC | 48.85 B | 0.033 | 33 B | 0.68 |
423
+ | RedPajama - Books | 26.02 B | 0.03 | 30B | 1.15 |
424
+ | RedPajama - arXiv | 28.10 B | 0.019 | 19 B | 0.68 |
425
+ | RedPajama - StackExchange | 20.54 B | 0.014 | 14 B |0.68 |
426
+
427
+ Samples for each batch were selected from one of the datasets with the probability specified above.
428
+ The examples were shuffled within each dataset, and each example was constructed from as many sequences from that dataset as were necessary to fill the 2048 sequence length.
429
+
430
+ The data was tokenized using the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer. This BPE tokenizer has a number of desirable characteristics,
431
+ most of which are relevant for tokenizing code:
432
+ (1) It was trained on a diverse mix of data that includes code (The Pile)
433
+ (2) It applies consistent space delimitation, unlike the GPT2 tokenizer which tokenizes inconsistently depending on the presence of prefix spaces
434
+ (3) It contains tokens for repeated space characters, which allows superior compression of text with large amounts of repeated space characters.
435
+
436
+ The model vocabulary size of 50432 was set to be a multiple of 128 (as in [MEGATRON-LM](https://arxiv.org/abs/1909.08053)), model flop utilization (MFU) increased by up to four percentage points.
437
+
438
+ ### Training Configuration
439
+
440
+ This model was trained on 440 A100-40GBs for about 9.5 days using the [MosaicML Platform](https://www.mosaicml.com/platform).
441
+ The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the [LION](https://arxiv.org/abs/2302.06675) optimizer.
442
+
443
+ ## Limitations and Biases
444
+
445
+ _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
446
+
447
+ MPT-7B (Base) is **not** intended for deployment without finetuning.
448
+ It should not be used for human-facing interactions without further guardrails and user consent.
449
+
450
+ MPT-7B can produce factually incorrect output, and should not be relied on to produce factually accurate information.
451
+ MPT-7B was trained on various public datasets.
452
+ 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.
453
+
454
+
455
+ ## MosaicML Platform
456
+
457
+ 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).
458
+
459
+ ## Disclaimer
460
+
461
+ 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 cosult an attorney before using this model for commercial purposes.
462
+
463
+ ## Citation
464
+
465
+ Please cite this model using the following format:
466
+
467
+ ```
468
+ @online{MosaicML2023Introducing,
469
+ author = {MosaicML NLP Team},
470
+ title = {Introducing MPT-7B: A New Standard for Open-Source,
471
+ ly Usable LLMs},
472
+ year = {2023},
473
+ url = {www.mosaicml.com/blog/mpt-7b},
474
+ note = {Accessed: 2023-03-28}, % change this date
475
+ urldate = {2023-03-28} % change this date
476
+ }
477
+ ```