大模型部署手记(21)Windows+ChatGLM3

听说 ChatGLM3发布了。张小白就想着在Windows上试一试:

先安装Git Large File Storage:

打开 git-lfs.github.com

点击Download

安装下载好的文件:

打开Git Bash:

执行:git lfs install

至此,Git LFS安装成功。

cd /f/

git clone https://huggingface.co/THUDM/chatglm3-6b

由于众所周知的原因,这条路不通。

只能从modelscope走走看了:

打开 https://modelscope.cn/models/ZhipuAI/chatglm3-6b/summary

打开 Anaconda PowerShell Prompt

conda activate model310

F:

进入python命令行,执行:

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

下载好的模型文件放到了 C:\Users\xishu\.cache\modelscope\hub\ZhipuAI\chatglm3-6b

将其挪到 F:\models\THUDM\chatglm3-6b

回到 F:\

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

没办法,只好下载zip包后解压:

cd F:\ChatGLM3-main

conda deactivate

conda create -n chatglm3 python=3.10

conda activate chatglm3

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

这里肯定安装了torch 2.1.0的CPU版本,记得要用 conda改成 GPU版本。

打开

根据:

conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

pip install chardet

在Python命令行执行以下脚本:

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("\\models\\THUDM\\chatglm3-6b", trust_remote_code=True)
model = AutoModel.from_pretrained("\\models\\THUDM\\chatglm3-6b", trust_remote_code=True, device='cuda')
model = model.eval()
response, history = model.chat(tokenizer, "你好", history=[])
print(response)
response, history = model.chat(tokenizer, "你能做什么", history=history)
print(response)
response, history = model.chat(tokenizer, "告诉我阿甘正传是一部什么电影", history=history)
print(response)

pip install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install jupyterlab -i https://pypi.tuna.tsinghua.edu.cn/simple

cd composite_demo

修改client.py

MODEL_PATH = os.environ.get('MODEL_PATH', 'THUDM/chatglm3-6b')

改为

MODEL_PATH = "\\models\\THUDM\\chatglm3-6b"

streamlit run main.py

浏览器自动弹出:

切换到Tool:

下面来试一下ChatGLM3能否嵌入到 LongChain-ChatChat中。

打开配置文件 F:\Langchain-Chatchat\configs\model_config.py

增加以下内容:

切换到chatchat conda环境

conda deactivate

conda activate chatchat

F:

cd \Langchain-Chatchat

python startup.py --all-webui

弹出窗口后,切换到 LLM对话模式:

居然能显示Latex公式。

百度了下 方程式:

这个回答得对吗?

(全文完,谢谢阅读)

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张小白TWO

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值