ChatGLM3模型搭建(踩坑记录版)

参考

魔搭社区

https://zhuanlan.zhihu.com/p/720148240

智谱AI通用大模型:本地部署ChatGLM3-6B开源大模型 - 编程库

说明

搭建方式多篇文章结合着看;

模型下载强烈推荐魔塔社区下载ZhipuAI/chatglm3-6b;

官方github指定清华的模型没有config.json等文件,辣鸡;

最主要的就是模型下载比较费时间;

源码下载

踩坑:有说下载ChatGLM-6B的,不建议尝试。应该下载ChatGLM3。

目前ChatGLM3/basic_demo/web_demo_streamlit.py是可以跑通的。

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

下载技巧:若下载速度过慢,可以通过码云的"从GitHub导入仓库",然后再通过码云下载源码。

cd ChatGLM3

python依赖安装,踩坑:ChatGLMTokenizer._pad() got an unexpected keyword argument 'padding_side

解决参考:报错:"TypeError: ChatGLMTokenizer._pad() got an unexpected keyword argument 'padding_side' "-CSDN博客

参考上述链接,我将transformers调整为4.40.2,同时只安装basic所需的依赖,减少依赖安装耗时

basic requirements

#transformers==4.40.0

transformers==4.40.2

cpm_kernels>=1.0.11

torch>=2.3.0

vllm>=0.4.2

gradio>=4.26.0

sentencepiece>=0.2.0

sentence_transformers>=2.7.0

accelerate>=0.29.2

streamlit>=1.33.0

fastapi>=0.110.0

loguru~=0.7.2

mdtex2html>=1.3.0

latex2mathml>=3.77.0

jupyter_client>=8.6.1

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

模型下载

modelscope API下载(推荐)

pip install modelscope

from modelscope import snapshot_download model_dir = snapshot_download("ZhipuAI/chatglm3-6b", revision = "v1.0.0")

git下载

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

界面启动

streamlit run web_demo_stremlit.py,推荐该方式

python web_demo_gradio.py,仅能本地访问

运维脚本

bash 复制代码
# start.sh

# conda activate LLM
item_path=/home/ChatGLM3/basic_demo
nohup streamlit run $item_path'/web_demo_streamlit.py' >> $item_path'/web.log' 2>&1 &
bash 复制代码
# status.sh

item_path=/home/ChatGLM3/basic_demo
ps -aux|grep $item_path'/web_demo_streamlit.py'

nvidia-smi
bash 复制代码
# stop.sh

item_path=/home/ChatGLM3/basic_demo
kill -9 `ps -ef|grep $item_path'/web_demo_streamlit.py'|grep -v 'grep'|awk '{print $2}'`
相关推荐
承渊政道3 天前
【从零开始大模型开发与微调:基于PyTorch与ChatGLM】(从退化问题到信息高速公路:ResNet残差网络实战拆解)
网络·人工智能·pytorch·深度学习·resnet·chatglm·卷积
承渊政道10 天前
【从零开始大模型开发与微调:基于PyTorch与ChatGLM】(基于PyTorch卷积层的MNIST分类实战:从卷积直觉到高效卷积设计)
人工智能·pytorch·神经网络·分类·chatglm·卷积·大模型学习
诸神缄默不语6 个月前
如何用Python调用智谱清言GLM系API实现智能问答
python·ai·大模型·nlp·chatglm·glm·智谱清言
一碗甜汤ᐝ6 个月前
chatglm3-6b部署和微调
语言模型·大模型·微调·chatglm
橙子小哥的代码世界1 年前
【大模型部署】mac m1本地部署 ChatGLM3-6B 超详细教程
深度学习·神经网络·macos·大模型·transformer·chatglm·踩坑记录
算家云1 年前
基于Langchain-Chatchat + ChatGLM 本地部署知识库
langchain·chatglm·本地部署·chatchat·算家云·应用社区
程序员正茂2 年前
Win10本地部署大语言模型ChatGLM2-6B
人工智能·python·chatglm·大语言模型
木亦汐丫2 年前
【大模型系列篇】LLaMA-Factory大模型微调实践 - 从零开始
lora·大模型·微调·chatglm·llama·llama-factory
OT.Ter2 年前
ChatGLM2-6B微调记录【2】
chatgpt·大模型·微调·chatglm