a8nova's picture
nnopt port: MiniCPM-OCR-1.0-LiteRT
3715973 verified
|
Raw History Blame Contribute Delete
3.51 kB
---
license: apache-2.0
base_model: openbmb/MiniCPM-OCR-1.0
pipeline_tag: image-text-to-text
tags:
- on-device
- nnopt
- litert
- tflite
- android
- npu
- hexagon
- qualcomm
- ocr
- galaxy-s26-plus
---
# MiniCPM-OCR-1.0 on Samsung Galaxy S26+ (LiteRT)
Ported and verified on a real Samsung Galaxy S26+ by [nnopt.dev](https://nnopt.dev) — AI agents that port and optimize models for the hardware you ship.
The model is [openbmb/MiniCPM-OCR-1.0](https://huggingface.co/openbmb/MiniCPM-OCR-1.0) by OpenBMB, and it is theirs. The LiteRT port in this repository is nnopt's work: nnopt job NN-EF0726.
| | |
|---|---|
| Device | Samsung Galaxy S26+, Android 16 |
| Chip | Snapdragon 8 Elite Gen 5 (SM8850) |
| Processor | NPU (Hexagon HTP v81) for every model graph; CPU for JPEG/resize/tokenizer/embedding lookup/argmax |
| Runtime | LiteRT 2.3.1 (CompiledModel C API, Qualcomm dispatch), QNN 2.50.0 |
| Precision | FP16 on the HTP (fp32 graph I/O, bf16 checkpoint weights stored fp16) |
| Modality | image + text -> text (OCR) |
| Weights | included: models/*.tflite (10 graphs AOT-compiled for SM8850 by nnopt) and build/assets/embed.bf16 (token embeddings) with the tokenizer tables; Qualcomm's QNN runtime is fetched |
| nnopt job | NN-EF0726 (port) |
| Folder | [`sm8850-npu-fp16/`](https://huggingface.co/nnopt-dev/MiniCPM-OCR-1.0-LiteRT/tree/main/sm8850-npu-fp16) |
## Verified results
nnopt built the folder from a clean copy, deployed it to the device and checked it against the model's reference code on hidden inputs. The full report is `report.html` in the folder.
- Passed. Next-token agreement 98.3% (bar at least 98.0%, original precision)
- full check passed
- no speculative decoding
- Prefill 197 tokens/s
- Decode 31.1 tokens/s
- Time to first token 4.04 s
- Load time 1.65 s
- Peak memory 3,467 MB
- Runs on 10 graphs, NPU 100%
## Use it
```
mkdir MiniCPM-OCR-1.0-LiteRT && cd MiniCPM-OCR-1.0-LiteRT
curl -fsSL https://huggingface.co/nnopt-dev/MiniCPM-OCR-1.0-LiteRT/resolve/main/config.json -o config.json
hf download nnopt-dev/MiniCPM-OCR-1.0-LiteRT --include "sm8850-npu-fp16/*" --local-dir .
cd sm8850-npu-fp16
bash fetch.sh
bash deploy.sh /data/local/tmp/minicpm_ocr # adb: runner, LiteRT, QNN libs, 10 NPU graphs, assets (~3.9 GB)
adb push demo/input.jpg demo/prompt.txt /data/local/tmp/minicpm_ocr/
adb shell 'cd /data/local/tmp/minicpm_ocr && sh ./run.sh --image input.jpg --prompt-file prompt.txt \
--max-new-tokens 256 --out out.json --metrics metrics.json'
```
Needs: A Snapdragon SM8850 phone (Galaxy S26+), Android 16, adb, ~3.5 GB free storage and RAM; curl and unzip on the host. Rebuilding the runner or assets (`INPUTS_DIR=... bash build.sh`) needs the original weights.
`README.md` in the folder has every flag, the requirements and the known limits; `REPRO.md` (where present) reproduces the measurements.
## License
Apache 2.0, like openbmb/MiniCPM-OCR-1.0: see LICENSE and NOTICE. LiteRT in `vendor/litert/` is Apache 2.0. Qualcomm's QNN runtime is not here: `fetch.sh` gets it from Maven Central, under Qualcomm's license.
## Made with nnopt
[nnopt](https://nnopt.dev) is a platform where AI agents port, optimize and benchmark a model for a specific device. They write the runtime code on the real device, and a locked verification kit then checks the result against the model's own reference code before anything ships. Every number on this page comes from that check.
Want your model on your device? Start a job at [nnopt.dev](https://nnopt.dev).