3ib0n commited on
Commit
ca0b724
·
verified ·
1 Parent(s): cc788ed

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ 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
+ Qwen2.5-14B-Instruct.rkllm filter=lfs diff=lfs merge=lfs -text
37
+ demo_Linux_aarch64/lib/librkllmrt.so filter=lfs diff=lfs merge=lfs -text
38
+ demo_Linux_aarch64/lib/librknnrt.so filter=lfs diff=lfs merge=lfs -text
Qwen2.5-14B-Instruct.rkllm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebdf5fc0176ec42d6db7fb1debc726471dc234532e6f3ce7809486a8cc9c946b
3
+ size 15595364468
README.md ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - Qwen/Qwen2.5-14B
4
+ pipeline_tag: text-generation
5
+ library_name: transformers
6
+ tags:
7
+ - rknn
8
+ - rkllm
9
+ - chat
10
+ - rk3588
11
+ ---
12
+ ## 3ib0n's RKLLM Guide
13
+ These models and binaries require an RK3588 board running rknpu driver version 0.9.7 or above
14
+
15
+ ## Steps to reproduce conversion
16
+ ```shell
17
+ # Download and setup miniforge3
18
+ curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
19
+ bash Miniforge3-$(uname)-$(uname -m).sh
20
+
21
+ # activate the base environment
22
+ source ~/miniforge3/bin/activate
23
+
24
+ # create and activate a python 3.8 environment
25
+ conda create -n rknn-llm-1.1.4 python=3.8
26
+ conda activate rknn-llm-1.1.4
27
+
28
+ # clone the lastest rknn-llm toolkit
29
+ git clone https://github.com/airockchip/rknn-llm.git
30
+
31
+ # intstall dependencies for the toolkit
32
+ pip install transformers accelerate torchvision rknn-toolkit2==2.2.1
33
+ pip install --upgrade torch pillow
34
+
35
+ # install rkllm
36
+ pip install ../../rkllm-toolkit/packages/rkllm_toolkit-1.1.4-cp38-cp38-linux_x86_64.whl
37
+
38
+ # edit or create a script to export rkllm models
39
+ cd rknn-llm/examples/rkllm_multimodal_demo
40
+ nano export/export_rkllm.py # update input and output paths
41
+ python export/export_rkllm.py
42
+ ```
43
+
44
+ Example export_rkllm.py modified from https://github.com/airockchip/rknn-llm/blob/main/examples/rkllm_multimodel_demo/export/export_rkllm.py
45
+ ```python
46
+ import os
47
+ from rkllm.api import RKLLM
48
+ from datasets import load_dataset
49
+ from transformers import AutoTokenizer
50
+ from tqdm import tqdm
51
+ import torch
52
+ from torch import nn
53
+
54
+ modelpath = "~/models/Qwen/Qwen2.5-14B-Instruct/" ## UPDATE HERE
55
+ savepath = './Qwen2.5-14B-Instruct.rkllm' ## UPDATE HERE
56
+ llm = RKLLM()
57
+
58
+ # Load model
59
+ # Use 'export CUDA_VISIBLE_DEVICES=2' to specify GPU device
60
+ ret = llm.load_huggingface(model=modelpath, device='cpu')
61
+ if ret != 0:
62
+ print('Load model failed!')
63
+ exit(ret)
64
+
65
+ # Build model
66
+ qparams = None
67
+
68
+ ## Do not use the dataset parameter as we are converting a pure text model, not a multimodal
69
+ ret = llm.build(do_quantization=True, optimization_level=1, quantized_dtype='w8a8',
70
+ quantized_algorithm='normal', target_platform='rk3588', num_npu_core=3, extra_qparams=qparams)
71
+
72
+ if ret != 0:
73
+ print('Build model failed!')
74
+ exit(ret)
75
+
76
+ # # Export rkllm model
77
+ ret = llm.export_rkllm(savepath)
78
+ if ret != 0:
79
+ print('Export model failed!')
80
+ exit(ret)
81
+ ```
82
+
83
+ ## Steps to build and run demo
84
+
85
+ ```shell
86
+ # Dwonload the correct toolchain for working with rkllm
87
+ # Documentation here: https://github.com/airockchip/rknn-llm/blob/main/doc/Rockchip_RKLLM_SDK_EN_1.1.0.pdf
88
+ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu.tar.xz
89
+ tar -xz gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu.tar.xz
90
+
91
+ # ensure that the gcc compiler path is set to the location where the toolchain dowloaded earlier is unpacked
92
+ nano deploy/build-linux.sh # update the gcc compiler path
93
+
94
+ # compile the demo app
95
+ cd delpoy/
96
+ ./build-linux.sh
97
+ ```
98
+
99
+ ## Steps to run the app
100
+ More information and original guide: https://github.com/airockchip/rknn-llm/tree/main/examples/rkllm_multimodel_demo
101
+ ```shell
102
+ # push install dir to device
103
+ adb push ./install/demo_Linux_aarch64 /data
104
+ # push model file to device
105
+ adb push Qwen2.5-14B-Instruct.rkllm /data/models
106
+
107
+ adb shell
108
+ cd /data/demo_Linux_aarch64
109
+ # export lib path
110
+ export LD_LIBRARY_PATH=./lib
111
+ # soft link models dir
112
+ ln -s /data/models .
113
+ # run llm(Pure Text Example)
114
+ ./llm models/Qwen2.5-14B-Instruct.rkllm 128 512
115
+ ```
demo_Linux_aarch64/lib/librkllmrt.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cef353105c3bfd31f99c4963fce8498d2fac633d845633c904f523b7c3bcd0a
3
+ size 6239192
demo_Linux_aarch64/lib/librknnrt.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1170e5f99f2db7ed4d3a4c2bdbed941b7363bd090e0c28b4e210f40614327911
3
+ size 7192616
demo_Linux_aarch64/llm ADDED
Binary file (30.3 kB). View file