Instructions to use openbmb/MiniCPM-V-4_5-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/MiniCPM-V-4_5-gguf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="openbmb/MiniCPM-V-4_5-gguf", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("openbmb/MiniCPM-V-4_5-gguf", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use openbmb/MiniCPM-V-4_5-gguf with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M # Run inference directly in the terminal: llama cli -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M # Run inference directly in the terminal: llama cli -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
Use Docker
docker model run hf.co/openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use openbmb/MiniCPM-V-4_5-gguf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/MiniCPM-V-4_5-gguf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM-V-4_5-gguf", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
- SGLang
How to use openbmb/MiniCPM-V-4_5-gguf with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "openbmb/MiniCPM-V-4_5-gguf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM-V-4_5-gguf", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "openbmb/MiniCPM-V-4_5-gguf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM-V-4_5-gguf", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Ollama
How to use openbmb/MiniCPM-V-4_5-gguf with Ollama:
ollama run hf.co/openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
- Unsloth Studio
How to use openbmb/MiniCPM-V-4_5-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for openbmb/MiniCPM-V-4_5-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for openbmb/MiniCPM-V-4_5-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for openbmb/MiniCPM-V-4_5-gguf to start chatting
- Pi
How to use openbmb/MiniCPM-V-4_5-gguf with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "openbmb/MiniCPM-V-4_5-gguf:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use openbmb/MiniCPM-V-4_5-gguf with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use openbmb/MiniCPM-V-4_5-gguf with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "openbmb/MiniCPM-V-4_5-gguf:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use openbmb/MiniCPM-V-4_5-gguf with Docker Model Runner:
docker model run hf.co/openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
- Lemonade
How to use openbmb/MiniCPM-V-4_5-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull openbmb/MiniCPM-V-4_5-gguf:Q4_K_M
Run and chat with the model
lemonade run user.MiniCPM-V-4_5-gguf-Q4_K_M
List all available models
lemonade list
./ggml-model-Q6_K.gguf is not a multimodal model
Hi,
I run VLLM as API endpoint
vllm serve ./ggml-model-Q6_K.gguf --tokenizer openbmb/MiniCPM-V-4_5
using Open WebUI as client and uploading a jpg file but
VLLM report this is not a multimodal model.
See error:
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] Error in preprocessing prompt inputs
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] Traceback (most recent call last):
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/openai/serving_chat.py", line 220, in create_chat_completion
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ) = await self._preprocess_chat(
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/openai/serving_engine.py", line 869, in _preprocess_chat
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] conversation, mm_data_future = parse_chat_messages_futures(
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 1247, in parse_chat_messages_futures
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] sub_messages = _parse_chat_message_content(
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 1165, in _parse_chat_message_content
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] result = _parse_chat_message_content_parts(
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 1054, in _parse_chat_message_content_parts
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] parse_res = _parse_chat_message_content_part(
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 1119, in _parse_chat_message_content_part
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] mm_parser.parse_image(str_content)
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 757, in parse_image
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] placeholder = self._tracker.add("image", image_coro)
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 565, in add
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] self.mm_processor.validate_num_items(input_modality, num_items)
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ^^^^^^^^^^^^^^^^^
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/usr/lib/python3.12/functools.py", line 995, in get
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] val = self.func(instance)
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ^^^^^^^^^^^^^^^^^^^
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 555, in mm_processor
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] return self.mm_registry.create_processor(self.model_config)
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] File "/adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/multimodal/registry.py", line 312, in create_processor
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] raise ValueError(f"{model_config.model} is not a multimodal model")
(APIServer pid=11755) ERROR 08-31 20:07:35 [serving_chat.py:245] ValueError: ./ggml-model-Q6_K.gguf is not a multimodal model
(APIServer pid=11755) /adat/ai/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/openai/serving_chat.py:246: RuntimeWarning: coroutine 'MediaConnector.fetch_image_async' was never awaited
(APIServer pid=11755) return self.create_error_response(f"{e} {e.cause}")
(APIServer pid=11755) RuntimeWarning: Enable tracemalloc to get the object allocation traceback
(APIServer pid=11755) INFO: 172.17.0.2:53670 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request
@robert1968 Yes, you're indeed using an LLM model. Our vit component is https://huggingface.co/openbmb/MiniCPM-V-4_5-gguf/blob/main/mmproj-model-f16.gguf, which is used with llama.cpp, so it's separate.
I haven't tested using gguf directly with VLLM.
Hi,
Thanks for response.
Sorry but I dont understand your response in any way :)
What "vit component" mean?
why do you f16.gguf mention - if i refer ggml-model-Q6_K.gguf? and
why llama.cpp is important in this context?
Therotically gguf version is a quantized version of the openbmb/MiniCPM-V-4_5 - so it should be still a multimodal model.
Isn't this a correct theoretical assumption?
And beware when i load the unquantized version it provided answer for a picture upload!
( vllm serve openbmb/MiniCPM-V-4_5 --trust-remote-code --gpu-memory-utilization 0.95 --max-model-len 16000 --max-num-seqs 1)
best regards.
@robert1968
Hi,
Let me answer your question.
The author of llama.cpp is also the author of gguf and ggml. Therefore, by providing the gguf format, we prioritize the use of llama.cpp. We believe this is a way of respecting the original author.
When using the multimodal model in llama.cpp, they use a command line similar to the following:
./llama-mtmd-cli -m ../MiniCPM-V-4_5/model/Model-3.6B-F16.gguf --mmproj ../MiniCPM-V-4_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?"
This means that the LLM and vision components need to be loaded separately, so the gguf I provide is also split in this format. The vision component includes the VIT and resampler weights and is the visual module of the multimodal model.
If you use VLLM, I actually recommend using the floating-point model directly. I noticed that you have also run it successfully, and I hope this will meet your needs. If your GPU memory is limited, you can also try the awq quantized model. We also provide a quantized code repository.
I hope this helps you. Feel free to add any questions.
best regards.
Hi,
Many thanks for explaining so detailed! It is clear now.
got your points.
This means that the LLM and vision components need to be loaded separately,
Ahh that is very interesting and new to me. Many thanks to explain!
My first impression was mediocre with vllm with the MiniCPM-V-4_5 unquantized version.
it took 1 minute to load the model and start serving on API endpoint. It is far slower than my user experience with ollama and LM Studio.
For the model experience MiniCPM-V-4_5, it was not so bad, in my very short test. (2 pictures only.)
But when i ask to "provide all the text from the picture", it do an excellent job on OCR but started loop on one of the last sentences.
So i wont use vllm but probably try llama.ccp as you described, or wait to be available as LM studio model....
Many thanks for your patience :)
you can close this discussion - if you want.
best regards.
@robert1968
Thank you for your feedback. If you can verify the model's performance using the demo I created, it might be helpful in directly assessing its effectiveness.
https://minicpm-v.openbmb.cn/
If you have any other questions, please feel free to file an issue.
Also, I've heard a lot about the LM Studio framework in recent issues. I haven't used it before, but if it works well, I'll consider adapting it and incorporating it into the framework that needs to be updated every time we release a model.
