基础作业:
在茴香豆 Web 版中创建自己领域的知识问答助手
在 InternLM Studio 上部署茴香豆技术助手
视频链接
文档链接
基础知识介绍:
RAG概述:RAG(Retrieval Augmented Generation)技术,通过检索与用户输入相关的信息片段,并结合外部知识库来生成更准确、更丰富的回答。解决 LLMs 在处理知识密集型任务时可能遇到的挑战, 如幻觉、知识过时和缺乏透明、可追溯的推理过程等。提供更准确的回答、降低推理成本、实现外部记忆。
RAG工作原理:
RAG常见优化方法:
RAG与微调之间的优劣比较:
一般的评估框架和基准测试:
茴香豆的简单介绍:
茴香豆的核心特性:
茴香豆的完整工作流:
作业流程:
打开 Intern Studio
界面,点击 创建开发机 配置开发机系统,使用 Cuda11.7-conda 镜像,然后在资源配置中,使用 30% A100 * 1 的选项,然后立即创建开发机器。
配置环境
依次运行以下命令:
studio-conda -o internlm-base -t InternLM2_Huixiangdou
conda env list
conda activate InternLM2_Huixiangdou
得到结果如下:
下载基础文件
命令如下:
# 创建模型文件夹
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
下载安装茴香豆
# 安装 python 依赖
# pip install -r requirements.txt
pip install protobuf==4.25.3 accelerate==0.28.0 aiohttp==3.9.3 auto-gptq==0.7.1 bcembedding==0.1.3 beautifulsoup4==4.8.2 einops==0.7.0 faiss-gpu==1.7.2 langchain==0.1.14 loguru==0.7.2 lxml_html_clean==0.1.0 openai==1.16.1 openpyxl==3.1.2 pandas==2.2.1 pydantic==2.6.4 pymupdf==1.24.1 python-docx==1.1.0 pytoml==0.1.21 readability-lxml==0.8.1 redis==5.0.3 requests==2.31.0 scikit-learn==1.4.1.post1 sentence_transformers==2.2.2 textract==1.6.5 tiktoken==0.6.0 transformers==4.39.3 transformers_stream_generator==0.0.5 unstructured==0.11.2
## 因为 Intern Studio 不支持对系统文件的永久修改,在 Intern Studio 安装部署的同学不建议安装 Word 依赖,后续的操作和作业不会涉及 Word 解析。
## 想要自己尝试解析 Word 文件的同学,uncomment 掉下面这行,安装解析 .doc .docx 必需的依赖
# apt update && apt -y install python-dev python libxml2-dev libxslt1-dev antiword unrtf poppler-utils pstotext tesseract-ocr flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig libpulse-dev
cd /root
# 下载 repo
git clone https://github.com/internlm/huixiangdou && cd huixiangdou
git checkout 447c6f7e68a1657fce1c4f7c740ea1700bde0440
使用茴香豆搭建RAG助手
修改配置文件
sed -i '6s#.*#embedding_model_path = "/root/models/bce-embedding-base_v1"#' /root/huixiangdou/config.ini
sed -i '7s#.*#reranker_model_path = "/root/models/bce-reranker-base_v1"#' /root/huixiangdou/config.ini
sed -i '29s#.*#local_llm_path = "/root/models/internlm2-chat-7b"#' /root/huixiangdou/config.ini
修改好了之后,root -> huixiangdou -> config.ini
截图如下:
创建知识库
cd /root/huixiangdou && mkdir repodir
git clone https://github.com/internlm/huixiangdou --depth=1 repodir/huixiangdou
问答
cd /root/huixiangdou
mv resource/good_questions.json resource/good_questions_bk.json
echo '[
"mmpose中怎么调用mmyolo接口",
"mmpose实现姿态估计后怎么实现行为识别",
"mmpose执行提取关键点命令不是分为两步吗,一步是目标检测,另一步是关键点提取,我现在目标检测这部分的代码是demo/topdown_demo_with_mmdet.py demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth 现在我想把这个mmdet的checkpoints换位yolo的,那么应该怎么操作",
"在mmdetection中,如何同时加载两个数据集,两个dataloader",
"如何将mmdetection2.28.2的retinanet配置文件改为单尺度的呢?",
"1.MMPose_Tutorial.ipynb、inferencer_demo.py、image_demo.py、bottomup_demo.py、body3d_pose_lifter_demo.py这几个文件和topdown_demo_with_mmdet.py的区别是什么,\n2.我如果要使用mmdet是不是就只能使用topdown_demo_with_mmdet.py文件,",
"mmpose 测试 map 一直是 0 怎么办?",
"如何使用mmpose检测人体关键点?",
"我使用的数据集是labelme标注的,我想知道mmpose的数据集都是什么样式的,全都是单目标的数据集标注,还是里边也有多目标然后进行标注",
"如何生成openmmpose的c++推理脚本",
"mmpose",
"mmpose的目标检测阶段调用的模型,一定要是demo文件夹下的文件吗,有没有其他路径下的文件",
"mmpose可以实现行为识别吗,如果要实现的话应该怎么做",
"我在mmyolo的v0.6.0 (15/8/2023)更新日志里看到了他新增了支持基于 MMPose 的 YOLOX-Pose,我现在是不是只需要在mmpose/project/yolox-Pose内做出一些设置就可以,换掉demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py 改用mmyolo来进行目标检测了",
"mac m1从源码安装的mmpose是x86_64的",
"想请教一下mmpose有没有提供可以读取外接摄像头,做3d姿态并达到实时的项目呀?",
"huixiangdou 是什么?",
"使用科研仪器需要注意什么?",
"huixiangdou 是什么?",
"茴香豆 是什么?",
"茴香豆 能部署到微信吗?",
"茴香豆 怎么应用到飞书",
"茴香豆 能部署到微信群吗?",
"茴香豆 怎么应用到飞书群",
"huixiangdou 能部署到微信吗?",
"huixiangdou 怎么应用到飞书",
"huixiangdou 能部署到微信群吗?",
"huixiangdou 怎么应用到飞书群",
"huixiangdou",
"茴香豆",
"茴香豆 有哪些应用场景",
"huixiangdou 有什么用",
"huixiangdou 的优势有哪些?",
"茴香豆 已经应用的场景",
"huixiangdou 已经应用的场景",
"huixiangdou 怎么安装",
"茴香豆 怎么安装",
"茴香豆 最新版本是什么",
"茴香豆 支持哪些大模型",
"茴香豆 支持哪些通讯软件",
"config.ini 文件怎么配置",
"remote_llm_model 可以填哪些模型?"
]' > /root/huixiangdou/resource/good_questions.json
cd /root/huixiangdou
echo '[
"huixiangdou 是什么?",
"你好,介绍下自己"
]' > ./test_queries.json
# 创建向量数据库存储目录
cd /root/huixiangdou && mkdir workdir
# 分别向量化知识语料、接受问题和拒绝问题中后保存到 workdir
python3 -m huixiangdou.service.feature_store --sample ./test_queries.json
运行茴香豆知识助手
# 填入问题
sed -i '74s/.*/ queries = ["huixiangdou 是什么?", "茴香豆怎么部署到微信群", "今天天气怎么样?"]/' /root/huixiangdou/huixiangdou/main.py
# 运行茴香豆
cd /root/huixiangdou/
python3 -m huixiangdou.main --standalone
作业一(基础知识及笔记在上面)
作业使用的文档,是我正在学习的汇编课程老师上课使用的ppt
(我将ppt
转化成了pdf
)