本地搭建检索增强生成(RAG)大模型知识库项目

创建单独的python环境

conda create -n python311 python=3.11.7

conda activate python311

拉取仓库

git clone https://github.com/chatchat-space/Langchain-Chatchat.git

如果下载不了,本地运行代理 v2ray -config config.json

#git设置代理

git config --global http.proxy 127.0.0.1:1090

#取消代理

git config --global --unset http.proxy

进入目录

cd Langchain-Chatchat

安装全部依赖

pip install -r requirements.txt

pip install -r requirements_api.txt

pip install -r requirements_webui.txt

为了支持离线下载

pip install -U huggingface_hub

编辑环境变量

vim ~/.bashrc

在末尾加上

export HF_ENDPOINT=https://hf-mirror.com

使环境变量生效

source ~/.bashrc

下载模型

huggingface-cli download --resume-download THUDM/chatglm3-6b --local-dir chatglm3-6b

huggingface-cli download --resume-download BAAI/bge-large-zh --local-dir bge-large-zh

快速复制配置文件

python copy_config_example.py

修改配置文件

vim configs/model_config.py

修改model目录

MODEL_ROOT_PATH = ""

改为

MODEL_ROOT_PATH = "/root/model"

修改模型,对embedding_model_dict和llm_model_dict参数进行修改。

embedding_model_dict = {

"ernie-tiny": "nghuyong/ernie-3.0-nano-zh",

"ernie-base": "nghuyong/ernie-3.0-base-zh",

"text2vec": "/your_path/text2vec"

}

llm_model_dict = {

"chatyuan": "ClueAI/ChatYuan-large-v2",

"chatglm-6b-int4-qe": "THUDM/chatglm-6b-int4-qe",

"chatglm-6b-int4": "THUDM/chatglm-6b-int4",

"chatglm-6b-int8": "THUDM/chatglm-6b-int8",

"chatglm-6b": "/your_path/chatglm-6b", }

我的text2vec 路径是 /root/model/bge-large-zh

我的chatglm-6b 路径是 /root/model/chatglm3-6b

初始化自己的知识库

python init_database.py --recreate-vs

轻量级启动,使用在线模型和emddings,这个有webui界面操作

python startup.py -a --lite

更加轻量启动,只启动api相关

python startup.py --all-api

参考链接:

1.离线下载huggingface模型

https://blog.csdn.net/weixin_43431218/article/details/135403324

2.基于 ChatGLM-6B 搭建个人专属知识库

https://developer.aliyun.com/article/1212941?spm=a2c6h.12873639.article-detail.7.5b5b1ca7PgM0ht

3.项目文档

https://github.com/chatchat-space/Langchain-Chatchat/wiki/

相关推荐
uncle_ll12 小时前
RAG 系统性能跃迁:LlamaIndex 索引优化实战指南
llm·rag·检索·llamaindex
uncle_ll16 小时前
Milvus介绍及多模态检索实践:从部署到实战全解析
milvus·多模态·向量数据库·ann·rag·搜索·检索
猿小羽1 天前
AIGC 应用工程师(3-5 年)面试题精讲:从基础到实战的系统备战清单
面试·大模型·aigc·agent·rag
大傻^1 天前
RAG检索增强生成深度解析:从召回率瓶颈到企业级落地实践
rag·检索增强生成
OPEN-Source1 天前
大模型实战:搭建一张“看得懂”的大模型应用可观测看板
人工智能·python·langchain·rag·deepseek
爱喝白开水a2 天前
前端AI自动化测试:brower-use调研让大模型帮你做网页交互与测试
前端·人工智能·大模型·prompt·交互·agent·rag
落霞的思绪2 天前
GIS大模型RAG知识库
agent·rag
梵得儿SHI2 天前
(第十篇)Spring AI 核心技术攻坚全梳理:企业级能力矩阵 + 四大技术栈攻坚 + 性能优化 Checklist + 实战项目预告
java·人工智能·spring·rag·企业级ai应用·springai技术体系·多模态和安全防护
Java后端的Ai之路2 天前
【RAG技术】- RAG系统调优手段之GraphRAG(全局视野)
人工智能·知识库·调优·rag·graphrag
王建文go2 天前
RAG(宠物健康AI)
人工智能·宠物·rag