LoneStriker commited on
Commit
28c27ec
1 Parent(s): 3bb0af2

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -1,35 +1,5 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz 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
 
1
+ Mistral-Small-Instruct-2409-Q3_K_L.gguf filter=lfs diff=lfs merge=lfs -text
2
+ Mistral-Small-Instruct-2409-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
3
+ Mistral-Small-Instruct-2409-Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
4
+ Mistral-Small-Instruct-2409-Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
5
+ Mistral-Small-Instruct-2409-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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:ac090abf1fe5ccf61e12179ae004cfbac6e164ab60da8005b5c24bf023945ba7
3
+ size 11730429824
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:755071c1caa2b9efb98e73c15fb7a2ea683c0587cdf34bcebc90bc4db36162b1
3
+ size 13341239168
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:6c530a08ff34acfd62eba1d568014fefc0428b9413250d1f9cd2600a613037d5
3
+ size 15722555264
Mistral-Small-Instruct-2409-Q6_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:915db9ebc1ded552464a561e79bd0472ee5844a851e002553263a024e391e816
3
+ size 18252703616
Mistral-Small-Instruct-2409-Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16b26522cd7d946cfd67fb6fd28db885c99207df30187836ebcfdaecc15f28f2
3
+ size 23640549248
README.md ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: If you want to learn more about how we process your personal
17
+ data, please read our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
18
+ ---
19
+
20
+ # Model Card for Mistral-Small-Instruct-2409
21
+
22
+ Mistral-Small-Instruct-2409 is an instruct fine-tuned version with the following characteristics:
23
+
24
+ - 22B parameters
25
+ - Vocabulary to 32768
26
+ - Supports function calling
27
+ - 128k sequence length
28
+
29
+
30
+ ## Usage Examples
31
+
32
+ ### vLLM (recommended)
33
+
34
+ We recommend using this model with the [vLLM library](https://github.com/vllm-project/vllm)
35
+ to implement production-ready inference pipelines.
36
+
37
+ **_Installation_**
38
+
39
+ Make sure you install `vLLM >= v0.6.1.post1`:
40
+
41
+ ```
42
+ pip install --upgrade vllm
43
+ ```
44
+
45
+ Also make sure you have `mistral_common >= 1.4.1` installed:
46
+
47
+ ```
48
+ pip install --upgrade mistral_common
49
+ ```
50
+
51
+ 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).
52
+
53
+
54
+ **_Offline_**
55
+
56
+ ```py
57
+ from vllm import LLM
58
+ from vllm.sampling_params import SamplingParams
59
+
60
+ model_name = "mistralai/Mistral-Small-Instruct-2409"
61
+
62
+ sampling_params = SamplingParams(max_tokens=8192)
63
+
64
+ # note that running Mistral-Small on a single GPU requires at least 44 GB of GPU RAM
65
+ # If you want to divide the GPU requirement over multiple devices, please add *e.g.* `tensor_parallel=2`
66
+ llm = LLM(model=model_name, tokenizer_mode="mistral", config_format="mistral", load_format="mistral")
67
+
68
+ prompt = "How often does the letter r occur in Mistral?"
69
+
70
+ messages = [
71
+ {
72
+ "role": "user",
73
+ "content": prompt
74
+ },
75
+ ]
76
+
77
+ outputs = llm.chat(messages, sampling_params=sampling_params)
78
+
79
+ print(outputs[0].outputs[0].text)
80
+ ```
81
+
82
+ **_Server_**
83
+
84
+ You can also use Mistral Small in a server/client setting.
85
+
86
+ 1. Spin up a server:
87
+
88
+
89
+ ```
90
+ vllm serve mistralai/Mistral-Small-Instruct-2409 --tokenizer_mode mistral --config_format mistral --load_format mistral
91
+ ```
92
+
93
+ **Note:** Running Mistral-Small on a single GPU requires at least 44 GB of GPU RAM.
94
+
95
+ If you want to divide the GPU requirement over multiple devices, please add *e.g.* `--tensor_parallel=2`
96
+
97
+ 2. And ping the client:
98
+
99
+ ```
100
+ curl --location 'http://<your-node-url>:8000/v1/chat/completions' \
101
+ --header 'Content-Type: application/json' \
102
+ --header 'Authorization: Bearer token' \
103
+ --data '{
104
+ "model": "mistralai/Mistral-Small-Instruct-2409",
105
+ "messages": [
106
+ {
107
+ "role": "user",
108
+ "content": "How often does the letter r occur in Mistral?"
109
+ }
110
+ ]
111
+ }'
112
+
113
+ ```
114
+
115
+ ### Mistral-inference
116
+
117
+ We recommend using [mistral-inference](https://github.com/mistralai/mistral-inference) to quickly try out / "vibe-check" the model.
118
+
119
+
120
+ **_Install_**
121
+
122
+ Make sure to have `mistral_inference >= 1.4.1` installed.
123
+
124
+ ```
125
+ pip install mistral_inference --upgrade
126
+ ```
127
+
128
+ **_Download_**
129
+
130
+ ```py
131
+ from huggingface_hub import snapshot_download
132
+ from pathlib import Path
133
+
134
+ mistral_models_path = Path.home().joinpath('mistral_models', '22B-Instruct-Small')
135
+ mistral_models_path.mkdir(parents=True, exist_ok=True)
136
+
137
+ snapshot_download(repo_id="mistralai/Mistral-Small-Instruct-2409", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
138
+ ```
139
+
140
+ ### Chat
141
+
142
+ After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment. You can chat with the model using
143
+
144
+ ```
145
+ mistral-chat $HOME/mistral_models/22B-Instruct-Small --instruct --max_tokens 256
146
+ ```
147
+
148
+ ### Instruct following
149
+
150
+ ```py
151
+ from mistral_inference.transformer import Transformer
152
+ from mistral_inference.generate import generate
153
+
154
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
155
+ from mistral_common.protocol.instruct.messages import UserMessage
156
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
157
+
158
+
159
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
160
+ model = Transformer.from_folder(mistral_models_path)
161
+
162
+ completion_request = ChatCompletionRequest(messages=[UserMessage(content="How often does the letter r occur in Mistral?")])
163
+
164
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
165
+
166
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
167
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
168
+
169
+ print(result)
170
+ ```
171
+
172
+ ### Function calling
173
+
174
+ ```py
175
+ from mistral_common.protocol.instruct.tool_calls import Function, Tool
176
+ from mistral_inference.transformer import Transformer
177
+ from mistral_inference.generate import generate
178
+
179
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
180
+ from mistral_common.protocol.instruct.messages import UserMessage
181
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
182
+
183
+
184
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
185
+ model = Transformer.from_folder(mistral_models_path)
186
+
187
+ completion_request = ChatCompletionRequest(
188
+ tools=[
189
+ Tool(
190
+ function=Function(
191
+ name="get_current_weather",
192
+ description="Get the current weather",
193
+ parameters={
194
+ "type": "object",
195
+ "properties": {
196
+ "location": {
197
+ "type": "string",
198
+ "description": "The city and state, e.g. San Francisco, CA",
199
+ },
200
+ "format": {
201
+ "type": "string",
202
+ "enum": ["celsius", "fahrenheit"],
203
+ "description": "The temperature unit to use. Infer this from the users location.",
204
+ },
205
+ },
206
+ "required": ["location", "format"],
207
+ },
208
+ )
209
+ )
210
+ ],
211
+ messages=[
212
+ UserMessage(content="What's the weather like today in Paris?"),
213
+ ],
214
+ )
215
+
216
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
217
+
218
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
219
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
220
+
221
+ print(result)
222
+ ```
223
+
224
+ ### Usage in Hugging Face Transformers
225
+
226
+ You can also use Hugging Face `transformers` library to run inference using various chat templates, or fine-tune the model.
227
+ Example for inference:
228
+
229
+ ```python
230
+ from transformers import LlamaTokenizerFast, MistralForCausalLM
231
+ import torch
232
+
233
+ device = "cuda"
234
+ tokenizer = LlamaTokenizerFast.from_pretrained('mistralai/Mistral-Small-Instruct-2409')
235
+ tokenizer.pad_token = tokenizer.eos_token
236
+
237
+ model = MistralForCausalLM.from_pretrained('mistralai/Mistral-Small-Instruct-2409', torch_dtype=torch.bfloat16)
238
+ model = model.to(device)
239
+
240
+ prompt = "How often does the letter r occur in Mistral?"
241
+
242
+ messages = [
243
+ {"role": "user", "content": prompt},
244
+ ]
245
+
246
+ model_input = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(device)
247
+ gen = model.generate(model_input, max_new_tokens=150)
248
+ dec = tokenizer.batch_decode(gen)
249
+ print(dec)
250
+ ```
251
+
252
+ And you should obtain
253
+ ```text
254
+ <s>
255
+ [INST]
256
+ How often does the letter r occur in Mistral?
257
+ [/INST]
258
+ To determine how often the letter "r" occurs in the word "Mistral,"
259
+ we can simply count the instances of "r" in the word.
260
+ The word "Mistral" is broken down as follows:
261
+ - M
262
+ - i
263
+ - s
264
+ - t
265
+ - r
266
+ - a
267
+ - l
268
+ Counting the "r"s, we find that there is only one "r" in "Mistral."
269
+ Therefore, the letter "r" occurs once in the word "Mistral."
270
+ </s>
271
+ ```
272
+
273
+ ## The Mistral AI Team
274
+
275
+ 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
tokenizer.model.v3 ADDED
Binary file (588 kB). View file