mgoin commited on
Commit
9c4c171
·
verified ·
1 Parent(s): 06a0f90

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ 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
+ tekken.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,699 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - fr
5
+ - de
6
+ - es
7
+ - pt
8
+ - it
9
+ - ja
10
+ - ko
11
+ - ru
12
+ - zh
13
+ - ar
14
+ - fa
15
+ - id
16
+ - ms
17
+ - ne
18
+ - pl
19
+ - ro
20
+ - sr
21
+ - sv
22
+ - tr
23
+ - uk
24
+ - vi
25
+ - hi
26
+ - bn
27
+ license: apache-2.0
28
+ library_name: vllm
29
+ inference: false
30
+ base_model:
31
+ - mistralai/Mistral-Small-3.1-24B-Base-2503
32
+ extra_gated_description: >-
33
+ If you want to learn more about how we process your personal data, please read
34
+ our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
35
+ pipeline_tag: image-text-to-text
36
+ ---
37
+
38
+ Deploy this FP8 quantized variant with vLLM using:
39
+
40
+ ```
41
+ vllm serve RedHatAI/Mistral-Small-3.2-24B-Instruct-2506-FP8 --tokenizer_mode mistral --config_format mistral --load_format mistral --tool-call-parser mistral --enable-auto-tool-choice --limit_mm_per_prompt 'image=10
42
+ ```
43
+
44
+ # Mistral-Small-3.2-24B-Instruct-2506
45
+
46
+ Mistral-Small-3.2-24B-Instruct-2506 is a minor update of [Mistral-Small-3.1-24B-Instruct-2503](https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503).
47
+
48
+ Small-3.2 improves in the following categories:
49
+ - **Instruction following**: Small-3.2 is better at following precise instructions
50
+ - **Repetition errors**: Small-3.2 produces less infinite generations or repetitive answers
51
+ - **Function calling**: Small-3.2's function calling template is more robust (see [here](https://github.com/mistralai/mistral-common/blob/535b4d0a0fc94674ea17db6cf8dc2079b81cbcfa/src/mistral_common/tokens/tokenizers/instruct.py#L778) and [examples](#function-calling))
52
+
53
+ In all other categories Small-3.2 should match or slightly improve compared to [Mistral-Small-3.1-24B-Instruct-2503](https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503).
54
+
55
+ ## Key Features
56
+ - same as [Mistral-Small-3.1-24B-Instruct-2503](https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503#key-features)
57
+
58
+ ## Benchmark Results
59
+
60
+ We compare Mistral-Small-3.2-24B to [Mistral-Small-3.1-24B-Instruct-2503](https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503).
61
+ For more comparison against other models of similar size, please check [Mistral-Small-3.1's Benchmarks'](https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503#benchmark-results)
62
+
63
+ ### Text
64
+
65
+ #### Instruction Following / Chat / Tone
66
+
67
+ | Model | Wildbench v2 | Arena Hard v2 | IF (Internal; accuracy) |
68
+ |-------|---------------|---------------|------------------------|
69
+ | Small 3.1 24B Instruct | 55.6% | 19.56% | 82.75% |
70
+ | **Small 3.2 24B Instruct** | **65.33%** | **43.1%** | **84.78%** |
71
+
72
+ #### Infinite Generations
73
+
74
+ Small 3.2 reduces infinite generations by 2x on challenging, long and repetitive prompts.
75
+
76
+ | Model | Infinite Generations (Internal; Lower is better) |
77
+ |-------|-------|
78
+ | Small 3.1 24B Instruct | 2.11% |
79
+ | **Small 3.2 24B Instruct** | **1.29%** |
80
+
81
+ #### STEM
82
+
83
+ | Model | MMLU | MMLU Pro (5-shot CoT) | MATH | GPQA Main (5-shot CoT) | GPQA Diamond (5-shot CoT )| MBPP Plus - Pass@5 | HumanEval Plus - Pass@5 | SimpleQA (TotalAcc)|
84
+ |--------------------------------|-----------|-----------------------|------------------------|------------------------|---------------------------|--------------------|-------------------------|--------------------|
85
+ | Small 3.1 24B Instruct | 80.62% | 66.76% | 69.30% | 44.42% | 45.96% | 74.63% | 88.99% | 10.43% |
86
+ | **Small 3.2 24B Instruct** | 80.50% | **69.06%** | 69.42% | 44.22% | 46.13% | **78.33%** | **92.90%** | **12.10%** |
87
+
88
+ ### Vision
89
+
90
+ | Model | MMMU | Mathvista | ChartQA | DocVQA | AI2D |
91
+ |--------------------------------|------------|-----------|-----------|-----------|-----------|
92
+ | Small 3.1 24B Instruct | **64.00%** | **68.91%**| 86.24% | 94.08% | 93.72% |
93
+ | **Small 3.2 24B Instruct** | 62.50% | 67.09% | **87.4%** | 94.86% | 92.91% |
94
+
95
+
96
+ ## Usage
97
+
98
+ The model can be used with the following frameworks;
99
+ - [`vllm (recommended)`](https://github.com/vllm-project/vllm): See [here](#vllm-recommended)
100
+ - [`transformers`](https://github.com/huggingface/transformers): See [here](#transformers)
101
+
102
+ **Note 1**: We recommend using a relatively low temperature, such as `temperature=0.15`.
103
+
104
+ **Note 2**: Make sure to add a system prompt to the model to best tailor it to your needs. If you want to use the model as a general assistant, we recommend to use the one provided in the [SYSTEM_PROMPT.txt](https://huggingface.co/mistralai/Mistral-Small-3.2-24B-Instruct-2506/blob/main/SYSTEM_PROMPT.txt) file.
105
+
106
+ ### vLLM (recommended)
107
+
108
+ We recommend using this model with [vLLM](https://github.com/vllm-project/vllm).
109
+
110
+ #### Installation
111
+
112
+ Make sure to install [`vLLM >= 0.9.1`](https://github.com/vllm-project/vllm/releases/tag/v0.9.1):
113
+
114
+ ```
115
+ pip install vllm --upgrade
116
+ ```
117
+
118
+ Doing so should automatically install [`mistral_common >= 1.6.2`](https://github.com/mistralai/mistral-common/releases/tag/v1.6.2).
119
+
120
+ To check:
121
+ ```
122
+ python -c "import mistral_common; print(mistral_common.__version__)"
123
+ ```
124
+
125
+ 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).
126
+
127
+ #### Serve
128
+
129
+ We recommend that you use Mistral-Small-3.2-24B-Instruct-2506 in a server/client setting.
130
+
131
+ 1. Spin up a server:
132
+
133
+ ```
134
+ vllm serve mistralai/Mistral-Small-3.2-24B-Instruct-2506 --tokenizer_mode mistral --config_format mistral --load_format mistral --tool-call-parser mistral --enable-auto-tool-choice --limit_mm_per_prompt 'image=10' --tensor-parallel-size 2
135
+ ```
136
+
137
+ **Note:** Running Mistral-Small-3.2-24B-Instruct-2506 on GPU requires ~55 GB of GPU RAM in bf16 or fp16.
138
+
139
+
140
+ 2. To ping the client you can use a simple Python snippet. See the following examples.
141
+
142
+
143
+ #### Vision reasoning
144
+
145
+ Leverage the vision capabilities of Mistral-Small-3.2-24B-Instruct-2506 to make the best choice given a scenario, go catch them all !
146
+
147
+ <details>
148
+ <summary>Python snippet</summary>
149
+
150
+ ```py
151
+ from datetime import datetime, timedelta
152
+
153
+ from openai import OpenAI
154
+ from huggingface_hub import hf_hub_download
155
+
156
+ # Modify OpenAI's API key and API base to use vLLM's API server.
157
+ openai_api_key = "EMPTY"
158
+ openai_api_base = "http://localhost:8000/v1"
159
+
160
+ TEMP = 0.15
161
+ MAX_TOK = 131072
162
+
163
+ client = OpenAI(
164
+ api_key=openai_api_key,
165
+ base_url=openai_api_base,
166
+ )
167
+
168
+ models = client.models.list()
169
+ model = models.data[0].id
170
+
171
+
172
+ def load_system_prompt(repo_id: str, filename: str) -> str:
173
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
174
+ with open(file_path, "r") as file:
175
+ system_prompt = file.read()
176
+ today = datetime.today().strftime("%Y-%m-%d")
177
+ yesterday = (datetime.today() - timedelta(days=1)).strftime("%Y-%m-%d")
178
+ model_name = repo_id.split("/")[-1]
179
+ return system_prompt.format(name=model_name, today=today, yesterday=yesterday)
180
+
181
+
182
+ model_id = "mistralai/Mistral-Small-3.2-24B-Instruct-2506"
183
+ SYSTEM_PROMPT = load_system_prompt(model_id, "SYSTEM_PROMPT.txt")
184
+ image_url = "https://static.wikia.nocookie.net/essentialsdocs/images/7/70/Battle.png/revision/latest?cb=20220523172438"
185
+
186
+ messages = [
187
+ {"role": "system", "content": SYSTEM_PROMPT},
188
+ {
189
+ "role": "user",
190
+ "content": [
191
+ {
192
+ "type": "text",
193
+ "text": "What action do you think I should take in this situation? List all the possible actions and explain why you think they are good or bad.",
194
+ },
195
+ {"type": "image_url", "image_url": {"url": image_url}},
196
+ ],
197
+ },
198
+ ]
199
+
200
+
201
+ response = client.chat.completions.create(
202
+ model=model,
203
+ messages=messages,
204
+ temperature=TEMP,
205
+ max_tokens=MAX_TOK,
206
+ )
207
+
208
+ print(response.choices[0].message.content)
209
+ # In this situation, you are playing a Pokémon game where your Pikachu (Level 42) is facing a wild Pidgey (Level 17). Here are the possible actions you can take and an analysis of each:
210
+
211
+ # 1. **FIGHT**:
212
+ # - **Pros**: Pikachu is significantly higher level than the wild Pidgey, which suggests that it should be able to defeat Pidgey easily. This could be a good opportunity to gain experience points and possibly items or money.
213
+ # - **Cons**: There is always a small risk of Pikachu fainting, especially if Pidgey has a powerful move or a status effect that could hinder Pikachu. However, given the large level difference, this risk is minimal.
214
+
215
+ # 2. **BAG**:
216
+ # - **Pros**: You might have items in your bag that could help in this battle, such as Potions, Poké Balls, or Berries. Using an item could help you capture the Pidgey or heal your Pikachu if needed.
217
+ # - **Cons**: Using items might not be necessary given the level difference. It could be more efficient to just fight and defeat the Pidgey quickly.
218
+
219
+ # 3. **POKÉMON**:
220
+ # - **Pros**: You might have another Pokémon in your party that is better suited for this battle or that you want to gain experience. Switching Pokémon could also be a strategic move if you want to train a lower-level Pokémon.
221
+ # - **Cons**: Switching Pokémon might not be necessary since Pikachu is at a significant advantage. It could also waste time and potentially give Pidgey a turn to attack.
222
+
223
+ # 4. **RUN**:
224
+ # - **Pros**: Running away could save time and conserve your Pokémon's health and resources. If you are in a hurry or do not need the experience or items, running away is a safe option.
225
+ # - **Cons**: Running away means you miss out on the experience points and potential items or money that you could gain from defeating the Pidgey. It also means you do not get the chance to capture the Pidgey if you wanted to.
226
+
227
+ # ### Recommendation:
228
+ # Given the significant level advantage, the best action is likely to **FIGHT**. This will allow you to quickly defeat the Pidgey, gain experience points, and potentially earn items or money. If you are concerned about Pikachu's health, you could use an item from your **BAG** to heal it before or during the battle. Running away or switching Pokémon does not seem necessary in this situation.
229
+ ```
230
+ </details>
231
+
232
+ #### Function calling
233
+
234
+ Mistral-Small-3.2-24B-Instruct-2506 is excellent at function / tool calling tasks via vLLM. *E.g.:*
235
+
236
+ <details>
237
+ <summary>Python snippet - easy</summary>
238
+
239
+ ```py
240
+ from openai import OpenAI
241
+ from huggingface_hub import hf_hub_download
242
+
243
+ # Modify OpenAI's API key and API base to use vLLM's API server.
244
+ openai_api_key = "EMPTY"
245
+ openai_api_base = "http://localhost:8000/v1"
246
+
247
+ TEMP = 0.15
248
+ MAX_TOK = 131072
249
+
250
+ client = OpenAI(
251
+ api_key=openai_api_key,
252
+ base_url=openai_api_base,
253
+ )
254
+
255
+ models = client.models.list()
256
+ model = models.data[0].id
257
+
258
+ def load_system_prompt(repo_id: str, filename: str) -> str:
259
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
260
+ with open(file_path, "r") as file:
261
+ system_prompt = file.read()
262
+ return system_prompt
263
+
264
+ model_id = "mistralai/Mistral-Small-3.2-24B-Instruct-2506"
265
+ SYSTEM_PROMPT = load_system_prompt(model_id, "SYSTEM_PROMPT.txt")
266
+
267
+ image_url = "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/europe.png"
268
+
269
+ tools = [
270
+ {
271
+ "type": "function",
272
+ "function": {
273
+ "name": "get_current_population",
274
+ "description": "Get the up-to-date population of a given country.",
275
+ "parameters": {
276
+ "type": "object",
277
+ "properties": {
278
+ "country": {
279
+ "type": "string",
280
+ "description": "The country to find the population of.",
281
+ },
282
+ "unit": {
283
+ "type": "string",
284
+ "description": "The unit for the population.",
285
+ "enum": ["millions", "thousands"],
286
+ },
287
+ },
288
+ "required": ["country", "unit"],
289
+ },
290
+ },
291
+ },
292
+ {
293
+ "type": "function",
294
+ "function": {
295
+ "name": "rewrite",
296
+ "description": "Rewrite a given text for improved clarity",
297
+ "parameters": {
298
+ "type": "object",
299
+ "properties": {
300
+ "text": {
301
+ "type": "string",
302
+ "description": "The input text to rewrite",
303
+ }
304
+ },
305
+ },
306
+ },
307
+ },
308
+ ]
309
+
310
+ messages = [
311
+ {"role": "system", "content": SYSTEM_PROMPT},
312
+ {
313
+ "role": "user",
314
+ "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.",
315
+ },
316
+ {
317
+ "role": "assistant",
318
+ "content": "",
319
+ "tool_calls": [
320
+ {
321
+ "id": "bbc5b7ede",
322
+ "type": "function",
323
+ "function": {
324
+ "name": "rewrite",
325
+ "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."}',
326
+ },
327
+ }
328
+ ],
329
+ },
330
+ {
331
+ "role": "tool",
332
+ "content": '{"action":"rewrite","outcome":"OpenAI is a FOR-profit company."}',
333
+ "tool_call_id": "bbc5b7ede",
334
+ "name": "rewrite",
335
+ },
336
+ {
337
+ "role": "assistant",
338
+ "content": "---\n\nOpenAI is a FOR-profit company.",
339
+ },
340
+ {
341
+ "role": "user",
342
+ "content": [
343
+ {
344
+ "type": "text",
345
+ "text": "Can you tell me what is the biggest country depicted on the map?",
346
+ },
347
+ {
348
+ "type": "image_url",
349
+ "image_url": {
350
+ "url": image_url,
351
+ },
352
+ },
353
+ ],
354
+ }
355
+ ]
356
+
357
+ response = client.chat.completions.create(
358
+ model=model,
359
+ messages=messages,
360
+ temperature=TEMP,
361
+ max_tokens=MAX_TOK,
362
+ tools=tools,
363
+ tool_choice="auto",
364
+ )
365
+
366
+ assistant_message = response.choices[0].message.content
367
+ print(assistant_message)
368
+ # The biggest country depicted on the map is Russia.
369
+
370
+ messages.extend([
371
+ {"role": "assistant", "content": assistant_message},
372
+ {"role": "user", "content": "What is the population of that country in millions?"},
373
+ ])
374
+
375
+ response = client.chat.completions.create(
376
+ model=model,
377
+ messages=messages,
378
+ temperature=TEMP,
379
+ max_tokens=MAX_TOK,
380
+ tools=tools,
381
+ tool_choice="auto",
382
+ )
383
+
384
+ print(response.choices[0].message.tool_calls)
385
+ # [ChatCompletionMessageToolCall(id='3e92V6Vfo', function=Function(arguments='{"country": "Russia", "unit": "millions"}', name='get_current_population'), type='function')]
386
+ ```
387
+
388
+ </details>
389
+
390
+ <details>
391
+ <summary>Python snippet - complex</summary>
392
+
393
+ ```python
394
+ import json
395
+ from openai import OpenAI
396
+ from huggingface_hub import hf_hub_download
397
+
398
+ # Modify OpenAI's API key and API base to use vLLM's API server.
399
+ openai_api_key = "EMPTY"
400
+ openai_api_base = "http://localhost:8000/v1"
401
+
402
+ TEMP = 0.15
403
+ MAX_TOK = 131072
404
+
405
+ client = OpenAI(
406
+ api_key=openai_api_key,
407
+ base_url=openai_api_base,
408
+ )
409
+
410
+ models = client.models.list()
411
+ model = models.data[0].id
412
+
413
+
414
+ def load_system_prompt(repo_id: str, filename: str) -> str:
415
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
416
+ with open(file_path, "r") as file:
417
+ system_prompt = file.read()
418
+ return system_prompt
419
+
420
+
421
+ model_id = "mistralai/Mistral-Small-3.2-24B-Instruct-2506"
422
+ SYSTEM_PROMPT = load_system_prompt(model_id, "SYSTEM_PROMPT.txt")
423
+
424
+ image_url = "https://math-coaching.com/img/fiche/46/expressions-mathematiques.jpg"
425
+
426
+
427
+ def my_calculator(expression: str) -> str:
428
+ return str(eval(expression))
429
+
430
+
431
+ tools = [
432
+ {
433
+ "type": "function",
434
+ "function": {
435
+ "name": "my_calculator",
436
+ "description": "A calculator that can evaluate a mathematical expression.",
437
+ "parameters": {
438
+ "type": "object",
439
+ "properties": {
440
+ "expression": {
441
+ "type": "string",
442
+ "description": "The mathematical expression to evaluate.",
443
+ },
444
+ },
445
+ "required": ["expression"],
446
+ },
447
+ },
448
+ },
449
+ {
450
+ "type": "function",
451
+ "function": {
452
+ "name": "rewrite",
453
+ "description": "Rewrite a given text for improved clarity",
454
+ "parameters": {
455
+ "type": "object",
456
+ "properties": {
457
+ "text": {
458
+ "type": "string",
459
+ "description": "The input text to rewrite",
460
+ }
461
+ },
462
+ },
463
+ },
464
+ },
465
+ ]
466
+
467
+ messages = [
468
+ {"role": "system", "content": SYSTEM_PROMPT},
469
+ {
470
+ "role": "user",
471
+ "content": [
472
+ {
473
+ "type": "text",
474
+ "text": "Can you calculate the results for all the equations displayed in the image? Only compute the ones that involve numbers.",
475
+ },
476
+ {
477
+ "type": "image_url",
478
+ "image_url": {
479
+ "url": image_url,
480
+ },
481
+ },
482
+ ],
483
+ },
484
+ ]
485
+
486
+ response = client.chat.completions.create(
487
+ model=model,
488
+ messages=messages,
489
+ temperature=TEMP,
490
+ max_tokens=MAX_TOK,
491
+ tools=tools,
492
+ tool_choice="auto",
493
+ )
494
+
495
+ tool_calls = response.choices[0].message.tool_calls
496
+ print(tool_calls)
497
+ # [ChatCompletionMessageToolCall(id='CyQBSAtGh', function=Function(arguments='{"expression": "6 + 2 * 3"}', name='my_calculator'), type='function'), ChatCompletionMessageToolCall(id='KQqRCqvzc', function=Function(arguments='{"expression": "19 - (8 + 2) + 1"}', name='my_calculator'), type='function')]
498
+
499
+ results = []
500
+ for tool_call in tool_calls:
501
+ function_name = tool_call.function.name
502
+ function_args = tool_call.function.arguments
503
+ if function_name == "my_calculator":
504
+ result = my_calculator(**json.loads(function_args))
505
+ results.append(result)
506
+
507
+ messages.append({"role": "assistant", "tool_calls": tool_calls})
508
+ for tool_call, result in zip(tool_calls, results):
509
+ messages.append(
510
+ {
511
+ "role": "tool",
512
+ "tool_call_id": tool_call.id,
513
+ "name": tool_call.function.name,
514
+ "content": result,
515
+ }
516
+ )
517
+
518
+
519
+ response = client.chat.completions.create(
520
+ model=model,
521
+ messages=messages,
522
+ temperature=TEMP,
523
+ max_tokens=MAX_TOK,
524
+ )
525
+
526
+ print(response.choices[0].message.content)
527
+ # Here are the results for the equations that involve numbers:
528
+
529
+ # 1. \( 6 + 2 \times 3 = 12 \)
530
+ # 3. \( 19 - (8 + 2) + 1 = 10 \)
531
+
532
+ # For the other equations, you need to substitute the variables with specific values to compute the results.
533
+ ```
534
+
535
+ </details>
536
+
537
+ #### Instruction following
538
+
539
+ Mistral-Small-3.2-24B-Instruct-2506 will follow your instructions down to the last letter !
540
+
541
+ <details>
542
+ <summary>Python snippet</summary>
543
+
544
+ ```python
545
+ from openai import OpenAI
546
+ from huggingface_hub import hf_hub_download
547
+
548
+ # Modify OpenAI's API key and API base to use vLLM's API server.
549
+ openai_api_key = "EMPTY"
550
+ openai_api_base = "http://localhost:8000/v1"
551
+
552
+ TEMP = 0.15
553
+ MAX_TOK = 131072
554
+
555
+ client = OpenAI(
556
+ api_key=openai_api_key,
557
+ base_url=openai_api_base,
558
+ )
559
+
560
+ models = client.models.list()
561
+ model = models.data[0].id
562
+
563
+
564
+ def load_system_prompt(repo_id: str, filename: str) -> str:
565
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
566
+ with open(file_path, "r") as file:
567
+ system_prompt = file.read()
568
+ return system_prompt
569
+
570
+
571
+ model_id = "mistralai/Mistral-Small-3.2-24B-Instruct-2506"
572
+ SYSTEM_PROMPT = load_system_prompt(model_id, "SYSTEM_PROMPT.txt")
573
+
574
+ messages = [
575
+ {"role": "system", "content": SYSTEM_PROMPT},
576
+ {
577
+ "role": "user",
578
+ "content": "Write me a sentence where every word starts with the next letter in the alphabet - start with 'a' and end with 'z'.",
579
+ },
580
+ ]
581
+
582
+ response = client.chat.completions.create(
583
+ model=model,
584
+ messages=messages,
585
+ temperature=TEMP,
586
+ max_tokens=MAX_TOK,
587
+ )
588
+
589
+ assistant_message = response.choices[0].message.content
590
+ print(assistant_message)
591
+
592
+ # Here's a sentence where each word starts with the next letter of the alphabet, starting from 'a' and ending with 'z':
593
+
594
+ # "Always brave cats dance elegantly, fluffy giraffes happily ignore jungle kites, lovingly munching nuts, observing playful quails racing swiftly, tiny unicorns vaulting while xylophones yodel zealously."
595
+
596
+ # This sentence follows the sequence from A to Z without skipping any letters.
597
+ ```
598
+ </details>
599
+
600
+ ### Transformers
601
+
602
+ You can also use Mistral-Small-3.2-24B-Instruct-2506 with `Transformers` !
603
+
604
+ To make the best use of our model with `Transformers` make sure to have [installed](https://github.com/mistralai/mistral-common) `mistral-common >= 1.6.2` to use our tokenizer.
605
+
606
+ ```bash
607
+ pip install mistral-common --upgrade
608
+ ```
609
+
610
+ Then load our tokenizer along with the model and generate:
611
+
612
+ <details>
613
+ <summary>Python snippet</summary>
614
+
615
+ ```python
616
+ from datetime import datetime, timedelta
617
+ import torch
618
+
619
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
620
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
621
+ from huggingface_hub import hf_hub_download
622
+ from transformers import Mistral3ForConditionalGeneration
623
+
624
+
625
+ def load_system_prompt(repo_id: str, filename: str) -> str:
626
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
627
+ with open(file_path, "r") as file:
628
+ system_prompt = file.read()
629
+ today = datetime.today().strftime("%Y-%m-%d")
630
+ yesterday = (datetime.today() - timedelta(days=1)).strftime("%Y-%m-%d")
631
+ model_name = repo_id.split("/")[-1]
632
+ return system_prompt.format(name=model_name, today=today, yesterday=yesterday)
633
+
634
+
635
+ model_id = "mistralai/Mistral-Small-3.2-24B-Instruct-2506"
636
+ SYSTEM_PROMPT = load_system_prompt(model_id, "SYSTEM_PROMPT.txt")
637
+
638
+ tokenizer = MistralTokenizer.from_hf_hub(model_id)
639
+
640
+ model = Mistral3ForConditionalGeneration.from_pretrained(
641
+ model_id, torch_dtype=torch.bfloat16
642
+ )
643
+
644
+ image_url = "https://static.wikia.nocookie.net/essentialsdocs/images/7/70/Battle.png/revision/latest?cb=20220523172438"
645
+
646
+ messages = [
647
+ {"role": "system", "content": SYSTEM_PROMPT},
648
+ {
649
+ "role": "user",
650
+ "content": [
651
+ {
652
+ "type": "text",
653
+ "text": "What action do you think I should take in this situation? List all the possible actions and explain why you think they are good or bad.",
654
+ },
655
+ {"type": "image_url", "image_url": {"url": image_url}},
656
+ ],
657
+ },
658
+ ]
659
+
660
+ tokenized = tokenizer.encode_chat_completion(ChatCompletionRequest(messages=messages))
661
+
662
+ input_ids = torch.tensor([tokenized.tokens])
663
+ attention_mask = torch.ones_like(input_ids)
664
+ pixel_values = torch.tensor(tokenized.images[0], dtype=torch.bfloat16).unsqueeze(0)
665
+ image_sizes = torch.tensor([pixel_values.shape[-2:]])
666
+
667
+ output = model.generate(
668
+ input_ids=input_ids,
669
+ attention_mask=attention_mask,
670
+ pixel_values=pixel_values,
671
+ image_sizes=image_sizes,
672
+ max_new_tokens=1000,
673
+ )[0]
674
+
675
+ decoded_output = tokenizer.decode(output[len(tokenized.tokens) :])
676
+ print(decoded_output)
677
+ # In this situation, you are playing a Pokémon game where your Pikachu (Level 42) is facing a wild Pidgey (Level 17). Here are the possible actions you can take and an analysis of each:
678
+
679
+ # 1. **FIGHT**:
680
+ # - **Pros**: Pikachu is significantly higher level than the wild Pidgey, which suggests that it should be able to defeat Pidgey easily. This could be a good opportunity to gain experience points and possibly items or money.
681
+ # - **Cons**: There is always a small risk of Pikachu fainting, especially if Pidgey has a powerful move or a status effect that could hinder Pikachu. However, given the large level difference, this risk is minimal.
682
+
683
+ # 2. **BAG**:
684
+ # - **Pros**: You might have items in your bag that could help in this battle, such as Potions, Poké Balls, or Berries. Using an item could help you capture Pidgey or heal Pikachu if needed.
685
+ # - **Cons**: Using items might not be necessary given the level difference. It could be more efficient to just fight and defeat Pidgey quickly.
686
+
687
+ # 3. **POKÉMON**:
688
+ # - **Pros**: You might have another Pokémon in your party that is better suited for this battle or that you want to gain experience. Switching Pokémon could also be strategic if you want to train a lower-level Pokémon.
689
+ # - **Cons**: Switching Pokémon might not be necessary since Pikachu is at a significant advantage. It could also waste time and potentially give Pidgey a turn to attack.
690
+
691
+ # 4. **RUN**:
692
+ # - **Pros**: Running away could be a quick way to avoid the battle altogether. This might be useful if you are trying to conserve resources or if you are in a hurry to get to another location.
693
+ # - **Cons**: Running away means you miss out on the experience points, items, or money that you could gain from defeating Pidgey. It also might not be the most efficient use of your time if you are trying to train your Pokémon.
694
+
695
+ # ### Recommendation:
696
+ # Given the significant level advantage, the best action to take is likely **FIGHT**. This will allow you to quickly defeat Pidgey and gain experience points for Pikachu. If you are concerned about Pikachu's health, you could use the **BAG** to heal Pikachu before or during the battle. Running away or switching Pokémon does not seem necessary in this situation.
697
+ ```
698
+
699
+ </details>
SYSTEM_PROMPT.txt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are {name}, a Large Language Model (LLM) created by Mistral AI, a French startup headquartered in Paris.
2
+ You power an AI assistant called Le Chat.
3
+ Your knowledge base was last updated on 2023-10-01.
4
+ The current date is {today}.
5
+
6
+ When you're not sure about some information or when the user's request requires up-to-date or specific data, you must use the available tools to fetch the information. Do not hesitate to use tools whenever they can provide a more accurate or complete response. If no relevant tools are available, then clearly state that you don't have the information and avoid making up anything.
7
+ 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?").
8
+ You are always very attentive to dates, in particular you try to resolve dates (e.g. "yesterday" is {yesterday}) and when asked about information at specific dates, you discard information that is at another date.
9
+ You follow these instructions in all languages, and always respond to the user in the language they use or request.
10
+ Next sections describe the capabilities that you have.
11
+
12
+ # WEB BROWSING INSTRUCTIONS
13
+
14
+ You cannot perform any web search or access internet to open URLs, links etc. If it seems like the user is expecting you to do so, you clarify the situation and ask the user to copy paste the text directly in the chat.
15
+
16
+ # MULTI-MODAL INSTRUCTIONS
17
+
18
+ You have the ability to read images, but you cannot generate images. You also cannot transcribe audio files or videos.
19
+ You cannot read nor transcribe audio files or videos.
20
+
21
+ TOOL CALLING INSTRUCTIONS
22
+
23
+ You may have access to tools that you can use to fetch information or perform actions. You must use these tools in the following situations:
24
+
25
+ 1. When the request requires up-to-date information.
26
+ 2. When the request requires specific data that you do not have in your knowledge base.
27
+ 3. When the request involves actions that you cannot perform without tools.
28
+
29
+ Always prioritize using tools to provide the most accurate and helpful response. If tools are not available, inform the user that you cannot perform the requested action at the moment.
consolidated.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41ea047d36ad1bd552dd2d78abb8a74031d3f9042a658a0365df02a73202ea29
3
+ size 25793007560
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_sample": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 11,
6
+ "temperature": 0.15,
7
+ "max_length": 131072,
8
+ "top_p": 1.00,
9
+ "transformers_version": "4.52.4"
10
+ }
params.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dim": 5120,
3
+ "n_layers": 40,
4
+ "head_dim": 128,
5
+ "hidden_dim": 32768,
6
+ "n_heads": 32,
7
+ "n_kv_heads": 8,
8
+ "rope_theta": 1000000000.0,
9
+ "norm_eps": 1e-05,
10
+ "vocab_size": 131072,
11
+ "max_position_embeddings": 131072,
12
+ "vision_encoder": {
13
+ "hidden_size": 1024,
14
+ "num_channels": 3,
15
+ "max_image_size": 1540,
16
+ "patch_size": 14,
17
+ "rope_theta": 10000.0,
18
+ "intermediate_size": 4096,
19
+ "num_hidden_layers": 24,
20
+ "num_attention_heads": 16,
21
+ "adapter_bias": false,
22
+ "mm_projector_id": "patch_merge",
23
+ "spatial_merge_size": 2,
24
+ "add_pre_mm_projector_layer_norm": true,
25
+ "image_token_id": 10,
26
+ "image_break_token_id": 12,
27
+ "image_end_token_id": 13,
28
+ "image_size": 1540
29
+ },
30
+ "quantization": {
31
+ "config_groups": {
32
+ "group_0": {
33
+ "input_activations": {
34
+ "dynamic": true,
35
+ "num_bits": 8,
36
+ "observer": null,
37
+ "strategy": "token",
38
+ "symmetric": true,
39
+ "type": "float"
40
+ },
41
+ "targets": [
42
+ "Linear"
43
+ ],
44
+ "weights": {
45
+ "dynamic": false,
46
+ "num_bits": 8,
47
+ "observer": "minmax",
48
+ "strategy": "tensor",
49
+ "symmetric": true,
50
+ "type": "float"
51
+ }
52
+ }
53
+ },
54
+ "format": "float-quantized",
55
+ "ignore": [
56
+ "lm_head",
57
+ "output"
58
+ ],
59
+ "quant_method": "compressed-tensors",
60
+ "quantization_status": "compressed"
61
+ }
62
+ }
tekken.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e2501687ccd0e1f30f36319eaf2b46958b897811e246cd8eb5d385b9e3de7d1
3
+ size 19399895