jartine commited on
Commit
29fb37a
1 Parent(s): 71973b5

Add README.md to repo

Browse files
Files changed (1) hide show
  1. README.md +474 -0
README.md ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: mistralai/Mixtral-8x7B-Instruct-v0.1
3
+ inference: false
4
+ language:
5
+ - fr
6
+ - it
7
+ - de
8
+ - es
9
+ - en
10
+ license: apache-2.0
11
+ model_creator: Mistral AI_
12
+ model_name: Mixtral 8X7B Instruct v0.1
13
+ model_type: mixtral
14
+ prompt_template: '[INST] {prompt} [/INST]
15
+
16
+ '
17
+ quantized_by: TheBloke
18
+ widget:
19
+ - output:
20
+ text: 'Arr, shiver me timbers! Ye have a llama on yer lawn, ye say? Well, that
21
+ be a new one for me! Here''s what I''d suggest, arr:
22
+
23
+
24
+ 1. Firstly, ensure yer safety. Llamas may look gentle, but they can be protective
25
+ if they feel threatened.
26
+
27
+ 2. Try to make the area less appealing to the llama. Remove any food sources
28
+ or water that might be attracting it.
29
+
30
+ 3. Contact local animal control or a wildlife rescue organization. They be the
31
+ experts and can provide humane ways to remove the llama from yer property.
32
+
33
+ 4. If ye have any experience with animals, you could try to gently herd the
34
+ llama towards a nearby field or open space. But be careful, arr!
35
+
36
+
37
+ Remember, arr, it be important to treat the llama with respect and care. It
38
+ be a creature just trying to survive, like the rest of us.'
39
+ text: '[INST] You are a pirate chatbot who always responds with Arr and pirate speak!
40
+
41
+ There''s a llama on my lawn, how can I get rid of him? [/INST]'
42
+ ---
43
+ <!-- markdownlint-disable MD041 -->
44
+
45
+ <!-- header start -->
46
+ <!-- 200823 -->
47
+ <div style="width: auto; margin-left: auto; margin-right: auto">
48
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
49
+ </div>
50
+ <div style="display: flex; justify-content: space-between; width: 100%;">
51
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
52
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
53
+ </div>
54
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
55
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
56
+ </div>
57
+ </div>
58
+ <div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
59
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
60
+ <!-- header end -->
61
+
62
+ # Mixtral 8X7B Instruct v0.1 - GGUF
63
+ - Model creator: [Mistral AI_](https://huggingface.co/mistralai)
64
+ - Original model: [Mixtral 8X7B Instruct v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1)
65
+
66
+ <!-- description start -->
67
+ ## Description
68
+
69
+ This repo contains GGUF format model files for [Mistral AI_'s Mixtral 8X7B Instruct v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1).
70
+
71
+ <!-- description end -->
72
+ <!-- README_GGUF.md-about-gguf start -->
73
+ ### About GGUF
74
+
75
+ GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp.
76
+
77
+ ### Mixtral GGUF
78
+
79
+ Support for Mixtral was merged into Llama.cpp on December 13th.
80
+
81
+ These Mixtral GGUFs are known to work in:
82
+
83
+ * llama.cpp as of December 13th
84
+ * KoboldCpp 1.52 as later
85
+ * LM Studio 0.2.9 and later
86
+ * llama-cpp-python 0.2.23 and later
87
+
88
+ Other clients/libraries, not listed above, may not yet work.
89
+
90
+ <!-- README_GGUF.md-about-gguf end -->
91
+ <!-- repositories-available start -->
92
+ ## Repositories available
93
+
94
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ)
95
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GPTQ)
96
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF)
97
+ * [Mistral AI_'s original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1)
98
+ <!-- repositories-available end -->
99
+
100
+ <!-- prompt-template start -->
101
+ ## Prompt template: Mistral
102
+
103
+ ```
104
+ [INST] {prompt} [/INST]
105
+
106
+ ```
107
+
108
+ <!-- prompt-template end -->
109
+
110
+
111
+ <!-- compatibility_gguf start -->
112
+ ## Compatibility
113
+
114
+ These Mixtral GGUFs are compatible with llama.cpp from December 13th onwards. Other clients/libraries may not work yet.
115
+
116
+ ## Explanation of quantisation methods
117
+
118
+ <details>
119
+ <summary>Click to see details</summary>
120
+
121
+ The new methods available are:
122
+
123
+ * 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)
124
+ * 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.
125
+ * 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.
126
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
127
+ * 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
128
+
129
+ Refer to the Provided Files table below to see what files use which methods, and how.
130
+ </details>
131
+ <!-- compatibility_gguf end -->
132
+
133
+ <!-- README_GGUF.md-provided-files start -->
134
+ ## Provided files
135
+
136
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
137
+ | ---- | ---- | ---- | ---- | ---- | ----- |
138
+ | [mixtral-8x7b-instruct-v0.1.Q2_K.gguf](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/blob/main/mixtral-8x7b-instruct-v0.1.Q2_K.gguf) | Q2_K | 2 | 15.64 GB| 18.14 GB | smallest, significant quality loss - not recommended for most purposes |
139
+ | [mixtral-8x7b-instruct-v0.1.Q3_K_M.gguf](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/blob/main/mixtral-8x7b-instruct-v0.1.Q3_K_M.gguf) | Q3_K_M | 3 | 20.36 GB| 22.86 GB | very small, high quality loss |
140
+ | [mixtral-8x7b-instruct-v0.1.Q4_0.gguf](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/blob/main/mixtral-8x7b-instruct-v0.1.Q4_0.gguf) | Q4_0 | 4 | 26.44 GB| 28.94 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
141
+ | [mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/blob/main/mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf) | Q4_K_M | 4 | 26.44 GB| 28.94 GB | medium, balanced quality - recommended |
142
+ | [mixtral-8x7b-instruct-v0.1.Q5_0.gguf](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/blob/main/mixtral-8x7b-instruct-v0.1.Q5_0.gguf) | Q5_0 | 5 | 32.23 GB| 34.73 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
143
+ | [mixtral-8x7b-instruct-v0.1.Q5_K_M.gguf](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/blob/main/mixtral-8x7b-instruct-v0.1.Q5_K_M.gguf) | Q5_K_M | 5 | 32.23 GB| 34.73 GB | large, very low quality loss - recommended |
144
+ | [mixtral-8x7b-instruct-v0.1.Q6_K.gguf](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/blob/main/mixtral-8x7b-instruct-v0.1.Q6_K.gguf) | Q6_K | 6 | 38.38 GB| 40.88 GB | very large, extremely low quality loss |
145
+ | [mixtral-8x7b-instruct-v0.1.Q8_0.gguf](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/blob/main/mixtral-8x7b-instruct-v0.1.Q8_0.gguf) | Q8_0 | 8 | 49.62 GB| 52.12 GB | very large, extremely low quality loss - not recommended |
146
+
147
+ **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.
148
+
149
+
150
+
151
+ <!-- README_GGUF.md-provided-files end -->
152
+
153
+ <!-- README_GGUF.md-how-to-download start -->
154
+ ## How to download GGUF files
155
+
156
+ **Note for manual downloaders:** You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single file.
157
+
158
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
159
+
160
+ * LM Studio
161
+ * LoLLMS Web UI
162
+ * Faraday.dev
163
+
164
+ ### In `text-generation-webui`
165
+
166
+ Under Download Model, you can enter the model repo: TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF and below it, a specific filename to download, such as: mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf.
167
+
168
+ Then click Download.
169
+
170
+ ### On the command line, including multiple files at once
171
+
172
+ I recommend using the `huggingface-hub` Python library:
173
+
174
+ ```shell
175
+ pip3 install huggingface-hub
176
+ ```
177
+
178
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
179
+
180
+ ```shell
181
+ huggingface-cli download TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
182
+ ```
183
+
184
+ <details>
185
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
186
+
187
+ You can also download multiple files at once with a pattern:
188
+
189
+ ```shell
190
+ huggingface-cli download TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
191
+ ```
192
+
193
+ For more documentation on downloading with `huggingface-cli`, please see: [HF -> Hub Python Library -> Download files -> Download from the CLI](https://huggingface.co/docs/huggingface_hub/guides/download#download-from-the-cli).
194
+
195
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
196
+
197
+ ```shell
198
+ pip3 install hf_transfer
199
+ ```
200
+
201
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
202
+
203
+ ```shell
204
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
205
+ ```
206
+
207
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
208
+ </details>
209
+ <!-- README_GGUF.md-how-to-download end -->
210
+
211
+ <!-- README_GGUF.md-how-to-run start -->
212
+ ## Example `llama.cpp` command
213
+
214
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
215
+
216
+ ```shell
217
+ ./main -ngl 35 -m mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf --color -c 2048 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "[INST] {prompt} [/INST]"
218
+ ```
219
+
220
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
221
+
222
+ Change `-c 2048` to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically. Note that longer sequence lengths require much more resources, so you may need to reduce this value.
223
+
224
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
225
+
226
+ For other parameters and how to use them, please refer to [the llama.cpp documentation](https://github.com/ggerganov/llama.cpp/blob/master/examples/main/README.md)
227
+
228
+ ## How to run in `text-generation-webui`
229
+
230
+ Note that text-generation-webui may not yet be compatible with Mixtral GGUFs. Please check compatibility first.
231
+
232
+ Further instructions can be found in the text-generation-webui documentation, here: [text-generation-webui/docs/04 ‐ Model Tab.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/04%20%E2%80%90%20Model%20Tab.md#llamacpp).
233
+
234
+ ## How to run from Python code
235
+
236
+ You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) version 0.2.23 and later.
237
+
238
+ ### How to load this model in Python code, using llama-cpp-python
239
+
240
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
241
+
242
+ #### First install the package
243
+
244
+ Run one of the following commands, according to your system:
245
+
246
+ ```shell
247
+ # Base ctransformers with no GPU acceleration
248
+ pip install llama-cpp-python
249
+ # With NVidia CUDA acceleration
250
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
251
+ # Or with OpenBLAS acceleration
252
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
253
+ # Or with CLBLast acceleration
254
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
255
+ # Or with AMD ROCm GPU acceleration (Linux only)
256
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
257
+ # Or with Metal GPU acceleration for macOS systems only
258
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
259
+
260
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
261
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
262
+ pip install llama-cpp-python
263
+ ```
264
+
265
+ #### Simple llama-cpp-python example code
266
+
267
+ ```python
268
+ from llama_cpp import Llama
269
+
270
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
271
+ llm = Llama(
272
+ model_path="./mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf", # Download the model file first
273
+ n_ctx=2048, # The max sequence length to use - note that longer sequence lengths require much more resources
274
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
275
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
276
+ )
277
+
278
+ # Simple inference example
279
+ output = llm(
280
+ "[INST] {prompt} [/INST]", # Prompt
281
+ max_tokens=512, # Generate up to 512 tokens
282
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
283
+ echo=True # Whether to echo the prompt
284
+ )
285
+
286
+ # Chat Completion API
287
+
288
+ llm = Llama(model_path="./mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
289
+ llm.create_chat_completion(
290
+ messages = [
291
+ {"role": "system", "content": "You are a story writing assistant."},
292
+ {
293
+ "role": "user",
294
+ "content": "Write a story about llamas."
295
+ }
296
+ ]
297
+ )
298
+ ```
299
+
300
+ ## How to use with LangChain
301
+
302
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
303
+
304
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
305
+
306
+ <!-- README_GGUF.md-how-to-run end -->
307
+
308
+ <!-- footer start -->
309
+ <!-- 200823 -->
310
+ ## Discord
311
+
312
+ For further support, and discussions on these models and AI in general, join us at:
313
+
314
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
315
+
316
+ ## Thanks, and how to contribute
317
+
318
+ Thanks to the [chirper.ai](https://chirper.ai) team!
319
+
320
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
321
+
322
+ 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.
323
+
324
+ 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.
325
+
326
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
327
+
328
+ * Patreon: https://patreon.com/TheBlokeAI
329
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
330
+
331
+ **Special thanks to**: Aemon Algiz.
332
+
333
+ **Patreon special mentions**: Michael Levine, 阿明, Trailburnt, Nikolai Manek, John Detwiler, Randy H, Will Dee, Sebastain Graf, NimbleBox.ai, Eugene Pentland, Emad Mostaque, Ai Maven, Jim Angel, Jeff Scroggin, Michael Davis, Manuel Alberto Morcote, Stephen Murray, Robert, Justin Joy, Luke @flexchar, Brandon Frisco, Elijah Stavena, S_X, Dan Guido, Undi ., Komninos Chatzipapas, Shadi, theTransient, Lone Striker, Raven Klaugh, jjj, Cap'n Zoog, Michel-Marie MAUDET (LINAGORA), Matthew Berman, David, Fen Risland, Omer Bin Jawed, Luke Pendergrass, Kalila, OG, Erik Bjäreholt, Rooh Singh, Joseph William Delisle, Dan Lewis, TL, John Villwock, AzureBlack, Brad, Pedro Madruga, Caitlyn Gatomon, K, jinyuan sun, Mano Prime, Alex, Jeffrey Morgan, Alicia Loh, Illia Dulskyi, Chadd, transmissions 11, fincy, Rainer Wilmers, ReadyPlayerEmma, knownsqashed, Mandus, biorpg, Deo Leter, Brandon Phillips, SuperWojo, Sean Connelly, Iucharbius, Jack West, Harry Royden McLaughlin, Nicholas, terasurfer, Vitor Caleffi, Duane Dunston, Johann-Peter Hartmann, David Ziegler, Olakabola, Ken Nordquist, Trenton Dambrowitz, Tom X Nguyen, Vadim, Ajan Kanaga, Leonard Tan, Clay Pascal, Alexandros Triantafyllidis, JM33133, Xule, vamX, ya boyyy, subjectnull, Talal Aujan, Alps Aficionado, wassieverse, Ari Malik, James Bentley, Woland, Spencer Kim, Michael Dempsey, Fred von Graf, Elle, zynix, William Richards, Stanislav Ovsiannikov, Edmond Seymore, Jonathan Leane, Martin Kemka, usrbinkat, Enrico Ros
334
+
335
+
336
+ Thank you to all my generous patrons and donaters!
337
+
338
+ And thank you again to a16z for their generous grant.
339
+
340
+ <!-- footer end -->
341
+
342
+ <!-- original-model-card start -->
343
+ # Original model card: Mistral AI_'s Mixtral 8X7B Instruct v0.1
344
+
345
+ # Model Card for Mixtral-8x7B
346
+ The Mixtral-8x7B Large Language Model (LLM) is a pretrained generative Sparse Mixture of Experts. The Mixtral-8x7B outperforms Llama 2 70B on most benchmarks we tested.
347
+
348
+ For full details of this model please read our [release blog post](https://mistral.ai/news/mixtral-of-experts/).
349
+
350
+ ## Warning
351
+ This repo contains weights that are compatible with [vLLM](https://github.com/vllm-project/vllm) serving of the model as well as Hugging Face [transformers](https://github.com/huggingface/transformers) library. It is based on the original Mixtral [torrent release](magnet:?xt=urn:btih:5546272da9065eddeb6fcd7ffddeef5b75be79a7&dn=mixtral-8x7b-32kseqlen&tr=udp%3A%2F%http://2Fopentracker.i2p.rocks%3A6969%2Fannounce&tr=http%3A%2F%http://2Ftracker.openbittorrent.com%3A80%2Fannounce), but the file format and parameter names are different. Please note that model cannot (yet) be instantiated with HF.
352
+
353
+ ## Instruction format
354
+
355
+ This format must be strictly respected, otherwise the model will generate sub-optimal outputs.
356
+
357
+ The template used to build a prompt for the Instruct model is defined as follows:
358
+ ```
359
+ <s> [INST] Instruction [/INST] Model answer</s> [INST] Follow-up instruction [/INST]
360
+ ```
361
+ Note that `<s>` and `</s>` are special tokens for beginning of string (BOS) and end of string (EOS) while [INST] and [/INST] are regular strings.
362
+
363
+ As reference, here is the pseudo-code used to tokenize instructions during fine-tuning:
364
+ ```python
365
+ def tokenize(text):
366
+ return tok.encode(text, add_special_tokens=False)
367
+
368
+ [BOS_ID] +
369
+ tokenize("[INST]") + tokenize(USER_MESSAGE_1) + tokenize("[/INST]") +
370
+ tokenize(BOT_MESSAGE_1) + [EOS_ID] +
371
+
372
+ tokenize("[INST]") + tokenize(USER_MESSAGE_N) + tokenize("[/INST]") +
373
+ tokenize(BOT_MESSAGE_N) + [EOS_ID]
374
+ ```
375
+
376
+ In the pseudo-code above, note that the `tokenize` method should not add a BOS or EOS token automatically, but should add a prefix space.
377
+
378
+ ## Run the model
379
+
380
+ ```python
381
+ from transformers import AutoModelForCausalLM, AutoTokenizer
382
+
383
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
384
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
385
+
386
+ model = AutoModelForCausalLM.from_pretrained(model_id)
387
+
388
+ text = "Hello my name is"
389
+ inputs = tokenizer(text, return_tensors="pt")
390
+
391
+ outputs = model.generate(**inputs, max_new_tokens=20)
392
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
393
+ ```
394
+
395
+ By default, transformers will load the model in full precision. Therefore you might be interested to further reduce down the memory requirements to run the model through the optimizations we offer in HF ecosystem:
396
+
397
+ ### In half-precision
398
+
399
+ Note `float16` precision only works on GPU devices
400
+
401
+ <details>
402
+ <summary> Click to expand </summary>
403
+
404
+ ```diff
405
+ + import torch
406
+ from transformers import AutoModelForCausalLM, AutoTokenizer
407
+
408
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
409
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
410
+
411
+ + model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16).to(0)
412
+
413
+ text = "Hello my name is"
414
+ + inputs = tokenizer(text, return_tensors="pt").to(0)
415
+
416
+ outputs = model.generate(**inputs, max_new_tokens=20)
417
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
418
+ ```
419
+ </details>
420
+
421
+ ### Lower precision using (8-bit & 4-bit) using `bitsandbytes`
422
+
423
+ <details>
424
+ <summary> Click to expand </summary>
425
+
426
+ ```diff
427
+ + import torch
428
+ from transformers import AutoModelForCausalLM, AutoTokenizer
429
+
430
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
431
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
432
+
433
+ + model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True)
434
+
435
+ text = "Hello my name is"
436
+ + inputs = tokenizer(text, return_tensors="pt").to(0)
437
+
438
+ outputs = model.generate(**inputs, max_new_tokens=20)
439
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
440
+ ```
441
+ </details>
442
+
443
+ ### Load the model with Flash Attention 2
444
+
445
+ <details>
446
+ <summary> Click to expand </summary>
447
+
448
+ ```diff
449
+ + import torch
450
+ from transformers import AutoModelForCausalLM, AutoTokenizer
451
+
452
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
453
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
454
+
455
+ + model = AutoModelForCausalLM.from_pretrained(model_id, use_flash_attention_2=True)
456
+
457
+ text = "Hello my name is"
458
+ + inputs = tokenizer(text, return_tensors="pt").to(0)
459
+
460
+ outputs = model.generate(**inputs, max_new_tokens=20)
461
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
462
+ ```
463
+ </details>
464
+
465
+ ## Limitations
466
+
467
+ The Mixtral-8x7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
468
+ It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
469
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
470
+
471
+ # The Mistral AI Team
472
+ Albert Jiang, Alexandre Sablayrolles, Arthur Mensch, Blanche Savary, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Emma Bou Hanna, Florian Bressand, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Lélio Renard Lavaud, Louis Ternon, Lucile Saulnier, Marie-Anne Lachaux, Pierre Stock, Teven Le Scao, Théophile Gervet, Thibaut Lavril, Thomas Wang, Timothée Lacroix, William El Sayed.
473
+
474
+ <!-- original-model-card end -->