Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,137 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
base_model:
|
6 |
+
- openbmb/MiniCPM4-0.5B
|
7 |
+
pipeline_tag: text2text-generation
|
8 |
+
tags:
|
9 |
+
- minicpm4
|
10 |
+
- int8
|
11 |
+
---
|
12 |
+
|
13 |
+
|
14 |
+
# MiniCPM4-0.5B-Int8
|
15 |
+
|
16 |
+
This version of MiniCPM4-0.5B has been converted to run on the Axera NPU using **w8a16** quantization.
|
17 |
+
|
18 |
+
This model has been optimized with the following LoRA:
|
19 |
+
|
20 |
+
Compatible with Pulsar2 version: 4.1(Not released yet)
|
21 |
+
|
22 |
+
## Convert tools links:
|
23 |
+
|
24 |
+
For those who are interested in model conversion, you can try to export axmodel through the original repo :
|
25 |
+
https://huggingface.co/openbmb/MiniCPM4-0.5B
|
26 |
+
|
27 |
+
[Pulsar2 Link, How to Convert LLM from Huggingface to axmodel](https://pulsar2-docs.readthedocs.io/en/latest/appendix/build_llm.html)
|
28 |
+
|
29 |
+
[AXera NPU LLM Runtime](https://github.com/AXERA-TECH/ax-llm)
|
30 |
+
|
31 |
+
|
32 |
+
## Support Platform
|
33 |
+
|
34 |
+
- AX650
|
35 |
+
- [M4N-Dock(爱芯派Pro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html)
|
36 |
+
- [M.2 Accelerator card](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_guide_hardware.html)
|
37 |
+
- AX630C
|
38 |
+
- *developing*
|
39 |
+
|
40 |
+
|Chips|w8a16|w4a16|
|
41 |
+
|--|--|--|
|
42 |
+
|AX650| 36 tokens/sec|TBD|
|
43 |
+
|
44 |
+
## How to use
|
45 |
+
|
46 |
+
Download all files from this repository to the device
|
47 |
+
|
48 |
+
```
|
49 |
+
root@ax650:/mnt/qtang/llm-test/minicpm4-0.5b-ctx# tree -L 1
|
50 |
+
.
|
51 |
+
|-- main_ax650
|
52 |
+
|-- main_axcl_aarch64
|
53 |
+
|-- main_axcl_x86
|
54 |
+
|-- minicpm4-0.5b-int8-ctx-ax650
|
55 |
+
|-- minicpm4_tokenizer
|
56 |
+
|-- minicpm4_tokenizer_uid.py
|
57 |
+
|-- post_config.json
|
58 |
+
|-- run_minicpm4_0.5b_int8_ctx_ax650.sh
|
59 |
+
`-- run_minicpm4_0.5b_int8_ctx_axcl_x86.sh
|
60 |
+
2 directories, 7 files
|
61 |
+
```
|
62 |
+
|
63 |
+
#### Start the Tokenizer service
|
64 |
+
|
65 |
+
Install requirement
|
66 |
+
|
67 |
+
```
|
68 |
+
pip install transformers jinja2
|
69 |
+
```
|
70 |
+
|
71 |
+
```
|
72 |
+
root@ax650:/mnt/qtang/llm-test/minicpm4-0.5b-ctx# python3 minicpm4_tokenizer_uid.py
|
73 |
+
Server running at http://0.0.0.0:12345
|
74 |
+
```
|
75 |
+
|
76 |
+
#### Inference with AX650 Host, such as M4N-Dock(爱芯派Pro) or AX650N DEMO Board
|
77 |
+
|
78 |
+
Open another terminal and run `run_minicpm4_0.5b_int8_ctx_ax650.sh`
|
79 |
+
|
80 |
+
```
|
81 |
+
root@ax650:/mnt/qtang/llm-test/minicpm4-0.5b-ctx# ./run_minicpm4_0.5b_int8_ctx_ax650.sh
|
82 |
+
[I][ Init][ 110]: LLM init start
|
83 |
+
[I][ Init][ 34]: connect http://127.0.0.1:12345 ok
|
84 |
+
[I][ Init][ 57]: uid: c779ded0-ff14-4877-869b-1aacc948f2d8
|
85 |
+
bos_id: 1, eos_id: 73440
|
86 |
+
100% | ████████████████████████████████ | 27 / 27 [2.53s<2.53s, 10.67 count/s] init post axmodel ok,remain_cmm(4244 MB)
|
87 |
+
[I][ Init][ 188]: max_token_len : 1023
|
88 |
+
[I][ Init][ 193]: kv_cache_size : 128, kv_cache_num: 1023
|
89 |
+
[I][ Init][ 201]: prefill_token_num : 128
|
90 |
+
[I][ Init][ 205]: grp: 1, prefill_max_token_num : 1
|
91 |
+
[I][ Init][ 205]: grp: 2, prefill_max_token_num : 128
|
92 |
+
[I][ Init][ 205]: grp: 3, prefill_max_token_num : 512
|
93 |
+
[I][ Init][ 209]: prefill_max_token_num : 512
|
94 |
+
[I][ load_config][ 282]: load config:
|
95 |
+
{
|
96 |
+
"enable_repetition_penalty": false,
|
97 |
+
"enable_temperature": false,
|
98 |
+
"enable_top_k_sampling": true,
|
99 |
+
"enable_top_p_sampling": false,
|
100 |
+
"penalty_window": 20,
|
101 |
+
"repetition_penalty": 1.2,
|
102 |
+
"temperature": 0.9,
|
103 |
+
"top_k": 1,
|
104 |
+
"top_p": 0.8
|
105 |
+
}
|
106 |
+
|
107 |
+
[I][ Init][ 218]: LLM init ok
|
108 |
+
Type "q" to exit, Ctrl+c to stop current running
|
109 |
+
[I][ GenerateKVCachePrefill][ 271]: input token num : 25, prefill_split_num : 1 prefill_grpid : 2
|
110 |
+
[I][ GenerateKVCachePrefill][ 308]: input_num_token:25
|
111 |
+
[I][ main][ 230]: precompute_len: 25
|
112 |
+
[I][ main][ 231]: system_prompt: You are MiniCPM4, created by ModelBest. You are a helpful assistant.
|
113 |
+
prompt >> 你是谁?
|
114 |
+
[I][ SetKVCache][ 531]: prefill_grpid:2 kv_cache_num:128 precompute_len:25 input_num_token:12
|
115 |
+
[I][ SetKVCache][ 534]: current prefill_max_token_num:384
|
116 |
+
[I][ Run][ 660]: input token num : 12, prefill_split_num : 1
|
117 |
+
[I][ Run][ 686]: input_num_token:12
|
118 |
+
[I][ Run][ 829]: ttft: 147.65 ms
|
119 |
+
你好,我是MiniCPM系列模型,由面壁智能和OpenBMB开源社区开发。详细信息请访问https://github.com/OpenBMB/
|
120 |
+
|
121 |
+
[N][ Run][ 943]: hit eos,avg 35.75 token/s
|
122 |
+
|
123 |
+
[I][ GetKVCache][ 500]: precompute_len:162, remaining:350
|
124 |
+
prompt >> 9.9与9.11
|
125 |
+
[I][ SetKVCache][ 531]: prefill_grpid:3 kv_cache_num:512 precompute_len:162 input_num_token:17
|
126 |
+
[I][ SetKVCache][ 534]: current prefill_max_token_num:256
|
127 |
+
[I][ Run][ 660]: input token num : 17, prefill_split_num : 1
|
128 |
+
[I][ Run][ 686]: input_num_token:17
|
129 |
+
[I][ Run][ 829]: ttft: 274.38 ms
|
130 |
+
9.9比9.11大。
|
131 |
+
|
132 |
+
[N][ Run][ 943]: hit eos,avg 35.44 token/s
|
133 |
+
|
134 |
+
[I][ GetKVCache][ 500]: precompute_len:189, remaining:323
|
135 |
+
prompt >> q
|
136 |
+
root@ax650:/mnt/qtang/llm-test/minicpm4-0.5b-ctx#
|
137 |
+
```
|