Chars commited on
Commit
ec83eae
1 Parent(s): 51f0a30

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +56 -0
README.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+
6
+ # ChatGLM3-32k 模型量化
7
+
8
+ 本项目用于演示如何使用 ChatGLM3-6b-32k 模型,并通过 ChatGLM.cpp 工具仓库对模型进行量化。
9
+
10
+
11
+ ## 拉取模型和工具仓库
12
+
13
+ 首先,需要将 ChatGLM3-6b-32k 模型和 ChatGLM.cpp 工具仓库拉取到本地:
14
+
15
+ ```shell
16
+ git lfs install
17
+ git clone https://huggingface.co/THUDM/chatglm3-6b-32k
18
+ git clone https://github.com/li-plus/chatglm.cpp.git
19
+ ```
20
+
21
+
22
+ ## 安装依赖
23
+
24
+ 在开始量化之前,请确保已安装以下依赖项:
25
+
26
+ ```shell
27
+ python3 -m pip install -U -q pip
28
+ python3 -m pip install -q torch tabulate tqdm transformers accelerate sentencepiece
29
+ ```
30
+
31
+
32
+ ## 模型量化
33
+
34
+ 使用 ChatGLM.cpp 工具仓库中的 `convert.py` 脚本,可以对 ChatGLM3-6b-32k 模型进行量化。
35
+
36
+ ```shell
37
+ types=("q4_0" "q4_1" "q5_0" "q5_1" "q8_0")
38
+
39
+ for type_str in "${types[@]}"; do
40
+ python3 ./chatglm.cpp/chatglm_cpp/convert.py -i ./chatglm3-6b-32k -t ${type_str} -o chatglm3-32k-ggml-${type_str}.bin
41
+ done
42
+ ```
43
+
44
+ 上述代码会对 ChatGLM3-32k 模型进行多个量化操作,并生成对应的量化模型文件。量化类型包括:"q4_0"、"q4_1"、"q5_0"、"q5_1" 和 "q8_0"。
45
+
46
+ 请确保已在终端中切换到正确的工作目录,然后执行上述代码段。
47
+
48
+ 量化后的模型文件将以 `chatglm3-32k-ggml-{type_str}.bin` 的形式保存在当前目录下。
49
+
50
+ ---
51
+
52
+ 如果您有任何问题,请随时联系我们。
53
+
54
+ 模型地址:[https://huggingface.co/THUDM/chatglm3-6b-32k](https://huggingface.co/THUDM/chatglm3-6b-32k)
55
+
56
+ 工具仓库地址:[https://github.com/li-plus/chatglm.cpp](https://github.com/li-plus/chatglm.cpp)