ChatGLM

创建日期:2024-06-21
更新日期:2025-02-01

官方网站:https://chatglm.cn/

开源项目

--ChatGLM-6B(开源):https://github.com/THUDM/ChatGLM-6B--

ChatGLM3(开源):https://github.com/THUDM/ChatGLM3

技术文档:https://zhipu-ai.feishu.cn/wiki/WvQbwIJ9tiPAxGk8ywDck6yfnof

模型下载1:https://huggingface.co/THUDM/chatglm3-6b

模型下载2:https://modelscope.cn/models/ZhipuAI/chatglm3-6b/summary

模型下载3:https://www.wisemodel.cn/models/ZhipuAI/chatglm3-6b

使用方法

1、下载开源项目。

git clone git@github.com:THUDM/ChatGLM3.git

2、下载模型。

git clone https://www.modelscope.cn/ZhipuAI/chatglm3-6b.git

3、编辑文件 ChatGLM3/tools_using_demo/cli_demo_tool.py,修改其中的模型路径。

MODEL_PATH = os.environ.get('MODEL_PATH', 'E:/github/chatglm3-6b')
TOKENIZER_PATH = os.environ.get("TOKENIZER_PATH", MODEL_PATH)

4、运行:cli_demo_tool.py。

cd tools_using_demo
python cli_demo_tool.py

加速方案

开源项目:https://github.com/li-plus/chatglm.cpp

1、下载源码和第三方依赖。

git@github.com:li-plus/chatglm.cpp.git
cd chatglm.cpp
git submodule update --init --recursive

2、安装python依赖。

pip install torch tabulate tqdm transformers accelerate sentencepiece

3、量化模型。

python chatglm_cpp/convert.py -i E:/github/chatglm3-6b -t q4_0 -o E:/github/chatglm3-6b/chatglm-ggml.bin

q4_0 表示:具有fp16标度的4位整数量化。

4、编译c++项目。

cmake -G "MinGW Makefiles" -S . -B build
cd build
make

5、启动项目。

./build/bin/main -m chatglm3-ggml.bin -p 你好 -s "You are ChatGLM3, a large language model trained by Zhipu.AI. Follow the user's instructions carefully." --top_p 0.8 --temp 0.8

其他资料

GLM-130B:https://models.aminer.cn/glm-130b/

ChatGLM微调:https://github.com/mymusise/ChatGLM-Tuning

常见问题

1、运行 ChatGLM3/tools_using_demo/cli_demo_tool.py 报错:urllib3.exceptions.ConnectTimeoutError: (, 'Connection to huggingface.co timed out. (connect timeout=10)')。

国内连不上huggingface,可以使用 modelscope 或 wisemodel 下载模型。然后编辑 ChatGLM3/tools_using_demo/cli_demo_tool.py,修改其中的模型路径。

MODEL_PATH = os.environ.get('MODEL_PATH', 'E:/github/chatglm3-6b')
TOKENIZER_PATH = os.environ.get("TOKENIZER_PATH", MODEL_PATH)

2、cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_'。

将urllib3降级到1.x.x版本即可。

pip install --no-cache-dir urllib3<2