Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,110 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- fr
|
5 |
+
- it
|
6 |
+
- de
|
7 |
+
- es
|
8 |
+
- en
|
9 |
---
|
10 |
+
# Model Card for Mixtral-8x7B
|
11 |
+
The Mixtral-8x7B Large Language Model (LLM) is a pretrained generative Sparse Mixture of Experts. The Mistral-8x7B outperforms Llama 2 70B on most benchmarks we tested.
|
12 |
+
|
13 |
+
For full details of this model please read our [release blog post](https://mistral.ai/news/mixtral-of-experts/).
|
14 |
+
|
15 |
+
## Warning
|
16 |
+
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.
|
17 |
+
|
18 |
+
## Run the model
|
19 |
+
|
20 |
+
|
21 |
+
```python
|
22 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
23 |
+
|
24 |
+
model_id = "mistralai/Mixtral-8x7B-v0.1"
|
25 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
26 |
+
|
27 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
28 |
+
|
29 |
+
text = "Hello my name is"
|
30 |
+
inputs = tokenizer(text, return_tensors="pt")
|
31 |
+
|
32 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
33 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
34 |
+
```
|
35 |
+
|
36 |
+
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:
|
37 |
+
|
38 |
+
### In half-precision
|
39 |
+
|
40 |
+
Note `float16` precision only works on GPU devices
|
41 |
+
|
42 |
+
<details>
|
43 |
+
<summary> Click to expand </summary>
|
44 |
+
|
45 |
+
```diff
|
46 |
+
+ import torch
|
47 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
48 |
+
|
49 |
+
model_id = "mistralai/Mixtral-8x7B-v0.1"
|
50 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
51 |
+
|
52 |
+
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16).to(0)
|
53 |
+
|
54 |
+
text = "Hello my name is"
|
55 |
+
+ inputs = tokenizer(text, return_tensors="pt").to(0)
|
56 |
+
|
57 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
58 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
59 |
+
```
|
60 |
+
</details>
|
61 |
+
|
62 |
+
### Lower precision using (8-bit & 4-bit) using `bitsandbytes`
|
63 |
+
|
64 |
+
<details>
|
65 |
+
<summary> Click to expand </summary>
|
66 |
+
|
67 |
+
```diff
|
68 |
+
+ import torch
|
69 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
70 |
+
|
71 |
+
model_id = "mistralai/Mixtral-8x7B-v0.1"
|
72 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
73 |
+
|
74 |
+
+ model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True)
|
75 |
+
|
76 |
+
text = "Hello my name is"
|
77 |
+
+ inputs = tokenizer(text, return_tensors="pt").to(0)
|
78 |
+
|
79 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
80 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
81 |
+
```
|
82 |
+
</details>
|
83 |
+
|
84 |
+
### Load the model with Flash Attention 2
|
85 |
+
|
86 |
+
<details>
|
87 |
+
<summary> Click to expand </summary>
|
88 |
+
|
89 |
+
```diff
|
90 |
+
+ import torch
|
91 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
92 |
+
|
93 |
+
model_id = "mistralai/Mixtral-8x7B-v0.1"
|
94 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
95 |
+
|
96 |
+
+ model = AutoModelForCausalLM.from_pretrained(model_id, use_flash_attention_2=True)
|
97 |
+
|
98 |
+
text = "Hello my name is"
|
99 |
+
+ inputs = tokenizer(text, return_tensors="pt").to(0)
|
100 |
+
|
101 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
102 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
103 |
+
```
|
104 |
+
</details>
|
105 |
+
|
106 |
+
## Notice
|
107 |
+
Mixtral-8x7B is a pretrained base model and therefore does not have any moderation mechanisms.
|
108 |
+
|
109 |
+
# The Mistral AI Team
|
110 |
+
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.
|