部署文档
环境准备
项目需要Python>=3.8.1
- git clone本项目, 您可以在自己的terminal中执行:
git clone https://github.com/thomas-yanxin/LangChain-ChatGLM-Webui.git
. 若国内用户访问Github存在网络问题, 也可以执行: https://openi.pcl.ac.cn/Learning-Develop-Union/LangChain-ChatGLM-Webui.git
- 进入本项目目录:
cd LangChain-ChatGLM-Webui
- 安装依赖包:
pip install -r requirements.txt
, 国内用户可设置清华源加速下载.
另: 若您想要安装测试ModelScope版本, 需要额外安装ModelScope包: pip install modelscope==1.4.3 -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
OpenI启智社区部署推荐的Docker镜像: dockerhub.pcl.ac.cn:5000/user-images/openi:LangChain_ChatLLM
启动程序
Huggingface版本
在terminal中执行命令: python3 app.py
ModelScope版本
- 进入modelscope文件目录:
cd modelscope
- 执行命令:
python3 app.py
常见问题
模型下载问题
对于国内用户来说, 直接从HuggingFace下载模型可能会遇到网络阻碍, 您可以先通过以下链接提前将模型下载并解压到本地:
然后在 app.py
文件中对以下字段进行修改:
embedding_model_dict = {
"ernie-tiny": "your_model_path",
"ernie-base": "your_model_path",
"ernie-medium": "your_model_path",
"ernie-xbase": "your_model_path",
"text2vec": "your_model_path"
}
llm_model_dict = {
"ChatGLM-6B": "your_model_path",
"ChatGLM-6B-int4": "your_model_path",
"ChatGLM-6B-int8": "your_model_path",
"ChatGLM-6b-int4-qe": "your_model_path"
}
爆显存问题
- ChatGLM-6B 模型硬件需求
量化等级 |
最低 GPU 显存(推理) |
最低 GPU 显存(高效参数微调) |
FP16(无量化) |
13 GB |
14 GB |
INT8 |
8 GB |
9 GB |
INT4 |
6 GB |
7 GB |
若您的设备显存有限
- 可以选择
ChatGLM-6B-int8
或者 ChatGLM-6B-int4
以及选择较小的Embedding Model进行组合使用.
- 参数选择时,可以选择叫小的history进行尝试.
常见的细节问题
- 需要等文件完全上传之后再进行对话
- 若detectron2安装有问题, 可以执行:
pip install 'git+https://openi.pcl.ac.cn/Learning-Develop-Union/detectron2.git'