Skip to content

Commit b8c5d3e

Browse files
authored
[Python][Model] Add ministral3_reasoning template (#3419)
1 parent 1a23ff5 commit b8c5d3e

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

python/mlc_llm/conversation_template/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
llama,
1818
llava,
1919
ministral3,
20+
ministral3_reasoning,
2021
mistral,
2122
nemotron,
2223
oasst,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Ministral3 reasoning templates"""
2+
3+
from mlc_llm.protocol.conversation_protocol import Conversation, MessagePlaceholders
4+
5+
from .registry import ConvTemplateRegistry
6+
7+
# Ministral-3-XB-Reasoning-2512
8+
ConvTemplateRegistry.register_conv_template(
9+
Conversation(
10+
name="ministral3_reasoning",
11+
system_template=(
12+
f"[SYSTEM_PROMPT]{MessagePlaceholders.SYSTEM.value}[/SYSTEM_PROMPT]"
13+
f"{MessagePlaceholders.FUNCTION.value}"
14+
),
15+
system_message=(
16+
"# HOW YOU SHOULD THINK AND ANSWER\n\n"
17+
"First draft your thinking process (inner monologue) until you arrive at a response. "
18+
"Format your response using Markdown, and use LaTeX for any mathematical equations. "
19+
"Write both your thoughts and the response in the same language as the input.\n\n"
20+
"Your thinking process must follow the template below:"
21+
"[THINK]Your thoughts or/and draft, like working through an exercise on scratch paper. "
22+
"Be as casual and as long as you want until you are confident to generate the response "
23+
"to the user.[/THINK]Here, provide a self-contained response."
24+
),
25+
role_templates={
26+
"user": f"[INST]{MessagePlaceholders.USER.value}[/INST]",
27+
"assistant": f"{MessagePlaceholders.ASSISTANT.value}</s>",
28+
"tool": f"[TOOL_RESULTS]{MessagePlaceholders.TOOL.value}[/TOOL_RESULTS]",
29+
},
30+
roles={"user": "", "assistant": "", "tool": ""},
31+
seps=[""],
32+
role_content_sep="",
33+
role_empty_sep="",
34+
stop_str=["</s>"],
35+
stop_token_ids=[2],
36+
system_prefix_token_ids=[1],
37+
)
38+
)

python/mlc_llm/interface/gen_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ def gen_config( # pylint: disable=too-many-locals,too-many-arguments,too-many-b
310310
"llama-2",
311311
"mistral_default",
312312
"ministral3",
313+
"ministral3_reasoning",
313314
"gpt2",
314315
"codellama_completion",
315316
"codellama_instruct",

python/mlc_llm/model/model_preset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
"use_cache": True,
251251
"vocab_size": 32768,
252252
},
253-
"ministral3_3b_reasoning_2512": {
253+
"ministral3_3b_2512": {
254254
"architectures": ["Mistral3ForConditionalGeneration"],
255255
"dtype": "bfloat16",
256256
"image_token_index": 10,

0 commit comments

Comments
 (0)