Qwen2.5 VL 7B Instruct FP8 Dynamic
Qwen2.5-VL-7B-Instruct的FP8量化版本,通過vLLM支持高效視覺-文本推理
下載量 25.18k
發布時間 : 2/6/2025
模型概述
基於Qwen2.5-VL-7B-Instruct的FP8動態量化模型,支持視覺-文本輸入和文本輸出,適用於多模態理解和生成任務
模型特點
FP8動態量化
權重和激活均採用FP8量化技術,在保持模型精度的同時提升推理效率
vLLM優化支持
專為vLLM推理引擎優化,支持高效部署和推理加速
多模態理解
支持視覺和文本的聯合輸入,能夠理解和分析圖像內容
模型能力
視覺問答
圖像內容理解
文檔解析
圖表分析
數學視覺推理
多模態文本生成
使用案例
文檔處理
文檔視覺問答
解析和理解文檔圖像中的內容並回答問題
在DocVQA數據集上達到94.27 ANLS分數
視覺推理
圖表分析
理解和解釋圖表數據
在ChartQA測試集上達到86.80%準確率
數學視覺問題解答
解決包含視覺元素的數學問題
在Mathvista測試集上達到71.07%準確率
🚀 Qwen2.5-VL-7B-Instruct-FP8-Dynamic
這是 Qwen/Qwen2.5-VL-7B-Instruct 的量化版本,通過將權重量化為 FP8 數據類型,可使用 vLLM >= 0.5.2 進行推理。
✨ 主要特性
- 模型架構:Qwen2.5-VL-7B-Instruct,輸入為視覺 - 文本,輸出為文本。
- 模型優化:權重和激活均採用 FP8 量化。
- 發佈日期:2025 年 2 月 24 日
- 版本:1.0
- 模型開發者:Neural Magic
🚀 快速開始
使用 vLLM 部署
此模型可以使用 vLLM 後端進行高效部署,示例代碼如下:
from vllm.assets.image import ImageAsset
from vllm import LLM, SamplingParams
# prepare model
llm = LLM(
model="neuralmagic/Qwen2.5-VL-7B-Instruct-FP8-Dynamic",
trust_remote_code=True,
max_model_len=4096,
max_num_seqs=2,
)
# prepare inputs
question = "What is the content of this image?"
inputs = {
"prompt": f"<|user|>\n<|image_1|>\n{question}<|end|>\n<|assistant|>\n",
"multi_modal_data": {
"image": ImageAsset("cherry_blossom").pil_image.convert("RGB")
},
}
# generate response
print("========== SAMPLE GENERATION ==============")
outputs = llm.generate(inputs, SamplingParams(temperature=0.2, max_tokens=64))
print(f"PROMPT : {outputs[0].prompt}")
print(f"RESPONSE: {outputs[0].outputs[0].text}")
print("==========================================")
vLLM 還支持兼容 OpenAI 的服務,更多詳情請參閱 文檔。
📦 安裝指南
文檔中未提及安裝步驟,故跳過此章節。
💻 使用示例
基礎用法
from vllm.assets.image import ImageAsset
from vllm import LLM, SamplingParams
# prepare model
llm = LLM(
model="neuralmagic/Qwen2.5-VL-7B-Instruct-FP8-Dynamic",
trust_remote_code=True,
max_model_len=4096,
max_num_seqs=2,
)
# prepare inputs
question = "What is the content of this image?"
inputs = {
"prompt": f"<|user|>\n<|image_1|>\n{question}<|end|>\n<|assistant|>\n",
"multi_modal_data": {
"image": ImageAsset("cherry_blossom").pil_image.convert("RGB")
},
}
# generate response
print("========== SAMPLE GENERATION ==============")
outputs = llm.generate(inputs, SamplingParams(temperature=0.2, max_tokens=64))
print(f"PROMPT : {outputs[0].prompt}")
print(f"RESPONSE: {outputs[0].outputs[0].text}")
print("==========================================")
高級用法
文檔中未提及高級用法相關代碼,故跳過此部分。
📚 詳細文檔
模型創建
此模型使用 llm-compressor 創建,代碼如下:
模型創建代碼
import requests
import torch
from PIL import Image
from transformers import AutoProcessor
from llmcompressor.transformers import oneshot
from llmcompressor.transformers.tracing import (
TraceableQwen2_5_VLForConditionalGeneration,
)
from llmcompressor.modifiers.quantization import QuantizationModifier
# Load model.
model_id = Qwen/Qwen2.5-VL-7B-Instruct
model = TraceableQwen2_5_VLForConditionalGeneration.from_pretrained(
model_id, device_map="auto", torch_dtype="auto"
)
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
# Recipe
recipe = [
QuantizationModifier(
targets="Linear",
scheme="FP8_DYNAMIC",
sequential_targets=["MistralDecoderLayer"],
ignore=["re:.*lm_head", "re:vision_tower.*", "re:multi_modal_projector.*"],
),
]
SAVE_DIR=f"{model_id.split('/')[1]}-FP8-Dynamic"
# Perform oneshot
oneshot(
model=model,
recipe=recipe,
trust_remote_code_model=True,
output_dir=SAVE_DIR
)
模型評估
模型使用 mistral-evals 進行視覺相關任務評估,使用 lm_evaluation_harness 進行部分基於文本的基準測試。評估命令如下:
評估命令
視覺任務
- vqav2
- docvqa
- mathvista
- mmmu
- chartqa
vllm serve neuralmagic/pixtral-12b-quantized.w8a8 --tensor_parallel_size 1 --max_model_len 25000 --trust_remote_code --max_num_seqs 8 --gpu_memory_utilization 0.9 --dtype float16 --limit_mm_per_prompt image=7
python -m eval.run eval_vllm \
--model_name neuralmagic/pixtral-12b-quantized.w8a8 \
--url http://0.0.0.0:8000 \
--output_dir ~/tmp \
--eval_name <vision_task_name>
基於文本的任務
MMLU
lm_eval \
--model vllm \
--model_args pretrained="<model_name>",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=<n>,gpu_memory_utilization=0.8,enable_chunked_prefill=True,trust_remote_code=True \
--tasks mmlu \
--num_fewshot 5 \
--batch_size auto \
--output_path output_dir
MGSM
lm_eval \
--model vllm \
--model_args pretrained="<model_name>",dtype=auto,max_model_len=4096,max_gen_toks=2048,max_num_seqs=128,tensor_parallel_size=<n>,gpu_memory_utilization=0.9 \
--tasks mgsm_cot_native \
--apply_chat_template \
--num_fewshot 0 \
--batch_size auto \
--output_path output_dir
準確率
類別 | 指標 | Qwen/Qwen2.5-VL-7B-Instruct | neuralmagic/Qwen2.5-VL-7B-Instruct-FP8-Dynamic | 恢復率 (%) |
---|---|---|---|---|
視覺 | MMMU (val, CoT) explicit_prompt_relaxed_correctness |
52.00 | 52.55 | 101.06% |
視覺 | VQAv2 (val) vqa_match |
75.59 | 75.79 | 100.26% |
視覺 | DocVQA (val) anls |
94.27 | 94.27 | 100.00% |
視覺 | ChartQA (test, CoT) anywhere_in_answer_relaxed_correctness |
86.44 | 86.80 | 100.42% |
視覺 | Mathvista (testmini, CoT) explicit_prompt_relaxed_correctness |
69.47 | 71.07 | 102.31% |
視覺 | 平均得分 | 75.95 | 76.50 | 100.73% |
文本 | MGSM (CoT) | 56.38 | 55.34 | 98.16% |
文本 | MMLU (5-shot) | 71.09 | 70.98 | 99.85% |
推理性能
此模型在單流部署中最高可實現 1.3 倍加速,在多流部署中最高可實現 1.37 倍加速,具體取決於硬件和使用場景。以下性能基準測試使用 vLLM 版本 0.7.2 和 GuideLLM 進行。
基準測試命令
``` guidellm --model neuralmagic/Qwen2.5-VL-7B-Instruct-FP8-Dynamic --target "http://localhost:8000/v1" --data-type emulated --data prompt_tokens=單流性能(使用 vLLM 版本 0.7.2 測量)
硬件 | 模型 | 平均成本降低 | 文檔視覺問答 1680W x 2240H 64/128 延遲 (s) |
文檔視覺問答 1680W x 2240H 64/128 每美元查詢次數 |
視覺推理 640W x 480H 128/128 延遲 (s) |
視覺推理 640W x 480H 128/128 每美元查詢次數 |
圖像描述 480W x 360H 0/128 延遲 (s) |
圖像描述 480W x 360H 0/128 每美元查詢次數 |
---|---|---|---|---|---|---|---|---|
A6000x1 | Qwen/Qwen2.5-VL-7B-Instruct | 4.9 | 912 | 3.2 | 1386 | 3.1 | 1431 | |
A6000x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w8a8 | 1.50 | 3.6 | 1248 | 2.1 | 2163 | 2.0 | 2237 |
A6000x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w4a16 | 2.05 | 3.3 | 1351 | 1.4 | 3252 | 1.4 | 3321 |
A100x1 | Qwen/Qwen2.5-VL-7B-Instruct | 2.8 | 707 | 1.7 | 1162 | 1.7 | 1198 | |
A100x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w8a8 | 1.24 | 2.4 | 851 | 1.4 | 1454 | 1.3 | 1512 |
A100x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w4a16 | 1.49 | 2.2 | 912 | 1.1 | 1791 | 1.0 | 1950 |
H100x1 | Qwen/Qwen2.5-VL-7B-Instruct | 2.0 | 557 | 1.2 | 919 | 1.2 | 941 | |
H100x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-FP8-Dynamic | 1.28 | 1.6 | 698 | 0.9 | 1181 | 0.9 | 1219 |
H100x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w4a16 | 1.28 | 1.6 | 686 | 0.9 | 1191 | 0.9 | 1228 |
用例配置文件:圖像大小 (WxH) / 提示詞令牌 / 生成令牌
QPD:每美元查詢次數,基於 Lambda Labs 的按需成本(2025 年 2 月 18 日觀測)
多流異步性能(使用 vLLM 版本 0.7.2 測量)
硬件 | 模型 | 平均成本降低 | 文檔視覺問答 1680W x 2240H 64/128 最大吞吐量 (QPS) |
文檔視覺問答 1680W x 2240H 64/128 每美元查詢次數 |
視覺推理 640W x 480H 128/128 最大吞吐量 (QPS) |
視覺推理 640W x 480H 128/128 每美元查詢次數 |
圖像描述 480W x 360H 0/128 最大吞吐量 (QPS) |
圖像描述 480W x 360H 0/128 每美元查詢次數 |
---|---|---|---|---|---|---|---|---|
A6000x1 | Qwen/Qwen2.5-VL-7B-Instruct | 0.4 | 1837 | 1.5 | 6846 | 1.7 | 7638 | |
A6000x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w8a8 | 1.41 | 0.5 | 2297 | 2.3 | 10137 | 2.5 | 11472 |
A6000x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w4a16 | 1.60 | 0.4 | 1828 | 2.7 | 12254 | 3.4 | 15477 |
A100x1 | Qwen/Qwen2.5-VL-7B-Instruct | 0.7 | 1347 | 2.6 | 5221 | 3.0 | 6122 | |
A100x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w8a8 | 1.27 | 0.8 | 1639 | 3.4 | 6851 | 3.9 | 7918 |
A100x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w4a16 | 1.21 | 0.7 | 1314 | 3.0 | 5983 | 4.6 | 9206 |
H100x1 | Qwen/Qwen2.5-VL-7B-Instruct | 0.9 | 969 | 3.1 | 3358 | 3.3 | 3615 | |
H100x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-FP8-Dynamic | 1.29 | 1.2 | 1331 | 3.8 | 4109 | 4.2 | 4598 |
H100x1 | neuralmagic/Qwen2.5-VL-7B-Instruct-quantized.w4a16 | 1.28 | 1.2 | 1298 | 3.8 | 4190 | 4.2 | 4573 |
用例配置文件:圖像大小 (WxH) / 提示詞令牌 / 生成令牌
QPS:每秒查詢次數
QPD:每美元查詢次數,基於 Lambda Labs 的按需成本(2025 年 2 月 18 日觀測)
📄 許可證
本項目採用 Apache-2.0 許可證。
Clip Vit Large Patch14 336
基於Vision Transformer架構的大規模視覺語言預訓練模型,支持圖像與文本的跨模態理解
文本生成圖像
Transformers

C
openai
5.9M
241
Fashion Clip
MIT
FashionCLIP是基於CLIP開發的視覺語言模型,專門針對時尚領域進行微調,能夠生成通用產品表徵。
文本生成圖像
Transformers 英語

F
patrickjohncyh
3.8M
222
Gemma 3 1b It
Gemma 3是Google推出的輕量級先進開放模型系列,基於與Gemini模型相同的研究和技術構建。該模型是多模態模型,能夠處理文本和圖像輸入並生成文本輸出。
文本生成圖像
Transformers

G
google
2.1M
347
Blip Vqa Base
Bsd-3-clause
BLIP是一個統一的視覺語言預訓練框架,擅長視覺問答任務,通過語言-圖像聯合訓練實現多模態理解與生成能力
文本生成圖像
Transformers

B
Salesforce
1.9M
154
CLIP ViT H 14 Laion2b S32b B79k
MIT
基於OpenCLIP框架在LAION-2B英文數據集上訓練的視覺-語言模型,支持零樣本圖像分類和跨模態檢索任務
文本生成圖像
Safetensors
C
laion
1.8M
368
CLIP ViT B 32 Laion2b S34b B79k
MIT
基於OpenCLIP框架在LAION-2B英語子集上訓練的視覺-語言模型,支持零樣本圖像分類和跨模態檢索
文本生成圖像
Safetensors
C
laion
1.1M
112
Pickscore V1
PickScore v1 是一個針對文本生成圖像的評分函數,可用於預測人類偏好、評估模型性能和圖像排序等任務。
文本生成圖像
Transformers

P
yuvalkirstain
1.1M
44
Owlv2 Base Patch16 Ensemble
Apache-2.0
OWLv2是一種零樣本文本條件目標檢測模型,可通過文本查詢在圖像中定位對象。
文本生成圖像
Transformers

O
google
932.80k
99
Llama 3.2 11B Vision Instruct
Llama 3.2 是 Meta 發佈的多語言多模態大型語言模型,支持圖像文本到文本的轉換任務,具備強大的跨模態理解能力。
文本生成圖像
Transformers 支持多種語言

L
meta-llama
784.19k
1,424
Owlvit Base Patch32
Apache-2.0
OWL-ViT是一個零樣本文本條件目標檢測模型,可以通過文本查詢搜索圖像中的對象,無需特定類別的訓練數據。
文本生成圖像
Transformers

O
google
764.95k
129
精選推薦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