MiniCPM-V-4.6 是面壁智能开源的高效多模态视觉语言模型(VLM),采用 NaViT 风格视觉编码器(SigLIP 底座)+ Qwen3.5 线性/全注意力混合文本主干,支持中英文图像理解与对话。
transformers.models.minicpmv4_6(MiniCPMV4_6ForConditionalGeneration),无需 trust_remote_code| 项目 | 版本 |
|---|---|
| NPU | Ascend 910(64GB HBM) |
| CANN | 8.5.1 |
| torch / torch_npu | 2.9.0 / 25.5.5 配套 |
| transformers | 5.7.0 |
| Python | 3.11.14 |
推理引擎:torch_npu(PyTorch 原生 npu:0 设备,fp16)。
见 requirements.txt。核心:torch、torch_npu、transformers==5.7.0、pillow。
export PYTHONPATH=/tmp/tf5 # transformers 5.7.0(含 minicpmv4_6 原生实现)
source /usr/local/Ascend/cann-8.5.1/set_env.sh
export MINICPMV46_MODEL_DIR=/tmp/bigw/MiniCPM-V-4.6 # 已下载权重目录
python inference.py --device npuinference.py 自动完成:权重加载(fp16 → npu:0)→ 严格加载审计 → 合成 PIL 图 + 中/英 prompt 生成 → 重复度检查 → 性能统计,结果写入 /tmp/minicpmv46_npu_results.json。
output_loading_info 实测 missing=0 / unexpected=0 / mismatched=0(0/0/0),618+ 全部张量逐一对齐。vision_config/text_config 以嵌套子 config 对象形式落地,为预期行为,其内部字段逐一核对一致)。输入:程序合成的 640×480 PIL 图(深蓝背景、红色矩形左下、绿色三角中部、蓝色圆右侧、白色水平线)。
用例 1(中文):详细描述这张图片中的所有形状、颜色和它们的位置。
这张图片呈现了一个深蓝色背景,上面分布着几个几何图形……1. 一个红色的矩形:位于图像左下角,有白色的边框,内部填充红色……2. 一个绿色的三角形:位于图像中央偏右,部分重叠在蓝色的圆体上……
用例 2(英文):Describe all shapes, colors and their positions in this image.
- Green Triangle — green triangular shape, positioned slightly to the right and centered horizontally, overlapping with a blue circle. 2. Blue Circle — a large blue circular shape, located to the right of the green triangle……
重复度检查:中文 4-gram diversity = 0.97,英文 = 0.73,输出非退化、无复读。
| 指标 | 数值 |
|---|---|
| 预热 | 5 次 |
| 正式测次 | 20 次 |
| 单次生成 16 token | avg 0.578s / p50 0.578s / min 0.569s / max 0.594s |
| 生成吞吐 | 27.67 tok/s |
| 峰值 HBM(torch.npu allocator) | 2.6 GB |
| 96 token 首轮完整生成 | 6.3s(zh)/ 4.8s(en),含算子编译后稳态 |
assets/agent_workflow.png:模型上卡日志(权重解析 → fp16 加载 → npu:0)assets/npu_device_call.png:npu-smi 实时占用 + torch_npu 设备断言assets/model_result.png:真机 NPU 推理输出#NPU