mav23 commited on
Commit
0c66392
1 Parent(s): 9b5c282

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,20 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ mixtral-8x7b-instruct-v0.1.Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
37
+ mixtral-8x7b-instruct-v0.1.Q3_K.gguf filter=lfs diff=lfs merge=lfs -text
38
+ mixtral-8x7b-instruct-v0.1.Q3_K_L.gguf filter=lfs diff=lfs merge=lfs -text
39
+ mixtral-8x7b-instruct-v0.1.Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
40
+ mixtral-8x7b-instruct-v0.1.Q3_K_S.gguf filter=lfs diff=lfs merge=lfs -text
41
+ mixtral-8x7b-instruct-v0.1.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
42
+ mixtral-8x7b-instruct-v0.1.Q4_1.gguf filter=lfs diff=lfs merge=lfs -text
43
+ mixtral-8x7b-instruct-v0.1.Q4_K.gguf filter=lfs diff=lfs merge=lfs -text
44
+ mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
45
+ mixtral-8x7b-instruct-v0.1.Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -text
46
+ mixtral-8x7b-instruct-v0.1.Q5_0.gguf filter=lfs diff=lfs merge=lfs -text
47
+ mixtral-8x7b-instruct-v0.1.Q5_1.gguf filter=lfs diff=lfs merge=lfs -text
48
+ mixtral-8x7b-instruct-v0.1.Q5_K.gguf filter=lfs diff=lfs merge=lfs -text
49
+ mixtral-8x7b-instruct-v0.1.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
50
+ mixtral-8x7b-instruct-v0.1.Q5_K_S.gguf filter=lfs diff=lfs merge=lfs -text
51
+ mixtral-8x7b-instruct-v0.1.Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
52
+ mixtral-8x7b-instruct-v0.1.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - fr
4
+ - it
5
+ - de
6
+ - es
7
+ - en
8
+ license: apache-2.0
9
+ base_model: mistralai/Mixtral-8x7B-v0.1
10
+ inference:
11
+ parameters:
12
+ temperature: 0.5
13
+ widget:
14
+ - messages:
15
+ - role: user
16
+ content: What is your favorite condiment?
17
+
18
+ extra_gated_description: If you want to learn more about how we process your personal data, please read our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
19
+ ---
20
+ # Model Card for Mixtral-8x7B
21
+
22
+ ### Tokenization with `mistral-common`
23
+
24
+ ```py
25
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
26
+ from mistral_common.protocol.instruct.messages import UserMessage
27
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
28
+
29
+ mistral_models_path = "MISTRAL_MODELS_PATH"
30
+
31
+ tokenizer = MistralTokenizer.v1()
32
+
33
+ completion_request = ChatCompletionRequest(messages=[UserMessage(content="Explain Machine Learning to me in a nutshell.")])
34
+
35
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
36
+ ```
37
+
38
+ ## Inference with `mistral_inference`
39
+
40
+ ```py
41
+ from mistral_inference.transformer import Transformer
42
+ from mistral_inference.generate import generate
43
+
44
+ model = Transformer.from_folder(mistral_models_path)
45
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
46
+
47
+ result = tokenizer.decode(out_tokens[0])
48
+
49
+ print(result)
50
+ ```
51
+
52
+ ## Inference with hugging face `transformers`
53
+
54
+ ```py
55
+ from transformers import AutoModelForCausalLM
56
+
57
+ model = AutoModelForCausalLM.from_pretrained("mistralai/Mixtral-8x7B-Instruct-v0.1")
58
+ model.to("cuda")
59
+
60
+ generated_ids = model.generate(tokens, max_new_tokens=1000, do_sample=True)
61
+
62
+ # decode with mistral tokenizer
63
+ result = tokenizer.decode(generated_ids[0].tolist())
64
+ print(result)
65
+ ```
66
+
67
+ > [!TIP]
68
+ > PRs to correct the transformers tokenizer so that it gives 1-to-1 the same results as the mistral-common reference implementation are very welcome!
69
+
70
+
71
+ ---
72
+ 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.
73
+
74
+ For full details of this model please read our [release blog post](https://mistral.ai/news/mixtral-of-experts/).
75
+
76
+ ## Warning
77
+ 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.
78
+
79
+ ## Instruction format
80
+
81
+ This format must be strictly respected, otherwise the model will generate sub-optimal outputs.
82
+
83
+ The template used to build a prompt for the Instruct model is defined as follows:
84
+ ```
85
+ <s> [INST] Instruction [/INST] Model answer</s> [INST] Follow-up instruction [/INST]
86
+ ```
87
+ 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.
88
+
89
+ As reference, here is the pseudo-code used to tokenize instructions during fine-tuning:
90
+ ```python
91
+ def tokenize(text):
92
+ return tok.encode(text, add_special_tokens=False)
93
+
94
+ [BOS_ID] +
95
+ tokenize("[INST]") + tokenize(USER_MESSAGE_1) + tokenize("[/INST]") +
96
+ tokenize(BOT_MESSAGE_1) + [EOS_ID] +
97
+
98
+ tokenize("[INST]") + tokenize(USER_MESSAGE_N) + tokenize("[/INST]") +
99
+ tokenize(BOT_MESSAGE_N) + [EOS_ID]
100
+ ```
101
+
102
+ 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.
103
+
104
+ In the Transformers library, one can use [chat templates](https://huggingface.co/docs/transformers/main/en/chat_templating) which make sure the right format is applied.
105
+
106
+ ## Run the model
107
+
108
+ ```python
109
+ from transformers import AutoModelForCausalLM, AutoTokenizer
110
+
111
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
112
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
113
+
114
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
115
+
116
+ messages = [
117
+ {"role": "user", "content": "What is your favourite condiment?"},
118
+ {"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"},
119
+ {"role": "user", "content": "Do you have mayonnaise recipes?"}
120
+ ]
121
+
122
+ inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
123
+
124
+ outputs = model.generate(inputs, max_new_tokens=20)
125
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
126
+ ```
127
+
128
+ 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:
129
+
130
+ ### In half-precision
131
+
132
+ Note `float16` precision only works on GPU devices
133
+
134
+ <details>
135
+ <summary> Click to expand </summary>
136
+
137
+ ```diff
138
+ + import torch
139
+ from transformers import AutoModelForCausalLM, AutoTokenizer
140
+
141
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
142
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
143
+
144
+ + model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
145
+
146
+ messages = [
147
+ {"role": "user", "content": "What is your favourite condiment?"},
148
+ {"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"},
149
+ {"role": "user", "content": "Do you have mayonnaise recipes?"}
150
+ ]
151
+
152
+ input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
153
+
154
+ outputs = model.generate(input_ids, max_new_tokens=20)
155
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
156
+ ```
157
+ </details>
158
+
159
+ ### Lower precision using (8-bit & 4-bit) using `bitsandbytes`
160
+
161
+ <details>
162
+ <summary> Click to expand </summary>
163
+
164
+ ```diff
165
+ + import torch
166
+ from transformers import AutoModelForCausalLM, AutoTokenizer
167
+
168
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
169
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
170
+
171
+ + model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True, device_map="auto")
172
+
173
+ text = "Hello my name is"
174
+ messages = [
175
+ {"role": "user", "content": "What is your favourite condiment?"},
176
+ {"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"},
177
+ {"role": "user", "content": "Do you have mayonnaise recipes?"}
178
+ ]
179
+
180
+ input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
181
+
182
+ outputs = model.generate(input_ids, max_new_tokens=20)
183
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
184
+ ```
185
+ </details>
186
+
187
+ ### Load the model with Flash Attention 2
188
+
189
+ <details>
190
+ <summary> Click to expand </summary>
191
+
192
+ ```diff
193
+ + import torch
194
+ from transformers import AutoModelForCausalLM, AutoTokenizer
195
+
196
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
197
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
198
+
199
+ + model = AutoModelForCausalLM.from_pretrained(model_id, use_flash_attention_2=True, device_map="auto")
200
+
201
+ messages = [
202
+ {"role": "user", "content": "What is your favourite condiment?"},
203
+ {"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"},
204
+ {"role": "user", "content": "Do you have mayonnaise recipes?"}
205
+ ]
206
+
207
+ input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
208
+
209
+ outputs = model.generate(input_ids, max_new_tokens=20)
210
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
211
+ ```
212
+ </details>
213
+
214
+ ## Limitations
215
+
216
+ The Mixtral-8x7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
217
+ It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
218
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
219
+
220
+ # The Mistral AI Team
221
+ 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,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "MixtralForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 4096,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 14336,
12
+ "max_position_embeddings": 32768,
13
+ "model_type": "mixtral",
14
+ "num_attention_heads": 32,
15
+ "num_experts_per_tok": 2,
16
+ "num_hidden_layers": 32,
17
+ "num_key_value_heads": 8,
18
+ "num_local_experts": 8,
19
+ "output_router_logits": false,
20
+ "rms_norm_eps": 1e-05,
21
+ "rope_theta": 1000000.0,
22
+ "router_aux_loss_coef": 0.02,
23
+ "sliding_window": null,
24
+ "tie_word_embeddings": false,
25
+ "torch_dtype": "bfloat16",
26
+ "transformers_version": "4.36.0.dev0",
27
+ "use_cache": true,
28
+ "vocab_size": 32000
29
+ }
mixtral-8x7b-instruct-v0.1.Q2_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:579c3d8310e3ea34368c86f9642bf09a6ab0b015acd4222a1783af0d8148dd08
3
+ size 17311230880
mixtral-8x7b-instruct-v0.1.Q3_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e78fe08249805f551b74f4b2bdbae55abe3d2f81825d7aa03b914cb603105a5
3
+ size 22546451360
mixtral-8x7b-instruct-v0.1.Q3_K_L.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05bc9cc97bf313507f85b407c6121791a406f63b3d58b08d33accb64937b1994
3
+ size 24169647008
mixtral-8x7b-instruct-v0.1.Q3_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e78fe08249805f551b74f4b2bdbae55abe3d2f81825d7aa03b914cb603105a5
3
+ size 22546451360
mixtral-8x7b-instruct-v0.1.Q3_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34f1e0ab41fd4278820607a960e6f104214eb115b40d14c41062c56634db62cf
3
+ size 20432522144
mixtral-8x7b-instruct-v0.1.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc886476785d49ac2b616616910b3edd5948814c6b21f03e283ccd9fe1e818de
3
+ size 26443590560
mixtral-8x7b-instruct-v0.1.Q4_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6ba5936ffaaf1c6c4ce4a704b1621ce22d686008a80eb9f830d258b162cf7d7
3
+ size 29337463712
mixtral-8x7b-instruct-v0.1.Q4_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:016aaf5588e795a6bfe9b8601af7b8122dae112f34a745cdb1fc5ccb0495cd2d
3
+ size 28448467872
mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:016aaf5588e795a6bfe9b8601af7b8122dae112f34a745cdb1fc5ccb0495cd2d
3
+ size 28448467872
mixtral-8x7b-instruct-v0.1.Q4_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77e2e304ba9548c18230a5eeb9498f63279ea7e2c6bf67ed85297da28d928b1a
3
+ size 26745580448
mixtral-8x7b-instruct-v0.1.Q5_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d06489d687faf1ceac15dd491baf28566c87826af50da4ea53bf198afa653fd7
3
+ size 32231336864
mixtral-8x7b-instruct-v0.1.Q5_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cebaf76c57351422cd088f9c9ea8ca0ea10b0bfce651df2f979b8a5cec599734
3
+ size 35125210016
mixtral-8x7b-instruct-v0.1.Q5_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f7535c2b6f4e8d19f490ffa2e88fdf17f1f326ec13dd56250d26f3f53c25ead
3
+ size 33229581216
mixtral-8x7b-instruct-v0.1.Q5_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f7535c2b6f4e8d19f490ffa2e88fdf17f1f326ec13dd56250d26f3f53c25ead
3
+ size 33229581216
mixtral-8x7b-instruct-v0.1.Q5_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:034b3a064166e0997d904635c7c419b8886ff2d69e96983161b5c5438a1f47c8
3
+ size 32231336864
mixtral-8x7b-instruct-v0.1.Q6_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:798ed34a2429fba82574bc3f8fa7536e66e98c965aaeb88008279f88bf9f5b46
3
+ size 38380817312
mixtral-8x7b-instruct-v0.1.Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5aa92cba409e7718f5e8f6b5419edec197ee71570539a84dc91c10631ac17aca
3
+ size 49626319776