跳转至

LLaVA-OneVision-Qwen2-0.5B-OV

1 简介

llava-hf/llava-onevision-qwen2-0.5b-ov-hf 是基于 Qwen2 构建的紧凑型多模态模型。它支持纯文本生成,以及图像理解、多图像推理和视觉对话。

本文档展示了该模型在 vLLM Ascend 上的主要验证步骤,包括环境准备、单 NPU 部署、功能验证以及仓库中使用的现有精度基线。

2 支持的功能

请参考 支持功能列表 获取模型支持的功能矩阵。

请参考 功能指南 获取功能的配置。

3 环境准备

3.1 模型权重

经过验证的单卡部署使用一块 Atlas A2 NPU。建议提前将模型权重缓存到 /root/.cache 下,以减少启动时间。

4 安装

您可以直接使用官方 Docker 镜像运行 LLaVA-OneVision-Qwen2-0.5B-OV。

请根据您的机器类型选择镜像,并在节点上启动 Docker 镜像。请参考 使用 Docker。

export IMAGE=quay.io/ascend/vllm-ascend:v0.23.0
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

5 在线服务部署

5.1 单节点部署

5.1.1 单 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

5.1.2 多 NPU

对于该 0.5B 模型,建议使用单 NPU 部署。

5.2 Prefill-Decode 分离

暂不支持。

6 功能验证

如果服务启动成功,您可以看到类似以下日志:

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

6.1 纯文本请求

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?"}}]}

6.2 图像理解请求

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\"..."}}]}

7 精度评估

仓库中已经包含该模型在 tests/e2e/models/configs/llava-onevision-qwen2-0.5b-ov-hf.yaml 中的端到端精度基线。

数据集 平台 指标 值
ceval-valid A2 acc,none 0.42

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 vl/vllm-ascend