Upload folder using huggingface_hub
Browse files- .gitattributes +3 -0
- Export.py +111 -0
- OrpheusRkllm.ipynb +0 -0
- orpheus_3b_0.1_ft_w8a8_3588.rkllm +3 -0
.gitattributes
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
@@ -33,3 +35,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
|
|
|
|
1 |
+
*.rkllm filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.RKLLM filter=lfs diff=lfs merge=lfs -text
|
3 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
4 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
5 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
35 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
36 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
37 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
38 |
+
orpheus_3b_0.1_ft_w8a8_RK3588.rkllm filter=lfs diff=lfs merge=lfs -text
|
Export.py
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
try:
|
2 |
+
from rkllm.api import RKLLM
|
3 |
+
except ImportError:
|
4 |
+
print("RKLLM not installed. Please install from wheel 'https://github.com/airockchip/rknn-llm'.")
|
5 |
+
|
6 |
+
|
7 |
+
llm = RKLLM()
|
8 |
+
from getpass import getpass
|
9 |
+
from huggingface_hub import snapshot_download, hf_hub_download
|
10 |
+
|
11 |
+
def DownloadLoraModel(token) :
|
12 |
+
|
13 |
+
repo_id = "Prince-1/orpheus-3b-0.1-ft_4_25"
|
14 |
+
local_dir = "OrpheusLora" # "/content/OrpheusLora" # Choose a local directory
|
15 |
+
print("Downloading Lora model from Hugging Face Hub...")
|
16 |
+
|
17 |
+
snapshot_download(repo_id=repo_id, local_dir=local_dir, token= token) #userdata.get("HF_TOKEN"))
|
18 |
+
print("Lora model downloaded successfully.")
|
19 |
+
|
20 |
+
print("Downloading main model from Hugging Face Hub...")
|
21 |
+
repo_id = "unsloth/orpheus-3b-0.1-ft-unsloth-bnb-4bit"
|
22 |
+
local_dir = "OrpheusMain" #"/content/OrpheusMain" # Choose a local directory
|
23 |
+
snapshot_download(repo_id=repo_id, local_dir=local_dir, token= token)#userdata.get("HF_TOKEN"))
|
24 |
+
print("Main model downloaded successfully.")
|
25 |
+
|
26 |
+
|
27 |
+
return ("OrpheusMain","OrpheusLora")
|
28 |
+
|
29 |
+
def DownloadGGUF(token) :
|
30 |
+
print("Downloading GGUF model from Hugging Face Hub...")
|
31 |
+
path = hf_hub_download(repo_id="Prince-1/orpheus_3b_0.1_GGUF", filename="unsloth.F16.gguf",token= token,local_dir="GGUF")
|
32 |
+
print("GGUF model downloaded successfully.")
|
33 |
+
return path
|
34 |
+
|
35 |
+
|
36 |
+
def UsingHf(llm,modelpath,modelLora) :
|
37 |
+
|
38 |
+
print("Loading model...")
|
39 |
+
print(modelpath,modelLora)
|
40 |
+
ret = llm.load_huggingface(model=modelpath, model_lora = modelLora,device='cpu')
|
41 |
+
|
42 |
+
if ret != 0:
|
43 |
+
print('Load model failed!')
|
44 |
+
exit(ret)
|
45 |
+
return llm
|
46 |
+
|
47 |
+
def UsingGGUF(llm,modelpath) :
|
48 |
+
print("Loading model...")
|
49 |
+
ret = llm.load_gguf(model=modelpath)
|
50 |
+
|
51 |
+
if ret != 0:
|
52 |
+
print('Load model failed!')
|
53 |
+
exit(ret)
|
54 |
+
return llm
|
55 |
+
|
56 |
+
|
57 |
+
password = getpass("Please Enter your Hugging Face Token: ")
|
58 |
+
if password == "" :
|
59 |
+
print("No token provided.")
|
60 |
+
exit(1)
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
while True :
|
65 |
+
print("Do you want to download Lora model or GGUF model ?")
|
66 |
+
print("1. Lora")
|
67 |
+
print("2. GGUF")
|
68 |
+
i = input()
|
69 |
+
if i == "1" :
|
70 |
+
main,lora = DownloadLoraModel(password)
|
71 |
+
UsingHf(llm,main,lora)
|
72 |
+
|
73 |
+
break
|
74 |
+
elif i == "2" :
|
75 |
+
gguf = DownloadGGUF(password)
|
76 |
+
UsingGGUF(llm,gguf)
|
77 |
+
break
|
78 |
+
else :
|
79 |
+
print("Invalid input. Please enter 1 or 2.")
|
80 |
+
continue
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
# Build model
|
85 |
+
dataset = None
|
86 |
+
qparams = None
|
87 |
+
target_platform = "RK3588"
|
88 |
+
optimization_level = 1
|
89 |
+
quantized_dtype = "w8a8" #"w4a16_g32" #w4a16_g64 or w4a16_g128
|
90 |
+
quantized_algorithm = "normal"
|
91 |
+
num_npu_core = 3
|
92 |
+
|
93 |
+
print("Building model...")
|
94 |
+
ret = llm.build(
|
95 |
+
do_quantization=False,optimization_level=optimization_level,
|
96 |
+
quantized_dtype=quantized_dtype,quantized_algorithm=quantized_algorithm,
|
97 |
+
target_platform=target_platform, num_npu_core=num_npu_core,
|
98 |
+
extra_qparams=qparams, dataset=dataset)
|
99 |
+
if ret != 0:
|
100 |
+
print('Build model failed!')
|
101 |
+
exit(ret)
|
102 |
+
|
103 |
+
print("Model Build successfully.")
|
104 |
+
|
105 |
+
# Export rkllm model
|
106 |
+
ret =llm.export_rkllm(f"orpheus_3b_0.1_ft_{quantized_dtype}_{target_platform[2:]}.rkllm")
|
107 |
+
if ret != 0:
|
108 |
+
print('Export model failed!')
|
109 |
+
exit(ret)
|
110 |
+
|
111 |
+
print("Model Export successfully.")
|
OrpheusRkllm.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
orpheus_3b_0.1_ft_w8a8_3588.rkllm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d4c4cd27fabfd8b3d2930065c4e0c59023afcfb4fda71269af3df3e398da2e61
|
3 |
+
size 7596587780
|