This is an unofficial MNN conversion of openbmb/MiniCPM-V-4.7-1B, a 1B vision-language model, for CPU and edge inference with the MNN runtime.
MNN's exporter (llmexport) did not support the minicpmv4_7 architecture, so the conversion used a patched copy of it. The vision encoder was re-implemented as an export-friendly graph that accepts a different image resolution per request.
This repository is not affiliated with OpenBMB or the MNN team.
| Part | Setting |
|---|---|
| Language model | 4-bit, block size 128 |
lm_head |
8-bit |
| Embeddings | 8-bit |
| Vision encoder | 8-bit, block size 128 |
The repository holds the files llmexport writes for an MNN model: the language model (llm.mnn and its weight file), the vision encoder (visual.mnn and its weight file), the tokenizer, and the runtime configs (config.json, llm_config.json).
Install the MNN Python package, download the repository, and point llm.create at config.json:
pip install -U MNN huggingface_hub
from huggingface_hub import snapshot_download
import MNN.llm as llm
path = snapshot_download("bakhil-aissa/MiniCPM-V-4.7-1B-MNN")
model = llm.create(f"{path}/config.json")
model.load()
# text only
print(model.response("What is the capital of France?"))
# image: <hw>height,width</hw> sets this image's size (see below)
print(model.response("<img><hw>448,448</hw>/path/to/image.png</img>Describe this image."))
Each image is resized to the height and width given in <hw>H,W</hw> (height first). Both values must be multiples of 56, and the number of visual tokens is (H / 56) * (W / 56). For example, 448 x 448 gives 64 tokens and 672 x 448 gives 96.
Always include <hw> for every image. The runtime may reuse the previous size when it is missing.
The vision layers before the early token compression attend over every 14-pixel patch, so cost grows quickly with image size. A budget of about 144 tokens is a reasonable CPU default. This helper picks a size that keeps the aspect ratio:
import math
def pick_size(img_w, img_h, max_tokens=144, unit=56, min_units=4):
s = min(1.0, math.sqrt(max_tokens * unit * unit / (img_w * img_h)))
H = max(min_units, round(img_h * s / unit)) * unit
W = max(min_units, round(img_w * s / unit)) * unit
while (H // unit) * (W // unit) > max_tokens:
if H >= W: H -= unit
else: W -= unit
return H, W
H, W = pick_size(1080, 2400)
prompt = f"<img><hw>{H},{W}</hw>/path/to/screenshot.png</img>Describe this image."
llmexport was patched to load MiniCPMV4_7ForConditionalGeneration and to reuse its Qwen3.5 text mapping for the language model.image, so MNN's runtime uses its generic single-image path.minicpm_v47_to_mnn_dynamic.ipynb.The base model, openbmb/MiniCPM-V-4.7-1B, is released under Apache-2.0, and this conversion keeps that license. Please check the base model page for the current terms. Credit for the model goes to OpenBMB, and for the runtime to the MNN team at Alibaba.
openbmb/MiniCPM-V-4.7-1B