Instructions to use MiniMaxAI/MiniMax-M3.1-Flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MiniMaxAI/MiniMax-M3.1-Flash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="MiniMaxAI/MiniMax-M3.1-Flash", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("MiniMaxAI/MiniMax-M3.1-Flash", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("MiniMaxAI/MiniMax-M3.1-Flash", trust_remote_code=True, device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MiniMaxAI/MiniMax-M3.1-Flash with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MiniMaxAI/MiniMax-M3.1-Flash" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MiniMaxAI/MiniMax-M3.1-Flash", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/MiniMaxAI/MiniMax-M3.1-Flash
- SGLang
How to use MiniMaxAI/MiniMax-M3.1-Flash with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "MiniMaxAI/MiniMax-M3.1-Flash" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MiniMaxAI/MiniMax-M3.1-Flash", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "MiniMaxAI/MiniMax-M3.1-Flash" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MiniMaxAI/MiniMax-M3.1-Flash", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use MiniMaxAI/MiniMax-M3.1-Flash with Docker Model Runner:
docker model run hf.co/MiniMaxAI/MiniMax-M3.1-Flash
Improve factual reliability and Jinja2 compatibility in chat template
Browse files## Summary
This PR proposes improvements to the MiniMax-M3.1-Flash chat template, primarily focusing on factual reliability, hallucination reduction, and standard Jinja2 compatibility.
MiniMax-M3.1-Flash demonstrates strong overall capabilities, but its AA-Omniscience v1.1 performance appears relatively weak compared with its results on other benchmarks.
Since AA-Omniscience penalizes incorrect answers, improving confidence calibration and reducing unsupported factual claims may help address this weakness.
The proposed changes are intentionally minimal and do not modify the model's special tokens, message structure, reasoning protocol, or tool-calling format.
## Changes
### 1. Improve factual reliability and confidence calibration
Added general-purpose instructions to the system prompt to encourage the model to:
- Distinguish known facts from unsupported assumptions.
- Avoid plausible-sounding guesses when factual information is insufficient.
- Exercise greater caution with exact names, dates, numbers, software versions, quotations, and citations.
- Explicitly acknowledge uncertainty when an answer cannot be reliably determined.
- Avoid claiming to have verified sources that were not actually checked.
- Continue answering questions that can be solved through reliable reasoning or calculation.
- Preserve the user's requested response format.
These instructions are task-agnostic and do not contain benchmark-specific answers, examples, or evaluation data.
### 2. Fix standard Jinja2 compatibility
Changed:
`tojson(ensure_ascii=False)`
to:
`tojson`
The original expression raises a `TypeError` with the standard Jinja2 3.1.x implementation because the `tojson` filter does not accept an `ensure_ascii` argument.
This change allows tool definitions to be serialized using the standard Jinja2 filter.
## Compatibility
The modification preserves the existing:
- MiniMax-specific message delimiters and special tokens.
- Role mapping and conversation structure.
- Thinking and reasoning tags.
- Tool-call serialization format.
- Image and video markers.
The JSON serialization change may affect the textual escaping of non-ASCII characters, while preserving their JSON values.
## Validation
Basic Jinja2 rendering checks were performed for normal conversations and tool definitions.
However, these checks do not establish behavioral equivalence with the original template across all inputs.
Importantly, **no inference-based A/B benchmark has been performed yet**. Improvements to AA-Omniscience v1.1, hallucination rates, or general model accuracy have therefore not been demonstrated.
## Expected Benefits
The primary goal is to improve factual answer calibration without unnecessarily reducing the model's ability to answer questions through reasoning.
Potential benefits include fewer unsupported factual claims, more appropriate abstention on uncertain questions, and improved reliability in knowledge-intensive tasks.
These remain hypotheses until validated through controlled evaluation.
## Suggested Evaluation
I recommend comparing the original and modified templates under identical inference settings using AA-Omniscience v1.1 and complementary benchmarks.
Useful metrics would include:
- Correct answer rate.
- Incorrect answer rate.
- Abstention rate.
- AA-Omniscience net score.
- Performance on reasoning, coding, and tool-use tasks.
The goal should be to reduce incorrect answers without introducing excessive abstention or degrading the model's existing strengths.
## Feedback
I would appreciate feedback from the MiniMax team, particularly regarding whether system-level factual reliability guidance aligns with the model's intended instruction hierarchy and whether there are any compatibility considerations specific to its inference implementation.
Thank you for developing and releasing MiniMax-M3.1-Flash!
- chat_template.jinja +3 -1
|
@@ -36,7 +36,7 @@
|
|
| 36 |
{#- Tool Rendering Functions ============================================== -#}
|
| 37 |
{%- macro render_tool_namespace(namespace_name, tool_list) -%}
|
| 38 |
{%- for tool in tool_list -%}
|
| 39 |
-
<tool>{{ tool.function | tojson
|
| 40 |
{% endfor -%}
|
| 41 |
{%- endmacro -%}
|
| 42 |
{%- macro visible_text(content) -%}
|
|
@@ -76,6 +76,8 @@
|
|
| 76 |
{{- 'Your model version is MiniMax-M3.1, developed by MiniMax. Knowledge cutoff: January 2026. Founded in early 2022, MiniMax is a global AI foundation model company committed to advancing the frontiers of AI towards AGI.' }}
|
| 77 |
{%- endif -%}
|
| 78 |
|
|
|
|
|
|
|
| 79 |
{#- Thinking mode instructions -#}
|
| 80 |
{{- '\n\n<thinking_instructions>\n' }}
|
| 81 |
{{- 'You have a thinking capability that allows you to reason step by step before responding. When thinking is enabled, wrap your reasoning in ' ~ think_begin_token ~ think_end_token ~ ' tags before your response. When thinking is disabled, begin your response directly after the ' ~ think_end_token ~ ' prefix. When thinking is adaptive, decide on your own whether to think for the current turn.\n' }}
|
|
|
|
| 36 |
{#- Tool Rendering Functions ============================================== -#}
|
| 37 |
{%- macro render_tool_namespace(namespace_name, tool_list) -%}
|
| 38 |
{%- for tool in tool_list -%}
|
| 39 |
+
<tool>{{ tool.function | tojson }}</tool>
|
| 40 |
{% endfor -%}
|
| 41 |
{%- endmacro -%}
|
| 42 |
{%- macro visible_text(content) -%}
|
|
|
|
| 76 |
{{- 'Your model version is MiniMax-M3.1, developed by MiniMax. Knowledge cutoff: January 2026. Founded in early 2022, MiniMax is a global AI foundation model company committed to advancing the frontiers of AI towards AGI.' }}
|
| 77 |
{%- endif -%}
|
| 78 |
|
| 79 |
+
{#- Factual reliability guidance: conservative, task-agnostic, and not benchmark-specific. -#}
|
| 80 |
+
{{- '\n\nWhen answering factual questions, first use facts you actually know or conclusions you can reliably derive. Do not fill gaps with plausible-sounding guesses. For exact details such as names, dates, numbers, software versions, quotations, or citations, answer only when reasonably confident of the specific detail. If you cannot determine an answer reliably from the information available, explicitly say you do not know rather than inventing an answer. Do not claim to have checked a source you did not check. Do not abstain from questions you can solve by sound reasoning or calculation. Follow the user\'s requested answer format.' }}
|
| 81 |
{#- Thinking mode instructions -#}
|
| 82 |
{{- '\n\n<thinking_instructions>\n' }}
|
| 83 |
{{- 'You have a thinking capability that allows you to reason step by step before responding. When thinking is enabled, wrap your reasoning in ' ~ think_begin_token ~ think_end_token ~ ' tags before your response. When thinking is disabled, begin your response directly after the ' ~ think_end_token ~ ' prefix. When thinking is adaptive, decide on your own whether to think for the current turn.\n' }}
|