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