Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extend-ignore-identifiers-re = [
"tese",
"seperable",
"Seperable",
"setp",
]

[files]
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ Please submit requests for new models [here](https://github.com/EricLBuehler/mis
## Quick examples

*After following installation instructions*

- 🤗🤗🤗 Run the **SmolLM 3** long-context hybrid-reasoning model with full tool-calling support: [documentation](docs/SMOLLM3.md)
<details>
<summary>Show command</summary>

**Default, easiest:**
```bash
./mistralrs-server -i --isq 8 run -m HuggingFaceTB/SmolLM3-3B
```

**UQFF prequantized:**
```bash
./mistralrs-server -i run -m EricB/SmolLM3-3B-UQFF -f smollm33b-q4k-0.uqff
```
</details>

- 🔊 Run the **Dia 1.6b** model for highly-realistic dialogue generation: [documentation](docs/DIA.md)
<details>
<summary>Show command</summary>
Expand Down Expand Up @@ -493,6 +509,7 @@ If you do not specify the architecture, an attempt will be made to use the model
- `deepseekv3`
- `qwen3`
- `qwen3moe`
- `smollm3`

</details>

Expand Down Expand Up @@ -576,6 +593,7 @@ Please submit more benchmarks via raising an issue!
|Mistral 3| | |✅|
|Llama 4| | |✅|
|Qwen 3|✅| |✅|
|SmolLM3| | |✅|
|Dia 1.6b| | |✅|
</details>

Expand Down Expand Up @@ -622,6 +640,7 @@ Please submit more benchmarks via raising an issue!
|Mistral 3| | | |
|Llama 4| | | |
|Qwen 3| | | |
|SmolLM3|✅| | |
</details>

<details>
Expand Down Expand Up @@ -655,6 +674,7 @@ Please submit more benchmarks via raising an issue!
|Mistral 3|✅|
|Llama 4| |
|Qwen 3| |
|SmolLM3|✅|
</details>

### Using derivative and adapter models
Expand Down
89 changes: 89 additions & 0 deletions chat_templates/smollm3.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{# ───── defaults ───── #}
{%- if enable_thinking is not defined -%}
{%- set enable_thinking = true -%}
{%- endif -%}

{# ───── reasoning mode ───── #}
{%- if enable_thinking -%}
{%- set reasoning_mode = "/think" -%}
{%- else -%}
{%- set reasoning_mode = "/no_think" -%}
{%- endif -%}

{# ───── header (system message) ───── #}
{{- "<|im_start|>system\n" -}}

{%- if messages[0].role == "system" -%}
{%- set system_message = messages[0].content -%}
{%- if "/no_think" in system_message -%}
{%- set reasoning_mode = "/no_think" -%}
{%- elif "/think" in system_message -%}
{%- set reasoning_mode = "/think" -%}
{%- endif -%}
{%- set custom_instructions = system_message.replace("/no_think", "").replace("/think", "").rstrip() -%}
{%- endif -%}

{%- if "/system_override" in system_message -%}
{{- custom_instructions.replace("/system_override", "").rstrip() -}}
{{- "<|im_end|>\n" -}}
{%- else -%}
{{- "## Metadata\n\n" -}}
{{- "Knowledge Cutoff Date: June 2025\n" -}}
{%- set today = strftime_now("%d %B %Y") -%}
{{- "Today Date: " ~ today ~ "\n" -}}
{{- "Reasoning Mode: " + reasoning_mode + "\n\n" -}}

{{- "## Custom Instructions\n\n" -}}
{%- if custom_instructions -%}
{{- custom_instructions + "\n\n" -}}
{%- elif reasoning_mode == "/think" -%}
{{- "You are a helpful AI assistant named SmolLM, trained by Hugging Face. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracking, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format: <think> Thought section </think> Solution section. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The Solution section should be logical, accurate, and concise and detail necessary steps needed to reach the conclusion.\n\n" -}}
{%- else -%}
{{- "You are a helpful AI assistant named SmolLM, trained by Hugging Face.\n\n" -}}
{%- endif -%}

{%- if xml_tools or python_tools -%}
{{- "### Tools\n\n" -}}
{%- if xml_tools -%}
{%- set ns = namespace(xml_tool_string="You may call one or more functions to assist with the user query.\nYou are provided with function signatures within <tools></tools> XML tags:\n\n<tools>\n") -%}
{%- for tool in xml_tools[:] -%} {# The slicing makes sure that xml_tools is a list #}
{%- set ns.xml_tool_string = ns.xml_tool_string ~ (tool | string) ~ "\n" -%}
{%- endfor -%}
{%- set xml_tool_string = ns.xml_tool_string + "</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>" -%}
{{- xml_tool_string -}}
{%- endif -%}
{%- if python_tools -%}
{%- set ns = namespace(python_tool_string="When you send a message containing Python code between '<code>' and '</code>' tags, it will be executed in a stateful Jupyter notebook environment, and you will then be given the output to continued reasoning in an agentic loop.\n\nYou can use the following tools in your python code like regular functions:\n<tools>\n") -%}
{%- for tool in python_tools[:] -%} {# The slicing makes sure that python_tools is a list #}
{%- set ns.python_tool_string = ns.python_tool_string ~ (tool | string) ~ "\n" -%}
{%- endfor -%}
{%- set python_tool_string = ns.python_tool_string + "</tools>\n\nThe state persists between code executions: so variables that you define in one step are still available thereafter." -%}
{{- python_tool_string -}}
{%- endif -%}
{{- "\n\n" -}}
{{- "<|im_end|>\n" -}}
{%- endif -%}
{%- endif -%}
{# ───── main loop ───── #}
{%- for message in messages -%}
{%- set content = message.content if message.content is string else "" -%}
{%- if message.role == "user" -%}
{{ "<|im_start|>" + message.role + "\n" + content + "<|im_end|>\n" }}
{%- elif message.role == "assistant" -%}
{%- if reasoning_mode == "/think" -%}
{{ "<|im_start|>assistant\n" + content.lstrip("\n") + "<|im_end|>\n" }}
{%- else -%}
{{ "<|im_start|>assistant\n" + "<think>\n\n</think>\n" + content.lstrip("\n") + "<|im_end|>\n" }}
{%- endif -%}
{%- elif message.role == "tool" -%}
{{ "<|im_start|>" + "user\n" + content + "<|im_end|>\n" }}
{%- endif -%}
{%- endfor -%}
{# ───── generation prompt ───── #}
{%- if add_generation_prompt -%}
{%- if reasoning_mode == "/think" -%}
{{ "<|im_start|>assistant\n" }}
{%- else -%}
{{ "<|im_start|>assistant\n" + "<think>\n\n</think>\n" }}
{%- endif -%}
{%- endif -%}
2 changes: 1 addition & 1 deletion docs/ANYMOE.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{"role": "user", "content": "Tell me a story about the Rust type system."}
],
Expand Down
4 changes: 2 additions & 2 deletions docs/DEEPSEEKV2.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ while True:
prompt = input(">>> ")
messages.append({"role": "user", "content": prompt})
completion = client.chat.completions.create(
model="ignore",
model="default",
messages=messages,
max_tokens=256,
frequency_penalty=1.0,
Expand All @@ -60,7 +60,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{"role": "user", "content": "Tell me a story about the Rust type system."}
],
Expand Down
4 changes: 2 additions & 2 deletions docs/DEEPSEEKV3.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ while True:
prompt = input(">>> ")
messages.append({"role": "user", "content": prompt})
completion = client.chat.completions.create(
model="ignore",
model="default",
messages=messages,
max_tokens=256,
frequency_penalty=1.0,
Expand All @@ -69,7 +69,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{"role": "user", "content": "Tell me a story about the Rust type system."}
],
Expand Down
2 changes: 1 addition & 1 deletion docs/DIA.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")
text_to_speak = "[S1] mistral r s is a local LLM inference engine. [S2] You can run text and vision models, and also image generation and speech generation. [S1] There is agentic web search, tool calling, and a convenient Python API. [S2] Check it out on github."

response = client.audio.speech.create(
model="ignore", voice="N/A", input=text_to_speak, response_format="wav"
model="default", voice="N/A", input=text_to_speak, response_format="wav"
)

output_path = Path("output.wav")
Expand Down
2 changes: 1 addition & 1 deletion docs/FLUX.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ from openai import OpenAI
client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")

result = client.images.generate(
model="ignore",
model="default",
prompt="A vibrant sunset in the mountains, 4k, high quality.",
n=1,
)
Expand Down
4 changes: 2 additions & 2 deletions docs/GEMMA2.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ while True:
prompt = input(">>> ")
messages.append({"role": "user", "content": prompt})
completion = client.chat.completions.create(
model="ignore",
model="default",
messages=messages,
max_tokens=256,
frequency_penalty=1.0,
Expand All @@ -44,7 +44,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{"role": "user", "content": "Tell me a story about the Rust type system."}
],
Expand Down
4 changes: 2 additions & 2 deletions docs/GEMMA3.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")


completion = client.chat.completions.create(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down Expand Up @@ -160,7 +160,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down
4 changes: 2 additions & 2 deletions docs/GLM4.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ while True:
prompt = input(">>> ")
messages.append({"role": "user", "content": prompt})
completion = client.chat.completions.create(
model="ignore",
model="default",
messages=messages,
max_tokens=256,
frequency_penalty=1.0,
Expand All @@ -44,7 +44,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{"role": "user", "content": "Tell me a story about the Rust type system."}
],
Expand Down
8 changes: 4 additions & 4 deletions docs/HTTP.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ client = openai.OpenAI(
)

completion = client.chat.completions.create(
model="ignore",
model="default",
messages=[
{"role": "system", "content": "You are Mistral.rs, an AI assistant."},
{"role": "user", "content": "Write a story about Rust error handling."}
Expand All @@ -62,7 +62,7 @@ curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer EMPTY" \
-d '{
"model": "ignore",
"model": "default",
"messages": [
{
"role": "system",
Expand Down Expand Up @@ -116,7 +116,7 @@ client = openai.OpenAI(
)

completion = client.completions.create(
model="ignore",
model="default",
prompt="What is Rust?",
max_tokens=256,
frequency_penalty=1.0,
Expand All @@ -133,7 +133,7 @@ curl http://localhost:8080/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer EMPTY" \
-d '{
"model": "ignore",
"model": "default",
"prompt": "What is Rust?"
}'
```
Expand Down
4 changes: 2 additions & 2 deletions docs/IDEFICS2.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ from openai import OpenAI
client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")

completion = client.chat.completions.create(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down Expand Up @@ -155,7 +155,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down
4 changes: 2 additions & 2 deletions docs/IDEFICS3.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ from openai import OpenAI
client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")

completion = client.chat.completions.create(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down Expand Up @@ -217,7 +217,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down
4 changes: 2 additions & 2 deletions docs/LLAMA4.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")


completion = client.chat.completions.create(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down Expand Up @@ -181,7 +181,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down
4 changes: 2 additions & 2 deletions docs/LLaVA.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ from openai import OpenAI
client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")

completion = client.chat.completions.create(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down Expand Up @@ -164,7 +164,7 @@ runner = Runner(

res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{
"role": "user",
Expand Down
2 changes: 1 addition & 1 deletion docs/MCP/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ runner = mistralrs.Runner(
# Use the model - tools are automatically available
res = runner.send_chat_completion_request(
mistralrs.ChatCompletionRequest(
model="ignore",
model="default",
messages=[
{"role": "user", "content": "List the files in the current directory and create a test.txt file"}
],
Expand Down
Loading
Loading