Mistral Small 3.1 24B Instruct 2503 FP8 Dynamic
模型简介
模型特点
模型能力
使用案例
🚀 Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic
本模型结合了Mistral架构与FP8量化技术,在降低资源需求的同时保持高性能,适用于多种自然语言处理和图像文本处理场景。
🚀 快速开始
部署示例
此模型可以使用 vLLM 后端高效部署,示例代码如下:
from vllm import LLM, SamplingParams
from transformers import AutoProcessor
model_id = "RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic"
number_gpus = 1
sampling_params = SamplingParams(temperature=0.7, top_p=0.8, max_tokens=256)
processor = AutoProcessor.from_pretrained(model_id)
messages = [{"role": "user", "content": "Give me a short introduction to large language model."}]
prompts = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
llm = LLM(model=model_id, tensor_parallel_size=number_gpus)
outputs = llm.generate(prompts, sampling_params)
generated_text = outputs[0].outputs[0].text
print(generated_text)
vLLM 还支持与 OpenAI 兼容的服务,更多详情请参阅 文档。
✨ 主要特性
- 模型架构:Mistral3ForConditionalGeneration,支持文本和图像输入,输出文本。
- 模型优化:采用 FP8 激活量化和权重量化,减少 GPU 内存需求约 50%,提高矩阵乘法计算吞吐量约 2 倍,同时磁盘大小需求也减少约 50%。
- 适用场景广泛:适用于快速响应的对话代理、低延迟函数调用、通过微调成为主题专家、处理敏感数据的本地推理、编程和数学推理、长文档理解以及视觉理解等场景。
📚 详细文档
模型概述
属性 | 详情 |
---|---|
模型架构 | Mistral3ForConditionalGeneration,输入为文本或图像,输出为文本 |
模型优化 | 激活量化和权重量化均采用 FP8 |
预期用例 | 快速响应的对话代理、低延迟函数调用、通过微调成为主题专家、处理敏感数据的本地推理、编程和数学推理、长文档理解、视觉理解 |
不适用范围 | 以任何违反适用法律法规(包括贸易合规法律)的方式使用;在模型未官方支持的语言中使用 |
发布日期 | 2025 年 4 月 15 日 |
版本 | 1.0 |
模型开发者 | RedHat (Neural Magic) |
模型优化
本模型通过将 Mistral-Small-3.1-24B-Instruct-2503 的激活和权重量化为 FP8 数据类型获得。仅对 Transformer 块内线性算子的权重和激活进行量化,权重采用对称静态逐通道方案量化,激活采用对称动态逐令牌方案量化,使用 llm-compressor 库进行量化。
模型创建
创建详情
本模型使用 [llm-compressor](https://github.com/vllm-project/llm-compressor) 创建,代码片段如下: ```python from llmcompressor.modifiers.quantization import QuantizationModifier from llmcompressor.transformers import oneshot from transformers import AutoModelForImageTextToText, AutoProcessor加载模型
model_stub = "mistralai/Mistral-Small-3.1-24B-Instruct-2503" model_name = model_stub.split("/")[-1]
model = AutoModelForImageTextToText.from_pretrained(model_stub)
processor = AutoProcessor.from_pretrained(model_stub)
配置量化算法和方案
recipe = QuantizationModifier( ignore=["language_model.lm_head", "re:vision_tower.", "re:multi_modal_projector."], targets="Linear", scheme="FP8_dynamic", )
应用量化
oneshot( model=model, recipe=recipe, )
以压缩张量格式保存到磁盘
save_path = model_name + "-FP8-dynamic" model.save_pretrained(save_path) processor.save_pretrained(save_path) print(f"模型和分词器保存到: {save_path}")
</details>
### 模型评估
本模型在 OpenLLM 排行榜任务(版本 1)、MMLU-pro、GPQA、HumanEval 和 MBPP 上进行了评估。非编码任务使用 [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) 评估,编码任务使用 [evalplus](https://github.com/neuralmagic/evalplus) 的一个分支进行评估,所有评估均使用 [vLLM](https://docs.vllm.ai/en/stable/) 作为引擎。
<details>
<summary>评估详情</summary>
**MMLU**
lm_eval
--model vllm
--model_args pretrained="RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=2
--tasks mmlu
--num_fewshot 5
--apply_chat_template
--fewshot_as_multiturn
--batch_size auto
**ARC Challenge**
lm_eval
--model vllm
--model_args pretrained="RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=2
--tasks arc_challenge
--num_fewshot 25
--apply_chat_template
--fewshot_as_multiturn
--batch_size auto
**GSM8k**
lm_eval
--model vllm
--model_args pretrained="RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.9,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=2
--tasks gsm8k
--num_fewshot 8
--apply_chat_template
--fewshot_as_multiturn
--batch_size auto
**Hellaswag**
lm_eval
--model vllm
--model_args pretrained="RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=2
--tasks hellaswag
--num_fewshot 10
--apply_chat_template
--fewshot_as_multiturn
--batch_size auto
**Winogrande**
lm_eval
--model vllm
--model_args pretrained="RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=2
--tasks winogrande
--num_fewshot 5
--apply_chat_template
--fewshot_as_multiturn
--batch_size auto
**TruthfulQA**
lm_eval
--model vllm
--model_args pretrained="RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=2
--tasks truthfulqa
--num_fewshot 0
--apply_chat_template
--batch_size auto
**MMLU-pro**
lm_eval
--model vllm
--model_args pretrained="RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=2
--tasks mmlu_pro
--num_fewshot 5
--apply_chat_template
--fewshot_as_multiturn
--batch_size auto
**编码任务**
以下命令可用于 MBPP,只需替换数据集名称即可。
*生成*
python3 codegen/generate.py
--model RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic
--bs 16
--temperature 0.2
--n_samples 50
--root "."
--dataset humaneval
*清理*
python3 evalplus/sanitize.py
humaneval/RedHatAI--Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic_vllm_temp_0.2
*评估*
evalplus.evaluate
--dataset humaneval
--samples humaneval/RedHatAI--Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic_vllm_temp_0.2-sanitized
</details>
### 准确率
| 类别 | 基准测试 | Mistral-Small-3.1-24B-Instruct-2503 | Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic(本模型) | 恢复率 |
|------|------|------|------|------|
| **OpenLLM v1** | MMLU (5-shot) | 80.67 | 80.71 | 100.1% |
| **OpenLLM v1** | ARC Challenge (25-shot) | 72.78 | 72.87 | 100.1% |
| **OpenLLM v1** | GSM-8K (5-shot, strict-match) | 58.68 | 49.96 | 85.1% |
| **OpenLLM v1** | Hellaswag (10-shot) | 83.70 | 83.67 | 100.0% |
| **OpenLLM v1** | Winogrande (5-shot) | 83.74 | 82.56 | 98.6% |
| **OpenLLM v1** | TruthfulQA (0-shot, mc2) | 70.62 | 70.88 | 100.4% |
| **OpenLLM v1** | **平均** | **75.03** | **73.49** | **97.9%** |
| | MMLU-Pro (5-shot) | 67.25 | 66.86 | 99.4% |
| | GPQA CoT main (5-shot) | 42.63 | 41.07 | 99.4% |
| | GPQA CoT diamond (5-shot) | 45.96 | 45.45 | 98.9% |
| **编码** | HumanEval pass@1 | 84.70 | 84.70 | 100.0% |
| **编码** | HumanEval+ pass@1 | 79.50 | 79.30 | 99.8% |
| **编码** | MBPP pass@1 | 71.10 | 70.00 | 98.5% |
| **编码** | MBPP+ pass@1 | 60.60 | 59.50 | 98.2% |
## 📄 许可证
本模型采用 Apache-2.0 许可证。


