Instructions to use luispoveda93/MiniCPM5-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use luispoveda93/MiniCPM5-2B with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
File size: 3,230 Bytes
36afcc7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | ---
license: apache-2.0
language:
- en
- zh
base_model:
- openbmb/MiniCPM5-2B
pipeline_tag: text-generation
library_name: litert
tags:
- minicpm
- minicpm5
- litert
- tflite
- on-device
- edge-ai
---
# MiniCPM5-2B (LiteRT-LM)
This repository hosts a [**LiteRT-LM**](https://ai.google.dev/edge/litert-lm) (LiteRT, formerly TensorFlow Lite) conversion of **[openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B)**, optimized for fully on-device inference on mobile and edge hardware.
The model was re-authored with `ai-edge-torch` (Llama-architecture decoder, since MiniCPM5-2B ships as a standard `LlamaForCausalLM`), verified for numerical parity against the original HF checkpoint (cosine similarity 0.999995 on last-token logits), converted to a multi-signature (`prefill_8/64/128/256/512/1024` + `decode`) `.tflite` with INT8 dynamic weight-only quantization, and packaged into `.litertlm` with `litert-lm-builder`.
## Available Files
* **`MiniCPM5-2B_wi8_afp32.litertlm`**: dynamic weight-only INT8 quantization (`wi8`) with FP32 activations (`afp32`). KV cache buffer length 1280 tokens.
## Model Information
| Item | Value |
| --- | --- |
| Type | Causal Language Model |
| Architecture | Standard `LlamaForCausalLM` |
| Layers | 42 |
| Hidden size | 2048 |
| Attention Heads (GQA) | 16 (Q) / 2 (KV), head_dim 128 |
| Vocab size | 130,560 |
| Context Length (native) | 131,072 |
| Exported KV cache length | 1,280 |
## Verification
- **Numerical parity**: re-authored `ai-edge-torch` model vs. original HF `transformers` forward pass — cosine similarity **0.999995** on last-token logits (identical top-5 token predictions).
- **End-to-end generation**: verified with `litert-lm run`, including correct `<think>...</think>` reasoning-channel parsing and coherent completions (factual QA + code generation tested).
## Use the model
### Desktop/CLI
Install `uv` and run the model directly from the LiteRT-LM command line:
```bash
uv tool install litert-lm
uvx litert-lm run --from-huggingface-repo=luispoveda93/MiniCPM5-2B-litert-lm MiniCPM5-2B_wi8_afp32.litertlm --prompt="What is the capital of France?"
```
### Edge Gallery App (Android)
1. Install the [app](https://play.google.com/store/apps/details?id=com.google.ai.edge.gallery) from Google Play or the [GitHub releases page](https://github.com/google-ai-edge/gallery/releases).
2. In **Model manager**, tap **+ → Import from HF**, paste this repo's `.litertlm` URL, and download.
## Links
- 🤗 Original model (BF16): [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B)
- 📦 GitHub: [OpenBMB/MiniCPM](https://github.com/OpenBMB/MiniCPM)
- 🛠️ LiteRT docs: [ai.google.dev/edge/litert](https://ai.google.dev/edge/litert)
- Reference conversion for the smaller checkpoint: [litert-community/MiniCPM5-1B](https://huggingface.co/litert-community/MiniCPM5-1B)
## License
Released under the **Apache-2.0 License**, consistent with the upstream [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B).
## Citation
```bibtex
@article{minicpm4,
title={MiniCPM4: Ultra-efficient LLMs on end devices},
author={MiniCPM, Team},
journal={arXiv preprint arXiv:2506.07900},
year={2025}
}
```
|