eardoi/UnifoLM-VLM-Base-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

UnifoLM-VLM-Base(昇腾 NPU 适配)

UnifoLM-VLA-0(UnifoLM-VLM-Base)是宇树科技(Unitree)的视觉-语言-动作(VLA) 大模型基础版,基于 Qwen2.5-VL-7B(8.3B 参数),在人形机器人操作数据上继续预训练, 从"视觉语言理解"进化为具备物理常识的"具身大脑",可完成多类复杂操作任务。

本项目完成其在**华为昇腾 NPU(Ascend 910B)**上的推理适配与验证 (采用标准图文对话接口验证推理链路)。

模型规格

项目说明
模型架构Qwen2_5_VLForConditionalGeneration(qwen2_5_vl)
参数量8.3B(hidden 3584,28 层)
视觉编码器Qwen2.5-VL ViT
权重格式safetensors(16GB,4 分片,BF16)
支持任务图文对话、视觉理解(VLA 基础模型)

环境要求

项目要求
硬件Ascend 910B 系列(≥1 卡,HBM ≥ 32GB)
CANN≥ 8.0(source /usr/local/Ascend/ascend-toolkit/set_env.sh)
Python3.10 – 3.11
torch / torch_npu2.9.0 / 2.9.0.post1
transformers≥ 4.30(含 qwen2_5_vl 架构)

环境准备

source /usr/local/Ascend/ascend-toolkit/set_env.sh
export PIP_INDEX_URL=https://repo.huaweicloud.com/repository/pypi/simple/
pip install torch_npu==2.9.0.post1 transformers>=5.0 pillow safetensors \
    -i https://repo.huaweicloud.com/repository/pypi/simple/

模型权重

权重通过 HuggingFace 镜像获取:

git clone --depth 1 https://hf-mirror.com/unitreerobotics/UnifoLM-VLM-Base model_src

权重目录包含:model-00001~00004-of-00004.safetensors(16GB)/ tokenizer.json / preprocessor_config.json 等。

推理

cd /workspace/UnifoLM-VLM-Base
python3 inference.py --model_path ./model_src \
    --image 图片.png --question "Describe this image." --device npu:0

参数

参数说明默认值
--model_path模型权重目录./model_src
--image输入图片(真实图片,必选)-
--question文本问题Describe this image in detail.
--device推理设备(npu:0 / cpu)npu:0
--max_new_tokens最大生成 token 数256
--output结果保存文件(可选)stdout

设备解析:NPU 优先,自动回退 CPU。

验证结果(Ascend 910B, npu:0)

输入:真实表单文档图片(980×506)+ 问题 "What type of document is this? Describe briefly."

[info] model loaded: qwen2_5_vl (8.3B)
[info] generating on npu:0 (max_new_tokens=150) ...
============================================================
[info] 回答: This image shows a Georgia Government Transparency and
Campaign Finance Commission form, specifically Form D00, which is a
declaration intending to accept campaign contributions. The form is
titled "Declaration Intention to Accept Campaign Contributions
(Form D00)" and is dated 5/21/21. ... (详细准确的文档描述)
============================================================

8.3B 模型在 NPU 上(BF16)对真实文档图给出准确详细描述 (正确识别表单类型、机构、标题与日期),NPU 推理链路完整跑通。

适配说明

  • 纯 Transformers Qwen2.5-VL 架构,无 CUDA 特有 API,直接 .to(npu) 迁移即可。
  • 权重以 BF16 加载(NPU 上),推理使用 torch.no_grad() + model.generate()。
  • 图片以对象形式嵌入 conversation({"type": "image", "image": <PIL>}), 经 processor.apply_chat_template() + processor() 生成输入。
  • 设备解析 resolve_device():NPU 可用性检测,失败自动回退 CPU。
  • 模型权重不推送到仓库:*.safetensors / *.bin 已加入 .gitignore, 仓库仅包含推理脚本、模型卡片与截图素材。

目录结构

.
├── README.md          # 模型卡片(本文件)
├── inference.py       # NPU 推理脚本
└── assets/            # 适配过程截图素材

引用

  • 模型:https://huggingface.co/unitreerobotics/UnifoLM-VLM-Base
  • 项目:https://github.com/unitreerobotics/unifolm-vla