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