🚀 MiniCPM-o 2.6
本仓库包含用于 llama.cpp 的 MiniCPM-o 2.6 模型权重,格式为 GGUF。
目前,此 README 仅支持 minicpm-omni 的视觉能力,我们将尽快更新以支持全模式。
🚀 快速开始
准备模型和代码
从 Hugging Face 下载 MiniCPM-o-2_6 PyTorch 模型到 “MiniCPM-o-2_6” 文件夹。
克隆 llama.cpp 仓库:
git clone git@github.com:OpenBMB/llama.cpp.git
cd llama.cpp
git checkout minicpm-omni
📦 安装指南
转换 PyTorch 模型为 gguf 文件
(你也可以下载我们已经转换好的 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
./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
使用 CMake 构建 llama.cpp
参考:https://github.com/ggerganov/llama.cpp/blob/master/docs/build.md
cmake -B build
cmake --build build --config Release
💻 使用示例
基础用法
在 Linux 或 Mac 上进行推理:
./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?"
./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?"
高级用法
以交互模式运行:
./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 -i