jay2jp commited on
Commit
a579f01
1 Parent(s): 4cffecd

Upload folder using huggingface_hub

Browse files
.ipynb_checkpoints/requirements-checkpoint.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ auto-gptq==0.6.0
README.md ADDED
@@ -0,0 +1,499 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 - AWQ
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 AWQ model files for [Mistral AI_'s Mixtral 8X7B Instruct v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1).
70
+
71
+
72
+ ### About AWQ
73
+
74
+ AWQ is an efficient, accurate and blazing-fast low-bit weight quantization method, currently supporting 4-bit quantization. Compared to GPTQ, it offers faster Transformers-based inference with equivalent or better quality compared to the most commonly used GPTQ settings.
75
+
76
+ AWQ models are currently supported on Linux and Windows, with NVidia GPUs only. macOS users: please use GGUF models instead.
77
+
78
+ It is supported by:
79
+
80
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
81
+ - [vLLM](https://github.com/vllm-project/vllm) - version 0.2.2 or later for support for all model types.
82
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
83
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later, from any code or client that supports Transformers
84
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
85
+
86
+ <!-- description end -->
87
+ <!-- repositories-available start -->
88
+ ## Repositories available
89
+
90
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ)
91
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GPTQ)
92
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF)
93
+ * [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)
94
+ <!-- repositories-available end -->
95
+
96
+ <!-- prompt-template start -->
97
+ ## Prompt template: Mistral
98
+
99
+ ```
100
+ [INST] {prompt} [/INST]
101
+
102
+ ```
103
+
104
+ <!-- prompt-template end -->
105
+
106
+
107
+ <!-- README_AWQ.md-provided-files start -->
108
+ ## Provided files, and AWQ parameters
109
+
110
+ I currently release 128g GEMM models only. The addition of group_size 32 models, and GEMV kernel models, is being actively considered.
111
+
112
+ Models are released as sharded safetensors files.
113
+
114
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
115
+ | ------ | ---- | -- | ----------- | ------- | ---- |
116
+ | main | 4 | 128 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 8192 | 24.65 GB
117
+
118
+ <!-- README_AWQ.md-provided-files end -->
119
+
120
+ <!-- README_AWQ.md-text-generation-webui start -->
121
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
122
+
123
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
124
+
125
+ It is strongly recommended to use the text-generation-webui one-click-installers unless you're sure you know how to make a manual install.
126
+
127
+ 1. Click the **Model tab**.
128
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ`.
129
+ 3. Click **Download**.
130
+ 4. The model will start downloading. Once it's finished it will say "Done".
131
+ 5. In the top left, click the refresh icon next to **Model**.
132
+ 6. In the **Model** dropdown, choose the model you just downloaded: `Mixtral-8x7B-Instruct-v0.1-AWQ`
133
+ 7. Select **Loader: AutoAWQ**.
134
+ 8. Click Load, and the model will load and is now ready for use.
135
+ 9. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
136
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
137
+ <!-- README_AWQ.md-text-generation-webui end -->
138
+
139
+ <!-- README_AWQ.md-use-from-vllm start -->
140
+ ## Multi-user inference server: vLLM
141
+
142
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
143
+
144
+ - Please ensure you are using vLLM version 0.2 or later.
145
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
146
+
147
+ For example:
148
+
149
+ ```shell
150
+ python3 -m vllm.entrypoints.api_server --model TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ --quantization awq --dtype auto
151
+ ```
152
+
153
+ - When using vLLM from Python code, again set `quantization=awq`.
154
+
155
+ For example:
156
+
157
+ ```python
158
+ from vllm import LLM, SamplingParams
159
+
160
+ prompts = [
161
+ "Tell me about AI",
162
+ "Write a story about llamas",
163
+ "What is 291 - 150?",
164
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
165
+ ]
166
+ prompt_template=f'''[INST] {prompt} [/INST]
167
+ '''
168
+
169
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
170
+
171
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
172
+
173
+ llm = LLM(model="TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ", quantization="awq", dtype="auto")
174
+
175
+ outputs = llm.generate(prompts, sampling_params)
176
+
177
+ # Print the outputs.
178
+ for output in outputs:
179
+ prompt = output.prompt
180
+ generated_text = output.outputs[0].text
181
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
182
+ ```
183
+ <!-- README_AWQ.md-use-from-vllm start -->
184
+
185
+ <!-- README_AWQ.md-use-from-tgi start -->
186
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
187
+
188
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
189
+
190
+ Example Docker parameters:
191
+
192
+ ```shell
193
+ --model-id TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
194
+ ```
195
+
196
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
197
+
198
+ ```shell
199
+ pip3 install huggingface-hub
200
+ ```
201
+
202
+ ```python
203
+ from huggingface_hub import InferenceClient
204
+
205
+ endpoint_url = "https://your-endpoint-url-here"
206
+
207
+ prompt = "Tell me about AI"
208
+ prompt_template=f'''[INST] {prompt} [/INST]
209
+ '''
210
+
211
+ client = InferenceClient(endpoint_url)
212
+ response = client.text_generation(prompt,
213
+ max_new_tokens=128,
214
+ do_sample=True,
215
+ temperature=0.7,
216
+ top_p=0.95,
217
+ top_k=40,
218
+ repetition_penalty=1.1)
219
+
220
+ print(f"Model output: ", response)
221
+ ```
222
+ <!-- README_AWQ.md-use-from-tgi end -->
223
+
224
+ <!-- README_AWQ.md-use-from-python start -->
225
+ ## Inference from Python code using Transformers
226
+
227
+ ### Install the necessary packages
228
+
229
+ - Requires: [Transformers](https://huggingface.co/docs/transformers) 4.35.0 or later.
230
+ - Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.6 or later.
231
+
232
+ ```shell
233
+ pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"
234
+ ```
235
+
236
+ Note that if you are using PyTorch 2.0.1, the above AutoAWQ command will automatically upgrade you to PyTorch 2.1.0.
237
+
238
+ If you are using CUDA 11.8 and wish to continue using PyTorch 2.0.1, instead run this command:
239
+
240
+ ```shell
241
+ pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl
242
+ ```
243
+
244
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
245
+
246
+ ```shell
247
+ pip3 uninstall -y autoawq
248
+ git clone https://github.com/casper-hansen/AutoAWQ
249
+ cd AutoAWQ
250
+ pip3 install .
251
+ ```
252
+
253
+ ### Transformers example code (requires Transformers 4.35.0 and later)
254
+
255
+ ```python
256
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
257
+
258
+ model_name_or_path = "TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ"
259
+
260
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
261
+ model = AutoModelForCausalLM.from_pretrained(
262
+ model_name_or_path,
263
+ low_cpu_mem_usage=True,
264
+ device_map="cuda:0"
265
+ )
266
+
267
+ # Using the text streamer to stream output one token at a time
268
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
269
+
270
+ prompt = "Tell me about AI"
271
+ prompt_template=f'''[INST] {prompt} [/INST]
272
+ '''
273
+
274
+ # Convert prompt to tokens
275
+ tokens = tokenizer(
276
+ prompt_template,
277
+ return_tensors='pt'
278
+ ).input_ids.cuda()
279
+
280
+ generation_params = {
281
+ "do_sample": True,
282
+ "temperature": 0.7,
283
+ "top_p": 0.95,
284
+ "top_k": 40,
285
+ "max_new_tokens": 512,
286
+ "repetition_penalty": 1.1
287
+ }
288
+
289
+ # Generate streamed output, visible one token at a time
290
+ generation_output = model.generate(
291
+ tokens,
292
+ streamer=streamer,
293
+ **generation_params
294
+ )
295
+
296
+ # Generation without a streamer, which will include the prompt in the output
297
+ generation_output = model.generate(
298
+ tokens,
299
+ **generation_params
300
+ )
301
+
302
+ # Get the tokens from the output, decode them, print them
303
+ token_output = generation_output[0]
304
+ text_output = tokenizer.decode(token_output)
305
+ print("model.generate output: ", text_output)
306
+
307
+ # Inference is also possible via Transformers' pipeline
308
+ from transformers import pipeline
309
+
310
+ pipe = pipeline(
311
+ "text-generation",
312
+ model=model,
313
+ tokenizer=tokenizer,
314
+ **generation_params
315
+ )
316
+
317
+ pipe_output = pipe(prompt_template)[0]['generated_text']
318
+ print("pipeline output: ", pipe_output)
319
+
320
+ ```
321
+ <!-- README_AWQ.md-use-from-python end -->
322
+
323
+ <!-- README_AWQ.md-compatibility start -->
324
+ ## Compatibility
325
+
326
+ The files provided are tested to work with:
327
+
328
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
329
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
330
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
331
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later.
332
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
333
+
334
+ <!-- README_AWQ.md-compatibility end -->
335
+
336
+ <!-- footer start -->
337
+ <!-- 200823 -->
338
+ ## Discord
339
+
340
+ For further support, and discussions on these models and AI in general, join us at:
341
+
342
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
343
+
344
+ ## Thanks, and how to contribute
345
+
346
+ Thanks to the [chirper.ai](https://chirper.ai) team!
347
+
348
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
349
+
350
+ 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.
351
+
352
+ 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.
353
+
354
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
355
+
356
+ * Patreon: https://patreon.com/TheBlokeAI
357
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
358
+
359
+ **Special thanks to**: Aemon Algiz.
360
+
361
+ **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
362
+
363
+
364
+ Thank you to all my generous patrons and donaters!
365
+
366
+ And thank you again to a16z for their generous grant.
367
+
368
+ <!-- footer end -->
369
+
370
+ # Original model card: Mistral AI_'s Mixtral 8X7B Instruct v0.1
371
+
372
+ # Model Card for Mixtral-8x7B
373
+ 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.
374
+
375
+ For full details of this model please read our [release blog post](https://mistral.ai/news/mixtral-of-experts/).
376
+
377
+ ## Warning
378
+ 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.
379
+
380
+ ## Instruction format
381
+
382
+ This format must be strictly respected, otherwise the model will generate sub-optimal outputs.
383
+
384
+ The template used to build a prompt for the Instruct model is defined as follows:
385
+ ```
386
+ <s> [INST] Instruction [/INST] Model answer</s> [INST] Follow-up instruction [/INST]
387
+ ```
388
+ 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.
389
+
390
+ As reference, here is the pseudo-code used to tokenize instructions during fine-tuning:
391
+ ```python
392
+ def tokenize(text):
393
+ return tok.encode(text, add_special_tokens=False)
394
+
395
+ [BOS_ID] +
396
+ tokenize("[INST]") + tokenize(USER_MESSAGE_1) + tokenize("[/INST]") +
397
+ tokenize(BOT_MESSAGE_1) + [EOS_ID] +
398
+
399
+ tokenize("[INST]") + tokenize(USER_MESSAGE_N) + tokenize("[/INST]") +
400
+ tokenize(BOT_MESSAGE_N) + [EOS_ID]
401
+ ```
402
+
403
+ 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.
404
+
405
+ ## Run the model
406
+
407
+ ```python
408
+ from transformers import AutoModelForCausalLM, AutoTokenizer
409
+
410
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
411
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
412
+
413
+ model = AutoModelForCausalLM.from_pretrained(model_id)
414
+
415
+ text = "Hello my name is"
416
+ inputs = tokenizer(text, return_tensors="pt")
417
+
418
+ outputs = model.generate(**inputs, max_new_tokens=20)
419
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
420
+ ```
421
+
422
+ 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:
423
+
424
+ ### In half-precision
425
+
426
+ Note `float16` precision only works on GPU devices
427
+
428
+ <details>
429
+ <summary> Click to expand </summary>
430
+
431
+ ```diff
432
+ + import torch
433
+ from transformers import AutoModelForCausalLM, AutoTokenizer
434
+
435
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
436
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
437
+
438
+ + model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16).to(0)
439
+
440
+ text = "Hello my name is"
441
+ + inputs = tokenizer(text, return_tensors="pt").to(0)
442
+
443
+ outputs = model.generate(**inputs, max_new_tokens=20)
444
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
445
+ ```
446
+ </details>
447
+
448
+ ### Lower precision using (8-bit & 4-bit) using `bitsandbytes`
449
+
450
+ <details>
451
+ <summary> Click to expand </summary>
452
+
453
+ ```diff
454
+ + import torch
455
+ from transformers import AutoModelForCausalLM, AutoTokenizer
456
+
457
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
458
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
459
+
460
+ + model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True)
461
+
462
+ text = "Hello my name is"
463
+ + inputs = tokenizer(text, return_tensors="pt").to(0)
464
+
465
+ outputs = model.generate(**inputs, max_new_tokens=20)
466
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
467
+ ```
468
+ </details>
469
+
470
+ ### Load the model with Flash Attention 2
471
+
472
+ <details>
473
+ <summary> Click to expand </summary>
474
+
475
+ ```diff
476
+ + import torch
477
+ from transformers import AutoModelForCausalLM, AutoTokenizer
478
+
479
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
480
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
481
+
482
+ + model = AutoModelForCausalLM.from_pretrained(model_id, use_flash_attention_2=True)
483
+
484
+ text = "Hello my name is"
485
+ + inputs = tokenizer(text, return_tensors="pt").to(0)
486
+
487
+ outputs = model.generate(**inputs, max_new_tokens=20)
488
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
489
+ ```
490
+ </details>
491
+
492
+ ## Limitations
493
+
494
+ The Mixtral-8x7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
495
+ It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
496
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
497
+
498
+ # The Mistral AI Team
499
+ 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.
config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/workspace/process/mistralai_mixtral-8x7b-instruct-v0.1/source",
3
+ "architectures": [
4
+ "MixtralForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 1,
8
+ "eos_token_id": 2,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 4096,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 14336,
13
+ "max_position_embeddings": 32768,
14
+ "model_type": "mixtral",
15
+ "num_attention_heads": 32,
16
+ "num_experts_per_tok": 2,
17
+ "num_hidden_layers": 32,
18
+ "num_key_value_heads": 8,
19
+ "num_local_experts": 8,
20
+ "output_router_logits": false,
21
+ "pad_token_id": 0,
22
+ "pretraining_tp": 1,
23
+ "quantization_config": {
24
+ "bits": 4,
25
+ "group_size": 128,
26
+ "modules_to_not_convert": [
27
+ "gate"
28
+ ],
29
+ "quant_method": "awq",
30
+ "version": "gemm",
31
+ "zero_point": true
32
+ },
33
+ "rms_norm_eps": 1e-05,
34
+ "rope_theta": 1000000.0,
35
+ "router_aux_loss_coef": 0.02,
36
+ "sliding_window": 4096,
37
+ "tie_word_embeddings": false,
38
+ "torch_dtype": "float16",
39
+ "transformers_version": "4.36.0.dev0",
40
+ "use_cache": true,
41
+ "vocab_size": 32000
42
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.36.0.dev0"
6
+ }
model-00001-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6251f54496d2946e844b2397b8b1cb45a16ea5327e189bf7ddacb82d24553790
3
+ size 9973278720
model-00002-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1233c8a0c379c11503565e773f0bacc1b8cafa582e22a356c92b61c913eab2f
3
+ size 9977085640
model-00003-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1073cbc34284f6e96916d9369718cb7bcbb174af451a5424535e29fab31eb019
3
+ size 4703590984
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
quant_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "zero_point": true,
3
+ "q_group_size": 128,
4
+ "w_bit": 4,
5
+ "version": "GEMM",
6
+ "modules_to_not_convert": [
7
+ "gate"
8
+ ]
9
+ }
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ auto-gptq==0.6.0
special_tokens_map.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "unk_token": "<unk>"
5
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dadfd56d766715c61d2ef780a525ab43b8e6da4de6865bda3d95fdef5e134055
3
+ size 493443
tokenizer_config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "0": {
6
+ "content": "<unk>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "1": {
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "2": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ }
29
+ },
30
+ "additional_special_tokens": [],
31
+ "bos_token": "<s>",
32
+ "clean_up_tokenization_spaces": false,
33
+ "eos_token": "</s>",
34
+ "legacy": true,
35
+ "model_max_length": 1000000000000000019884624838656,
36
+ "pad_token": null,
37
+ "sp_model_kwargs": {},
38
+ "spaces_between_special_tokens": false,
39
+ "tokenizer_class": "LlamaTokenizer",
40
+ "unk_token": "<unk>",
41
+ "use_default_system_prompt": false,
42
+ "chat_template": "{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}"
43
+ }