【笔记】在Mac上部署ChatGLM模型
前言
在Mac上部署ChatGLM模型
准备工作
- Git Large File Storage(Git LFS)
1 | brew install git-lfs |
下载模型
- 模型20多G,网速较好的情况下也需要耐心等待20分钟
1 | GIT_CURL_VERBOSE=1 git clone https://huggingface.co/THUDM/chatglm-6b |
下载依赖
1 | pip3 install protobuf "transformers==4.27.1" "cpm_kernels" "torch>=1.10" gradio mdtex2html sentencepiece accelerate |
下载MacM1适配的Torch
1 | pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu |
编写Python代码调用模型
1 | from transformers import AutoTokenizer, AutoModel |
1 | 我是一个名为 ChatGLM-6B 的人工智能助手,是基于清华大学 KEG 实验室和智谱 AI 公司于 2023 年共同训练的语言模型开发的。我的任务是针对用户的问题和要求提供适当的答复和支持。 |