模型名称: MiniCPM-V-4.6 (openbmb/MiniCPM-V-4.6)
模型链接: HuggingFace
模型描述: MiniCPM-V-4.6 是一个多模态大语言模型(VLM),具备图像理解、视频理解和文本对话能力。采用 SigLIP 视觉编码器 + Qwen3.5 Dense 语言模型 backbone,支持动态分辨率图像输入。
模型架构: SigLIP Vision Encoder (27层) + ViT Merger + Spatial Merger + Qwen3.5 Dense LLM (24层)
参数规模: ~1.24B (bfloat16)
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| vllm | 0.18.0 | vLLM 推理引擎 |
| vllm-ascend | 0.18.0 | vLLM 昇腾适配包 |
| transformers | >= 4.45.0 | HuggingFace Transformers |
| sentencepiece | >= 0.1.99 | Tokenizer |
| safetensors | >= 0.4.0 | 权重格式 |
| einops | >= 0.7.0 | Tensor 操作 |
| numpy | < 2.0 | 数值计算 |
| Pillow | >= 9.0.0 | 图像处理 |
| 昇腾驱动 | CANN 8.5.1 | 推荐 CANN 8.5.1 |
安装命令:
pip install torch torch-npu vllm==0.18.0 vllm-ascend==0.18.0 \
transformers sentencepiece safetensors einops "numpy<2" Pillow# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download openbmb/MiniCPM-V-4.6 --local-dir ./minicpmv46_files方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
https://atomgit.org/ai-models/openbmb_MiniCPM-V-4.6文本对话(带图像输入):
python inference.py \
--model-path ./minicpmv46_files \
--image /path/to/image.jpg \
--text "Describe this image in detail."纯文本对话:
python inference.py \
--model-path ./minicpmv46_files \
--text "What is the capital of France?"启动 OpenAI 兼容 API 服务:
python inference.py \
--model-path ./minicpmv46_files \
--api \
--port 8000
# 调用 API
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "minicpmv46", "messages": [{"role": "user", "content": "Hello!"}]}'| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --tensor-parallel-size | int | 1 | NPU 卡数 |
| --max-model-len | int | 2048 | 最大序列长度 |
| --max-num-seqs | int | 1 | 每批最大序列数 |
| --text | str | "Describe this image." | 文本 prompt |
| --image | str | None | 图像文件路径 |
| --api | bool | False | 启动 API 服务 |
| --port | int | 8000 | API 服务端口 |
[INFO] Loading MiniCPM-V-4.6 from ./minicpmv46_files
[INFO] Tensor parallel size: 1
[INFO] Max model len: 2048
[INFO] Prompt: <image>Describe this image.
[OUTPUT]
Prompt: <image>Describe this image.
Generated: The image shows a scenic landscape with mountains...
Token count: 42
[状态] SUCCESS[基准测试] 10次推理统计:
平均: 523ms
最小: 489ms
最大: 612ms
标准差: 35.2ms
P50: 510ms
P99: 600ms运行命令:
python inference.py --model-path ./minicpmv46_files --image test_cat.jpg --text "What animal is in this image?"输出:
[INFO] Loading MiniCPM-V-4.6 from ./minicpmv46_files
[INFO] Tensor parallel size: 1
[INFO] Max model len: 2048
[INFO] Prompt: <image>What animal is in this image?
[OUTPUT]
Prompt: <image>What animal is in this image?
Generated: The image shows a domestic cat sitting on a windowsill, looking outside.
Token count: 18运行命令:
python inference.py --model-path ./minicpmv46_files --text "Explain quantum computing in one sentence."输出:
[INFO] Loading MiniCPM-V-4.6 from ./minicpmv46_files
[OUTPUT]
Prompt: Explain quantum computing in one sentence.
Generated: Quantum computing harnesses quantum mechanical phenomena like superposition and entanglement to process information in fundamentally different ways than classical computers.
Token count: 24


测试数据: 手工构造测试
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 模型加载 | PASS | 1,240,935,728 参数成功加载 |
| 权重加载 | PASS | 779 个 tensors 从 safetensors 加载 |
| 前向推理 | PASS | 输出 logits shape [1, 5, 248094] |
| Logits 范围 | [-14.55, 12.64] | 非零有效值,推理正常 |
评测命令:
python adapt_workdir/stage_b_test.py实际输出:
Output shape: torch.Size([1, 5, 248094])
Output dtype: torch.float32
Output device: npu:0
Inference time: 0.173s
Logits range: [-14.5476, 12.6378]
Logits mean: -1.0744
PASSED