🚀 Mistral-Small-3.1-24B-Instruct-2503-GPTQ-4b-128g
本项目是将 Mistral-Small-3.1-24B-Instruct-2503 模型的权重量化为 INT4 数据类型得到的模型。通过量化优化,减少了模型的磁盘占用和 GPU 内存需求,同时保持了一定的性能。
🚀 快速开始
环境准备
推理示例
以下是通过 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": "system",
"content": [{"type": "text", "text": "You are a helpful assistant."}]
},
{
"role": "user",
"content": [
{"type": "image", "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg"},
{"type": "text", "text": "Describe this image in detail."}
]
}
]
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)
✨ 主要特性
📚 详细文档
评估
该模型在 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
📄 许可证
本模型采用 Apache-2.0 许可证。