MiniCPM-o 2.6是面壁智能发布的全球首个端侧全模态AI模型,仅8亿参数(8B),性能对标GPT-4o、Claude-3.5-Sonnet等顶尖模型。其最大亮点在于本地化部署能力,支持在iPad等移动设备上实现实时多模态交互,标志着AI技术从云端向终端设备的重大迁移。
MiniCPM-o 2.6 可以通过多种方式轻松使用:(1) llama.cpp 支持在本地设备上进行高效的 CPU 推理,(2) int4 和 GGUF 格式的量化模型,有 16 种尺寸,(3) vLLM 支持高吞吐量和内存高效的推理,(4) 通过LLaMA-Factory框架针对新领域和任务进行微调,(5) 使用 Gradio 快速设置本地 WebUI 演示,(6) 在线demo。本文详细说明如何在 瑞莎星睿 O6 开发板上使用 llama.cpp 高效运行 MiniCPM-o 2.6 推理。
git clone https://github.com/ggml-org/llama.cpp.git
sudo apt install cmake gcc g++
瑞莎星睿 O6 搭载 ARM-v9 CPU,可添加 armv9-a
编译选项开启 sve、i8mm 和点积加速等硬件功能优化。
cmake -B build -DGGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=armv9-a+i8mm+dotprod+sve+sve2+fp16
cmake --build build --config Release -j8
从 Huggingface 下载 MiniCPM-o-2_6 Pytorch 模型 ,并将 Pytorch 模型转换为 GGUF 格式 。
python ./examples/llava/minicpmv-surgery.py -m ../MiniCPM-o-2_6
python ./examples/llava/minicpmv-convert-image-encoder-to-gguf.py -m ../MiniCPM-o-2_6 --minicpmv-projector ../MiniCPM-o-2_6/minicpmv.projector --output-dir ../MiniCPM-o-2_6/ --image-mean 0.5 0.5 0.5 --image-std 0.5 0.5 0.5 --minicpmv_version 4
python ./convert_hf_to_gguf.py ../MiniCPM-o-2_6/model
# quantize int4 version
./build/bin/llama-quantize ../MiniCPM-o-2_6/model/ggml-model-f16.gguf ../MiniCPM-o-2_6/model/ggml-model-Q4_K_M.gguf Q4_K_M
也可以直接下载转换好的 GGUF 模型。
本实验主要验证模型的识图能力,即输入一副图像,让模型描述图像的内容。
可以使用llama.cpp库编译得到的bin文件 llama-minicpmv-cli
, 选择运行浮点模型或int4量化后的模型:
# run f16 version
./build/bin/llama-minicpmv-cli -m ../MiniCPM-o-2_6/model/ggml-model-f16.gguf --mmproj ../MiniCPM-o-2_6/mmproj-model-f16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 --image xx.jpg -p "What is in the image?"
# run quantized int4 version
./build/bin/llama-minicpmv-cli -m ../MiniCPM-o-2_6/model/ggml-model-Q4_K_M.gguf --mmproj ../MiniCPM-o-2_6/mmproj-model-f16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 --image xx.jpg -p "What is in the image?"
模型对图片内容给出了详细的描述:
<user>What is in the image?
<assistant>
The image shows three young boys playing soccer on a field. One boy is wearing an orange shirt, while the other two are dressed in blue shirts with numbers 7 and 11 printed on them respectively. They appear to be engaged in active gameplay, possibly competing for control of the ball or strategizing their next move during what seems like an organized match given the presence of spectators in the background. The scene captures a moment typical of youth sports activities – teamwork, competition, physical activity, and social interaction among peers under adult supervision.
星睿O6搭载的强劲CPU在多模态模型推理方面表现出色,获得了7.7token/s的解码输出。
llama_perf_context_print: load time = 3397.87 ms
llama_perf_context_print: prompt eval time = 2052.77 ms / 79 tokens ( 25.98 ms per token, 38.48 tokens per second)
llama_perf_context_print: eval time = 13815.58 ms / 107 runs ( 129.12 ms per token, 7.74 tokens per second)
llama_perf_context_print: total time = 17473.33 ms / 186 tokens
MiniCPM-o 2.6通过轻量化架构与全模态能力,重新定义了端侧AI的可能性。其技术突破不仅降低了AI部署门槛,更推动了智能终端向情感化、自然化交互演进。随着开源生态的扩展与硬件升级,该模型有望成为AI普惠化进程中的关键驱动力。