ChatGLM-6B模型使用

一、创建环境

conda create -n chatglm python=3.8
conda activate chatglm 

二、下载代码

git clone https://github.com/THUDM/ChatGLM-6B.git

三、安装依赖

我这里是cuda11.2,根据自己的版本安装,这里是pytorch版本:https://pytorch.org/get-started/previous-versions/

pip install torch==1.10.0+cu111 torchvision==0.11.1+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
pip install -r requirement.txt

四、修改代码

vim web_demo.py
# 增加server_name和server_port参数
demo.queue().launch(share=True,server_name="0.0.0.0",server_port=9234)
# 如果gpu太小,修改如下代码
model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().quantize(4).cuda()

在这里插入图片描述

五、运行代码

python web_demo.py

六、测试

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq236237606/article/details/132043790