许可协议: apache-2.0
库名称: vllm
流水线标签: 图像文本到文本
标签:
- int4
- vllm
- llmcompressor
基础模型: mistralai/Mistral-Small-3.1-24B-Instruct-2503
Mistral-Small-3.1-24B-Instruct-2503-GPTQ-4b-128g
模型概述
本模型通过对Mistral-Small-3.1-24B-Instruct-2503的权重进行INT4量化获得。该优化将每个参数的比特数从16降至4,使磁盘大小和GPU内存需求减少约75%。
仅对language_model
转换器块中的线性算子权重进行量化。视觉模型和多模态投影保持原始精度。采用分组大小为128的对称逐组方案进行量化,并应用GPTQ算法完成量化过程。
模型检查点以compressed_tensors格式保存。
评估
本模型在OpenLLM v1基准测试中进行评估,模型输出由vLLM
引擎生成。
模型 |
ArcC |
GSM8k |
Hellaswag |
MMLU |
TruthfulQA-mc2 |
Winogrande |
平均分 |
恢复率 |
Mistral-Small-3.1-24B-Instruct-2503 |
0.7125 |
0.8848 |
0.8576 |
0.8107 |
0.6409 |
0.8398 |
0.7910 |
1.0000 |
Mistral-Small-3.1-24B-Instruct-2503-INT4 (本模型) |
0.7073 |
0.8711 |
0.8530 |
0.8062 |
0.6252 |
0.8256 |
0.7814 |
0.9878 |
复现方法
通过以下命令获得评估结果:
MODEL=ISTA-DASLab/Mistral-Small-3.1-24B-Instruct-2503-GPTQ-4b-128g
MODEL_ARGS="pretrained=$MODEL,max_model_len=4096,tensor_parallel_size=1,dtype=auto,gpu_memory_utilization=0.80"
lm_eval \
--model vllm \
--model_args $MODEL_ARGS \
--tasks openllm \
--batch_size auto
使用说明
-
在transformers
中使用本模型需更新至Mistral-3稳定版
pip install git+https://github.com/huggingface/transformers@v4.49.0-Mistral-3
-
在vLLM
中使用需升级至vllm>=0.8.0
版本
以下是通过transformers进行推理的示例:
from transformers import AutoProcessor, AutoModelForImageTextToText
from PIL import Image
import requests
import torch
model_id = "ISTA-DASLab/Mistral-Small-3.1-24B-Instruct-2503-GPTQ-4b-128g"
model = AutoModelForImageTextToText.from_pretrained(
model_id, device_map="auto"
).eval()
processor = AutoProcessor.from_pretrained(model_id)
messages = [
{
"role": "系统",
"content": [{"type": "文本", "text": "你是一个乐于助人的助手。"}]
},
{
"role": "用户",
"content": [
{"type": "图像", "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg"},
{"type": "文本", "text": "详细描述这张图片。"}
]
}
]
inputs = processor.apply_chat_template(
messages, add_generation_prompt=True, tokenize=True,
return_dict=True, return_tensors="pt"
).to(model.device, dtype=torch.bfloat16)
input_len = inputs["input_ids"].shape[-1]
with torch.inference_mode():
generation = model.generate(**inputs, max_new_tokens=100, do_sample=False)
generation = generation[0][input_len:]
decoded = processor.decode(generation, skip_special_tokens=True)
print(decoded)