M
Mistral Small 3.1 24B Instruct 2503 Quantized.w8a8
由 RedHatAI 开发
这是一个经过INT8量化的Mistral-Small-3.1-24B-Instruct-2503模型,由Red Hat和Neural Magic优化,适用于快速响应和低延迟场景。
下载量 833
发布时间 : 4/15/2025
模型介绍
内容详情
替代品
模型简介
该模型是基于Mistral-Small-3.1-24B-Instruct-2503的量化版本,通过将权重和激活量化为INT8,显著降低了GPU内存需求并提高了计算效率。
模型特点
高效量化
通过INT8量化技术,将GPU内存需求降低约50%,计算吞吐量提高约2倍
多语言支持
支持24种语言的文本生成和理解
多功能应用
适用于对话代理、函数调用、文档理解和视觉理解等多种任务
快速响应
优化后的模型特别适合需要低延迟的应用场景
模型能力
文本生成
多语言处理
对话代理
函数调用
长文档理解
视觉理解
编程和数学推理
使用案例
对话系统
客户服务聊天机器人
部署快速响应的客户服务代理
降低响应延迟,提高用户体验
开发工具
代码辅助
帮助开发者进行编程和调试
提高开发效率
内容理解
长文档摘要
快速理解和总结长文档内容
提高信息处理效率
语言:
- 英语
- 法语
- 德语
- 西班牙语
- 葡萄牙语
- 意大利语
- 日语
- 韩语
- 俄语
- 中文
- 阿拉伯语
- 波斯语
- 印尼语
- 马来语
- 尼泊尔语
- 波兰语
- 罗马尼亚语
- 塞尔维亚语
- 瑞典语
- 土耳其语
- 乌克兰语
- 越南语
- 印地语
- 孟加拉语
许可证: apache-2.0 库名称: vllm 基础模型:
- mistralai/Mistral-Small-3.1-24B-Instruct-2503 管道标签: 图像文本到文本 标签:
- neuralmagic
- redhat
- llmcompressor
- 量化
- int8
Mistral-Small-3.1-24B-Instruct-2503-quantized.w8a8
模型概述
- 模型架构: Mistral3ForConditionalGeneration
- 输入: 文本/图像
- 输出: 文本
- 模型优化:
- 激活量化: INT8
- 权重量化: INT8
- 适用场景: 适用于:
- 快速响应的对话代理。
- 低延迟函数调用。
- 通过微调成为特定领域的专家。
- 处理敏感数据的个人爱好者和组织的本地推理。
- 编程和数学推理。
- 长文档理解。
- 视觉理解。
- 不适用场景: 任何违反适用法律或法规(包括贸易合规法律)的使用。使用模型不正式支持的语言。
- 发布日期: 2025年4月15日
- 版本: 1.0
- 模型开发者: Red Hat (Neural Magic)
模型优化
该模型是通过将Mistral-Small-3.1-24B-Instruct-2503的激活和权重量化为INT8数据类型获得的。
这一优化将表示权重和激活的位数从16位减少到8位,降低了GPU内存需求(约50%)并提高了矩阵乘法计算吞吐量(约2倍)。
权重量化还将磁盘空间需求减少了约50%。
仅量化了transformer块内线性运算符的权重和激活。
权重采用对称静态每通道方案量化,而激活采用对称动态每令牌方案量化。
结合SmoothQuant和GPTQ算法进行量化,具体实现见llm-compressor库。
部署
该模型可以使用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兼容的服务。更多详情请参阅文档。
创建
创建详情
该模型是通过运行以下代码片段使用[llm-compressor](https://github.com/vllm-project/llm-compressor)创建的。from transformers import AutoProcessor
from llmcompressor.modifiers.quantization import GPTQModifier
from llmcompressor.modifiers.smoothquant import SmoothQuantModifier
from llmcompressor.transformers import oneshot
from llmcompressor.transformers.tracing import TraceableMistral3ForConditionalGeneration
from datasets import load_dataset, interleave_datasets
from PIL import Image
import io
# 加载模型
model_stub = "mistralai/Mistral-Small-3.1-24B-Instruct-2503"
model_name = model_stub.split("/")[-1]
num_text_samples = 1024
num_vision_samples = 1024
max_seq_len = 8192
processor = AutoProcessor.from_pretrained(model_stub)
model = TraceableMistral3ForConditionalGeneration.from_pretrained(
model_stub,
device_map="auto",
torch_dtype="auto",
)
# 纯文本数据子集
def preprocess_text(example):
input = {
"text": processor.apply_chat_template(
example["messages"],
add_generation_prompt=False,
),
"images": None,
}
tokenized_input = processor(**input, max_length=max_seq_len, truncation=True)
tokenized_input["pixel_values"] = tokenized_input.get("pixel_values", None)
tokenized_input["image_sizes"] = tokenized_input.get("image_sizes", None)
return tokenized_input
dst = load_dataset("neuralmagic/calibration", name="LLM", split="train").select(range(num_text_samples))
dst = dst.map(preprocess_text, remove_columns=dst.column_names)
# 文本+视觉数据子集
def preprocess_vision(example):
messages = []
image = None
for message in example["messages"]:
message_content = []
for content in message["content"]:
if content["type"] == "text":
message_content.append({"type": "text", "text": content["text"]})
else:
message_content.append({"type": "image"})
image = Image.open(io.BytesIO(content["image"]))
messages.append(
{
"role": message["role"],
"content": message_content,
}
)
input = {
"text": processor.apply_chat_template(
messages,
add_generation_prompt=False,
),
"images": image,
}
tokenized_input = processor(**input, max_length=max_seq_len, truncation=True)
tokenized_input["pixel_values"] = tokenized_input.get("pixel_values", None)
tokenized_input["image_sizes"] = tokenized_input.get("image_sizes", None)
return tokenized_input
dsv = load_dataset("neuralmagic/calibration", name="VLM", split="train").select(range(num_vision_samples))
dsv = dsv.map(preprocess_vision, remove_columns=dsv.column_names)
# 交错子集
ds = interleave_datasets((dsv, dst))
# 配置量化算法和方案
recipe = [
SmoothQuantModifier(
smoothing_strength=0.8,
mappings=[
[["re:.*q_proj", "re:.*k_proj", "re:.*v_proj"], "re:.*input_layernorm"],
[["re:.*gate_proj", "re:.*up_proj"], "re:.*post_attention_layernorm"],
[["re:.*down_proj"], "re:.*up_proj"],
],
),
GPTQModifier(
ignore=["language_model.lm_head", "re:vision_tower.*", "re:multi_modal_projector.*"],
sequential_targets=["MistralDecoderLayer"],
dampening_frac=0.01,
targets="Linear",
scheme="W8A8",
),
]
# 定义数据整理器
def data_collator(batch):
import torch
assert len(batch) == 1
collated = {}
for k, v in batch[0].items():
if v is None:
continue
if k == "input_ids":
collated[k] = torch.LongTensor(v)
elif k == "pixel_values":
collated[k] = torch.tensor(v, dtype=torch.bfloat16)
else:
collated[k] = torch.tensor(v)
return collated
# 应用量化
oneshot(
model=model,
dataset=ds,
recipe=recipe,
max_seq_length=max_seq_len,
data_collator=data_collator,
num_calibration_samples=num_text_samples + num_vision_samples,
)
# 以压缩张量格式保存到磁盘
save_path = model_name + "-quantized.w8a8"
model.save_pretrained(save_path)
processor.save_pretrained(save_path)
print(f"Model and tokenizer saved to: {save_path}")
评估
该模型在OpenLLM排行榜任务(版本1)、MMLU-pro、GPQA、HumanEval和MBPP上进行了评估。
非编码任务使用lm-evaluation-harness评估,而编码任务使用evalplus的分支评估。
所有情况下均使用vLLM作为引擎。
评估详情
MMLU
lm_eval \
--model vllm \
--model_args pretrained="RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-quantized.w8a8",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挑战
lm_eval \
--model vllm \
--model_args pretrained="RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-quantized.w8a8",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-quantized.w8a8",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-quantized.w8a8",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-quantized.w8a8",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-quantized.w8a8",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 vll
Mistral Small 3.1 24B Instruct 2503 FP8 Dynamic
Apache-2.0
这是一个基于Mistral3架构的24B参数条件生成模型,经过FP8动态量化优化,适用于多语言文本生成和视觉理解任务。
文本到文本
Safetensors
支持多种语言
M
RedHatAI
2,650
5
Mistral Small 3.1 24B Instruct 2503 Quantized.w8a8
Apache-2.0
这是一个经过INT8量化的Mistral-Small-3.1-24B-Instruct-2503模型,由Red Hat和Neural Magic优化,适用于快速响应和低延迟场景。
文本到文本
Safetensors
支持多种语言
M
RedHatAI
833
2
Smolvlm2 2.2B Instruct I1 GGUF
Apache-2.0
SmolVLM2-2.2B-Instruct 是一个2.2B参数规模的视觉语言模型,专注于视频文本到文本任务,支持英语。
文本到文本
英语
S
mradermacher
285
0
Spatialvla 4b Mix 224 Pt
MIT
SpatialVLA是一个视觉-语言-动作模型,通过微调基础模型在分形与桥数据集上获得,专为机器人控制任务设计。
文本到文本
Transformers

英语
S
IPEC-COMMUNITY
72
4
Llava Next Inst It Vicuna 7B
Apache-2.0
LLaVA-Next-Inst-It-Vicuna-7B 是一款在多模态实例级理解方面表现卓越的模型,通过显式视觉提示指令调优增强多模态实例理解。
文本到文本
Safetensors
英语
L
Inst-IT
14
2
精选推荐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
AIbase是一个专注于MCP服务的平台,为AI开发者提供高质量的模型上下文协议服务,助力AI应用开发。
简体中文