danielhanchen commited on
Commit
3ceb2ca
·
verified ·
1 Parent(s): 70fca30

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
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,553 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: vllm
3
+ language:
4
+ - en
5
+ - fr
6
+ - es
7
+ - de
8
+ - it
9
+ - pt
10
+ - nl
11
+ - zh
12
+ - ja
13
+ - ko
14
+ - ar
15
+ license: apache-2.0
16
+ inference: false
17
+ base_model:
18
+ - mistralai/Ministral-3-3B-Instruct-2512
19
+ tags:
20
+ - mistral-common
21
+ - mistral
22
+ - unsloth
23
+ ---
24
+ <div>
25
+ <p style="margin-bottom: 0; margin-top: 0;">
26
+ <strong>See our <a href="https://huggingface.co/collections/unsloth/ministral-3">Ministral 3 collection</a> for all versions including GGUF, 4-bit & FP8 formats.</strong>
27
+ </p>
28
+ <p style="margin-bottom: 0;">
29
+ <em>Learn to run Ministral correctly - <a href="https://docs.unsloth.ai/new/ministral-3">Read our Guide</a>.</em>
30
+ </p>
31
+ <p style="margin-top: 0;margin-bottom: 0;">
32
+ <em>See <a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0 GGUFs</a> for our quantization benchmarks.</em>
33
+ </p>
34
+ <div style="display: flex; gap: 5px; align-items: center; ">
35
+ <a href="https://github.com/unslothai/unsloth/">
36
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
37
+ </a>
38
+ <a href="https://discord.gg/unsloth">
39
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
40
+ </a>
41
+ <a href="https://docs.unsloth.ai/new/ministral-3">
42
+ <img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
43
+ </a>
44
+ </div>
45
+ <h1 style="margin-top: 0rem;">✨ Read our Ministral 3 Guide <a href="https://docs.unsloth.ai/new/ministral-3">here</a>!</h1>
46
+ </div>
47
+
48
+ - Fine-tune Ministral 3 for free using our [Google Colab notebook](https://docs.unsloth.ai/new/ministral-3#fine-tuning)
49
+ - Or train Ministral 3 with reinforcement learning (GSPO) with our [free notebook](https://docs.unsloth.ai/new/ministral-3#reinforcement-learning-grpo).
50
+ - View the rest of our notebooks in our [docs here](https://docs.unsloth.ai/get-started/unsloth-notebooks).
51
+ ---
52
+
53
+ # Ministral 3 3B Instruct 2512
54
+ The smallest model in the Ministral 3 family, **Ministral 3 3B** is a powerful, efficient tiny language model with vision capabilities.
55
+
56
+ The Ministral 3 family is designed for edge deployment, capable of running on a wide range of hardware. Ministral 3 3B can even be deployed locally, capable of fitting in 8GB of VRAM in FP8, and less if further quantized.
57
+
58
+ ## Key Features
59
+ Ministral 3 3B consists of two main architectural components:
60
+ - **3.4B Language Model**
61
+ - **0.4B Vision Encoder**
62
+
63
+ The Ministral 3 3B Instruct model offers the following capabilities:
64
+ - **Vision**: Enables the model to analyze images and provide insights based on visual content, in addition to text.
65
+ - **Multilingual**: Supports dozens of languages, including English, French, Spanish, German, Italian, Portuguese, Dutch, Chinese, Japanese, Korean, Arabic.
66
+ - **System Prompt**: Maintains strong adherence and support for system prompts.
67
+ - **Agentic**: Offers best-in-class agentic capabilities with native function calling and JSON outputting.
68
+ - **Edge-Optimized**: Delivers best-in-class performance at a small scale, deployable anywhere.
69
+ - **Apache 2.0 License**: Open-source license allowing usage and modification for both commercial and non-commercial purposes.
70
+ - **Large Context Window**: Supports a 256k context window.
71
+
72
+ ### Use Cases
73
+ Ideal for lightweight, real-time applications on edge or low-resource devices, such as:
74
+ - Image captioning
75
+ - Text classification
76
+ - Real-time efficient translation
77
+ - Data extraction
78
+ - Short content generation
79
+ - Fine-tuning and specialization
80
+ - And more...
81
+
82
+ Bringing advanced AI capabilities to edge and distributed environments for embedded systems.
83
+
84
+ ## Ministral 3 Family
85
+
86
+ | Model Name | Type | Precision | Link |
87
+ |--------------------------------|--------------------|-----------|------------------------------------------------------------------------------------------|
88
+ | Ministral 3 3B Base 2512 | Base pre-trained | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-3B-Base-2512) |
89
+ | Ministral 3 3B Instruct 2512 | Instruct post-trained | FP8 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-3B-Instruct-2512) |
90
+ | Ministral 3 3B Reasoning 2512 | Reasoning capable | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-3B-Reasoning-2512) |
91
+ | Ministral 3 8B Base 2512 | Base pre-trained | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-8B-Base-2512) |
92
+ | Ministral 3 8B Instruct 2512 | Instruct post-trained | FP8 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-8B-Instruct-2512) |
93
+ | Ministral 3 8B Reasoning 2512 | Reasoning capable | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-8B-Reasoning-2512) |
94
+ | Ministral 3 14B Base 2512 | Base pre-trained** | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-14B-Base-2512) |
95
+ | Ministral 3 14B Instruct 2512 | Instruct post-trained | FP8 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-14B-Instruct-2512) |
96
+ | Ministral 3 14B Reasoning 2512 | Reasoning capable | BF16 | [Hugging Face](https://huggingface.co/mistralai/Ministral-3-14B-Reasoning-2512) |
97
+
98
+ Other formats available [here](https://huggingface.co/collections/mistralai/ministral-3-more).
99
+
100
+ ## Benchmark Results
101
+
102
+ We compare Ministral 3 to similar sized models.
103
+
104
+ ### Reasoning
105
+
106
+ | Model | AIME25 | AIME24 | GPQA Diamond | LiveCodeBench |
107
+ |---------------------------|-------------|-------------|--------------|---------------|
108
+ | **Ministral 3 14B** | <u>0.850</u>| <u>0.898</u>| <u>0.712</u> | <u>0.646</u> |
109
+ | Qwen3-14B (Thinking) | 0.737 | 0.837 | 0.663 | 0.593 |
110
+ | | | | | |
111
+ | **Ministral 3 8B** | 0.787 | <u>0.860</u>| 0.668 | <u>0.616</u> |
112
+ | Qwen3-VL-8B-Thinking | <u>0.798</u>| <u>0.860</u>| <u>0.671</u> | 0.580 |
113
+ | | | | | |
114
+ | **Ministral 3 3B** | <u>0.721</u>| <u>0.775</u>| 0.534 | <u>0.548</u> |
115
+ | Qwen3-VL-4B-Thinking | 0.697 | 0.729 | <u>0.601</u> | 0.513 |
116
+
117
+ ### Instruct
118
+
119
+ | Model | Arena Hard | WildBench | MATH Maj@1 | MM MTBench |
120
+ |---------------------------|-------------|------------|-------------|------------------|
121
+ | **Ministral 3 14B** | <u>0.551</u>| <u>68.5</u>| <u>0.904</u>| <u>8.49</u> |
122
+ | Qwen3 14B (Non-Thinking) | 0.427 | 65.1 | 0.870 | NOT MULTIMODAL |
123
+ | Gemma3-12B-Instruct | 0.436 | 63.2 | 0.854 | 6.70 |
124
+ | | | | | |
125
+ | **Ministral 3 8B** | 0.509 | <u>66.8</u>| 0.876 | <u>8.08</u> |
126
+ | Qwen3-VL-8B-Instruct | <u>0.528</u>| 66.3 | <u>0.946</u>| 8.00 |
127
+ | | | | | |
128
+ | **Ministral 3 3B** | 0.305 | <u>56.8</u>| 0.830 | 7.83 |
129
+ | Qwen3-VL-4B-Instruct | <u>0.438</u>| <u>56.8</u>| <u>0.900</u>| <u>8.01</u> |
130
+ | Qwen3-VL-2B-Instruct | 0.163 | 42.2 | 0.786 | 6.36 |
131
+ | Gemma3-4B-Instruct | 0.318 | 49.1 | 0.759 | 5.23 |
132
+
133
+ ### Base
134
+
135
+ | Model | Multilingual MMLU | MATH CoT 2-Shot | AGIEval 5-shot | MMLU Redux 5-shot | MMLU 5-shot | TriviaQA 5-shot |
136
+ |---------------------|-------------------|-----------------|----------------|-------------------|-------------|-----------------|
137
+ | **Ministral 3 14B** | 0.742 | <u>0.676</u> | 0.648 | 0.820 | 0.794 | 0.749 |
138
+ | Qwen3 14B Base | <u>0.754</u> | 0.620 | <u>0.661</u> | <u>0.837</u> | <u>0.804</u>| 0.703 |
139
+ | Gemma 3 12B Base | 0.690 | 0.487 | 0.587 | 0.766 | 0.745 | <u>0.788</u> |
140
+ | | | | | | | |
141
+ | **Ministral 3 8B** | <u>0.706</u> | <u>0.626</u> | 0.591 | 0.793 | <u>0.761</u>| <u>0.681</u> |
142
+ | Qwen 3 8B Base | 0.700 | 0.576 | <u>0.596</u> | <u>0.794</u> | 0.760 | 0.639 |
143
+ | | | | | | | |
144
+ | **Ministral 3 3B** | 0.652 | <u>0.601</u> | 0.511 | 0.735 | 0.707 | 0.592 |
145
+ | Qwen 3 4B Base | <u>0.677</u> | 0.405 | <u>0.570</u> | <u>0.759</u> | <u>0.713</u>| 0.530 |
146
+ | Gemma 3 4B Base | 0.516 | 0.294 | 0.430 | 0.626 | 0.589 | <u>0.640</u> |
147
+
148
+ ## Usage
149
+
150
+ The model can be used with the following frameworks;
151
+ - [`vllm`](https://github.com/vllm-project/vllm): See [here](#vllm)
152
+ - [`transformers`](https://github.com/huggingface/transformers): See [here](#transformers)
153
+
154
+ ### vLLM
155
+
156
+ We recommend using this model with [vLLM](https://github.com/vllm-project/vllm).
157
+
158
+ #### Installation
159
+
160
+ Make sure to install [`vLLM >= 0.12.0`](https://github.com/vllm-project/vllm/releases/tag/v0.12.0):
161
+
162
+ ```
163
+ pip install vllm --upgrade
164
+ ```
165
+
166
+ Doing so should automatically install [`mistral_common >= 1.8.6`](https://github.com/mistralai/mistral-common/releases/tag/v1.8.6).
167
+
168
+ To check:
169
+ ```
170
+ python -c "import mistral_common; print(mistral_common.__version__)"
171
+ ```
172
+
173
+ 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).
174
+
175
+ #### Serve
176
+
177
+ Due to their size and the FP8 format of their weights `Ministral-3-3B-Instruct-2512`, `Ministral-3-8B-Instruct-2512` and `Ministral-3-14B-Instruct-2512` can run on a single 1xH200 GPU.
178
+
179
+ A simple launch command is:
180
+
181
+ ```bash
182
+ vllm serve mistralai/Ministral-3-3B-Instruct-2512 \
183
+ --enable-auto-tool-choice --tool-call-parser mistral
184
+ ```
185
+
186
+ Key parameter notes:
187
+
188
+ * enable-auto-tool-choice: Required when enabling tool usage.
189
+ * tool-call-parser mistral: Required when enabling tool usage.
190
+
191
+
192
+ Additional flags:
193
+
194
+ * You can set `--max-model-len` to preserve memory. By default it is set to `262144` which is quite large but not necessary for most scenarios.
195
+ * You can set `--max-num-batched-tokens` to balance throughput and latency, higher means higher throughput but higher latency.
196
+
197
+ #### Usage of the model
198
+
199
+ Here we asumme that the model `mistralai/Ministral-3-3B-Instruct-2512` is served and you can ping it to the domain `localhost` with the port `8000` which is the default for vLLM.
200
+
201
+ <details>
202
+ <summary>Vision Reasoning</summary>
203
+
204
+ Let's see if the Ministral 3 knows when to pick a fight !
205
+
206
+ ```python
207
+ from datetime import datetime, timedelta
208
+
209
+ from openai import OpenAI
210
+ from huggingface_hub import hf_hub_download
211
+
212
+ # Modify OpenAI's API key and API base to use vLLM's API server.
213
+ openai_api_key = "EMPTY"
214
+ openai_api_base = "http://localhost:8000/v1"
215
+
216
+ TEMP = 0.15
217
+ MAX_TOK = 262144
218
+
219
+ client = OpenAI(
220
+ api_key=openai_api_key,
221
+ base_url=openai_api_base,
222
+ )
223
+
224
+ models = client.models.list()
225
+ model = models.data[0].id
226
+
227
+
228
+ def load_system_prompt(repo_id: str, filename: str) -> str:
229
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
230
+ with open(file_path, "r") as file:
231
+ system_prompt = file.read()
232
+ today = datetime.today().strftime("%Y-%m-%d")
233
+ yesterday = (datetime.today() - timedelta(days=1)).strftime("%Y-%m-%d")
234
+ model_name = repo_id.split("/")[-1]
235
+ return system_prompt.format(name=model_name, today=today, yesterday=yesterday)
236
+
237
+
238
+ SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
239
+ image_url = "https://static.wikia.nocookie.net/essentialsdocs/images/7/70/Battle.png/revision/latest?cb=20220523172438"
240
+
241
+ messages = [
242
+ {"role": "system", "content": SYSTEM_PROMPT},
243
+ {
244
+ "role": "user",
245
+ "content": [
246
+ {
247
+ "type": "text",
248
+ "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.",
249
+ },
250
+ {"type": "image_url", "image_url": {"url": image_url}},
251
+ ],
252
+ },
253
+ ]
254
+
255
+ print(messages)
256
+
257
+
258
+ response = client.chat.completions.create(
259
+ model=model,
260
+ messages=messages,
261
+ temperature=TEMP,
262
+ max_tokens=MAX_TOK,
263
+ )
264
+
265
+ print(response.choices[0].message.content)
266
+ ```
267
+
268
+ </details>
269
+
270
+ <details>
271
+ <summary>Function Calling</summary>
272
+
273
+ Let's solve some equations thanks to our simple Python calculator tool.
274
+
275
+ ```python
276
+ import json
277
+ from openai import OpenAI
278
+ from huggingface_hub import hf_hub_download
279
+
280
+ # Modify OpenAI's API key and API base to use vLLM's API server.
281
+ openai_api_key = "EMPTY"
282
+ openai_api_base = "http://localhost:8000/v1"
283
+
284
+ TEMP = 0.15
285
+ MAX_TOK = 262144
286
+
287
+ client = OpenAI(
288
+ api_key=openai_api_key,
289
+ base_url=openai_api_base,
290
+ )
291
+
292
+ models = client.models.list()
293
+ model = models.data[0].id
294
+
295
+
296
+ def load_system_prompt(repo_id: str, filename: str) -> str:
297
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
298
+ with open(file_path, "r") as file:
299
+ system_prompt = file.read()
300
+ return system_prompt
301
+
302
+
303
+ SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
304
+
305
+ image_url = "https://math-coaching.com/img/fiche/46/expressions-mathematiques.jpg"
306
+
307
+
308
+ def my_calculator(expression: str) -> str:
309
+ return str(eval(expression))
310
+
311
+
312
+ tools = [
313
+ {
314
+ "type": "function",
315
+ "function": {
316
+ "name": "my_calculator",
317
+ "description": "A calculator that can evaluate a mathematical expression.",
318
+ "parameters": {
319
+ "type": "object",
320
+ "properties": {
321
+ "expression": {
322
+ "type": "string",
323
+ "description": "The mathematical expression to evaluate.",
324
+ },
325
+ },
326
+ "required": ["expression"],
327
+ },
328
+ },
329
+ },
330
+ {
331
+ "type": "function",
332
+ "function": {
333
+ "name": "rewrite",
334
+ "description": "Rewrite a given text for improved clarity",
335
+ "parameters": {
336
+ "type": "object",
337
+ "properties": {
338
+ "text": {
339
+ "type": "string",
340
+ "description": "The input text to rewrite",
341
+ }
342
+ },
343
+ },
344
+ },
345
+ },
346
+ ]
347
+
348
+ messages = [
349
+ {"role": "system", "content": SYSTEM_PROMPT},
350
+ {
351
+ "role": "user",
352
+ "content": [
353
+ {
354
+ "type": "text",
355
+ "text": "Thanks to your calculator, compute the results for the equations that involve numbers displayed in the image.",
356
+ },
357
+ {
358
+ "type": "image_url",
359
+ "image_url": {
360
+ "url": image_url,
361
+ },
362
+ },
363
+ ],
364
+ },
365
+ ]
366
+
367
+ response = client.chat.completions.create(
368
+ model=model,
369
+ messages=messages,
370
+ temperature=TEMP,
371
+ max_tokens=MAX_TOK,
372
+ tools=tools,
373
+ tool_choice="auto",
374
+ )
375
+
376
+ tool_calls = response.choices[0].message.tool_calls
377
+
378
+ results = []
379
+ for tool_call in tool_calls:
380
+ function_name = tool_call.function.name
381
+ function_args = tool_call.function.arguments
382
+ if function_name == "my_calculator":
383
+ result = my_calculator(**json.loads(function_args))
384
+ results.append(result)
385
+
386
+ messages.append({"role": "assistant", "tool_calls": tool_calls})
387
+ for tool_call, result in zip(tool_calls, results):
388
+ messages.append(
389
+ {
390
+ "role": "tool",
391
+ "tool_call_id": tool_call.id,
392
+ "name": tool_call.function.name,
393
+ "content": result,
394
+ }
395
+ )
396
+
397
+
398
+ response = client.chat.completions.create(
399
+ model=model,
400
+ messages=messages,
401
+ temperature=TEMP,
402
+ max_tokens=MAX_TOK,
403
+ )
404
+
405
+ print(response.choices[0].message.content)
406
+ ```
407
+
408
+ </details>
409
+
410
+ <details>
411
+ <summary>Text-Only Request</summary>
412
+
413
+ Ministral 3 can follow your instructions to the letter.
414
+
415
+ ```python
416
+ from openai import OpenAI
417
+ from huggingface_hub import hf_hub_download
418
+
419
+ # Modify OpenAI's API key and API base to use vLLM's API server.
420
+ openai_api_key = "EMPTY"
421
+ openai_api_base = "http://localhost:8000/v1"
422
+
423
+ TEMP = 0.15
424
+ MAX_TOK = 262144
425
+
426
+ client = OpenAI(
427
+ api_key=openai_api_key,
428
+ base_url=openai_api_base,
429
+ )
430
+
431
+ models = client.models.list()
432
+ model = models.data[0].id
433
+
434
+
435
+ def load_system_prompt(repo_id: str, filename: str) -> str:
436
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
437
+ with open(file_path, "r") as file:
438
+ system_prompt = file.read()
439
+ return system_prompt
440
+
441
+
442
+ SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
443
+
444
+ messages = [
445
+ {"role": "system", "content": SYSTEM_PROMPT},
446
+ {
447
+ "role": "user",
448
+ "content": "Write me a sentence where every word starts with the next letter in the alphabet - start with 'a' and end with 'z'.",
449
+ },
450
+ ]
451
+
452
+ response = client.chat.completions.create(
453
+ model=model,
454
+ messages=messages,
455
+ temperature=TEMP,
456
+ max_tokens=MAX_TOK,
457
+ )
458
+
459
+ assistant_message = response.choices[0].message.content
460
+ print(assistant_message)
461
+ ```
462
+
463
+ </details>
464
+
465
+ ### Transformers
466
+
467
+ You can also use Ministral 3 3B Instruct 2512 with `Transformers` !
468
+
469
+ Transformers very recently added prelimenary support for FP8, so please make sure to install from main:
470
+
471
+ ```sh
472
+ uv pip install git+https://github.com/huggingface/transformers
473
+ ```
474
+
475
+ To make the best use of our model with `Transformers` make sure to have [installed](https://github.com/mistralai/mistral-common) `mistral-common >= 1.8.6` to use our tokenizer.
476
+
477
+ ```bash
478
+ pip install mistral-common --upgrade
479
+ ```
480
+
481
+ Try it out by running the following snippet.
482
+
483
+ > [!Tip]
484
+ > By default Transformers will load the checkpoint in FP8 and dequantize it to BF16 on the fly,
485
+ > which means the model currently does not make use of accelerated FP8-kernels.
486
+ > Compatibility with accelerated FP8-kernels is currently worked on and will be available in a couple of weeks.
487
+ > Stay tuned!
488
+
489
+ <details>
490
+ <summary>Python snippet</summary>
491
+
492
+ ```python
493
+ import torch
494
+ from transformers import Mistral3ForConditionalGeneration, MistralCommonBackend
495
+
496
+ model_id = "mistralai/Ministral-3-3B-Instruct-2512"
497
+
498
+ tokenizer = MistralCommonBackend.from_pretrained(model_id)
499
+ model = Mistral3ForConditionalGeneration.from_pretrained(model_id, device_map="auto")
500
+
501
+ image_url = "https://static.wikia.nocookie.net/essentialsdocs/images/7/70/Battle.png/revision/latest?cb=20220523172438"
502
+
503
+ messages = [
504
+ {
505
+ "role": "user",
506
+ "content": [
507
+ {
508
+ "type": "text",
509
+ "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.",
510
+ },
511
+ {"type": "image_url", "image_url": {"url": image_url}},
512
+ ],
513
+ },
514
+ ]
515
+
516
+ tokenized = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True)
517
+
518
+ tokenized["input_ids"] = tokenized["input_ids"].to(device="cuda")
519
+ tokenized["pixel_values"] = tokenized["pixel_values"].to(dtype=torch.bfloat16, device="cuda")
520
+ image_sizes = [tokenized["pixel_values"].shape[-2:]]
521
+
522
+ output = model.generate(
523
+ **tokenized,
524
+ image_sizes=image_sizes,
525
+ max_new_tokens=512,
526
+ )[0]
527
+
528
+ decoded_output = tokenizer.decode(output[len(tokenized["input_ids"][0]):])
529
+ print(decoded_output)
530
+ ```
531
+
532
+ **Note:**
533
+
534
+ Transformers allows you to automatically convert the checkpoint to Bfloat16. To so simple load the model as follows:
535
+
536
+ ```py
537
+ from transformers import Mistral3ForConditionalGeneration, FineGrainedFP8Config
538
+
539
+ model_id = "mistralai/Ministral-3-3B-Instruct-2512"
540
+ model = Mistral3ForConditionalGeneration.from_pretrained(
541
+ model_id,
542
+ device_map="auto",
543
+ quantization_config=FineGrainedFP8Config(dequantize=True)
544
+ )
545
+ ```
546
+
547
+ </details>
548
+
549
+ ## License
550
+
551
+ This model is licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0.txt).
552
+
553
+ *You must not use this model in a manner that infringes, misappropriates, or otherwise violates any third party’s rights, including intellectual property rights.*
chat_template.jinja ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#- Unsloth template fixes #}
2
+ {#- Default system message if no system prompt is passed. #}
3
+ {%- set default_system_message = 'You are Ministral-3-3B-Instruct-2512, a Large Language Model (LLM) created by Mistral AI, a French startup headquartered in Paris.\nYou power an AI assistant called Le Chat.\nYour knowledge base was last updated on 2023-10-01.\nThe current date is {today}.\n\nWhen 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.\nIf 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?").\nYou 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.\nYou follow these instructions in all languages, and always respond to the user in the language they use or request.\nNext sections describe the capabilities that you have.\n\n# WEB BROWSING INSTRUCTIONS\n\nYou 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.\n\n# MULTI-MODAL INSTRUCTIONS\n\nYou have the ability to read images, but you cannot generate images. You also cannot transcribe audio files or videos.\nYou cannot read nor transcribe audio files or videos.\n\n# TOOL CALLING INSTRUCTIONS\n\nYou may have access to tools that you can use to fetch information or perform actions. You must use these tools in the following situations:\n\n1. When the request requires up-to-date information.\n2. When the request requires specific data that you do not have in your knowledge base.\n3. When the request involves actions that you cannot perform without tools.\n\nAlways 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.' %}
4
+
5
+ {#- Begin of sequence token. #}
6
+ {{- bos_token }}
7
+
8
+ {#- Handle system prompt if it exists. #}
9
+ {#- System prompt supports text content or text chunks. #}
10
+ {%- if messages[0]['role'] == 'system' %}
11
+ {{- '[SYSTEM_PROMPT]' -}}
12
+ {%- if messages[0]['content'] is string %}
13
+ {{- messages[0]['content'] -}}
14
+ {%- else %}
15
+ {%- for block in messages[0]['content'] %}
16
+ {%- if block['type'] == 'text' %}
17
+ {{- block['text'] }}
18
+ {%- else %}
19
+ {{- raise_exception('Only text chunks are supported in system message contents.') }}
20
+ {%- endif %}
21
+ {%- endfor %}
22
+ {%- endif %}
23
+ {{- '[/SYSTEM_PROMPT]' -}}
24
+ {%- set loop_messages = messages[1:] %}
25
+ {%- else %}
26
+ {%- set loop_messages = messages %}
27
+ {%- if default_system_message != '' %}
28
+ {{- '[SYSTEM_PROMPT]' + default_system_message + '[/SYSTEM_PROMPT]' }}
29
+ {%- endif %}
30
+ {%- endif %}
31
+
32
+
33
+ {#- Tools definition #}
34
+ {%- set tools_definition = '' %}
35
+ {%- set has_tools = false %}
36
+ {%- if tools is defined and tools is not none and tools|length > 0 %}
37
+ {%- set has_tools = true %}
38
+ {%- set tools_definition = '[AVAILABLE_TOOLS]' + (tools| tojson) + '[/AVAILABLE_TOOLS]' %}
39
+ {{- tools_definition }}
40
+ {%- endif %}
41
+
42
+ {#- Checks for alternating user/assistant messages. #}
43
+ {%- set ns = namespace(index=0) %}
44
+ {%- for message in loop_messages %}
45
+ {%- if message.role == 'user' or (message.role == 'assistant' and (message.tool_calls is not defined or message.tool_calls is none or message.tool_calls | length == 0)) %}
46
+ {%- if (message['role'] == 'user') != (ns.index % 2 == 0) %}
47
+ {{- raise_exception('After the optional system message, conversation roles must alternate user and assistant roles except for tool calls and results.') }}
48
+ {%- endif %}
49
+ {%- set ns.index = ns.index + 1 %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+
53
+ {#- Handle conversation messages. #}
54
+ {%- for message in loop_messages %}
55
+
56
+ {#- User messages supports text content or text and image chunks. #}
57
+ {%- if message['role'] == 'user' %}
58
+ {%- if message['content'] is string %}
59
+ {{- '[INST]' + message['content'] + '[/INST]' }}
60
+ {%- elif message['content'] | length > 0 %}
61
+ {{- '[INST]' }}
62
+ {%- if message['content'] | length == 2 %}
63
+ {%- set blocks = message['content'] | sort(attribute='type') %}
64
+ {%- else %}
65
+ {%- set blocks = message['content'] %}
66
+ {%- endif %}
67
+ {%- for block in blocks %}
68
+ {%- if block['type'] == 'text' %}
69
+ {{- block['text'] }}
70
+ {%- elif block['type'] in ['image', 'image_url'] %}
71
+ {{- '[IMG]' }}
72
+ {%- else %}
73
+ {{- raise_exception('Only text, image and image_url chunks are supported in user message content.') }}
74
+ {%- endif %}
75
+ {%- endfor %}
76
+ {{- '[/INST]' }}
77
+ {%- else %}
78
+ {{- raise_exception('User message must have a string or a list of chunks in content') }}
79
+ {%- endif %}
80
+
81
+ {#- Assistant messages supports text content or text and image chunks. #}
82
+ {%- elif message['role'] == 'assistant' %}
83
+
84
+ {%- if message['content'] is string %}
85
+ {{- message['content'] }}
86
+ {%- elif message['content'] is iterable and message['content'] | length > 0 %}
87
+ {%- for block in message['content'] %}
88
+ {%- if block['type'] == 'text' %}
89
+ {{- block['text'] }}
90
+ {%- else %}
91
+ {{- raise_exception('Only text chunks are supported in assistant message contents.') }}
92
+ {%- endif %}
93
+ {%- endfor %}
94
+ {%- endif %}
95
+
96
+ {%- if message['tool_calls'] is defined and message['tool_calls'] is not none and message['tool_calls']|length > 0 %}
97
+ {%- for tool in message['tool_calls'] %}
98
+ {%- set arguments = tool['function']['arguments'] %}
99
+ {%- if arguments is not string %}
100
+ {%- set arguments = arguments|tojson|safe %}
101
+ {%- elif arguments == '' %}
102
+ {%- set arguments = '{}' %}
103
+ {%- endif %}
104
+ {{- '[TOOL_CALLS]' + tool['function']['name'] + '[ARGS]' + arguments }}
105
+ {%- endfor %}
106
+ {%- endif %}
107
+
108
+ {#- End of sequence token for each assistant messages. #}
109
+ {{- eos_token }}
110
+
111
+ {#- Tool messages only supports text content. #}
112
+ {%- elif message['role'] == 'tool' %}
113
+ {{- '[TOOL_RESULTS]' + message['content']|string + '[/TOOL_RESULTS]' }}
114
+
115
+ {#- Raise exception for unsupported roles. #}
116
+ {%- else %}
117
+ {{- raise_exception('Only user, assistant and tool roles are supported, got ' + message['role']) }}
118
+ {%- endif %}
119
+ {%- endfor %}
120
+
121
+ {#- Copyright 2025-present Unsloth. Apache 2.0 License. #}
config.json ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Mistral3ForConditionalGeneration"
4
+ ],
5
+ "bos_token_id": 1,
6
+ "torch_dtype": "bfloat16",
7
+ "eos_token_id": 2,
8
+ "image_token_index": 10,
9
+ "model_type": "mistral3",
10
+ "multimodal_projector_bias": false,
11
+ "pad_token_id": 11,
12
+ "projector_hidden_act": "gelu",
13
+ "quantization_config": {
14
+ "_load_in_4bit": true,
15
+ "_load_in_8bit": false,
16
+ "bnb_4bit_compute_dtype": "bfloat16",
17
+ "bnb_4bit_quant_storage": "uint8",
18
+ "bnb_4bit_quant_type": "nf4",
19
+ "bnb_4bit_use_double_quant": true,
20
+ "llm_int8_enable_fp32_cpu_offload": false,
21
+ "llm_int8_has_fp16_weight": false,
22
+ "llm_int8_skip_modules": [
23
+ "embed_tokens",
24
+ "embedding",
25
+ "lm_head",
26
+ "multi_modal_projector",
27
+ "merger",
28
+ "modality_projection",
29
+ "router",
30
+ "visual",
31
+ "vision_tower",
32
+ "model.vision_tower.transformer.layers.2.attention"
33
+ ],
34
+ "llm_int8_threshold": 6.0,
35
+ "load_in_4bit": true,
36
+ "load_in_8bit": false,
37
+ "quant_method": "bitsandbytes"
38
+ },
39
+ "spatial_merge_size": 2,
40
+ "text_config": {
41
+ "attention_dropout": 0.0,
42
+ "torch_dtype": "bfloat16",
43
+ "head_dim": 128,
44
+ "hidden_act": "silu",
45
+ "hidden_size": 3072,
46
+ "initializer_range": 0.02,
47
+ "intermediate_size": 9216,
48
+ "max_position_embeddings": 262144,
49
+ "model_type": "ministral3",
50
+ "num_attention_heads": 32,
51
+ "num_hidden_layers": 26,
52
+ "num_key_value_heads": 8,
53
+ "rms_norm_eps": 1e-05,
54
+ "rope_parameters": {
55
+ "beta_fast": 32.0,
56
+ "beta_slow": 1.0,
57
+ "factor": 16.0,
58
+ "llama_4_scaling_beta": 0.1,
59
+ "mscale": 1.0,
60
+ "mscale_all_dim": 1.0,
61
+ "original_max_position_embeddings": 16384,
62
+ "rope_theta": 1000000.0,
63
+ "rope_type": "yarn",
64
+ "type": "yarn"
65
+ },
66
+ "sliding_window": null,
67
+ "tie_word_embeddings": true,
68
+ "use_cache": true,
69
+ "vocab_size": 131072
70
+ },
71
+ "transformers_version": "5.0.0.dev0",
72
+ "unsloth_fixed": true,
73
+ "vision_config": {
74
+ "attention_dropout": 0.0,
75
+ "torch_dtype": "bfloat16",
76
+ "head_dim": 64,
77
+ "hidden_act": "silu",
78
+ "hidden_size": 1024,
79
+ "image_size": 1540,
80
+ "initializer_range": 0.02,
81
+ "intermediate_size": 4096,
82
+ "model_type": "pixtral",
83
+ "num_attention_heads": 16,
84
+ "num_channels": 3,
85
+ "num_hidden_layers": 24,
86
+ "patch_size": 14,
87
+ "rope_parameters": {
88
+ "rope_theta": 10000.0,
89
+ "rope_type": "default"
90
+ }
91
+ },
92
+ "vision_feature_layer": -1
93
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 1,
3
+ "eos_token_id": 2,
4
+ "max_length": 262144,
5
+ "pad_token_id": 11,
6
+ "transformers_version": "5.0.0.dev0"
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7f8923ccc0ea19d5f1f7f58da5b2675e116675d09e05301add56f9fa02d26542
3
+ size 3207330222
processor_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_break_token": "[IMG_BREAK]",
3
+ "image_end_token": "[IMG_END]",
4
+ "image_processor": {
5
+ "crop_size": null,
6
+ "data_format": "channels_first",
7
+ "device": null,
8
+ "disable_grouping": null,
9
+ "do_center_crop": null,
10
+ "do_convert_rgb": true,
11
+ "do_normalize": true,
12
+ "do_pad": null,
13
+ "do_rescale": true,
14
+ "do_resize": true,
15
+ "image_mean": [
16
+ 0.48145466,
17
+ 0.4578275,
18
+ 0.40821073
19
+ ],
20
+ "image_processor_type": "PixtralImageProcessorFast",
21
+ "image_seq_length": null,
22
+ "image_std": [
23
+ 0.26862954,
24
+ 0.26130258,
25
+ 0.27577711
26
+ ],
27
+ "input_data_format": null,
28
+ "pad_size": null,
29
+ "patch_size": 14,
30
+ "processor_class": "PixtralProcessor",
31
+ "resample": 3,
32
+ "rescale_factor": 0.00392156862745098,
33
+ "return_tensors": null,
34
+ "size": {
35
+ "longest_edge": 1540
36
+ }
37
+ },
38
+ "image_token": "[IMG]",
39
+ "patch_size": 14,
40
+ "processor_class": "PixtralProcessor",
41
+ "spatial_merge_size": 2
42
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:577575622324b2e099e2648be26bdeb5e5815ffe66d7004e9e3ddbf421db6bf1
3
+ size 17078110
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff