Magistral Small 2506
Magistral-Small-2506是基於Mistral Small 3.1構建的小型高效推理模型,擁有240億參數,支持多語言和長鏈推理。
下載量 13.51k
發布時間 : 6/4/2025
模型概述
Magistral-Small-2506是一個高效的小型推理模型,支持多語言和長鏈推理,適用於本地部署和多種應用場景。
模型特點
高效推理能力
模型在給出答案之前能夠進行長鏈推理,適合複雜任務。
多語言支持
支持數十種語言,包括英語、法語、德語、中文等。
本地部署
量化後可適配單張RTX 4090或配備32GB內存的MacBook。
大上下文窗口
擁有128k的上下文窗口,但建議最大設置為40k以獲得最佳性能。
模型能力
文本生成
多語言支持
長鏈推理
本地部署
使用案例
文本生成
多語言文本生成
生成多種語言的文本內容,適用於國際化應用。
高質量的多語言文本輸出
複雜推理
數學問題求解
解決複雜的數學問題,包括多步推理。
準確的數學答案和推理過程
🚀 Magistral-Small-2506模型卡片
Magistral-Small-2506基於Mistral Small 3.1(2503)構建,新增推理能力,經過從Magistral Medium痕跡進行的SFT和後續的RL優化,是一個擁有240億參數的小型高效推理模型。
Magistral Small可以進行本地部署,量化後可適配單張RTX 4090或配備32GB內存的MacBook。
在我們的博客文章中瞭解更多關於Magistral的信息。
該模型在論文Magistral中被提出。
🚀 快速開始
Magistral-Small-2506可在本地部署,量化後能適配單張RTX 4090或32GB內存的MacBook。你可以參考以下不同使用場景的具體操作。
✨ 主要特性
- 推理能力:在給出答案之前,能夠進行長鏈推理。
- 多語言支持:支持數十種語言,包括英語、法語、德語、希臘語、印地語、印尼語、意大利語、日語、韓語、馬來語、尼泊爾語、波蘭語、葡萄牙語、羅馬尼亞語、俄語、塞爾維亞語、西班牙語、土耳其語、烏克蘭語、越南語、阿拉伯語、孟加拉語、中文和波斯語。
- Apache 2.0許可證:開放許可,允許商業和非商業用途的使用和修改。
- 上下文窗口:擁有128k的上下文窗口,但超過40k時性能可能會下降。因此,我們建議將最大模型長度設置為40k。
📊 基準測試結果
模型 | AIME24 pass@1 | AIME25 pass@1 | GPQA Diamond | Livecodebench (v5) |
---|---|---|---|---|
Magistral Medium | 73.59% | 64.95% | 70.83% | 59.36% |
Magistral Small | 70.68% | 62.76% | 68.18% | 55.84% |
💡 採樣參數
請確保使用以下參數:
top_p
:0.95temperature
:0.7max_tokens
:40960
💻 使用示例
基本聊天模板
我們強烈建議在使用時包含RL期間使用的默認系統提示,以獲得最佳效果。你可以根據具體用例進行編輯和定製。
<s>[SYSTEM_PROMPT]system_prompt
A user will ask you to solve a task. You should first draft your thinking process (inner monologue) until you have derived the final answer. Afterwards, write a self-contained summary of your thoughts (i.e. your summary should be succinct but contain all the critical steps you needed to reach the conclusion). You should use Markdown to format your response. Write both your thoughts and summary in the same language as the task posed by the user. NEVER use \boxed{} in your response.
Your thinking process must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct answer.
</think>
Here, provide a concise summary that reflects your reasoning and presents a clear final answer to the user. Don't mention that this is a summary.
Problem:
[/SYSTEM_PROMPT][INST]user_message[/INST]<think>
reasoning_traces
</think>
assistant_response</s>[INST]user_message[/INST]
system_prompt
、user_message
和assistant_response
為佔位符。
你可以根據用例和需求,選擇在多輪交互中保留推理痕跡或僅保留最終的助手回覆。
請確保以mistral-common作為參考標準
不同框架下的使用
推理
此外,社區還提供了該模型的量化版本,可與以下框架配合使用(按字母順序排序):
llama.cpp
:https://huggingface.co/mistralai/Magistral-Small-2506_gguflmstudio
(llama.cpp, MLX):https://lmstudio.ai/models/mistralai/magistral-smallollama
:https://ollama.com/library/magistralunsloth
(llama.cpp):https://huggingface.co/unsloth/Magistral-Small-2506-GGUF
訓練
可使用以下框架進行微調(按字母順序排序):
axolotl
:https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/magistralunsloth
:https://docs.unsloth.ai/basics/magistral
其他
你還可以在以下平臺使用Magistral:
kaggle
:https://www.kaggle.com/models/mistral-ai/magistral-small-2506
vLLM(推薦)
我們建議使用vLLM
庫來實現可用於生產環境的推理管道。
📦 安裝指南
確保安裝最新的vLLM
代碼:
pip install -U vllm \
--pre \
--extra-index-url https://wheels.vllm.ai/nightly
這樣做應該會自動安裝mistral_common >= 1.6.0
。
要進行檢查,可運行:
python -c "import mistral_common; print(mistral_common.__version__)"
你也可以使用現成的Docker鏡像或在Docker Hub上獲取。
服務模型
按以下方式啟動服務:
vllm serve mistralai/Magistral-Small-2506 --tokenizer_mode mistral --config_format mistral --load_format mistral --tool-call-parser mistral --enable-auto-tool-choice --tensor-parallel-size 2
調用模型
from openai import OpenAI
from huggingface_hub import hf_hub_download
# Modify OpenAI's API key and API base to use vLLM's API server.
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8000/v1"
TEMP = 0.7
TOP_P = 0.95
MAX_TOK = 40_960
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
models = client.models.list()
model = models.data[0].id
def load_system_prompt(repo_id: str, filename: str) -> str:
file_path = hf_hub_download(repo_id=repo_id, filename=filename)
with open(file_path, "r") as file:
system_prompt = file.read()
return system_prompt
SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
query = "Write 4 sentences, each with at least 8 words. Now make absolutely sure that every sentence has exactly one word less than the previous sentence."
# or try out other queries
# query = "Exactly how many days ago did the French Revolution start? Today is June 4th, 2025."
# query = "Think about 5 random numbers. Verify if you can combine them with addition, multiplication, subtraction or division to 133"
# query = "If it takes 30 minutes to dry 12 T-shirts in the sun, how long does it take to dry 33 T-shirts?"
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": query}
]
stream = client.chat.completions.create(
model=model,
messages=messages,
stream=True,
temperature=TEMP,
top_p=TOP_P,
max_tokens=MAX_TOK,
)
print("client: Start streaming chat completions...")
printed_content = False
for chunk in stream:
content = None
# Check the content is content
if hasattr(chunk.choices[0].delta, "content"):
content = chunk.choices[0].delta.content
if content is not None:
if not printed_content:
printed_content = True
print("\ncontent:", end="", flush=True)
# Extract and print the content
print(content, end="", flush=True)
# content:<think>
# Alright, I need to write 4 sentences where each one has at least 8 words and each subsequent sentence has one fewer word than the previous one.
# ...
# Final boxed answer (the four sentences):
# \[
# \boxed{
# \begin{aligned}
# &\text{1. The quick brown fox jumps over lazy dog and yells hello.} \\
# &\text{2. I saw the cat on the stair with my hat.} \\
# &\text{3. The man in the moon came down quickly today.} \\
# &\text{4. A cat sat on the mat today patiently.}
# \end{aligned}
# }
# \]
📚 詳細文檔
模型信息
屬性 | 詳情 |
---|---|
基礎模型 | mistralai/Mistral-Small-3.1-24B-Instruct-2503 |
支持語言 | 英語、法語、德語、西班牙語、葡萄牙語、意大利語、日語、韓語、俄語、中文、阿拉伯語、波斯語、印尼語、馬來語、尼泊爾語、波蘭語、羅馬尼亞語、塞爾維亞語、瑞典語、土耳其語、烏克蘭語、越南語、印地語、孟加拉語 |
庫名稱 | vllm |
許可證 | apache - 2.0 |
推理 | 否 |
額外提示
⚠️ 重要提示
如果你想了解我們如何處理你的個人數據,請閱讀我們的隱私政策。
📄 許可證
本模型採用Apache 2.0許可證,允許商業和非商業用途的使用和修改。
Phi 2 GGUF
其他
Phi-2是微軟開發的一個小型但強大的語言模型,具有27億參數,專注於高效推理和高質量文本生成。
大型語言模型 支持多種語言
P
TheBloke
41.5M
205
Roberta Large
MIT
基於掩碼語言建模目標預訓練的大型英語語言模型,採用改進的BERT訓練方法
大型語言模型 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基礎模型的蒸餾版本,在保持相近性能的同時更輕量高效,適用於序列分類、標記分類等自然語言處理任務。
大型語言模型 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一個多語言大語言模型,針對多語言對話用例進行了優化,在常見的行業基準測試中表現優異。
大型語言模型 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基於100種語言的2.5TB過濾CommonCrawl數據預訓練的多語言模型,採用掩碼語言建模目標進行訓練。
大型語言模型 支持多種語言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基於Transformer架構的英語預訓練模型,通過掩碼語言建模目標在海量文本上訓練,支持文本特徵提取和下游任務微調
大型語言模型 英語
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI發佈的開放預訓練Transformer語言模型套件,參數量從1.25億到1750億,旨在對標GPT-3系列性能,同時促進大規模語言模型的開放研究。
大型語言模型 英語
O
facebook
6.3M
198
1
基於transformers庫的預訓練模型,適用於多種NLP任務
大型語言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多語言大語言模型系列,包含8B、70B和405B參數規模,支持8種語言和代碼生成,優化了多語言對話場景。
大型語言模型
Transformers 支持多種語言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基礎版是由Google開發的文本到文本轉換Transformer模型,參數規模2.2億,支持多語言NLP任務。
大型語言模型 支持多種語言
T
google-t5
5.4M
702
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98