本地搭建检索增强生成(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/

相关推荐
一条泥憨鱼10 小时前
能够让AI做事的“Skill“有什么奥秘
人工智能·ai·agent·rag·skill·mcp
fengxin_rou13 小时前
【Spring AI 集成 DeepSeek 实现 AI 摘要与 RAG 问答】:从原理到落地实践
数据库·mysql·rag·deepseek
Terrence Shen17 小时前
Agent面试八股文(系列之二)
人工智能·大模型·agent·rag
Restart-AHTCM1 天前
AI时代大前端Agent开发LangChain.js
typescript·langchain·memory·rag·tools
ZGi.ai1 天前
采购部门用AI审供应商资质:从3天压缩到3小时的方案
大数据·人工智能·rag·供应商管理·企业ai·文档审核·采购ai
德思特2 天前
从 Dify 配置页理解 RAG 的重要参数
java·人工智能·llm·dify·rag
鼎道开发者联盟2 天前
跳出传统 RAG!用 LLM Wiki 构建闭环式产品 Agent 协作体系
agent·rag·hermes·llmwiki
Honey Ro2 天前
浅析大模型 Agent 的记忆(Memory)机制
深度学习·语言模型·llm·rag
YDS8293 天前
DeepSeek RAG&MCP + Agent智能体项目 —— RAG知识库的搭建和接口实现
java·ai·springboot·agent·rag·deepseek
海蓝可知天湛3 天前
Agent&IELTS雅思口语专属语料库
人工智能·github·rag·ielts·skills