创建茴香豆专用虚拟环境并激活
安装茴香豆
下载茴香豆
cd /root
# 克隆代码仓库
git clone https://github.com/internlm/huixiangdou && cd huixiangdou
git checkout 79fa810
安装茴香豆所需依赖
conda activate huixiangdou
# parsing `word` format requirements
apt update
apt install python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils pstotext tesseract-ocr flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig libpulse-dev
# python requirements
pip install BCEmbedding==0.15 cmake==3.30.2 lit==18.1.8 sentencepiece==0.2.0 protobuf==5.27.3 accelerate==0.33.0
pip install -r requirements.txt
# python3.8 安装 faiss-gpu 而不是 faiss
安装依赖完成
下载模型文件
# 创建模型文件夹
cd /root && mkdir models
# 复制BCE模型
ln -s /root/share/new_models/maidalun1020/bce-embedding-base_v1 /root/models/bce-embedding-base_v1
ln -s /root/share/new_models/maidalun1020/bce-reranker-base_v1 /root/models/bce-reranker-base_v1
# 复制大模型参数(下面的模型,根据作业进度和任务进行**选择一个**就行)
ln -s /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-7b /root/models/internlm2-chat-7b
更改配置文件,运行以下指令
sed -i '9s#.*#embedding_model_path = "/root/models/bce-embedding-base_v1"#' /root/huixiangdou/config.ini
sed -i '15s#.*#reranker_model_path = "/root/models/bce-reranker-base_v1"#' /root/huixiangdou/config.ini
sed -i '43s#.*#local_llm_path = "/root/models/internlm2-chat-7b"#' /root/huixiangdou/config.ini
知识库创建
选用的是茴香豆和 MMPose 的文档,利用茴香豆搭建一个茴香豆和 MMPose 的知识问答助手
conda activate huixiangdou
cd /root/huixiangdou && mkdir repodir
git clone https://github.com/internlm/huixiangdou --depth=1 repodir/huixiangdou
git clone https://github.com/open-mmlab/mmpose --depth=1 repodir/mmpose
# Save the features of repodir to workdir, and update the positive and negative example thresholds into `config.ini`
mkdir workdir
python3 -m huixiangdou.service.feature_store
在 huixiangdou 文件加下创建 repodir 文件夹,用来储存知识库原始文档。再创建一个文件夹 workdir 用来存放原始文档特征提取到的向量知识库
完成
测试知识助手
命令行运行
conda activate huixiangdou
cd /root/huixiangdou
python3 -m huixiangdou.main --standalone
Gradio UI 界面测试
建立本地和服务器之间的透传
ssh -CNg -L 7860:127.0.0.1:7860 root@ssh.intern-ai.org.cn -p 42374
启动茴香豆 Web UI
conda activate huixiangdou
cd /root/huixiangdou
python3 -m huixiangdou.gradio
正在启动中...
启动成功
问答效果展示
更换知识库,加入AnimateAnyone相关内容
使茴香豆和 AnimateAnyone还有mmpose的文档,利用茴香豆搭建一个茴香豆和AnimateAnyone还有mmpose的知识问答助手
git clone https://github.com/MooreThreads/Moore-AnimateAnyone --depth=1 repodir/AnimateAnyone
创建知识库
python3 -m huixiangdou.service.feature_store
创建完成
启动茴香豆Web UI
python3 -m huixiangdou.gradio
问答效果如下