luispoveda93 commited on
Commit
36afcc7
·
verified ·
1 Parent(s): 4d2f6cc

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +83 -0
README.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - zh
6
+ base_model:
7
+ - openbmb/MiniCPM5-2B
8
+ pipeline_tag: text-generation
9
+ library_name: litert
10
+ tags:
11
+ - minicpm
12
+ - minicpm5
13
+ - litert
14
+ - tflite
15
+ - on-device
16
+ - edge-ai
17
+ ---
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
+ 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`.
24
+
25
+ ## Available Files
26
+
27
+ * **`MiniCPM5-2B_wi8_afp32.litertlm`**: dynamic weight-only INT8 quantization (`wi8`) with FP32 activations (`afp32`). KV cache buffer length 1280 tokens.
28
+
29
+ ## Model Information
30
+
31
+ | Item | Value |
32
+ | --- | --- |
33
+ | Type | Causal Language Model |
34
+ | Architecture | Standard `LlamaForCausalLM` |
35
+ | Layers | 42 |
36
+ | Hidden size | 2048 |
37
+ | Attention Heads (GQA) | 16 (Q) / 2 (KV), head_dim 128 |
38
+ | Vocab size | 130,560 |
39
+ | Context Length (native) | 131,072 |
40
+ | Exported KV cache length | 1,280 |
41
+
42
+ ## Verification
43
+
44
+ - **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).
45
+ - **End-to-end generation**: verified with `litert-lm run`, including correct `<think>...</think>` reasoning-channel parsing and coherent completions (factual QA + code generation tested).
46
+
47
+ ## Use the model
48
+
49
+ ### Desktop/CLI
50
+
51
+ Install `uv` and run the model directly from the LiteRT-LM command line:
52
+
53
+ ```bash
54
+ uv tool install litert-lm
55
+ uvx litert-lm run --from-huggingface-repo=luispoveda93/MiniCPM5-2B-litert-lm MiniCPM5-2B_wi8_afp32.litertlm --prompt="What is the capital of France?"
56
+ ```
57
+
58
+ ### Edge Gallery App (Android)
59
+
60
+ 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).
61
+ 2. In **Model manager**, tap **+ → Import from HF**, paste this repo's `.litertlm` URL, and download.
62
+
63
+ ## Links
64
+
65
+ - 🤗 Original model (BF16): [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B)
66
+ - 📦 GitHub: [OpenBMB/MiniCPM](https://github.com/OpenBMB/MiniCPM)
67
+ - 🛠️ LiteRT docs: [ai.google.dev/edge/litert](https://ai.google.dev/edge/litert)
68
+ - Reference conversion for the smaller checkpoint: [litert-community/MiniCPM5-1B](https://huggingface.co/litert-community/MiniCPM5-1B)
69
+
70
+ ## License
71
+
72
+ Released under the **Apache-2.0 License**, consistent with the upstream [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B).
73
+
74
+ ## Citation
75
+
76
+ ```bibtex
77
+ @article{minicpm4,
78
+ title={MiniCPM4: Ultra-efficient LLMs on end devices},
79
+ author={MiniCPM, Team},
80
+ journal={arXiv preprint arXiv:2506.07900},
81
+ year={2025}
82
+ }
83
+ ```