LangChain-Chatchat部署
离线知识库问答模型Windows环境部署使用
1. 安装ChatGLM2
1.1 创建conda环境
conda create -n chatglm2 python=3.9
conda activate chatglm2
1.2 安装依赖
git clone https://github.com/THUDM/ChatGLM2-6B.git
cd ChatGLM2-6B\
pip install -r requirements.txt
如果有必要安装对应cuda版本的torch
pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu118
2. 下载模型
2.1 ChatGLM2-6b语言模型
git lfs install
git clone https://www.modelscope.cn/ZhipuAI/chatglm2-6b.git
2.2 m3e嵌入模型
git clone https://www.modelscope.cn/xrunda/m3e-base.git
2.3 text2vec嵌入模型(可选)
git clone https://www.modelscope.cn/Jerry0/text2vec-large-chinese.git
3. 安装LangChain-Chatchat
3.1 下载
git clone https://github.com/chatchat-space/Langchain-Chatchat.git
3.2 安装依赖
cd Langchain-Chatchat\
pip install -r requirements.txt
pip install -r requirements_api.txt
pip install -r requirements_webui.txt
3.4 生成配置
python copy_config_example.py
3.5 修改模型路径
编辑文件configs/model_config.py,修改为下载模型的路径。
MODEL_PATH = {
……
# "m3e-base": "moka-ai/m3e-base",
"m3e-base": "../model/m3e-base",
……
# "chatglm2-6b": "THUDM/chatglm2-6b",
"chatglm2-6b": "../model/chatglm2-6b",
}
……
3.6 运行
生成知识库db
python init_database.py --recreate-vs
3.7 全部运行
python startup.py -a
3.8 使用
如果一切正常,可以打开Web开始使用。 http://127.0.0.1:8501/
4. 其他配置
4.1 开启局域网访问
修改configs/server_config.py
#DEFAULT_BIND_HOST = "0.0.0.0" if sys.platform != "win32" else "127.0.0.1"
DEFAULT_BIND_HOST = "0.0.0.0"
4.2 开启8bit量化
修改configs/server_config.py
FSCHAT_MODEL_WORKERS = {
"default": {
# "load_8bit": False, # 开启8bit量化
"load_8bit": True,
}
}
Last modified on 2023-11-20