- Running non-quantized version: More than 19GB of memory
- Running quantized version: More than 8GB of memory
Clone the specified branch using Git:
git clone -b minicpm-v2.5 https://github.com/OpenBMB/llama.cpp.git
Navigate to the llama.cpp directory and compile:
cd llama.cpp
make
make minicpmv-cli
Download the required model from Hugging Face or ModelScope:
git clone https://huggingface.co/openbmb/MiniCPM-Llama3-V-2_5
# Or
git clone https://modelscope.cn/models/OpenBMB/MiniCPM-Llama3-V-2_5.git
-
Get intermediate model outputs for converting to gguf
python ./examples/minicpmv/minicpmv-surgery.py -m ../MiniCPM-Llama3-V-2_5
-
Convert the Siglip model to gguf
python ./examples/minicpmv/minicpmv-convert-image-encoder-to-gguf.py -m ../MiniCPM-Llama3-V-2_5 --minicpmv-projector ../MiniCPM-Llama3-V-2_5/minicpmv.projector --output-dir ../MiniCPM-Llama3-V-2_5/ --image-mean 0.5 0.5 0.5 --image-std 0.5 0.5 0.5
-
Convert the language model to gguf
python ./convert.py ../MiniCPM-Llama3-V-2_5/model --outtype f16 --vocab-type bpe
If needed, quantize the language model:
./quantize ../MiniCPM-Llama3-V-2_5/model/model-8B-F16.gguf ../MiniCPM-Llama3-V-2_5/model/ggml-model-Q4_K_M.gguf Q4_K_M
Use the following commands for inference:
-
Infer with the Non-Quantized Model
./minicpmv-cli -m ../MiniCPM-Llama3-V-2_5/model/model-8B-F16.gguf --mmproj ../MiniCPM-Llama3-V-2_5/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?"
-
Infer with the Quantized Model
./minicpmv-cli -m ../MiniCPM-Llama3-V-2_5/model/ggml-model-Q4_K_M.gguf --mmproj ../MiniCPM-Llama3-V-2_5/mmproj-model-f16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 --image xx.jpg -i
Now you are ready to start efficient inference with llama.cpp!