HanzoHuang commited on
Commit
404ed01
Β·
verified Β·
1 Parent(s): 9237411

Add RKNN3 model card and deployment instructions

Browse files
Files changed (1) hide show
  1. README.md +143 -0
README.md CHANGED
@@ -1,3 +1,146 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ base_model: openbmb/MiniCPM5-2B
4
+ pipeline_tag: text-generation
5
+ library_name: rknn3
6
+ language:
7
+ - en
8
+ - zh
9
+ tags:
10
+ - rknn3
11
+ - rockchip
12
+ - rk1820
13
+ - rk1828
14
+ - minicpm
15
+ - minicpm5
16
+ - edge-ai
17
+ - on-device
18
+ - w4a16
19
  ---
20
+
21
+ # MiniCPM5-2B-RKNN3
22
+
23
+ RKNN3-converted [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B) artifacts for the Rockchip **RK1820** and **RK1828** AI coprocessors.
24
+
25
+ These are hardware-specific deployment artifacts, not a Transformers checkpoint and not an RKLLM model. They were produced with **rknn3-toolkit v1.1.0** for the new RKNN3 toolchain and are intended for use with a compatible RKNN3 Runtime, firmware, demo, or `rkllm3-server`.
26
+
27
+ ## Base model
28
+
29
+ - Upstream model: [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B)
30
+ - Model type: causal language model (`LlamaForCausalLM`)
31
+ - Parameters: 2.52B total, 1.98B excluding embeddings
32
+ - Upstream context length: 131,072 tokens
33
+ - Upstream license: Apache-2.0
34
+
35
+ The usable context length of an RKNN3 deployment is determined by the converted model and runtime configuration. Do not assume that it is identical to the upstream checkpoint's maximum context length.
36
+
37
+ ## Conversion
38
+
39
+ | Item | Value |
40
+ | --- | --- |
41
+ | Toolkit | [rknn3-toolkit v1.1.0](https://github.com/airockchip/rknn3-toolkit) |
42
+ | Conversion reference | [rknn3-model-zoo MiniCPM5 example](https://github.com/airockchip/rknn3-model-zoo/tree/main/examples/MiniCPM5) |
43
+ | Targets | RK1820 and RK1828 |
44
+ | Quantization | W4A16, `normal`, `group32` |
45
+ | Output format | Weight-separated RKNN3 (`.rknn` + `.weight`) |
46
+
47
+ RKNN3 is a separate toolchain from RKLLM Toolkit, RKNN-Toolkit, and RKNN-Toolkit2. Use RKNN3 v1.1.0 runtime components and RK182x firmware that are compatible with these converted artifacts.
48
+
49
+ ## Files
50
+
51
+ ```text
52
+ .
53
+ β”œβ”€β”€ MiniCPM5-2B-w4a16.weight
54
+ β”œβ”€β”€ MiniCPM5-2B.embed.bin
55
+ β”œβ”€β”€ MiniCPM5-2B.tokenizer.gguf
56
+ β”œβ”€β”€ RK1820/
57
+ β”‚ └── MiniCPM5-2B-RK1820-w4a16.rknn
58
+ └── RK1828/
59
+ └── MiniCPM5-2B-RK1828-w4a16.rknn
60
+ ```
61
+
62
+ The tokenizer, FP16 embedding table, and W4A16 weight file are shared by both targets. The RK1820 and RK1828 conversions produced byte-identical `.weight` files, so this repository stores one copy at the root. The `.rknn` files differ and you must select the one matching your coprocessor.
63
+
64
+ | Target | RKNN graph | Shared weight | Tokenizer | Embedding |
65
+ | --- | --- | --- | --- | --- |
66
+ | RK1820 | [MiniCPM5-2B-RK1820-w4a16.rknn](RK1820/MiniCPM5-2B-RK1820-w4a16.rknn) | [MiniCPM5-2B-w4a16.weight](MiniCPM5-2B-w4a16.weight) | [MiniCPM5-2B.tokenizer.gguf](MiniCPM5-2B.tokenizer.gguf) | [MiniCPM5-2B.embed.bin](MiniCPM5-2B.embed.bin) |
67
+ | RK1828 | [MiniCPM5-2B-RK1828-w4a16.rknn](RK1828/MiniCPM5-2B-RK1828-w4a16.rknn) | [MiniCPM5-2B-w4a16.weight](MiniCPM5-2B-w4a16.weight) | [MiniCPM5-2B.tokenizer.gguf](MiniCPM5-2B.tokenizer.gguf) | [MiniCPM5-2B.embed.bin](MiniCPM5-2B.embed.bin) |
68
+
69
+ Keep all four files from this repository revision together. A model graph or weight from a different conversion may be incompatible even when its filename looks similar.
70
+
71
+ ## Download
72
+
73
+ Install the current Hugging Face CLI and download the complete repository:
74
+
75
+ ```bash
76
+ hf download HanzoHuang/MiniCPM5-2B-RKNN3 \
77
+ --local-dir MiniCPM5-2B-RKNN3
78
+ ```
79
+
80
+ To download only the RK1820 runtime set:
81
+
82
+ ```bash
83
+ hf download HanzoHuang/MiniCPM5-2B-RKNN3 \
84
+ RK1820/MiniCPM5-2B-RK1820-w4a16.rknn \
85
+ MiniCPM5-2B-w4a16.weight \
86
+ MiniCPM5-2B.tokenizer.gguf \
87
+ MiniCPM5-2B.embed.bin \
88
+ --local-dir MiniCPM5-2B-RKNN3
89
+ ```
90
+
91
+ Replace `RK1820` with `RK1828` and use the corresponding filename for an RK1828 deployment.
92
+
93
+ ## Run with rkllm3-server
94
+
95
+ The official `rkllm3-server` accepts the graph, separated weight, tokenizer, and embedding as explicit paths. For RK1820:
96
+
97
+ ```bash
98
+ /usr/bin/rkllm3-server \
99
+ -m MiniCPM5-2B-RKNN3/RK1820/MiniCPM5-2B-RK1820-w4a16.rknn \
100
+ --weight MiniCPM5-2B-RKNN3/MiniCPM5-2B-w4a16.weight \
101
+ --vocab MiniCPM5-2B-RKNN3/MiniCPM5-2B.tokenizer.gguf \
102
+ --embed MiniCPM5-2B-RKNN3/MiniCPM5-2B.embed.bin
103
+ ```
104
+
105
+ For RK1828, change only the graph path:
106
+
107
+ ```bash
108
+ -m MiniCPM5-2B-RKNN3/RK1828/MiniCPM5-2B-RK1828-w4a16.rknn
109
+ ```
110
+
111
+ Use the server binary, RKNN3 Runtime libraries, transfer proxy, and RK182x firmware supplied for the same compatible RKNN3 release. RK1820/RK1828 operate as coprocessors and require a supported host platform and connection method.
112
+
113
+ ## Run the rknn3-model-zoo C++ demo
114
+
115
+ Build and deploy the official MiniCPM5 example as described by the [rknn3-model-zoo](https://github.com/airockchip/rknn3-model-zoo/tree/main/examples/MiniCPM5). From the deployed demo directory, an RK1820 invocation is:
116
+
117
+ ```bash
118
+ export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
119
+
120
+ ./rknn_minicpm5_demo \
121
+ /path/to/MiniCPM5-2B-RKNN3/RK1820/MiniCPM5-2B-RK1820-w4a16.rknn \
122
+ /path/to/MiniCPM5-2B-RKNN3/MiniCPM5-2B-w4a16.weight \
123
+ /path/to/MiniCPM5-2B-RKNN3/MiniCPM5-2B.tokenizer.gguf \
124
+ /path/to/MiniCPM5-2B-RKNN3/MiniCPM5-2B.embed.bin \
125
+ 0xff \
126
+ "Explain the theory of relativity"
127
+ ```
128
+
129
+ For RK1828, select the graph under `RK1828/`. The `0xff` argument is the NPU core mask used in Rockchip's example; adjust it for your deployment when necessary.
130
+
131
+ ## Compatibility and limitations
132
+
133
+ - These files require the RKNN3 software stack. They cannot be loaded by Transformers, llama.cpp, the legacy RKLLM Runtime, RKNN-Toolkit, or RKNN-Toolkit2.
134
+ - The `.rknn` graph is target-specific. Do not use the RK1820 graph on RK1828 or the RK1828 graph on RK1820.
135
+ - The root `.weight`, `.tokenizer.gguf`, and `.embed.bin` files are shared by the two graphs in this repository revision.
136
+ - Quantization can change generation quality relative to the upstream BF16 model. Validate accuracy and performance for your application.
137
+ - Runtime behavior depends on the installed RKNN3 Runtime, host software, transfer method, and RK182x firmware.
138
+
139
+ ## References and acknowledgements
140
+
141
+ - [MiniCPM5-2B by OpenBMB](https://huggingface.co/openbmb/MiniCPM5-2B)
142
+ - [Rockchip rknn3-toolkit](https://github.com/airockchip/rknn3-toolkit)
143
+ - [Rockchip rknn3-model-zoo](https://github.com/airockchip/rknn3-model-zoo)
144
+ - [MiniCPM5 conversion and deployment example](https://github.com/airockchip/rknn3-model-zoo/tree/main/examples/MiniCPM5)
145
+
146
+ Thanks to OpenBMB, Rockchip, and the RKNN community.