stelterlab commited on
Commit
7878939
·
verified ·
1 Parent(s): fdea05b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +416 -0
README.md ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: apache-2.0
14
+ library_name: vllm
15
+ inference: false
16
+ base_model:
17
+ - mistralai/Mistral-Small-24B-Instruct-2501
18
+ extra_gated_description: >-
19
+ If you want to learn more about how we process your personal data, please read
20
+ our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
21
+ tags:
22
+ - transformers
23
+ ---
24
+
25
+ AWQ quantization: done by stelterlab in INT4 GEMM with AutoAWQ by casper-hansen (https://github.com/casper-hansen/AutoAWQ/)
26
+
27
+ Original Weights by the Mistral AI. Original Model Card follows:
28
+
29
+ # Model Card for Mistral-Small-24B-Instruct-2501
30
+
31
+ Mistral Small 3 ( 2501 ) sets a new benchmark in the "small" Large Language Models category below 70B, boasting 24B parameters and achieving state-of-the-art capabilities comparable to larger models!
32
+ This model is an instruction-fine-tuned version of the base model: [Mistral-Small-24B-Base-2501](https://huggingface.co/mistralai/Mistral-Small-24B-Base-2501).
33
+
34
+ Mistral Small can be deployed locally and is exceptionally "knowledge-dense", fitting in a single RTX 4090 or a 32GB RAM MacBook once quantized.
35
+ Perfect for:
36
+ - Fast response conversational agents.
37
+ - Low latency function calling.
38
+ - Subject matter experts via fine-tuning.
39
+ - Local inference for hobbyists and organizations handling sensitive data.
40
+
41
+ For enterprises that need specialized capabilities (increased context, particular modalities, domain specific knowledge, etc.), we will be releasing commercial models beyond what Mistral AI contributes to the community.
42
+
43
+ This release demonstrates our commitment to open source, serving as a strong base model.
44
+
45
+ Learn more about Mistral Small in our [blog post](https://mistral.ai/news/mistral-small-3/).
46
+
47
+ Model developper: Mistral AI Team
48
+
49
+ ## Key Features
50
+ - **Multilingual:** Supports dozens of languages, including English, French, German, Spanish, Italian, Chinese, Japanese, Korean, Portuguese, Dutch, and Polish.
51
+ - **Agent-Centric:** Offers best-in-class agentic capabilities with native function calling and JSON outputting.
52
+ - **Advanced Reasoning:** State-of-the-art conversational and reasoning capabilities.
53
+ - **Apache 2.0 License:** Open license allowing usage and modification for both commercial and non-commercial purposes.
54
+ - **Context Window:** A 32k context window.
55
+ - **System Prompt:** Maintains strong adherence and support for system prompts.
56
+ - **Tokenizer:** Utilizes a Tekken tokenizer with a 131k vocabulary size.
57
+
58
+ ## Benchmark results
59
+
60
+
61
+ ### Human evaluated benchmarks
62
+
63
+ | Category | Gemma-2-27B | Qwen-2.5-32B | Llama-3.3-70B | Gpt4o-mini |
64
+ |----------|-------------|--------------|---------------|------------|
65
+ | Mistral is better | 0.536 | 0.496 | 0.192 | 0.200 |
66
+ | Mistral is slightly better | 0.196 | 0.184 | 0.164 | 0.204 |
67
+ | Ties | 0.052 | 0.060 | 0.236 | 0.160 |
68
+ | Other is slightly better | 0.060 | 0.088 | 0.112 | 0.124 |
69
+ | Other is better | 0.156 | 0.172 | 0.296 | 0.312 |
70
+
71
+ **Note**:
72
+
73
+ - We conducted side by side evaluations with an external third-party vendor, on a set of over 1k proprietary coding and generalist prompts.
74
+ - Evaluators were tasked with selecting their preferred model response from anonymized generations produced by Mistral Small 3 vs another model.
75
+ - We are aware that in some cases the benchmarks on human judgement starkly differ from publicly available benchmarks, but have taken extra caution in verifying a fair evaluation. We are confident that the above benchmarks are valid.
76
+
77
+ ### Publicly accesible benchmarks
78
+
79
+ **Reasoning & Knowledge**
80
+
81
+ | Evaluation | mistral-small-24B-instruct-2501 | gemma-2b-27b | llama-3.3-70b | qwen2.5-32b | gpt-4o-mini-2024-07-18 |
82
+ |------------|---------------|--------------|---------------|---------------|-------------|
83
+ | mmlu_pro_5shot_cot_instruct | 0.663 | 0.536 | 0.666 | 0.683 | 0.617 |
84
+ | gpqa_main_cot_5shot_instruct | 0.453 | 0.344 | 0.531 | 0.404 | 0.377 |
85
+
86
+ **Math & Coding**
87
+
88
+ | Evaluation | mistral-small-24B-instruct-2501 | gemma-2b-27b | llama-3.3-70b | qwen2.5-32b | gpt-4o-mini-2024-07-18 |
89
+ |------------|---------------|--------------|---------------|---------------|-------------|
90
+ | humaneval_instruct_pass@1 | 0.848 | 0.732 | 0.854 | 0.909 | 0.890 |
91
+ | math_instruct | 0.706 | 0.535 | 0.743 | 0.819 | 0.761 |
92
+
93
+ **Instruction following**
94
+
95
+ | Evaluation | mistral-small-24B-instruct-2501 | gemma-2b-27b | llama-3.3-70b | qwen2.5-32b | gpt-4o-mini-2024-07-18 |
96
+ |------------|---------------|--------------|---------------|---------------|-------------|
97
+ | mtbench_dev | 8.35 | 7.86 | 7.96 | 8.26 | 8.33 |
98
+ | wildbench | 52.27 | 48.21 | 50.04 | 52.73 | 56.13 |
99
+ | arena_hard | 0.873 | 0.788 | 0.840 | 0.860 | 0.897 |
100
+ | ifeval | 0.829 | 0.8065 | 0.8835 | 0.8401 | 0.8499 |
101
+
102
+ **Note**:
103
+
104
+ - Performance accuracy on all benchmarks were obtained through the same internal evaluation pipeline - as such, numbers may vary slightly from previously reported performance
105
+ ([Qwen2.5-32B-Instruct](https://qwenlm.github.io/blog/qwen2.5/), [Llama-3.3-70B-Instruct](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct), [Gemma-2-27B-IT](https://huggingface.co/google/gemma-2-27b-it)).
106
+ - Judge based evals such as Wildbench, Arena hard and MTBench were based on gpt-4o-2024-05-13.
107
+
108
+ ### Basic Instruct Template (V7-Tekken)
109
+
110
+ ```
111
+ <s>[SYSTEM_PROMPT]<system prompt>[/SYSTEM_PROMPT][INST]<user message>[/INST]<assistant response></s>[INST]<user message>[/INST]
112
+ ```
113
+ *`<system_prompt>`, `<user message>` and `<assistant response>` are placeholders.*
114
+
115
+ ***Please make sure to use [mistral-common](https://github.com/mistralai/mistral-common) as the source of truth***
116
+
117
+ ## Usage
118
+
119
+ The model can be used with the following frameworks;
120
+ - [`vllm`](https://github.com/vllm-project/vllm): See [here](#vLLM)
121
+ - [`transformers`](https://github.com/huggingface/transformers): See [here](#Transformers)
122
+
123
+ ### vLLM
124
+
125
+ We recommend using this model with the [vLLM library](https://github.com/vllm-project/vllm)
126
+ to implement production-ready inference pipelines.
127
+
128
+ **Note 1**: We recommond using a relatively low temperature, such as `temperature=0.15`.
129
+
130
+ **Note 2**: Make sure to add a system prompt to the model to best tailer it for your needs. If you want to use the model as a general assistant, we recommend the following
131
+ system prompt:
132
+
133
+ ```
134
+ system_prompt = """You are Mistral Small 3, a Large Language Model (LLM) created by Mistral AI, a French startup headquartered in Paris.
135
+ Your knowledge base was last updated on 2023-10-01. The current date is 2025-01-30.
136
+ When you're not sure about some information, you say that you don't have the information and don't make up anything.
137
+ If the user's question is not clear, ambiguous, or does not provide enough context for you to accurately answer the question, you do not try to answer it right away and you rather ask the user to clarify their request (e.g. \"What are some good restaurants around me?\" => \"Where are you?\" or \"When is the next flight to Tokyo\" => \"Where do you travel from?\")"""
138
+ ```
139
+
140
+ **_Installation_**
141
+
142
+ Make sure you install [`vLLM >= 0.6.4`](https://github.com/vllm-project/vllm/releases/tag/v0.6.4):
143
+
144
+ ```
145
+ pip install --upgrade vllm
146
+ ```
147
+
148
+ Also make sure you have [`mistral_common >= 1.5.2`](https://github.com/mistralai/mistral-common/releases/tag/v1.5.2) installed:
149
+
150
+ ```
151
+ pip install --upgrade mistral_common
152
+ ```
153
+
154
+ You can also make use of a ready-to-go [docker image](https://github.com/vllm-project/vllm/blob/main/Dockerfile) or on the [docker hub](https://hub.docker.com/layers/vllm/vllm-openai/latest/images/sha256-de9032a92ffea7b5c007dad80b38fd44aac11eddc31c435f8e52f3b7404bbf39).
155
+
156
+ #### Server
157
+
158
+ We recommand that you use Mistral-Small-24B-Instruct-2501 in a server/client setting.
159
+
160
+ 1. Spin up a server:
161
+
162
+ ```
163
+ vllm serve mistralai/Mistral-Small-24B-Instruct-2501 --tokenizer_mode mistral --config_format mistral --load_format mistral --tool-call-parser mistral --enable-auto-tool-choice
164
+ ```
165
+
166
+ **Note:** Running Mistral-Small-24B-Instruct-2501 on GPU requires ~55 GB of GPU RAM in bf16 or fp16.
167
+
168
+
169
+ 2. To ping the client you can use a simple Python snippet.
170
+
171
+ ```py
172
+ import requests
173
+ import json
174
+ from datetime import datetime, timedelta
175
+
176
+ url = "http://<your-server>:8000/v1/chat/completions"
177
+ headers = {"Content-Type": "application/json", "Authorization": "Bearer token"}
178
+
179
+ model = "mistralai/Mistral-Small-24B-Instruct-2501"
180
+
181
+ messages = [
182
+ {
183
+ "role": "system",
184
+ "content": "You are a conversational agent that always answers straight to the point, always end your accurate response with an ASCII drawing of a cat."
185
+ },
186
+ {
187
+ "role": "user",
188
+ "content": "Give me 5 non-formal ways to say 'See you later' in French."
189
+ },
190
+ ]
191
+
192
+ data = {"model": model, "messages": messages}
193
+
194
+ response = requests.post(url, headers=headers, data=json.dumps(data))
195
+ print(response.json()["choices"][0]["message"]["content"])
196
+
197
+ # Sure, here are five non-formal ways to say "See you later" in French:
198
+ #
199
+ # 1. À plus tard
200
+ # 2. À plus
201
+ # 3. Salut
202
+ # 4. À toute
203
+ # 5. Bisous
204
+ #
205
+ # ```
206
+ # /\_/\
207
+ # ( o.o )
208
+ # > ^ <
209
+ # ```
210
+ ```
211
+
212
+ ### Function calling
213
+
214
+ Mistral-Small-24-Instruct-2501 is excellent at function / tool calling tasks via vLLM. *E.g.:*
215
+
216
+ <details>
217
+ <summary>Example</summary>
218
+
219
+ ```py
220
+ import requests
221
+ import json
222
+ from huggingface_hub import hf_hub_download
223
+ from datetime import datetime, timedelta
224
+
225
+ url = "http://<your-url>:8000/v1/chat/completions"
226
+ headers = {"Content-Type": "application/json", "Authorization": "Bearer token"}
227
+
228
+ model = "mistralai/Mistral-Small-24B-Instruct-2501"
229
+
230
+
231
+ def load_system_prompt(repo_id: str, filename: str) -> str:
232
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
233
+ with open(file_path, "r") as file:
234
+ system_prompt = file.read()
235
+ today = datetime.today().strftime("%Y-%m-%d")
236
+ yesterday = (datetime.today() - timedelta(days=1)).strftime("%Y-%m-%d")
237
+ model_name = repo_id.split("/")[-1]
238
+ return system_prompt.format(name=model_name, today=today, yesterday=yesterday)
239
+
240
+
241
+ SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
242
+
243
+
244
+ tools = [
245
+ {
246
+ "type": "function",
247
+ "function": {
248
+ "name": "get_current_weather",
249
+ "description": "Get the current weather in a given location",
250
+ "parameters": {
251
+ "type": "object",
252
+ "properties": {
253
+ "city": {
254
+ "type": "string",
255
+ "description": "The city to find the weather for, e.g. 'San Francisco'",
256
+ },
257
+ "state": {
258
+ "type": "string",
259
+ "description": "The state abbreviation, e.g. 'CA' for California",
260
+ },
261
+ "unit": {
262
+ "type": "string",
263
+ "description": "The unit for temperature",
264
+ "enum": ["celsius", "fahrenheit"],
265
+ },
266
+ },
267
+ "required": ["city", "state", "unit"],
268
+ },
269
+ },
270
+ },
271
+ {
272
+ "type": "function",
273
+ "function": {
274
+ "name": "rewrite",
275
+ "description": "Rewrite a given text for improved clarity",
276
+ "parameters": {
277
+ "type": "object",
278
+ "properties": {
279
+ "text": {
280
+ "type": "string",
281
+ "description": "The input text to rewrite",
282
+ }
283
+ },
284
+ },
285
+ },
286
+ },
287
+ ]
288
+
289
+ messages = [
290
+ {"role": "system", "content": SYSTEM_PROMPT},
291
+ {
292
+ "role": "user",
293
+ "content": "Could you please make the below article more concise?\n\nOpenAI is an artificial intelligence research laboratory consisting of the non-profit OpenAI Incorporated and its for-profit subsidiary corporation OpenAI Limited Partnership.",
294
+ },
295
+ {
296
+ "role": "assistant",
297
+ "content": "",
298
+ "tool_calls": [
299
+ {
300
+ "id": "bbc5b7ede",
301
+ "type": "function",
302
+ "function": {
303
+ "name": "rewrite",
304
+ "arguments": '{"text": "OpenAI is an artificial intelligence research laboratory consisting of the non-profit OpenAI Incorporated and its for-profit subsidiary corporation OpenAI Limited Partnership."}',
305
+ },
306
+ }
307
+ ],
308
+ },
309
+ {
310
+ "role": "tool",
311
+ "content": '{"action":"rewrite","outcome":"OpenAI is a FOR-profit company."}',
312
+ "tool_call_id": "bbc5b7ede",
313
+ "name": "rewrite",
314
+ },
315
+ {
316
+ "role": "assistant",
317
+ "content": "---\n\nOpenAI is a FOR-profit company.",
318
+ },
319
+ {
320
+ "role": "user",
321
+ "content": "Can you tell me what the temperature will be in Dallas, in Fahrenheit?",
322
+ },
323
+ ]
324
+
325
+ data = {"model": model, "messages": messages, "tools": tools}
326
+
327
+ response = requests.post(url, headers=headers, data=json.dumps(data))
328
+ import ipdb; ipdb.set_trace()
329
+ print(response.json()["choices"][0]["message"]["tool_calls"])
330
+ # [{'id': '8PdihwL6d', 'type': 'function', 'function': {'name': 'get_current_weather', 'arguments': '{"city": "Dallas", "state": "TX", "unit": "fahrenheit"}'}}]
331
+ ```
332
+
333
+ </details>
334
+
335
+ #### Offline
336
+
337
+ ```py
338
+ from vllm import LLM
339
+ from vllm.sampling_params import SamplingParams
340
+ from datetime import datetime, timedelta
341
+
342
+ SYSTEM_PROMPT = "You are a conversational agent that always answers straight to the point, always end your accurate response with an ASCII drawing of a cat."
343
+
344
+ user_prompt = "Give me 5 non-formal ways to say 'See you later' in French."
345
+
346
+ messages = [
347
+ {
348
+ "role": "system",
349
+ "content": SYSTEM_PROMPT
350
+ },
351
+ {
352
+ "role": "user",
353
+ "content": user_prompt
354
+ },
355
+ ]
356
+
357
+ # note that running this model on GPU requires over 60 GB of GPU RAM
358
+ llm = LLM(model=model_name, tokenizer_mode="mistral", tensor_parallel_size=8)
359
+
360
+ sampling_params = SamplingParams(max_tokens=512, temperature=0.15)
361
+ outputs = llm.chat(messages, sampling_params=sampling_params)
362
+
363
+ print(outputs[0].outputs[0].text)
364
+ # Sure, here are five non-formal ways to say "See you later" in French:
365
+ #
366
+ # 1. À plus tard
367
+ # 2. À plus
368
+ # 3. Salut
369
+ # 4. À toute
370
+ # 5. Bisous
371
+ #
372
+ # ```
373
+ # /\_/\
374
+ # ( o.o )
375
+ # > ^ <
376
+ # ```
377
+ ```
378
+
379
+ ### Transformers
380
+
381
+ If you want to use Hugging Face transformers to generate text, you can do something like this.
382
+
383
+ ```py
384
+ from transformers import pipeline
385
+ import torch
386
+
387
+ messages = [
388
+ {"role": "user", "content": "Give me 5 non-formal ways to say 'See you later' in French."},
389
+ ]
390
+ chatbot = pipeline("text-generation", model="mistralai/Mistral-Small-24B-Instruct-2501", max_new_tokens=256, torch_dtype=torch.bfloat16)
391
+ chatbot(messages)
392
+ ```
393
+
394
+
395
+ ### Ollama
396
+
397
+ [Ollama](https://github.com/ollama/ollama) can run this model locally on MacOS, Windows and Linux.
398
+
399
+ ```
400
+ ollama run mistral-small
401
+ ```
402
+
403
+ 4-bit quantization (aliased to default):
404
+ ```
405
+ ollama run mistral-small:24b-instruct-2501-q4_K_M
406
+ ```
407
+
408
+ 8-bit quantization:
409
+ ```
410
+ ollama run mistral-small:24b-instruct-2501-q8_0
411
+ ```
412
+
413
+ FP16:
414
+ ```
415
+ ollama run mistral-small:24b-instruct-2501-fp16
416
+ ```