方式一:通过命令方式搭建
搭建该项目分为两部分:安装 xinference 框架以载入 LLM 和嵌入模型,以及配置 Langchain-Chatchat 项目。
第一步:创建 xinference 的 conda 环境
conda create -n xinference python=3.10
进入该环境:
conda activate xinference
第二步:安装 xinference 框架
pip install "xinference[transformers]" -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
拉起 xinference 服务:
XINFERENCE_HOME=自定义路径 xinference-local --host 0.0.0.0 --port 9997
详细信息请查看 xinference 官网。注意不同模型要求的引擎可能不同(如 Transformers),请根据模型查询官方文档。
第三步:装载 LLM 模型
确保模型文件完整后再加载。使用本地下载模型或参考官网自动下载。
xinference launch --model-engine Transformers --model-name qwen-chat --size-in-billions 7 --model-format pytorch --quantization none --model_path ~/.cache/modelscope/hub/Qwen/Qwen-7B-Chat
参数说明:
--model-name:固定为模型注册名,不可随意更改。--model_path:本地模型存储路径,若使用 modelscope 下载通常在~/.cache/modelscope/hub下。--model-engine:在 xinference 管理页面查看对应引擎类型。
第四步:装载嵌入模型
例如使用 bge-large-zh-v1.5:
xinference launch --model-name bge-large-zh-v1.5 --model-type embedding --model_path ~/.cache/modelscope/hub/Xorbits/bge-large-zh-v1.5
第五步:创建 chatchat 的环境
conda create -n chatchat python=3.10
conda activate chatchat
第六步:安装 Langchain-Chatchat 项目
pip install "langchain-chatchat[xinference]" -U -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
第七步:初始化项目配置与数据目录
设置 Chatchat 存储配置文件和数据文件的根目录(可选):
# Linux or macOS
export CHATCHAT_ROOT=/path/to/chatchat_data
# Windows
set CHATCHAT_ROOT=/path/to/chatchat_data


