Instructions to use litert-community/MiniCPM5-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/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
Upload README.md with huggingface_hub
#1
by luispoveda93 - opened
- .gitattributes +1 -0
- MiniCPM5-2B_wi8_afp32.litertlm +3 -0
- README.md +23 -39
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
MiniCPM5-2B_wi8_afp32.litertlm filter=lfs diff=lfs merge=lfs -text
|
MiniCPM5-2B_wi8_afp32.litertlm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b4236e8c86c3d4513a08cc92df336062c049764a0b5e7f92c6920bda187276c8
|
| 3 |
+
size 2613550960
|
README.md
CHANGED
|
@@ -18,72 +18,56 @@ tags:
|
|
| 18 |
|
| 19 |
# MiniCPM5-2B (LiteRT-LM)
|
| 20 |
|
| 21 |
-
This repository hosts
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
## Available Models
|
| 26 |
-
|
| 27 |
-
* **`minicpm_wi4c_wi8_afp32.litertlm`**: This model features mixed INT4/INT8 weight-only quantization with FP32 activations (afp32). MLP projections use channelwise INT4 with Hadamard rotation; all remaining weights (attention, embedding, and lmhead) use channelwise INT8.
|
| 28 |
-
* **`minicpm_wi8_afp32.litertlm`**: This model features weight-only INT8 quantization (wi8) with FP32 activations (afp32).
|
| 29 |
-
|
| 30 |
-
## What is MiniCPM?
|
| 31 |
|
| 32 |
-
**MiniCPM5-
|
| 33 |
|
| 34 |
-
##
|
| 35 |
|
| 36 |
-
-
|
| 37 |
-
- π οΈ **Tool use** β native tool-calling support in the chat template.
|
| 38 |
-
- π **Long context** β native **131,072**-token context length.
|
| 39 |
-
- π± **Built for the edge** β compact footprint designed for local assistants, coding agents, and tool-use workflows.
|
| 40 |
|
| 41 |
-
##
|
| 42 |
|
| 43 |
| Item | Value |
|
| 44 |
| --- | --- |
|
| 45 |
| Type | Causal Language Model |
|
| 46 |
| Architecture | Standard `LlamaForCausalLM` |
|
| 47 |
-
| Parameters | 2,516,756,480 (~2.5B) |
|
| 48 |
-
| Non-Embedding Parameters | 1,981,982,720 |
|
| 49 |
| Layers | 42 |
|
| 50 |
-
|
|
| 51 |
-
|
|
| 52 |
-
|
|
| 53 |
-
| Context Length | 131,072 |
|
| 54 |
-
|
| 55 |
-
---
|
| 56 |
-
|
| 57 |
-
## Use the model
|
| 58 |
|
| 59 |
-
##
|
| 60 |
-
|
| 61 |
-
1. **Get the App**: Install the [app](https://play.google.com/store/apps/details?id=com.google.ai.edge.gallery&pli=1) from Google Play or download the latest APK from the [GitHub releases page](https://github.com/google-ai-edge/gallery/releases).
|
| 62 |
-
2. **Importing the Model**: Navigate to the **Model manager** within the app and click the **"+" (plus)** icon in the bottom-right corner. Two options will appear:
|
| 63 |
-
* **Import from HF (Recommended)**: Select this option, and a dialog box will appear showing an example Hugging Face model URL. Enter the HF link for the desired `.litertlm` model and click submit. The model will then appear in your list, and you can proceed to download it (a Hugging Face account login is required).
|
| 64 |
-
* **From local model file**: First, download the `.litertlm` model directly to your Android device, OR download it to your computer and push it via ADB (e.g., `adb push minicpm_wi4c_wi8_afp32.litertlm /sdcard/Download/`). Then, select this option, choose the downloaded file from your storage, configure your preferred parameters, and tap **"Import"**.
|
| 65 |
|
| 66 |
-
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
###
|
| 71 |
|
| 72 |
Install `uv` and run the model directly from the LiteRT-LM command line:
|
| 73 |
|
| 74 |
```bash
|
| 75 |
uv tool install litert-lm
|
| 76 |
-
uvx litert-lm run --from-huggingface-repo=litert-community/MiniCPM5-2B
|
| 77 |
```
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
## Links
|
| 80 |
|
| 81 |
- π€ Original model (BF16): [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B)
|
| 82 |
-
- π€ Smaller sibling: [litert-community/MiniCPM5-1B](https://huggingface.co/litert-community/MiniCPM5-1B)
|
| 83 |
- π¦ GitHub: [OpenBMB/MiniCPM](https://github.com/OpenBMB/MiniCPM)
|
| 84 |
- π οΈ LiteRT docs: [ai.google.dev/edge/litert](https://ai.google.dev/edge/litert)
|
| 85 |
-
|
| 86 |
-
---
|
| 87 |
|
| 88 |
## License
|
| 89 |
|
|
|
|
| 18 |
|
| 19 |
# MiniCPM5-2B (LiteRT-LM)
|
| 20 |
|
| 21 |
+
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.
|
| 22 |
|
| 23 |
+
## Available Files
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
* **`MiniCPM5-2B_wi8_afp32.litertlm`**: dynamic weight-only INT8 quantization (`wi8`) with FP32 activations (`afp32`). KV cache buffer length 1280 tokens.
|
| 26 |
|
| 27 |
+
## Conversion Details
|
| 28 |
|
| 29 |
+
The model was re-authored with `ai-edge-torch` (Llama-architecture decoder-only builder, 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`.
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
## Model Information
|
| 32 |
|
| 33 |
| Item | Value |
|
| 34 |
| --- | --- |
|
| 35 |
| Type | Causal Language Model |
|
| 36 |
| Architecture | Standard `LlamaForCausalLM` |
|
|
|
|
|
|
|
| 37 |
| Layers | 42 |
|
| 38 |
+
| Hidden size | 2048 |
|
| 39 |
+
| Attention Heads (GQA) | 16 (Q) / 2 (KV), head_dim 128 |
|
| 40 |
+
| Vocab size | 130,560 |
|
| 41 |
+
| Context Length (native) | 131,072 |
|
| 42 |
+
| Exported KV cache length | 1,280 |
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
## Verification
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
- **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).
|
| 47 |
+
- **End-to-end generation**: verified with `litert-lm run`, including correct `<think>...</think>` reasoning-channel parsing and coherent completions (factual QA + code generation tested).
|
| 48 |
|
| 49 |
+
## Use the model
|
| 50 |
|
| 51 |
+
### Desktop/CLI
|
| 52 |
|
| 53 |
Install `uv` and run the model directly from the LiteRT-LM command line:
|
| 54 |
|
| 55 |
```bash
|
| 56 |
uv tool install litert-lm
|
| 57 |
+
uvx litert-lm run --from-huggingface-repo=litert-community/MiniCPM5-2B MiniCPM5-2B_wi8_afp32.litertlm --prompt="What is the capital of France?"
|
| 58 |
```
|
| 59 |
|
| 60 |
+
### Edge Gallery App (Android)
|
| 61 |
+
|
| 62 |
+
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).
|
| 63 |
+
2. In **Model manager**, tap **+ β Import from HF**, paste this repo's `.litertlm` URL, and download.
|
| 64 |
+
|
| 65 |
## Links
|
| 66 |
|
| 67 |
- π€ Original model (BF16): [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B)
|
|
|
|
| 68 |
- π¦ GitHub: [OpenBMB/MiniCPM](https://github.com/OpenBMB/MiniCPM)
|
| 69 |
- π οΈ LiteRT docs: [ai.google.dev/edge/litert](https://ai.google.dev/edge/litert)
|
| 70 |
+
- Reference conversion for the smaller checkpoint: [litert-community/MiniCPM5-1B](https://huggingface.co/litert-community/MiniCPM5-1B)
|
|
|
|
| 71 |
|
| 72 |
## License
|
| 73 |
|