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 許可證。

