MiniCPM-V Demo — iOS, Android & HarmonyOS
English | 中文
This demo runs the MiniCPM-V family of multimodal models fully on-device on iOS, Android, and HarmonyOS NEXT. Currently supported:
- MiniCPM-V 2.6
- MiniCPM-V 4.0
- MiniCPM-V 4.6
- MiniCPM-V 4.7 35B-A3B (MoE, streams experts from SSD)
- MiniCPM-V 4.7 1B (dense)
- MiniCPM5-1B (text-only)
- MiniCPM5-2B (text-only)
- MiniCPM5-15B-A2.5B (text-only MoE)
- VoxCPM2 (text-to-speech, TTS)
- MiniCPM-OCR 1.0 (document OCR — iOS & Android)
This repository contains three on-device demos for MiniCPM-V (multimodal LLM) running fully locally via llama.cpp:
MiniCPM-V-demo/ — iOS demo (Xcode project)
MiniCPM-V-demo-Android/ — Android demo (Gradle / Kotlin)
MiniCPM-V-demo-HarmonyOS/ — HarmonyOS NEXT demo (DevEco Studio / ArkTS)
All three demos share the same llama.cpp-omni submodule (tracking master) at the repo root.
NOTE: This project bundles llama.cpp as a git submodule. The upstream fork tc-mb/llama.cpp-omni carries a dozen unrelated branches and a full clone weighs ~350 MB, so shallow = true is set in .gitmodules by default. The recommended shallow + single-branch clone is:
# one-shot (parent repo + submodules, all shallow)
git clone --recurse-submodules --shallow-submodules \
https://github.com/OpenBMB/MiniCPM-V-Apps.git
cd MiniCPM-V-Apps
Or, if you’ve already cloned the parent repo and want to init the submodule afterwards:
git submodule update --init --recursive --depth 1 --single-branch
This only pulls the pinned commit (~tens of MB) instead of the full llama.cpp-omni fork history. Developers who need to push to tc-mb/llama.cpp-omni can run git fetch --unshallow inside the submodule to lift the shallow restriction.
The README is organised in two parts:
- Part 1 — Platform setup: how to build and run the demo on iOS, Android and HarmonyOS.
- Part 2 — GGUF model files: where to get the model weights for each MiniCPM-V version, and the minimum on-device hardware needed to run them.
Just want to install the app? Pre-built packages are below; step-by-step instructions (requirements, signing notes, MD5) are in DOWNLOAD.md. The rest of this README is only needed if you want to build from source.
1.1 iOS Demo
NOTE: To deploy and test the app on an iOS device, you may need an Apple Developer account.
-
Download Xcode from the App Store (verified on Xcode 26.1.1; project deployment target = iOS 16.6)
-
Install the Command Line Tools:
xcode-select --install
-
Agree to the software license agreement:
sudo xcodebuild -license
-
CMake ≥ 3.28 (needed by the xcframework build in the next step):
brew install cmake
1.1.2 Build llama.xcframework (required on first build)
This repo does not track any compiled artefacts, so the prebuilt llama.xcframework (~189 MB) needs to be produced locally from the llama.cpp-omni submodule and dropped into MiniCPM-V-demo/thirdparty/ for Xcode to link against. A one-shot script is provided — by default it only builds the two slices the demo actually links (real device + simulator), which takes ~2-3 min on a modern M-series Mac:
./scripts/build_xcframework.sh
The output is installed at MiniCPM-V-demo/thirdparty/llama.xcframework/.
If you need a different build scope, the script forwards MINIMAL_MODE:
MINIMAL_MODE=ios-sim ./scripts/build_xcframework.sh # simulator only (~3 min)
MINIMAL_MODE=ios-device ./scripts/build_xcframework.sh # device only (~3 min)
MINIMAL_MODE=ios ./scripts/build_xcframework.sh # device + simulator (default, ~3 min)
MINIMAL_MODE=macos ./scripts/build_xcframework.sh # macOS slice only (not used by this demo)
This demo only links the iOS slices (device + simulator), so the default is all you need. macos is a
separate mode for the Mac-side CLI; all currently behaves identically to ios (same branch in the
script), it is not a multi-platform build.
The script drives cmake directly against the llama.cpp-omni submodule (it modifies no file inside
it), then copies the resulting llama.cpp-omni/build-apple/llama.xcframework into
MiniCPM-V-demo/thirdparty/. There is no pre-existing build script inside the submodule — if you
need custom compile flags, read scripts/build_xcframework.sh.
During the build you will see warnings like ignoring duplicate libraries and skipping debug map object with duplicate name and timestamp — these come from llama.cpp’s mtmd module having identically-named .o files across different model architectures. They are harmless and the resulting framework works correctly.
When do I need to rebuild?
- The parent repo bumped the llama.cpp-omni submodule pointer (
git submodule status shows a commit different from your last local build).
- You edited any source under
llama.cpp-omni/ that affects the framework.
1.1.3 Download onnxruntime.xcframework (required on first build)
OCR layout detection links Microsoft ONNX Runtime. The repo does not track onnxruntime.xcframework (~44 MB zip / ~194 MB unpacked). Fetch the public onnxruntime-c 1.21.0 CocoaPods archive (iOS device + simulator + macOS slices) with:
./scripts/download_onnxruntime.sh
The script writes MiniCPM-V-demo/thirdparty/onnxruntime.xcframework/ and skips the download if 1.21.0 is already present. Re-fetch with FORCE=1 ./scripts/download_onnxruntime.sh.
The archive URL is Microsoft’s public host: https://download.onnxruntime.ai/pod-archive-onnxruntime-c-1.21.0.zip (SHA-256 is pinned in the script). This Xcode project always links that framework, so the download is required even if you are not using OCR.
1.1.4 Open in Xcode and run
Open MiniCPM-V-demo.xcodeproj at the repository root (it is not under the MiniCPM-V-demo/ subdirectory). It may take a moment for Xcode to automatically download the required dependencies.
- Switch to your own signing team. Select the
MiniCPM-V-demo target → Signing & Capabilities
and change Team to your own account. The repo ships with the author’s Team ID, so building without
changing it fails to sign.
- Enable Developer Mode on the device. Required on iOS / iPadOS 16 and later, otherwise
installation is rejected:
Settings → Privacy & Security → Developer Mode.
- Select the target device at the top, then click the “Run” (triangle) button to launch the demo.
- On first launch, go to Settings → Model Management, tap Download All for the model you want,
then Use This Model to activate it. See §2.4 for the files and their on-device locations.
If Xcode fails with There is no XCFramework found at '.../llama.xcframework', you skipped §1.1.2 — go back and run the build. If the missing path is onnxruntime.xcframework, you skipped §1.1.3.
1.2 Android Demo
Requirements:
- Android Studio (Giraffe or newer)
- Android SDK + NDK (the project pins NDK
27.0.12077973 and CMake 3.22.1)
- A physical device with a 64-bit ARM SoC (
arm64-v8a)
- Device RAM: see the per-model requirements in Part 2
Build & run:
cd MiniCPM-V-demo-Android
./gradlew assembleDebug
Or open MiniCPM-V-demo-Android/ directly in Android Studio and click Run.
The first launch will download the GGUF model files into the app’s external storage. You can also sideload model files manually via adb push — see in-app Model Manager for the expected directory layout.
1.3 HarmonyOS Demo
Requirements:
- DevEco Studio 5.0 or newer (with the HarmonyOS Native SDK / NDK)
- A real device or emulator running HarmonyOS API 15+ (e.g. nova 14 vitality / Mate 60 / Pura 70). The OCR pipeline pulls in
@ohos/onnxruntime, whose @ohos/aki dependency requires API 15; build-profile.json5.example therefore sets compatibleSdkVersion to 6.0.2(22)
- 64-bit ARM architecture (
arm64-v8a)
- Device RAM: see the per-model requirements in Part 2
Build & run:
- Open
MiniCPM-V-demo-HarmonyOS/ in DevEco Studio.
File → Project Structure → Signing Configs and tick Automatically generate signature (requires a Huawei developer account; this only needs to be done once).
- Connect the device with USB debugging enabled, then click Run (the green triangle).
After the first launch, open the in-app Model Manager, pick a model and tap Download. App-sandbox paths are protected by SELinux, so hdc file send into .../files/models/ is rejected on retail builds; the in-app downloader is the supported path.
To try the OCR pipeline without picking a photo, open Model Manager → MiniCPM-OCR 1.0 → Download, then tap 加载模型; the OCR page has a 示例文档 button that runs the bundled test_ticket.jpg through layout detection and recognition.
The HarmonyOS port shares the exact same llama.cpp-omni submodule, model catalogue, HuggingFace / ModelScope download URLs and MD5 hashes with the iOS / Android demos.
Part 2. GGUF Model Files
Hardware requirements
The on-device memory needed to run a model is roughly (model file size) + KV cache + a few hundred MB of working memory for the vision encoder and llama.cpp internals. The recommended values below leave enough headroom for the OS and the demo app itself.
| Model |
LLM params |
Recommended quant |
LLM file |
mmproj (f16) |
Total download |
Recommended device RAM |
| MiniCPM-V 2.6 |
8B |
Q4_K_M |
~4.4 GB |
~1.0 GB |
~5.4 GB |
≥ 8 GB |
| MiniCPM-V 4.0 |
4.1B |
Q4_K_M |
~2.0 GB |
~0.9 GB |
~2.9 GB |
≥ 6 GB |
| MiniCPM-V 4.6 |
1.3B |
Q4_K_M |
~0.5 GB |
~1.1 GB |
~1.6 GB |
≥ 6 GB |
| MiniCPM-V 4.7 35B-A3B |
35B (3B active) |
q3gud-im (Q3_K experts) |
~1.7 GB |
~1.1 GB |
~16.6 GB |
≥ 12 GB |
| MiniCPM-V 4.7 1B |
1B |
Q4_K_M |
~0.7 GB |
~1.1 GB |
~1.8 GB |
≥ 4 GB |
| MiniCPM5-1B |
1B |
Q4_K_M |
~0.5 GB |
— |
~0.5 GB |
≥ 4 GB |
| MiniCPM5-2B |
2B |
Q4_K_M |
~1.5 GB |
— |
~1.5 GB |
≥ 6 GB |
| MiniCPM5-15B-A2.5B |
15B (2.5B active) |
Q3_gud (Q3_K experts) |
~6.8 GB |
— |
~6.8 GB |
≥ 8 GB (Fastest mode: ≥ 12 GB) |
| VoxCPM2 (TTS) |
~2B |
Q4_K_M + F16 |
~1.0 GB |
— |
~2.8 GB |
≥ 6 GB |
| MiniCPM-OCR 1.0 (iOS) |
752M |
Q4_K_M |
~0.5 GB |
~0.9 GB |
~1.6 GB |
≥ 6 GB |
Notes:
mmproj is the vision projector + ViT weights; it is shipped in f16 because quantising the visual tower hurts perception quality noticeably more than quantising the LLM.
- MiniCPM5-1B and MiniCPM5-2B are text-only models and do not need an
mmproj file.
- MiniCPM5-15B-A2.5B is text-only. Its Q3_gud quant keeps Q3_K for the routed experts and a Q4_K_M recipe for everything else; the GGUF header reports
general.file_type as Q4_K_M, so the precision is spelled out in the file name. It has been validated on a 12 GB iPhone 18 Pro Max — see §2.7.
- VoxCPM2 requires two GGUF files (BaseLM + Acoustic) and does not use an
mmproj either — it is a pure TTS model.
- MiniCPM-OCR 1.0 is a three-file model: the LLM, the 4x vision projector, and a separate PP-DocLayoutV3 ONNX layout detector. It is wired up on iOS, Android and HarmonyOS. Its
mmproj is a 4x projector and is not interchangeable with the chat models’ mmproj.
- MiniCPM-V 4.7 35B-A3B uses a Q3_K expert quant (
mix_q3gud_im) rather than Q4, and its routed experts are repacked expert-major inside the same .gguf. The ~16.6 GB above is that one file (14.4 GB) + mmproj (1.1 GB); plan for ~17 GB of free storage. Because the experts are streamed from SSD on demand rather than held in RAM, this variant also needs fast internal storage — see §2.4.
- All three demos default to a context window of 4K tokens. MiniCPM5-15B-A2.5B (iOS) uses 8K (about 224 MB of KV cache); when it fills up, the app asks you to start a new chat. Larger contexts will increase the KV-cache footprint roughly linearly, so on a borderline device you may need to lower it.
- On Android / HarmonyOS, devices with 8 GB+ RAM are strongly recommended for V 2.6. On iOS, V 2.6 has been validated on iPhone 15 Pro / 16 series and recent iPads with M-series chips; older 6 GB devices may swap heavily.
- MiniCPM-V 4.7 35B-A3B has been validated on a 12 GB iPhone 17 Pro Max. On devices with less RAM the app automatically falls back to a smaller expert cache, which works but is considerably slower.
2.1 MiniCPM-V 2.6 GGUF Files
Download Official GGUF Files
Download the language model file (e.g., ggml-model-Q4_0.gguf) and the vision model file (mmproj-model-f16.gguf) from the repository.
2.2 MiniCPM-V 4.0 GGUF Files
Download Official GGUF Files
Download the language model file (e.g., ggml-model-Q4_K_M.gguf) and the vision model file (mmproj-model-f16.gguf) from the repository.
2.3 MiniCPM-V 4.6 GGUF Files
Download Official GGUF Files
Download the language model file (e.g., MiniCPM-V-4_6-Q4_K_M.gguf) and the vision model file (mmproj-model-f16.gguf) from the repository.
2.4 MiniCPM-V 4.7 GGUF Files
MiniCPM-V 4.7 ships in two sizes:
- MiniCPM-V 4.7 35B-A3B — MoE (35B total / 3B active). Uses MoE-SSD: the routed experts are
repacked expert-major (each expert’s
gate|up|down byte-contiguous) and kept inside the main
.gguf, streamed from SSD on demand. One file, which is what makes a 35B-class model runnable on
a phone.
- MiniCPM-V 4.7 1B — dense, small enough to keep everything resident.
Where to get the GGUF files
There are two sets, for two different purposes:
-
Standard quants — desktop / server. The official repos carry the usual whole-model quant range
(F16, Q4_K_M, Q5_K_M, Q6_K, Q8_0, …). Pick whichever fits your machine’s memory.
-
On-device repack — for this demo, on a phone. The LCO- prefixed file (and the 1B revision
this demo is actually built and tested against).
Why the LCO- prefix. LCO = llama.cpp-omni. The prefix marks a file laid out by
this engine, which standard llama.cpp cannot read: the routed experts are repacked expert-major
and described by an les.moe.descriptor metadata entry that only this engine understands. The rest
of the name follows the official convention unchanged (MiniCPM-V-4_7-35B-A3B-mix_q3gud_im), so a
LCO- file and its official counterpart are trivially paired.
Why a repack is needed at all. The expert streaming path reads one expert’s gate|up|down with a
single preadv, so those three tensors must be byte-contiguous per expert. The official GGUFs store
them family-major (ffn_up_exps starts 256 experts after ffn_gate_exps), which would need three
separate reads per expert — or, with the tensors left as-is, an mmap over the whole ~15.5 GB. The
LCO- repack is a byte move only: every resident tensor and every expert byte is identical to
the official file (verified 653/653), so it cannot change model output.
Files are grouped into per-model sub-directories:
| Variant |
Files |
On-device location |
| 35B-A3B |
MiniCPM-V-4.7-35B-A3B/LCO-MiniCPM-V-4_7-35B-A3B-mix_q3gud_im.gguf
MiniCPM-V-4.7-35B-A3B/mmproj-model-f16.gguf |
Documents/MiniCPMV47/ |
| 1B |
MiniCPM-V-4.7-1B/MiniCPM-V-4_7-1B-Q4_K_M.gguf
MiniCPM-V-4.7-1B/mmproj-model-f16.gguf |
Documents/MiniCPMV47_1B/ |
The LCO- file carries its own experts. There is no separate experts/ directory any more:
layout metadata lives in the file’s les.moe.descriptor entry, and the app reads it to size the
expert cache before loading. Downloading inside the app (Settings → tap the model →
Download) fetches both files and verifies the model’s size against the descriptor.
2.5 MiniCPM5-1B GGUF Files (text-only)
Download Official GGUF Files
Download the language model file (e.g., MiniCPM5-1B-Q4_K_M.gguf) from the repository. MiniCPM5 is text-only, so no mmproj is required.
2.6 MiniCPM5-2B GGUF Files (text-only)
Download Official GGUF Files
Download the language model file (e.g., MiniCPM5-2B-Q4_K_M.gguf) from the repository. MiniCPM5 is text-only, so no mmproj is required.
2.7 MiniCPM5-15B-A2.5B GGUF Files (text-only MoE)
MiniCPM5-15B-A2.5B is a text-only thinking MoE model (15B total / 2.5B active, 160 routed experts, top-16).
Download
The app downloads the single file itself (Settings → MiniCPM5-15B-A2.5B → Download All). To copy it in by hand, put it under Documents/MiniCPM5-15B-A2.5B/:
| File |
Size |
Notes |
MiniCPM5-15B-A2_5B-Q3_gud-LCO.gguf |
~6.8 GB |
The whole model, required. LES layout: each routed expert’s `gate |
The -LCO suffix marks our own repack: the weights are the upstream BF16 checkpoint quantised to Q3_gud (Q3_K routed experts, otherwise the Q4_K_M recipe) and then repacked expert-major. The packing moves bytes without re-quantising, and convert_les_gguf.py verify proves it: every resident tensor and every expert region is byte-identical to the source.
Inference modes
Settings → Feature settings → Inference mode switches between two ways of running the same file. Switching reloads the model.
- Fastest (default): the whole file is memory-mapped and the OS page cache manages it. Quickest decode, but memory use follows the system’s page cache. On a device that cannot hold the file plus about 4 GB, this is not the default: the phone may restart, so the app falls back to Memory saver there. Picking it by hand on such a device is still possible, behind a confirmation.
- Memory saver: routed experts are read from flash on demand into a fixed per-layer window. The app’s Metal memory stays at about 4 GB. Speed depends on how many experts are already cached or prefetched. This is the only mode that uses the trained expert predictor.
Measured on an iPhone 18 Pro Max (12 GB), Q3_gud, 64 generated tokens after a 22-token prompt:
| Mode |
Prefill |
Decode (wall clock) |
Metal memory |
| Fastest |
90.9 t/s |
49.9 t/s |
6.83 GiB (weights mapped) |
| Memory saver + predictor |
26.4 t/s |
24.4 t/s |
4.23 GiB |
An 8 GB iPhone 17 gets about 10 t/s in memory saver, because most expert reads go to flash: the OS page cache there is too small to hold the expert set.
Expert predictor
In memory-saver mode the engine prefetches the experts it expects the next layer to use. The predictor is trained on the same checkpoint as the model and ships inside the same GGUF file (resident ffn_gate_inp_pred / _prev tensors, about 71 MB of the 6.8 GB), so there is nothing extra to download. With the Expert predictor switch on it uses that trained head; with the switch off, or with a file that carries none, it falls back to the model’s own next-layer router. The predictor only changes which experts are prefetched — the output is identical either way.
The layout is part of LES, so a file with the predictor is still one file: convert_les_gguf.py attach can swap the head in later without re-packing the multi-GB expert region.
2.8 VoxCPM2 GGUF Files (text-to-speech)
VoxCPM2 is a ~2B-parameter text-to-speech model. It consists of two GGUF files:
- BaseLM (
VoxCPM2-BaseLM-Q4_K_M.gguf, ~956 MB) — the MiniCPM-4 based language model
- Acoustic (
VoxCPM2-Acoustic-F16.gguf, ~1.74 GB) — the acoustic decoder (FSQ + LocEnc + LocDiT + AudioVAE)
VoxCPM2 supports 30+ languages and 9 Chinese dialects. It can generate speech from text directly (voice-design mode) or clone a voice from a reference audio clip.
Download Official GGUF Files
After downloading, place both .gguf files in the app’s Documents directory (iOS) or in the per-model folder under {ExternalFilesDir}/models/ (Android / HarmonyOS). You can also download them directly inside the app via Model Manager. Once models are downloaded, select VoxCPM2 and the app switches to the TTS interface automatically.
2.9 MiniCPM-OCR 1.0 Files (document OCR, iOS & Android)
MiniCPM-OCR 1.0 turns a photo, screenshot or PDF page into Markdown: it detects layout blocks first, then runs the vision-language model on each crop and stitches the results back into reading order (headings, paragraphs, tables, formulas and seals).
The pipeline needs three files:
- LLM (
MiniCPM-OCR-1_0-Q4_K_M.gguf, ~529 MB) — 752M-parameter text tower
- mmproj (
MiniCPM-OCR-1_0-mmproj-F16-4x.gguf, ~901 MB) — 4x vision projector (ViT + final merger)
- Layout detector (
PPDocLayoutV3_fix4.onnx, ~142 MB) — PP-DocLayoutV3 ONNX model, run through ONNX Runtime
Roughly 1.6 GB in total. Plan for ≥ 6 GB RAM; OCR keeps the LLM context plus the vision encoder resident.
The mmproj here is a 4x projector (scale_factor=2) and is specific to OCR. Do not reuse the chat models’ mmproj-model-f16.gguf, and do not feed this one to a chat model.
Download
The upstream weights live in openbmb/MiniCPM-OCR-1.0-gguf. The Q4_K_M file above is quantised from the official MiniCPM-OCR-1_0-F16.gguf with llama-quantize; the mmproj is byte-identical to the official one.
Easiest path: open Settings → Model Management → MiniCPM-OCR 1.0 and tap Download All. The app races HuggingFace and ModelScope in parallel and keeps whichever responds first, so it works both inside and outside mainland China.
To place the files by hand, put all three in the app’s Documents directory and keep these exact names:
Documents/
├── MiniCPM-OCR-1_0-Q4_K_M.gguf
├── MiniCPM-OCR-1_0-mmproj-F16-4x.gguf
└── PPDocLayoutV3_fix4.onnx
Then select MiniCPM-OCR 1.0 in Settings; the app switches to the OCR interface. Downloads are MD5-checked before use, so a truncated transfer is rejected instead of silently failing at load time.
On Android the three files go to {ExternalFilesDir}/models/minicpm-ocr-1.0/, and the same Download All entry in Model Manager fetches them. ONNX Runtime comes from Maven there, so there is nothing to fetch by hand.
Building the iOS app from source additionally requires onnxruntime.xcframework — see §1.1.3.
Optional: Hexagon NPU acceleration (Android)
The Android client runs the OCR vision tower on the CPU by default, which is
correct everywhere but slow. On Qualcomm parts the same tower can run on the
Hexagon NPU from a precompiled QNN context binary, about two orders of magnitude
faster per crop.
This is opt-in and never a correctness dependency: the app asks the driver which
DSP generation the device has and loads the matching binary. If there is no
match it silently stays on the CPU and produces the same output.
./scripts/download_qnn_binary.sh v85 # ~868 MB per architecture
See scripts/qnn/README.md for which generations exist,
how the binaries are built from the published mmproj, and the numerical checks
behind them. That directory also holds the conversion pipeline.
评论