LLaVA-OneVision-Qwen2-0.5B-OV#
简介#
llava-hf/llava-onevision-qwen2-0.5b-ov-hf 是一个基于 Qwen2 构建的紧凑型多模态模型。它支持纯文本生成,以及图像理解、多图像推理和视觉对话。
本文档展示了该模型在 vLLM Ascend 上的主要验证步骤,包括环境准备、单 NPU 部署、功能验证以及代码库使用的现有精度基准。
支持的功能#
请参考支持的功能以获取该模型支持的功能矩阵。
请参考特性指南以获取功能的配置方法。
环境准备#
模型权重#
llava-hf/llava-onevision-qwen2-0.5b-ov-hf: 下载模型权重
已验证的单卡部署使用一个 Atlas A2 NPU。建议提前将模型权重缓存到 /root/.cache 目录下,以减少启动时间。
安装#
您可以使用官方的 docker 镜像直接运行 LLaVA-OneVision-Qwen2-0.5B-OV。
根据您的机器类型选择镜像并在节点上启动 docker 镜像,请参考使用 docker。
export IMAGE=quay.io/ascend/vllm-ascend:v0.20.2rc1
docker run --rm \
--name vllm-ascend \
--shm-size=1g \
--net=host \
--device /dev/davinci0 \
--device /dev/davinci_manager \
--device /dev/devmm_svm \
--device /dev/hisi_hdc \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v /root/.cache:/root/.cache \
-it $IMAGE bash
部署#
单节点部署#
单 NPU#
运行以下脚本在单个 Atlas A2 NPU 上启动 vLLM 服务:
export MODEL_PATH="llava-hf/llava-onevision-qwen2-0.5b-ov-hf"
vllm serve "${MODEL_PATH}" \
--host 0.0.0.0 \
--port 8000 \
--served-model-name LLaVA-OneVision-0.5B \
--trust-remote-code \
--gpu-memory-utilization 0.8
多 NPU#
对于这个 0.5B 的模型,建议使用单 NPU 部署。
Prefill-Decode 分离#
暂不支持。
功能验证#
如果您的服务启动成功,您将看到类似以下的日志:
INFO: Started server process [8173]
INFO: Waiting for application startup.
INFO: Application startup complete.
您可以首先验证模型是否通过 OpenAI 兼容的 API 暴露:
curl http://127.0.0.1:8000/v1/models
纯文本请求#
curl http://127.0.0.1:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "LLaVA-OneVision-0.5B",
"messages": [
{
"role": "user",
"content": "Say hello in one short sentence."
}
],
"max_completion_tokens": 16,
"temperature": 0
}'
如果请求成功,您将看到类似以下的响应:
{"choices":[{"message":{"content":"Hello! How can I assist you today?"}}]}
图像理解请求#
curl http://127.0.0.1:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "LLaVA-OneVision-0.5B",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image briefly."
},
{
"type": "image_url",
"image_url": {
"url": "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/qwen.png"
}
}
]
}
],
"max_completion_tokens": 64,
"temperature": 0
}'
如果请求成功,您将看到类似以下的响应:
{"choices":[{"message":{"content":"The image features a logo consisting of a stylized geometric figure and the text \"TONGYI\" and \"Qwen\"..."}}]}
精度评估#
代码库中已包含该模型的端到端精度基准,位于 tests/e2e/models/configs/llava-onevision-qwen2-0.5b-ov-hf.yaml。
数据集 |
平台 |
指标 |
值 |
|---|---|---|---|
ceval-valid |
A2 |
acc,none |
0.42 |