宣布Magistral——Mistral AI推出的首款推理模型,专精于垂直领域、具备透明化特性与多语言推理能力。

最优秀的人类思维并非线性——它穿梭于逻辑、洞见、不确定性与发现之间。推理型语言模型让我们得以将复杂思考和深度理解交由AI增强或代劳,提升了人类处理需要精确逐步推敲分析问题的能力。

但这一领域仍处于萌芽阶段。早期思维模型存在诸多已知局限:缺乏针对垂直领域问题的专业深度、透明度不足、以及目标语言环境下的推理不连贯等。

今天我们激动地宣布通过Magistral模型为AI研究做出最新贡献——这是我们首个推理模型。Magistral同步推出开源版与企业版,其设计理念是:以人类熟悉的思维方式进行深度推理论证,同时兼具跨专业领域的知识储备、可追踪验证的透明推理过程,以及深度的多语言适应能力。

亮点

在这里插入图片描述

Magistral Small 1.1

基于Mistral Small 3.1(2503版本)开发,额外增强推理能力,通过Magistral Medium轨迹进行监督微调并叠加强化学习,最终形成这款高效的小型推理模型,参数量达240亿。

Magistral Small支持本地部署,经量化后可适配单张RTX 4090显卡或32GB内存的MacBook设备运行。

Magistral Small 1.1 版本应提供与 基准测试结果 中 Magistral Small 1.0 相近的性能表现。

本次更新包含以下特性:

  • 更优化的语气与模型行为表现。您将体验到更出色的 LaTeX 和 Markdown 格式处理能力,以及对简单通用提示的更简洁回答。
  • 模型陷入无限生成循环的概率显著降低。
  • 新增 [THINK][/THINK] 特殊标记用于封装推理内容。该设计既便于解析思维轨迹,也能有效避免提示中出现’[THINK]'字符串时引发混淆。
  • 推理提示词现已整合至系统提示模板中。

主要特点

  • 推理能力:能够在给出答案前进行长链式推理追踪。
  • 多语言支持:支持数十种语言,包括英语、法语、德语、希腊语、印地语、印尼语、意大利语、日语、韩语、马来语、尼泊尔语、波兰语、葡萄牙语、罗马尼亚语、俄语、塞尔维亚语、西班牙语、土耳其语、乌克兰语、越南语、阿拉伯语、孟加拉语、中文及波斯语。
  • Apache 2.0许可证:开放许可协议,允许商业及非商业用途的修改和使用。
  • 上下文窗口:128k上下文窗口,超过40k后性能可能下降。因此建议将模型最大长度设置为40k。

基准测试结果

ModelAIME24 pass@1AIME25 pass@1GPQA DiamondLivecodebench (v5)
Magistral Medium 1.172.03%60.99%71.46%59.35%
Magistral Medium 1.073.59%64.95%70.83%59.36%
Magistral Small 1.170.52%62.03%65.78%59.17%
Magistral Small 1.070.68%62.76%68.18%55.84%

采样参数

请确保使用:

  • top_p: 0.95
  • temperature: 0.7
  • max_tokens: 40960

基础聊天模板

为获得最佳效果,我们强烈建议包含以下系统提示词(可根据具体使用场景进行编辑调整):

请先通过思维过程(内心独白)构思,直至形成最终回复。使用Markdown格式撰写回复,数学公式请用LaTeX表示。思维过程和回复内容需与输入语言保持一致。

思维过程必须遵循以下模板:[THINK]您的思考或草稿内容,如同在草稿纸上演算习题。可随意采用非正式表达并充分展开,直至有把握生成最终回复。语言需与输入保持一致。[/THINK]此处提供完整的最终回复内容。

[THINK][/THINK]是必须保持原样的特殊标记符。

请务必以mistral-common作为权威参考。下方提供支持mistral-common的库示例。

根据使用场景和需求,您可选择在多轮对话中保留推理痕迹,或仅保留助手最终回复内容。

使用方法

该模型可与以下框架配合使用:

推理

  • vllm(推荐): 参见下文
  • transformers: 参见下文

此外,社区还准备了量化版本的模型,可与以下框架配合使用(按字母顺序排序):

  • llama.cpp: https://huggingface.co/mistralai/Magistral-Small-2507-GGUF
  • lmstudio (llama.cpp, MLX): GGUF, MLX-bf16, MLX-8bit, MLX-6bit, MLX-4bit

训练

支持通过以下工具进行微调(按字母顺序排列):

  • axolotl: https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/magistral
  • unsloth: https://docs.unsloth.ai/basics/magistral

vLLM(推荐)

我们建议配合使用vLLM库部署生产级推理流水线。

安装指南

请确保安装最新版vLLM代码库:

pip install -U vllm \--pre \--extra-index-url https://wheels.vllm.ai/nightly

该操作会自动安装mistral_common >= 1.8.2版本。

版本验证命令:

python -c "import mistral_common; print(mistral_common.__version__)"

您也可以直接使用现成的 Docker 镜像 或从 Docker Hub 获取。

按如下方式启动模型服务:

vllm serve mistralai/Magistral-Small-2507 --reasoning-parser mistral --tokenizer_mode mistral --config_format mistral --load_format mistral --tool-call-parser mistral --enable-auto-tool-choice --tensor-parallel-size 2

按如下方式测试模型连通性:

from typing import Any
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_960client = OpenAI(api_key=openai_api_key,base_url=openai_api_base,
)models = client.models.list()
model = models.data[0].iddef load_system_prompt(repo_id: str, filename: str) -> dict[str, Any]:file_path = hf_hub_download(repo_id=repo_id, filename=filename)with open(file_path, "r") as file:system_prompt = file.read()index_begin_think = system_prompt.find("[THINK]")index_end_think = system_prompt.find("[/THINK]")return {"role": "system","content": [{"type": "text", "text": system_prompt[:index_begin_think]},{"type": "thinking","thinking": system_prompt[index_begin_think + len("[THINK]") : index_end_think],"closed": True,},{"type": "text","text": system_prompt[index_end_think + len("[/THINK]") :],},],}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 = [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...:\n")
printed_reasoning_content = False
answer = []for chunk in stream:reasoning_content = Nonecontent = None# Check the content is reasoning_content or contentif hasattr(chunk.choices[0].delta, "reasoning_content"):reasoning_content = chunk.choices[0].delta.reasoning_contentelif hasattr(chunk.choices[0].delta, "content"):content = chunk.choices[0].delta.contentif reasoning_content is not None:if not printed_reasoning_content:printed_reasoning_content = Trueprint("Start reasoning:\n", end="", flush=True)print(reasoning_content, end="", flush=True)elif content is not None:# Extract and print the contentif not reasoning_content and printed_reasoning_content:answer.extend(content)print(content, end="", flush=True)if answer:print("\n\n=============\nAnswer\n=============\n")print("".join(answer))
else:print("\n\n=============\nNo Answer\n=============\n")print("No answer was generated by the model, probably because the maximum number of tokens was reached.")# client: Start streaming chat completions...:
#
# Start reasoning:
# First, I need to write ...
# ...
#
#
# =============
# Answer
# =============
# 
# Here are four sentences where each has at least 8 words, and each subsequent sentence has exactly one word less than the previous one:# 1. The quick brown fox jumps over the lazy dog and rests.
# 2. The lazy dog rests under the big shady tree peacefully.
# 3. The big shady tree provides ample shade during summer.
# 4. The tree's leaves are very lush and green.

Transformers

请确保安装最新版本的Transformers代码:

pip install git+https://github.com/huggingface/transformers

同时请确保安装 mistral_common >= 1.8.2

pip install --upgrade mistral-common

检查

python -c "import mistral_common; print(mistral_common.__version__)"

现在你可以在Magistral中使用Transformers了:

from typing import Any
import torchfrom huggingface_hub import hf_hub_download
from transformers import AutoModelForCausalLM, AutoTokenizerTEMP = 0.7
TOP_P = 0.95
MAX_TOK = 40_960def load_system_prompt(repo_id: str, filename: str) -> dict[str, Any]:file_path = hf_hub_download(repo_id=repo_id, filename=filename)with open(file_path, "r") as file:system_prompt = file.read()index_begin_think = system_prompt.find("[THINK]")index_end_think = system_prompt.find("[/THINK]")return {"role": "system","content": [{"type": "text", "text": system_prompt[:index_begin_think]},{"type": "thinking","thinking": system_prompt[index_begin_think + len("[THINK]") : index_end_think],"closed": True,},{"type": "text","text": system_prompt[index_end_think + len("[/THINK]") :],},],}model_id = "mistralai/Magistral-Small-2507"
SYSTEM_PROMPT = load_system_prompt(model_id, "SYSTEM_PROMPT.txt")
query = "Think about 5 random numbers. Verify if you can combine them with addition, multiplication, subtraction or division to 133."
# or try out other queries
# query = "Exactly how many days ago did the French Revolution start? Today is June 4th, 2025."
# 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."
# query = "If it takes 30 minutes to dry 12 T-shirts in the sun, how long does it take to dry 33 T-shirts?"tokenizer = AutoTokenizer.from_pretrained(model_id, tokenizer_type="mistral", use_fast=False)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto"
)input_ids = tokenizer.apply_chat_template([SYSTEM_PROMPT,{"role": "user", "content": query},],
)output = model.generate(input_ids=torch.tensor([input_ids], device=model.device),pad_token_id=tokenizer.pad_token_id,eos_token_id=tokenizer.eos_token_id,temperature=TEMP,top_p=TOP_P,do_sample=True,max_new_tokens=MAX_TOK,
)[0]decoded_output = tokenizer.decode(output[len(input_ids) :])
print(decoded_output)# [THINK]Alright, I need to think of 5 random numbers first. Let's say I pick the numbers 5, 10, 2, 7, and 3.
# 
# Now, I need to see if I can combine these numbers using addition, multiplication, subtraction, or division to get 133.
# ...
# ...
# ...
# But if we're to find any five numbers that can be combined to make 133, then yes, such sets exist, like the one demonstrated above.[/THINK]Yes, it is possible to combine some sets of five random numbers to make 133 using basic arithmetic operations. For example, the numbers 13, 10, 1, 2, and 3 can be combined as follows to make 133:
# 
# \[ (13 \times 10) + (3 \times (2 - 1)) = 130 + 3 = 133 \]
# 
# However, not all sets of five random numbers can be combined in this way to make 133. For instance, with the numbers 5, 10, 2, 7, and 3, it is not possible to combine them using the allowed operations to get exactly 133.
# 
# Therefore, the ability to combine five random numbers to make 133 depends on the specific numbers chosen.
# 
# $133 = (13 \times 10) + (3 \times (2 - 1))$</s>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/pingmian/90891.shtml
繁体地址,请注明出处:http://hk.pswp.cn/pingmian/90891.shtml
英文地址,请注明出处:http://en.pswp.cn/pingmian/90891.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Kotlin】如何实现静态方法?(单例类、伴生对象、@JvmStatic)

静态方法 静态方法&#xff08;类方法&#xff09;&#xff1a;不需要创建实例就可以调用&#xff08;直接通过类名调用&#xff09;的方法 Java 中的静态方法&#xff08;static&#xff09; public class Util {public static void doAction() {//...} }调用&#xff1a;Util…

SQL Schema 和Pandas Schema什么意思

在数据处理和分析领域&#xff0c;SQL Schema 和 Pandas Schema 分别指的是在不同数据处理环境中数据的结构定义&#xff0c;以下为你详细介绍&#xff1a;SQL Schema含义SQL Schema&#xff08;模式&#xff09;是数据库对象的一个逻辑容器&#xff0c;它定义了数据库中表、视…

机器学习(一)KNN,K近邻算法(K-Nearest Neighbors)

&#x1f4a1; 建议初学者掌握KNN作为理解其他复杂算法&#xff08;如SVM、决策树、神经网络&#xff09;的基石。K近邻算法&#xff08;K-Nearest Neighbors, KNN&#xff09;详解&#xff1a;原理、实践与优化K近邻算法&#xff08;K-Nearest NeighboKrs&#xff0c;简称KNN&…

Qt 多线程数据库操作优化

在多线程应用中&#xff0c;数据库操作往往是性能瓶颈与稳定性风险的高发区。当多个线程同时读写数据库时&#xff0c;若处理不当&#xff0c;轻则出现查询卡顿、事务冲突&#xff0c;重则导致数据错乱、连接泄漏甚至程序崩溃。Qt作为跨平台框架&#xff0c;提供了QSql系列类支…

Qt 状态机框架:复杂交互逻辑的处理

Qt状态机框架&#xff08;Qt State Machine Framework&#xff09;是一个强大的工具&#xff0c;用于简化复杂的交互逻辑和状态管理。它基于UML状态图概念&#xff0c;提供了声明式的方式来定义对象行为&#xff0c;特别适合处理具有多种状态和转换的场景&#xff08;如GUI交互…

【docker】DM8达梦数据库的docker-compose以及一些启动踩坑

摘要&#xff1a;本文介绍了通过docker-compose配置启动达梦数据库(DM8)的方法。配置包括容器镜像、端口映射、数据卷挂载以及关键环境变量设置&#xff08;如字符集、大小写敏感等&#xff09;。也说明了启动过程可能遇到的一些问题。通过docker-compose启动达梦数据库可以按照…

服务器中的防火墙设置需要打开吗

服务器中的防火墙属于是一种保护计算机网络不会受到未经授权的网络设备所访问的技术手段&#xff0c;防火墙还有着将内部网络和外部网络进行隔离的功能&#xff0c;在网络之间创建安全屏障&#xff0c;以此来保护网络中数据的安全。防火墙是一种网络安全系统&#xff0c;可以帮…

Java项目:基于SSM框架实现的社区团购管理系统【ssm+B/S架构+源码+数据库+毕业论文+答辩PPT+远程部署】

摘 要 使用旧方法对社区团购信息进行系统化管理已经不再让人们信赖了&#xff0c;把现在的网络信息技术运用在社区团购信息的管理上面可以解决许多信息管理上面的难题&#xff0c;比如处理数据时间很长&#xff0c;数据存在错误不能及时纠正等问题。 这次开发的社区团购系统有…

介绍一下static关键字

在Java中&#xff0c;被static修饰的成员称为静态成员&#xff0c;static关键字可以用来修饰方法或者成员变量&#xff0c;且被static修饰的方法或者成员变量属于类方法或者类属性&#xff0c;也就是说被static修饰的方法或者成员变量不是单独存储在某一个对象的空间&#xff0…

【Java学习|黑马笔记|Day23】网络编程、反射、动态代理

【DAY23】 文章目录【DAY23】一.网络编程1&#xff09;三要素1.1&#xff09;IPInetAddress类的使用1.2&#xff09;端口号1.3&#xff09;协议2.1&#xff09;UDP协议发送数据2.2&#xff09;UDP协议接收数据2.3&#xff09;UDP的三种通信方式3.1&#xff09;TCP协议的发送和接…

【Zephyr】Window下的Zephyr编译和使用

工具下载 参考文档&#xff08;Getting Started Guide — Zephyr Project Documentation&#xff09;中介绍&#xff0c;可以直接通过winget下载&#xff1a; winget download Kitware.CMake Ninja-build.Ninja oss-winget.gperf python Git.Git oss-winget.dtc wget 7zip.7z…

图论(BFS)构造邻接表(运用队列实现搜索)

码蹄集OJ-夏日漫步 #include<bits/stdc.h> using namespace std; int n; int a[200010],dis[200010],qaq[1000010]; vector<int>son[200010]; int que[200010]; int main( ) {memset(qaq,-1,sizeof(qaq));memset(dis,-1,sizeof(dis));cin>>n;for(int i1;i…

vue怎么实现导入excel表功能

<el-uploadref"upload":action"aaa":on-change"importProject"name"excelFile"multiple:auto-upload"false":show-file-list"false"><el-button type"warning">导入</el-button><…

Linux DNS解析3 -- DNS解析代理配置使用

当网关设备配置了 /etc/hosts 文件时&#xff0c;确实可以为终端设备提供自定义DNS解析功能&#xff0c;但具体效果取决于网关的DNS代理服务配置。下面详细解释其工作原理和限制&#xff1a; 一、/etc/hosts 文件的作用 /etc/hosts 是本地静态域名解析文件&#xff0c;格式为&a…

历史版本的vscode下载地址

我有点厌恶vscode越来越臃肿的体积&#xff0c;也不需要层出不穷的新功能&#xff0c;于是网上找寻历史版本。 首先是这个页面&#xff1a;https://code.visualstudio.com/updates &#xff0c;但最多只显示两年&#xff0c;更早的就要手工修改地址栏&#xff0c;我试了最早的…

如何规范化项目执行

要实现项目执行的规范化&#xff0c;应做到以下几点&#xff1a;制定详细的项目执行计划、明确项目团队角色职责、建立高效沟通与协调机制、实施全面的质量与风险管理、采用合适的项目管理工具。其中&#xff0c;尤其重要的是明确项目团队角色职责&#xff0c;通过构建清晰的责…

【Rust异步】async和await异步编程实战:高并发任务处理全解析

✨✨ 欢迎大家来到景天科技苑✨✨ &#x1f388;&#x1f388; 养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; &#x1f3c6; 作者简介&#xff1a;景天科技苑 &#x1f3c6;《头衔》&#xff1a;大厂架构师&#xff0c;华为云开发者社区专家博主&#xff0c;…

在Linux上使用DuckCP实现从csv文件汇总数据到SQLite数据库的表

从pypi网站Duckcp页面下载duckcp-0.1.1-py3-none-any.whl 一开始用的Python 3.11.2环境。 继续沿用上文打补丁的方法&#xff0c;得到一个支持python3.11.1的安装包。 因为缺少zip压缩工具&#xff0c;使用python程序来完成对修改后文件的重新压缩。 import os import zipfile…

基于深度学习的图像分类:使用EfficientNet实现高效分类

前言 图像分类是计算机视觉领域中的一个基础任务&#xff0c;其目标是将输入的图像分配到预定义的类别中。近年来&#xff0c;深度学习技术&#xff0c;尤其是卷积神经网络&#xff08;CNN&#xff09;&#xff0c;在图像分类任务中取得了显著的进展。EfficientNet是一种新型的…

Java基础-综合案例

1、设计一个可以执行基本数学运算&#xff08;加减乘除&#xff09;的计算器程序功能描述&#xff1a;用户输入两个数字、一个运算符&#xff08;、-、*、/&#xff09;。根据所选运算符执行相应的数学运算&#xff0c;显示运算结果。import java.util.Scanner;public class Te…