mav23 commited on
Commit
2840d6e
1 Parent(s): 84b0708

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
+ mistral-small-instruct-2409.Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
37
+ mistral-small-instruct-2409.Q3_K.gguf filter=lfs diff=lfs merge=lfs -text
38
+ mistral-small-instruct-2409.Q3_K_L.gguf filter=lfs diff=lfs merge=lfs -text
39
+ mistral-small-instruct-2409.Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
40
+ mistral-small-instruct-2409.Q3_K_S.gguf filter=lfs diff=lfs merge=lfs -text
41
+ mistral-small-instruct-2409.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
42
+ mistral-small-instruct-2409.Q4_1.gguf filter=lfs diff=lfs merge=lfs -text
43
+ mistral-small-instruct-2409.Q4_K.gguf filter=lfs diff=lfs merge=lfs -text
44
+ mistral-small-instruct-2409.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
45
+ mistral-small-instruct-2409.Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -text
46
+ mistral-small-instruct-2409.Q5_0.gguf filter=lfs diff=lfs merge=lfs -text
47
+ mistral-small-instruct-2409.Q5_1.gguf filter=lfs diff=lfs merge=lfs -text
48
+ mistral-small-instruct-2409.Q5_K.gguf filter=lfs diff=lfs merge=lfs -text
49
+ mistral-small-instruct-2409.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
50
+ mistral-small-instruct-2409.Q5_K_S.gguf filter=lfs diff=lfs merge=lfs -text
51
+ mistral-small-instruct-2409.Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
52
+ mistral-small-instruct-2409.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - fr
5
+ - de
6
+ - es
7
+ - it
8
+ - pt
9
+ - zh
10
+ - ja
11
+ - ru
12
+ - ko
13
+ license: other
14
+ license_name: mrl
15
+ license_link: https://mistral.ai/licenses/MRL-0.1.md
16
+ extra_gated_description: >-
17
+ If you want to learn more about how we process your personal data, please read
18
+ our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
19
+ library_name: transformers
20
+ ---
21
+
22
+ # Model Card for Mistral-Small-Instruct-2409
23
+
24
+ Mistral-Small-Instruct-2409 is an instruct fine-tuned version with the following characteristics:
25
+
26
+ - 22B parameters
27
+ - Vocabulary to 32768
28
+ - Supports function calling
29
+ - 32k sequence length
30
+
31
+
32
+ ## Usage Examples
33
+
34
+ ### vLLM (recommended)
35
+
36
+ We recommend using this model with the [vLLM library](https://github.com/vllm-project/vllm)
37
+ to implement production-ready inference pipelines.
38
+
39
+ **_Installation_**
40
+
41
+ Make sure you install `vLLM >= v0.6.1.post1`:
42
+
43
+ ```
44
+ pip install --upgrade vllm
45
+ ```
46
+
47
+ Also make sure you have `mistral_common >= 1.4.1` installed:
48
+
49
+ ```
50
+ pip install --upgrade mistral_common
51
+ ```
52
+
53
+ You can also make use of a ready-to-go [docker image](https://hub.docker.com/layers/vllm/vllm-openai/latest/images/sha256-de9032a92ffea7b5c007dad80b38fd44aac11eddc31c435f8e52f3b7404bbf39?context=explore).
54
+
55
+
56
+ **_Offline_**
57
+
58
+ ```py
59
+ from vllm import LLM
60
+ from vllm.sampling_params import SamplingParams
61
+
62
+ model_name = "mistralai/Mistral-Small-Instruct-2409"
63
+
64
+ sampling_params = SamplingParams(max_tokens=8192)
65
+
66
+ # note that running Mistral-Small on a single GPU requires at least 44 GB of GPU RAM
67
+ # If you want to divide the GPU requirement over multiple devices, please add *e.g.* `tensor_parallel=2`
68
+ llm = LLM(model=model_name, tokenizer_mode="mistral", config_format="mistral", load_format="mistral")
69
+
70
+ prompt = "How often does the letter r occur in Mistral?"
71
+
72
+ messages = [
73
+ {
74
+ "role": "user",
75
+ "content": prompt
76
+ },
77
+ ]
78
+
79
+ outputs = llm.chat(messages, sampling_params=sampling_params)
80
+
81
+ print(outputs[0].outputs[0].text)
82
+ ```
83
+
84
+ **_Server_**
85
+
86
+ You can also use Mistral Small in a server/client setting.
87
+
88
+ 1. Spin up a server:
89
+
90
+
91
+ ```
92
+ vllm serve mistralai/Mistral-Small-Instruct-2409 --tokenizer_mode mistral --config_format mistral --load_format mistral
93
+ ```
94
+
95
+ **Note:** Running Mistral-Small on a single GPU requires at least 44 GB of GPU RAM.
96
+
97
+ If you want to divide the GPU requirement over multiple devices, please add *e.g.* `--tensor_parallel=2`
98
+
99
+ 2. And ping the client:
100
+
101
+ ```
102
+ curl --location 'http://<your-node-url>:8000/v1/chat/completions' \
103
+ --header 'Content-Type: application/json' \
104
+ --header 'Authorization: Bearer token' \
105
+ --data '{
106
+ "model": "mistralai/Mistral-Small-Instruct-2409",
107
+ "messages": [
108
+ {
109
+ "role": "user",
110
+ "content": "How often does the letter r occur in Mistral?"
111
+ }
112
+ ]
113
+ }'
114
+
115
+ ```
116
+
117
+ ### Mistral-inference
118
+
119
+ We recommend using [mistral-inference](https://github.com/mistralai/mistral-inference) to quickly try out / "vibe-check" the model.
120
+
121
+
122
+ **_Install_**
123
+
124
+ Make sure to have `mistral_inference >= 1.4.1` installed.
125
+
126
+ ```
127
+ pip install mistral_inference --upgrade
128
+ ```
129
+
130
+ **_Download_**
131
+
132
+ ```py
133
+ from huggingface_hub import snapshot_download
134
+ from pathlib import Path
135
+
136
+ mistral_models_path = Path.home().joinpath('mistral_models', '22B-Instruct-Small')
137
+ mistral_models_path.mkdir(parents=True, exist_ok=True)
138
+
139
+ snapshot_download(repo_id="mistralai/Mistral-Small-Instruct-2409", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
140
+ ```
141
+
142
+ ### Chat
143
+
144
+ After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment. You can chat with the model using
145
+
146
+ ```
147
+ mistral-chat $HOME/mistral_models/22B-Instruct-Small --instruct --max_tokens 256
148
+ ```
149
+
150
+ ### Instruct following
151
+
152
+ ```py
153
+ from mistral_inference.transformer import Transformer
154
+ from mistral_inference.generate import generate
155
+
156
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
157
+ from mistral_common.protocol.instruct.messages import UserMessage
158
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
159
+
160
+
161
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
162
+ model = Transformer.from_folder(mistral_models_path)
163
+
164
+ completion_request = ChatCompletionRequest(messages=[UserMessage(content="How often does the letter r occur in Mistral?")])
165
+
166
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
167
+
168
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
169
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
170
+
171
+ print(result)
172
+ ```
173
+
174
+ ### Function calling
175
+
176
+ ```py
177
+ from mistral_common.protocol.instruct.tool_calls import Function, Tool
178
+ from mistral_inference.transformer import Transformer
179
+ from mistral_inference.generate import generate
180
+
181
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
182
+ from mistral_common.protocol.instruct.messages import UserMessage
183
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
184
+
185
+
186
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
187
+ model = Transformer.from_folder(mistral_models_path)
188
+
189
+ completion_request = ChatCompletionRequest(
190
+ tools=[
191
+ Tool(
192
+ function=Function(
193
+ name="get_current_weather",
194
+ description="Get the current weather",
195
+ parameters={
196
+ "type": "object",
197
+ "properties": {
198
+ "location": {
199
+ "type": "string",
200
+ "description": "The city and state, e.g. San Francisco, CA",
201
+ },
202
+ "format": {
203
+ "type": "string",
204
+ "enum": ["celsius", "fahrenheit"],
205
+ "description": "The temperature unit to use. Infer this from the users location.",
206
+ },
207
+ },
208
+ "required": ["location", "format"],
209
+ },
210
+ )
211
+ )
212
+ ],
213
+ messages=[
214
+ UserMessage(content="What's the weather like today in Paris?"),
215
+ ],
216
+ )
217
+
218
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
219
+
220
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
221
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
222
+
223
+ print(result)
224
+ ```
225
+
226
+ ### Usage in Hugging Face Transformers
227
+
228
+ You can also use Hugging Face `transformers` library to run inference using various chat templates, or fine-tune the model.
229
+ Example for inference:
230
+
231
+ ```python
232
+ from transformers import LlamaTokenizerFast, MistralForCausalLM
233
+ import torch
234
+
235
+ device = "cuda"
236
+ tokenizer = LlamaTokenizerFast.from_pretrained('mistralai/Mistral-Small-Instruct-2409')
237
+ tokenizer.pad_token = tokenizer.eos_token
238
+
239
+ model = MistralForCausalLM.from_pretrained('mistralai/Mistral-Small-Instruct-2409', torch_dtype=torch.bfloat16)
240
+ model = model.to(device)
241
+
242
+ prompt = "How often does the letter r occur in Mistral?"
243
+
244
+ messages = [
245
+ {"role": "user", "content": prompt},
246
+ ]
247
+
248
+ model_input = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(device)
249
+ gen = model.generate(model_input, max_new_tokens=150)
250
+ dec = tokenizer.batch_decode(gen)
251
+ print(dec)
252
+ ```
253
+
254
+ And you should obtain
255
+ ```text
256
+ <s>
257
+ [INST]
258
+ How often does the letter r occur in Mistral?
259
+ [/INST]
260
+ To determine how often the letter "r" occurs in the word "Mistral,"
261
+ we can simply count the instances of "r" in the word.
262
+ The word "Mistral" is broken down as follows:
263
+ - M
264
+ - i
265
+ - s
266
+ - t
267
+ - r
268
+ - a
269
+ - l
270
+ Counting the "r"s, we find that there is only one "r" in "Mistral."
271
+ Therefore, the letter "r" occurs once in the word "Mistral."
272
+ </s>
273
+ ```
274
+
275
+ ## The Mistral AI Team
276
+
277
+ Albert Jiang, Alexandre Sablayrolles, Alexis Tacnet, Alok Kothari, Antoine Roux, Arthur Mensch, Audrey Herblin-Stoop, Augustin Garreau, Austin Birky, Bam4d, Baptiste Bout, Baudouin de Monicault, Blanche Savary, Carole Rambaud, Caroline Feldman, Devendra Singh Chaplot, Diego de las Casas, Diogo Costa, Eleonore Arcelin, Emma Bou Hanna, Etienne Metzger, Gaspard Blanchet, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Harizo Rajaona, Henri Roussez, Hichem Sattouf, Ian Mack, Jean-Malo Delignon, Jessica Chudnovsky, Justus Murke, Kartik Khandelwal, Lawrence Stewart, Louis Martin, Louis Ternon, Lucile Saulnier, Lélio Renard Lavaud, Margaret Jennings, Marie Pellat, Marie Torelli, Marie-Anne Lachaux, Marjorie Janiewicz, Mickaël Seznec, Nicolas Schuhl, Niklas Muhs, Olivier de Garrigues, Patrick von Platen, Paul Jacob, Pauline Buche, Pavan Kumar Reddy, Perry Savas, Pierre Stock, Romain Sauvestre, Sagar Vaze, Sandeep Subramanian, Saurabh Garg, Sophia Yang, Szymon Antoniak, Teven Le Scao, Thibault Schueller, Thibaut Lavril, Thomas Wang, Théophile Gervet, Timothée Lacroix, Valera Nemychnikova, Wendy Shang, William El Sayed, William Marshall
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "MistralForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "head_dim": 128,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 6144,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 16384,
13
+ "max_position_embeddings": 32768,
14
+ "model_type": "mistral",
15
+ "num_attention_heads": 48,
16
+ "num_hidden_layers": 56,
17
+ "num_key_value_heads": 8,
18
+ "rms_norm_eps": 1e-05,
19
+ "rope_theta": 1000000.0,
20
+ "sliding_window": null,
21
+ "tie_word_embeddings": false,
22
+ "torch_dtype": "bfloat16",
23
+ "transformers_version": "4.45.0.dev0",
24
+ "use_cache": true,
25
+ "vocab_size": 32768
26
+ }
mistral-small-instruct-2409.Q2_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bff4d6f2143fa4dc2dbab6bcac8254690c557ad729d7409774d025a2a4fa5ff3
3
+ size 8272097984
mistral-small-instruct-2409.Q3_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4981dd45365e859f26b0b6f316b98debfec6c16d54c75e0d51f004bc14cbaf76
3
+ size 10756829888
mistral-small-instruct-2409.Q3_K_L.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44ba7885fdb275896f66f79403eb190862f893b1b3da31c8ddda0b98a4758f2e
3
+ size 11730432704
mistral-small-instruct-2409.Q3_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4981dd45365e859f26b0b6f316b98debfec6c16d54c75e0d51f004bc14cbaf76
3
+ size 10756829888
mistral-small-instruct-2409.Q3_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1755f35608d044c10d96b02266d9d1f573dfa419789ab995ddff738197ad636
3
+ size 9641276096
mistral-small-instruct-2409.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d0305b03fbc65288e25cfbd4837bc2ecbddd1544d541fc68dd973e7dfce5f5c4
3
+ size 12569162432
mistral-small-instruct-2409.Q4_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ece9d006837c665c87be0c9dd826e43bee63d9557676742921e65864c7089d77
3
+ size 13946991296
mistral-small-instruct-2409.Q4_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f236f3b7d87e75d57be450a86591f8efb5a2b33e58f8ba10ae5b581d0da4192
3
+ size 13341242048
mistral-small-instruct-2409.Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f236f3b7d87e75d57be450a86591f8efb5a2b33e58f8ba10ae5b581d0da4192
3
+ size 13341242048
mistral-small-instruct-2409.Q4_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e7a6439fd5b3e4f06d9110d2b3a8788f653a17837729fe19e680ef1f6674c7e
3
+ size 12660388544
mistral-small-instruct-2409.Q5_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b8c9eeb26c8fa9facd455f804fa7a640e8c4afc8545e44894ad8e003a421e89
3
+ size 15324820160
mistral-small-instruct-2409.Q5_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82c28ad01199af5f1fdc9f02bf2aacd781c9c4db91e0ae185ab814b04eed921c
3
+ size 16702649024
mistral-small-instruct-2409.Q5_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d26f82ed11c578a5158ddb1ba25e2a60034347556d5b8c36d6093fdc921907d
3
+ size 15722558144
mistral-small-instruct-2409.Q5_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d26f82ed11c578a5158ddb1ba25e2a60034347556d5b8c36d6093fdc921907d
3
+ size 15722558144
mistral-small-instruct-2409.Q5_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b39df417efd2cb24ef23ea6d83715ec2504fd3cd1522229de67a4dba94aa3d0b
3
+ size 15324820160
mistral-small-instruct-2409.Q6_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3feed0ff7a2dce1ec9425ff2200bc0a87e0d76e0e8f96c76db215762b223911e
3
+ size 18252706496
mistral-small-instruct-2409.Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ff3f88081c1ea3506ff406ab5267898edfebf9f0dfc0c223e238618fbfcfe8e
3
+ size 23640552128