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
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: '<s>[INST] {prompt} [/INST]
|
15 |
+
|
16 |
+
'
|
17 |
+
quantized_by: TheBloke
|
18 |
+
---
|
19 |
+
<!-- markdownlint-disable MD041 -->
|
20 |
+
|
21 |
+
<!-- header start -->
|
22 |
+
<!-- 200823 -->
|
23 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
24 |
+
<img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
25 |
+
</div>
|
26 |
+
<div style="display: flex; justify-content: space-between; width: 100%;">
|
27 |
+
<div style="display: flex; flex-direction: column; align-items: flex-start;">
|
28 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
|
29 |
+
</div>
|
30 |
+
<div style="display: flex; flex-direction: column; align-items: flex-end;">
|
31 |
+
<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>
|
32 |
+
</div>
|
33 |
+
</div>
|
34 |
+
<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>
|
35 |
+
<hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
|
36 |
+
<!-- header end -->
|
37 |
+
|
38 |
+
# Mixtral 8X7B Instruct v0.1 - AWQ
|
39 |
+
- Model creator: [Mistral AI_](https://huggingface.co/mistralai)
|
40 |
+
- Original model: [Mixtral 8X7B Instruct v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1)
|
41 |
+
|
42 |
+
<!-- description start -->
|
43 |
+
## Description
|
44 |
+
|
45 |
+
This repo contains AWQ model files for [Mistral AI_'s Mixtral 8X7B Instruct v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1).
|
46 |
+
|
47 |
+
|
48 |
+
### About AWQ
|
49 |
+
|
50 |
+
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.
|
51 |
+
|
52 |
+
AWQ models are currently supported on Linux and Windows, with NVidia GPUs only. macOS users: please use GGUF models instead.
|
53 |
+
|
54 |
+
It is supported by:
|
55 |
+
|
56 |
+
- [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
|
57 |
+
- [vLLM](https://github.com/vllm-project/vllm) - version 0.2.2 or later for support for all model types.
|
58 |
+
- [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
|
59 |
+
- [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later, from any code or client that supports Transformers
|
60 |
+
- [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
|
61 |
+
|
62 |
+
<!-- description end -->
|
63 |
+
<!-- repositories-available start -->
|
64 |
+
## Repositories available
|
65 |
+
|
66 |
+
* [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ)
|
67 |
+
* [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GPTQ)
|
68 |
+
* [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF)
|
69 |
+
* [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)
|
70 |
+
<!-- repositories-available end -->
|
71 |
+
|
72 |
+
<!-- prompt-template start -->
|
73 |
+
## Prompt template: Mistral
|
74 |
+
|
75 |
+
```
|
76 |
+
<s>[INST] {prompt} [/INST]
|
77 |
+
|
78 |
+
```
|
79 |
+
|
80 |
+
<!-- prompt-template end -->
|
81 |
+
|
82 |
+
|
83 |
+
<!-- README_AWQ.md-provided-files start -->
|
84 |
+
## Provided files, and AWQ parameters
|
85 |
+
|
86 |
+
I currently release 128g GEMM models only. The addition of group_size 32 models, and GEMV kernel models, is being actively considered.
|
87 |
+
|
88 |
+
Models are released as sharded safetensors files.
|
89 |
+
|
90 |
+
| Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
|
91 |
+
| ------ | ---- | -- | ----------- | ------- | ---- |
|
92 |
+
| main | 4 | 128 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 8192 | 24.65 GB
|
93 |
+
|
94 |
+
<!-- README_AWQ.md-provided-files end -->
|
95 |
+
|
96 |
+
<!-- README_AWQ.md-text-generation-webui start -->
|
97 |
+
## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
|
98 |
+
|
99 |
+
Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
|
100 |
+
|
101 |
+
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.
|
102 |
+
|
103 |
+
1. Click the **Model tab**.
|
104 |
+
2. Under **Download custom model or LoRA**, enter `TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ`.
|
105 |
+
3. Click **Download**.
|
106 |
+
4. The model will start downloading. Once it's finished it will say "Done".
|
107 |
+
5. In the top left, click the refresh icon next to **Model**.
|
108 |
+
6. In the **Model** dropdown, choose the model you just downloaded: `Mixtral-8x7B-Instruct-v0.1-AWQ`
|
109 |
+
7. Select **Loader: AutoAWQ**.
|
110 |
+
8. Click Load, and the model will load and is now ready for use.
|
111 |
+
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.
|
112 |
+
10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
|
113 |
+
<!-- README_AWQ.md-text-generation-webui end -->
|
114 |
+
|
115 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
116 |
+
## Multi-user inference server: vLLM
|
117 |
+
|
118 |
+
Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
|
119 |
+
|
120 |
+
- Please ensure you are using vLLM version 0.2 or later.
|
121 |
+
- When using vLLM as a server, pass the `--quantization awq` parameter.
|
122 |
+
|
123 |
+
For example:
|
124 |
+
|
125 |
+
```shell
|
126 |
+
python3 -m vllm.entrypoints.api_server --model TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ --quantization awq --dtype auto
|
127 |
+
```
|
128 |
+
|
129 |
+
- When using vLLM from Python code, again set `quantization=awq`.
|
130 |
+
|
131 |
+
For example:
|
132 |
+
|
133 |
+
```python
|
134 |
+
from vllm import LLM, SamplingParams
|
135 |
+
|
136 |
+
prompts = [
|
137 |
+
"Tell me about AI",
|
138 |
+
"Write a story about llamas",
|
139 |
+
"What is 291 - 150?",
|
140 |
+
"How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
|
141 |
+
]
|
142 |
+
prompt_template=f'''<s>[INST] {prompt} [/INST]
|
143 |
+
'''
|
144 |
+
|
145 |
+
prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
|
146 |
+
|
147 |
+
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
|
148 |
+
|
149 |
+
llm = LLM(model="TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ", quantization="awq", dtype="auto")
|
150 |
+
|
151 |
+
outputs = llm.generate(prompts, sampling_params)
|
152 |
+
|
153 |
+
# Print the outputs.
|
154 |
+
for output in outputs:
|
155 |
+
prompt = output.prompt
|
156 |
+
generated_text = output.outputs[0].text
|
157 |
+
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
|
158 |
+
```
|
159 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
160 |
+
|
161 |
+
<!-- README_AWQ.md-use-from-tgi start -->
|
162 |
+
## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
|
163 |
+
|
164 |
+
Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
|
165 |
+
|
166 |
+
Example Docker parameters:
|
167 |
+
|
168 |
+
```shell
|
169 |
+
--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
|
170 |
+
```
|
171 |
+
|
172 |
+
Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
|
173 |
+
|
174 |
+
```shell
|
175 |
+
pip3 install huggingface-hub
|
176 |
+
```
|
177 |
+
|
178 |
+
```python
|
179 |
+
from huggingface_hub import InferenceClient
|
180 |
+
|
181 |
+
endpoint_url = "https://your-endpoint-url-here"
|
182 |
+
|
183 |
+
prompt = "Tell me about AI"
|
184 |
+
prompt_template=f'''<s>[INST] {prompt} [/INST]
|
185 |
+
'''
|
186 |
+
|
187 |
+
client = InferenceClient(endpoint_url)
|
188 |
+
response = client.text_generation(prompt,
|
189 |
+
max_new_tokens=128,
|
190 |
+
do_sample=True,
|
191 |
+
temperature=0.7,
|
192 |
+
top_p=0.95,
|
193 |
+
top_k=40,
|
194 |
+
repetition_penalty=1.1)
|
195 |
+
|
196 |
+
print(f"Model output: ", response)
|
197 |
+
```
|
198 |
+
<!-- README_AWQ.md-use-from-tgi end -->
|
199 |
+
|
200 |
+
<!-- README_AWQ.md-use-from-python start -->
|
201 |
+
## Inference from Python code using Transformers
|
202 |
+
|
203 |
+
### Install the necessary packages
|
204 |
+
|
205 |
+
- Requires: [Transformers](https://huggingface.co/docs/transformers) 4.35.0 or later.
|
206 |
+
- Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.6 or later.
|
207 |
+
|
208 |
+
```shell
|
209 |
+
pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"
|
210 |
+
```
|
211 |
+
|
212 |
+
Note that if you are using PyTorch 2.0.1, the above AutoAWQ command will automatically upgrade you to PyTorch 2.1.0.
|
213 |
+
|
214 |
+
If you are using CUDA 11.8 and wish to continue using PyTorch 2.0.1, instead run this command:
|
215 |
+
|
216 |
+
```shell
|
217 |
+
pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl
|
218 |
+
```
|
219 |
+
|
220 |
+
If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
|
221 |
+
|
222 |
+
```shell
|
223 |
+
pip3 uninstall -y autoawq
|
224 |
+
git clone https://github.com/casper-hansen/AutoAWQ
|
225 |
+
cd AutoAWQ
|
226 |
+
pip3 install .
|
227 |
+
```
|
228 |
+
|
229 |
+
### Transformers example code (requires Transformers 4.35.0 and later)
|
230 |
+
|
231 |
+
```python
|
232 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
233 |
+
|
234 |
+
model_name_or_path = "TheBloke/Mixtral-8x7B-Instruct-v0.1-AWQ"
|
235 |
+
|
236 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
|
237 |
+
model = AutoModelForCausalLM.from_pretrained(
|
238 |
+
model_name_or_path,
|
239 |
+
low_cpu_mem_usage=True,
|
240 |
+
device_map="cuda:0"
|
241 |
+
)
|
242 |
+
|
243 |
+
# Using the text streamer to stream output one token at a time
|
244 |
+
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
245 |
+
|
246 |
+
prompt = "Tell me about AI"
|
247 |
+
prompt_template=f'''<s>[INST] {prompt} [/INST]
|
248 |
+
'''
|
249 |
+
|
250 |
+
# Convert prompt to tokens
|
251 |
+
tokens = tokenizer(
|
252 |
+
prompt_template,
|
253 |
+
return_tensors='pt'
|
254 |
+
).input_ids.cuda()
|
255 |
+
|
256 |
+
generation_params = {
|
257 |
+
"do_sample": True,
|
258 |
+
"temperature": 0.7,
|
259 |
+
"top_p": 0.95,
|
260 |
+
"top_k": 40,
|
261 |
+
"max_new_tokens": 512,
|
262 |
+
"repetition_penalty": 1.1
|
263 |
+
}
|
264 |
+
|
265 |
+
# Generate streamed output, visible one token at a time
|
266 |
+
generation_output = model.generate(
|
267 |
+
tokens,
|
268 |
+
streamer=streamer,
|
269 |
+
**generation_params
|
270 |
+
)
|
271 |
+
|
272 |
+
# Generation without a streamer, which will include the prompt in the output
|
273 |
+
generation_output = model.generate(
|
274 |
+
tokens,
|
275 |
+
**generation_params
|
276 |
+
)
|
277 |
+
|
278 |
+
# Get the tokens from the output, decode them, print them
|
279 |
+
token_output = generation_output[0]
|
280 |
+
text_output = tokenizer.decode(token_output)
|
281 |
+
print("model.generate output: ", text_output)
|
282 |
+
|
283 |
+
# Inference is also possible via Transformers' pipeline
|
284 |
+
from transformers import pipeline
|
285 |
+
|
286 |
+
pipe = pipeline(
|
287 |
+
"text-generation",
|
288 |
+
model=model,
|
289 |
+
tokenizer=tokenizer,
|
290 |
+
**generation_params
|
291 |
+
)
|
292 |
+
|
293 |
+
pipe_output = pipe(prompt_template)[0]['generated_text']
|
294 |
+
print("pipeline output: ", pipe_output)
|
295 |
+
|
296 |
+
```
|
297 |
+
<!-- README_AWQ.md-use-from-python end -->
|
298 |
+
|
299 |
+
<!-- README_AWQ.md-compatibility start -->
|
300 |
+
## Compatibility
|
301 |
+
|
302 |
+
The files provided are tested to work with:
|
303 |
+
|
304 |
+
- [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
|
305 |
+
- [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
|
306 |
+
- [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
|
307 |
+
- [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later.
|
308 |
+
- [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
|
309 |
+
|
310 |
+
<!-- README_AWQ.md-compatibility end -->
|
311 |
+
|
312 |
+
<!-- footer start -->
|
313 |
+
<!-- 200823 -->
|
314 |
+
## Discord
|
315 |
+
|
316 |
+
For further support, and discussions on these models and AI in general, join us at:
|
317 |
+
|
318 |
+
[TheBloke AI's Discord server](https://discord.gg/theblokeai)
|
319 |
+
|
320 |
+
## Thanks, and how to contribute
|
321 |
+
|
322 |
+
Thanks to the [chirper.ai](https://chirper.ai) team!
|
323 |
+
|
324 |
+
Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
|
325 |
+
|
326 |
+
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.
|
327 |
+
|
328 |
+
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.
|
329 |
+
|
330 |
+
Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
|
331 |
+
|
332 |
+
* Patreon: https://patreon.com/TheBlokeAI
|
333 |
+
* Ko-Fi: https://ko-fi.com/TheBlokeAI
|
334 |
+
|
335 |
+
**Special thanks to**: Aemon Algiz.
|
336 |
+
|
337 |
+
**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
|
338 |
+
|
339 |
+
|
340 |
+
Thank you to all my generous patrons and donaters!
|
341 |
+
|
342 |
+
And thank you again to a16z for their generous grant.
|
343 |
+
|
344 |
+
<!-- footer end -->
|
345 |
+
|
346 |
+
# Original model card: Mistral AI_'s Mixtral 8X7B Instruct v0.1
|
347 |
+
|
348 |
+
# Model Card for Mixtral-8x7B
|
349 |
+
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.
|
350 |
+
|
351 |
+
For full details of this model please read our [release blog post](https://mistral.ai/news/mixtral-of-experts/).
|
352 |
+
|
353 |
+
## Warning
|
354 |
+
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.
|
355 |
+
|
356 |
+
## Instruction format
|
357 |
+
|
358 |
+
This format must be strictly respected, otherwise the model will generate sub-optimal outputs.
|
359 |
+
|
360 |
+
The template used to build a prompt for the Instruct model is defined as follows:
|
361 |
+
```
|
362 |
+
<s> [INST] Instruction [/INST] Model answer</s> [INST] Follow-up instruction [/INST]
|
363 |
+
```
|
364 |
+
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.
|
365 |
+
|
366 |
+
As reference, here is the pseudo-code used to tokenize instructions during fine-tuning:
|
367 |
+
```python
|
368 |
+
def tokenize(text):
|
369 |
+
return tok.encode(text, add_special_tokens=False)
|
370 |
+
|
371 |
+
[BOS_ID] +
|
372 |
+
tokenize("[INST]") + tokenize(USER_MESSAGE_1) + tokenize("[/INST]") +
|
373 |
+
tokenize(BOT_MESSAGE_1) + [EOS_ID] +
|
374 |
+
…
|
375 |
+
tokenize("[INST]") + tokenize(USER_MESSAGE_N) + tokenize("[/INST]") +
|
376 |
+
tokenize(BOT_MESSAGE_N) + [EOS_ID]
|
377 |
+
```
|
378 |
+
|
379 |
+
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.
|
380 |
+
|
381 |
+
## Run the model
|
382 |
+
|
383 |
+
```python
|
384 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
385 |
+
|
386 |
+
model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
387 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
388 |
+
|
389 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
390 |
+
|
391 |
+
text = "Hello my name is"
|
392 |
+
inputs = tokenizer(text, return_tensors="pt")
|
393 |
+
|
394 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
395 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
396 |
+
```
|
397 |
+
|
398 |
+
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:
|
399 |
+
|
400 |
+
### In half-precision
|
401 |
+
|
402 |
+
Note `float16` precision only works on GPU devices
|
403 |
+
|
404 |
+
<details>
|
405 |
+
<summary> Click to expand </summary>
|
406 |
+
|
407 |
+
```diff
|
408 |
+
+ import torch
|
409 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
410 |
+
|
411 |
+
model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
412 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
413 |
+
|
414 |
+
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16).to(0)
|
415 |
+
|
416 |
+
text = "Hello my name is"
|
417 |
+
+ inputs = tokenizer(text, return_tensors="pt").to(0)
|
418 |
+
|
419 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
420 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
421 |
+
```
|
422 |
+
</details>
|
423 |
+
|
424 |
+
### Lower precision using (8-bit & 4-bit) using `bitsandbytes`
|
425 |
+
|
426 |
+
<details>
|
427 |
+
<summary> Click to expand </summary>
|
428 |
+
|
429 |
+
```diff
|
430 |
+
+ import torch
|
431 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
432 |
+
|
433 |
+
model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
434 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
435 |
+
|
436 |
+
+ model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True)
|
437 |
+
|
438 |
+
text = "Hello my name is"
|
439 |
+
+ inputs = tokenizer(text, return_tensors="pt").to(0)
|
440 |
+
|
441 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
442 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
443 |
+
```
|
444 |
+
</details>
|
445 |
+
|
446 |
+
### Load the model with Flash Attention 2
|
447 |
+
|
448 |
+
<details>
|
449 |
+
<summary> Click to expand </summary>
|
450 |
+
|
451 |
+
```diff
|
452 |
+
+ import torch
|
453 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
454 |
+
|
455 |
+
model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
456 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
457 |
+
|
458 |
+
+ model = AutoModelForCausalLM.from_pretrained(model_id, use_flash_attention_2=True)
|
459 |
+
|
460 |
+
text = "Hello my name is"
|
461 |
+
+ inputs = tokenizer(text, return_tensors="pt").to(0)
|
462 |
+
|
463 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
464 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
465 |
+
```
|
466 |
+
</details>
|
467 |
+
|
468 |
+
## Limitations
|
469 |
+
|
470 |
+
The Mixtral-8x7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
|
471 |
+
It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
|
472 |
+
make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
|
473 |
+
|
474 |
+
# The Mistral AI Team
|
475 |
+
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.
|