Run MiniCPM-V 4.7 1B for On-Device Image and Video Understanding
OpenBMB's 1B vision-language model takes images and video, supports mixed 4x/16x visual token compression, and targets phones and small devices.
The code in this post comes from the model's docs and hasn't been run in our CI yet. If something breaks, let us know.
MiniCPM-V 4.7 1B is a small multimodal model from OpenBMB. It reads single images, multiple images and video, and answers in text. What makes it notable is the target: the card positions it for resource-constrained devices and lists iOS, Android and HarmonyOS support.
The 1B model is one of two MiniCPM-V 4.7 variants. The other, 35B-A3B, is a larger mixture-of-experts model (we cover it separately). This post is only about the 1B model.
Key specs
| Item | From the model card |
|---|---|
| Size | 1B variant |
| License | Apache-2.0 |
| Task | image-text-to-text (transformers) |
| Inputs | single image, multiple images, video |
| Visual token compression | mixed 4x / 16x, set with downsample_mode |
| Inference frameworks | SGLang, vLLM, llama.cpp, Ollama |
| Fine-tuning frameworks | SWIFT, LLaMA-Factory |
| Quantized variants | GGUF, BNB (int4), AWQ, GPTQ |
| Language backbone / vision module | Qwen3.5 and Qwen3.6 / SigLIP2 (per the acknowledgements) |
The card says that in Instruct mode the 1B variant “substantially outperforms Qwen3.5 0.8B in both overall score and inference efficiency.” The supporting numbers are in charts on the card, not in text, so check the charts before relying on that claim for your task.
The efficiency idea is “intra-ViT early compression”: visual tokens are compressed early inside the vision encoder, which reduces computation in later encoder layers. You choose between 16x (the default, merges tokens for efficiency) and 4x (four times as many tokens, finer detail) with the downsample_mode argument.
Install
pip install "transformers[torch]>=5.18.0" torchvision torchcodectorchcodec is used for video decoding. The card warns it can fail on some CUDA versions (for example RuntimeError: Could not load libtorchcodec). Its first workaround is to use PyAV instead:
pip install "transformers[torch]>=5.18.0" torchvision avRun it: image question answering
import torchfrom transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "openbmb/MiniCPM-V-4.7-1B"
processor = AutoProcessor.from_pretrained(model_id)model = AutoModelForImageTextToText.from_pretrained( model_id, torch_dtype="auto", device_map="auto")
messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/openbmb/DemoCase/resolve/main/refract.png"}, {"type": "text", "text": "What causes this phenomenon?"}, ], }]
downsample_mode = "16x" # use "4x" for finer detail
inputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt", downsample_mode=downsample_mode, max_slice_nums=36, enable_thinking=False,).to(model.device)
generated_ids = model.generate( **inputs, downsample_mode=downsample_mode, max_new_tokens=512, do_sample=True, temperature=0.7, top_p=0.95, top_k=100, min_p=0.0, presence_penalty=0, repetition_penalty=1.03,)generated_ids_trimmed = [ out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)]output_text = processor.batch_decode( generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False)print(output_text[0])The sampling values are the card’s recommended Instruct-mode settings. To run this on your own picture, replace the url with your image’s URL (the card’s examples use URLs).
Video understanding
Video uses the same load code, with different processor arguments:
messages = [ { "role": "user", "content": [ {"type": "video", "url": "https://huggingface.co/datasets/openbmb/DemoCase/resolve/main/football.mp4"}, {"type": "text", "text": "Describe this video in detail. Follow the timeline and focus on on-screen text, interface changes, main actions, and scene changes."}, ], }]
downsample_mode = "16x"
inputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt", downsample_mode=downsample_mode, max_num_frames=128, stack_frames=1, max_slice_nums=1, use_image_id=False, enable_thinking=False,).to(model.device)
generated_ids = model.generate( **inputs, downsample_mode=downsample_mode, max_new_tokens=2048, do_sample=True, temperature=0.7, top_p=0.95, top_k=100, min_p=0.0, presence_penalty=0, repetition_penalty=1.03,)generated_ids_trimmed = [ out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)]print(processor.batch_decode( generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0])(Run it after the model and processor from the previous script are loaded.) The processor arguments from the card:
| Argument | Default | Notes |
|---|---|---|
downsample_mode |
"16x" |
"4x" keeps four times as many tokens. Must also be passed to generate(). |
max_slice_nums |
9 |
Slices for high-resolution images. Card recommends 36 for images, 1 for video. |
max_num_frames |
128 |
Video only. Maximum main frames sampled. |
stack_frames |
1 |
Video only. 1 is main frames only; the card recommends 3 or 5 if you stack sub-frames. |
use_image_id |
True |
Card recommends True for images, False for video. |
Serve it with an OpenAI-compatible endpoint
Transformers includes a lightweight server for quick testing and moderate load:
pip install "transformers[serving]>=5.18.0"transformers serve openbmb/MiniCPM-V-4.7-1B --port 8000 --host 0.0.0.0Image request:
curl -s http://localhost:8000/v1/chat/completions \ -H 'Content-Type: application/json' \ -d '{ "model": "openbmb/MiniCPM-V-4.7-1B", "messages": [{ "role": "user", "content": [ {"type": "image_url", "image_url": {"url": "https://huggingface.co/datasets/openbmb/DemoCase/resolve/main/refract.png"}}, {"type": "text", "text": "What causes this phenomenon?"} ] }] }'The card also shows a tool-calling request with the standard tools field and a get_weather function:
curl -s http://localhost:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{ "model": "openbmb/MiniCPM-V-4.7-1B", "messages": [{"role": "user", "content": [ {"type": "text", "text": "the weather of Beijing"} ]}], "tools": [{ "type": "function", "function": { "name": "get_weather", "description": "Get the current weather for a given location", "parameters": { "type": "object", "properties": { "location": {"type": "string", "description": "City name"} }, "required": ["location"] } } }]}'The card doesn’t show the response format or how reliable tool calls are at this size, so test with your own tools.
Gotchas
- Pass
downsample_modetwice. It must go to bothapply_chat_template(so the placeholder count is right) andgenerate(for the vision encoder). Other parameters go only toapply_chat_template. - Transformers version. The card requires
transformers>=5.18.0. torchcodecand CUDA. Video decoding can fail on mismatched CUDA versions; use PyAV or pin the torch CUDA build as the card describes.- Sampling. The card recommends its listed Instruct-mode sampling parameters. The card’s examples all pass
enable_thinking=Falseand document nothing else about it, so this post doesn’t cover thinking mode. - Hardware is not specified. The card gives no memory figure. Measure on your own device.
- Quantized variants (GGUF, int4, AWQ, GPTQ) are separate repos linked from the card, with their own guides in the MiniCPM-V CookBook. This post didn’t use them.
When to pick it
Pick it if you need image, multi-image or video understanding in a small model, especially on phones or other constrained hardware, and you want a permissive Apache-2.0 license. The 4x/16x switch lets you trade detail against cost.
Skip it, or test hard first, if you need the strongest possible vision accuracy: the comparison the card states in text is against Qwen3.5 0.8B. If you have the hardware for the larger 35B-A3B variant in the same family, compare the two on your own images. Also note this post’s code was not run by us; confirm it on your setup.
Related
Run MiniCPM-V 4.7 35B-A3B for Image, Video and Tool Calls
MiniCPM-V 4.7 35B-A3B is OpenBMB's first MoE vision-language model, Apache-2.0, with a 16x/4x visual token switch. Load it with Transformers and serve it.
openbmb/MiniCPM-V-4.7-35B-A3B
Parse Scanned and Phone-Photo Documents with TeleOCR (1.2B)
TeleOCR is a 1.2B Apache-2.0 model that turns text, tables, formulas and layouts into structured output, including from photos of warped pages.
XingChen-AGI/TeleOCR
Aion 1.0 Instruct 2.3B: Microsoft's Small Model for Summaries and Rewrites
Run Microsoft's MIT-licensed 2.3B Aion 1.0 Instruct with transformers for summarizing, rewriting, chat and tool calls, with a 32K-token context.
microsoft/Aion-1.0-Instruct-2.3B