Files
enginex-mr_series-vl/README.md
2025-09-15 18:46:55 +08:00

48 lines
3.5 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 天数智芯 智铠100 视觉理解多模态
该模型测试框架在智铠100加速卡上基于Transfomer框架适配了 MiniCPM-Llama3-V-2_5 、MiniCPM_V_2_6 这2个模型。
* MiniCPMLlama3V2.5 是 openbmb 的 8B multimodal 模型,基于 SigLip400M 与 Llama3-8B-Instruct 构建,在 OCR 能力、多语言支持、部署效率等方面表现优秀,整体性能达到 GPT4V 级别
* MiniCPMV2.6 是 MiniCPMV 系列中最新且最强大的 8B 参数模型,具备更优的单图、多图与视频理解能力、卓越 OCR 效果、低 hallucination 率,并支持端侧设备(如 iPad实时视频理解
## 模型测试服务原理
尽管对于视觉多模态理解没有一个业界统一的API协议标准但我们也可以基于目前比较流行的Transfomer框架**适配**各类视觉理解多模态模型。
为了让我们的测试框架更通用一些我们基于Transfomer框架对于不同类型的模型系列adpat了一层方便对外提供http服务。
目前测试框架要求用户首先测试时指定需要测试的模型的地址mount到本地文件系统中`/model`之后通过unvicorn拉起服务。
其中,基础镜像 corex:4.3.0 通过联系天数智芯智铠100厂商技术支持可获取
测试过程中,外围测试环境,会首先调用“加载模型接口”:
```bash
curl -X POST http://localhost:10086/load_model \
-H "Content-Type: application/json" \
-d '{"model_path":"/model","dtype":"auto"}'
```
## 模型测试服务请求示例
准备好用于测试的图片和问题通过infer接口获取推理结果
```bash
base64 -w 0 demo.jpeg | \
jq -Rs --arg mp "/model" --arg prompt "Describe the picture" \
'{model_path: $mp, prompt: $prompt, images: ["data:image/jpeg;base64," + .], generation: {max_new_tokens: 50, temperature: 0.7}}' | \
curl -X POST "http://localhost:10086/infer" \
-H "Content-Type: application/json" \
-d @-
```
以上,图片为`demo.jpeg`,问题为`Describe the picture`,可根据需要相应替换。
## 如何使用视觉理解多模态测试框架
由于VLM相关的模型一般需要较大的存储空间为了更好的测试效率需要提前下载好模型相关文件k8s集群可以mount的持久化介质比如cephFS之后提交测试时指定模型存放的地址。
`docker-images/server.py`代码实现了一个接收图片和问题并返回回答文本和统计延迟信息的VLM HTTP 服务。测试框架集成了现成的可用的镜像`harbor.4pd.io/hardcore-tech/mr100-3.2.1-x86-ubuntu20.04-py3.10-poc-vlm-infer:0.0.1``server.py`作为入口可以用于本地端如有GPU卡测试。
作为测试对比我们也提供a100相对应的镜像 `harbor.4pd.io/hardcore-tech/a100-3.2.1-x86-ubuntu20.04-py3.10-poc-vlm-infer:0.0.1`
## 智铠100上视觉理解多模态模型运行测试结果
在智铠100上对部分视觉理解多模态模型进行适配测试方式为在 Nvidia A100 和 智铠100 加速卡上对10个图片相关问题回答获取运行时间
| 模型名称 | 模型类型 | 适配状态 | 智铠100运行时间/s | Nvidia A100运行时间/s |
| ---------- | ---------------------- | -------- | ----------------- | --------------------- |
| MiniCPMLlama3V2.5 | openbmb 8B multimodal | 成功 | 12.8615 | 6.2604 |
| MiniCPMV2.6 | MiniCPMV 系列 | 成功 | 8.8503 | 4.2654 |