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
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!