AI 文摘

RAGFlow—一个开源的RAG(检索增强生成)引擎





作者: 三人行AI 来源: 三人行AI

💡 什么是 RAGFlow?

RAGFlow[1] 是一个开源的 RAG(检索增强生成)引擎,基于深度文档理解。它为任何规模的企业提供了简化的 RAG 工作流程,结合大语言模型(LLM),提供真实的问题回答能力,并有复杂格式数据的可靠引用支持。

🎮 演示

试用我们的演示:https://demo.ragflow.io。

📌 最新更新

•2024-06-06 支持 Self-RAG,默认在对话设置中启用。•2024-05-30 集成 BCE [2]和 BGE 重排模型。•2024-05-28 支持 LLM Baichuan 和 VolcanoArk。•2024-05-23 支持 RAPTOR [3]以提高文本检索效果。•2024-05-21 支持流式输出和文本块检索 API。•2024-05-15 集成 OpenAI GPT-4o。•2024-05-08 集成 LLM DeepSeek-V2。

🌟 主要功能

•🍭**“质量输入,质量输出”** •基于深度文档理解[4]的知识提取,适用于复杂格式的非结构化数据。•在几乎无限的令牌数据中找到“数据干草堆中的针”。•🍱基于模板的分块 •智能且可解释。•提供多种模板选项可供选择。•🌱减少幻觉的有根引用 •文本分块的可视化以允许人工干预。•快速查看关键引用和可追溯的引用,支持有根答案。•🍔兼容异构数据源 •支持 Word、幻灯片、Excel、txt、图像、扫描件、结构化数据、网页等。•🛀自动化且无缝的 RAG 工作流程 •为个人和大型企业定制的简化 RAG 编排。•可配置的 LLM 和嵌入模型。•多重召回配合融合重排序。•直观的 API 便于与业务无缝集成。

🔎 系统架构

🎬 入门指南

📝 先决条件

•CPU ≥ 4 核•内存 ≥ 16 GB•硬盘 ≥ 50 GB•Docker ≥ 24.0.0 & Docker Compose ≥ v2.26.1

如果尚未在本地计算机(Windows、Mac 或 Linux)上安装 Docker,请参阅安装 Docker 引擎[5]。

🚀 启动服务器

1.确保 vm.max_map_count ≥ 262144:

检查 vm.max_map_count 的值:

$ sysctl vm.max_map_count

如果值小于 262144,请重置:

$ sudo sysctl -w vm.max_map_count=262144

此更改在系统重启后会重置。为了确保更改永久生效,请在 /etc/sysctl.conf 中添加或更新 vm.max_map_count 值:

vm.max_map_count=262144

2.克隆仓库:

$ git clone https://github.com/infiniflow/ragflow.git

3.构建预构建的 Docker 镜像并启动服务器:

以下命令将自动下载开发版 RAGFlow Docker 镜像。如需下载和运行指定的 Docker 版本,请在运行以下命令之前,将 docker/.env 中的 RAGFLOW_VERSION 更新为所需版本,例如 RAGFLOW_VERSION=v0.7.0。


$ cd ragflow/docker
$ chmod +x ./entrypoint.sh
$ docker compose up -d

核心镜像大约 9 GB,加载可能需要一些时间。

4.服务器启动后,检查服务器状态:

$ docker logs -f ragflow-server

以下输出确认系统成功启动:


    ____                 ______ __
   / __ \ ____ _ ____ _ / ____// /____  _      __
  / /_/ // __ `// __ `// /_   / // __ \| | /| / /
 / _, _// /_/ // /_/ // __/  / // /_/ /| |/ |/ /
/_/ |_| \__,_/ \__, //_/    /_/ \____/ |__/|__/
              /____/
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:9380
 * Running on http://x.x.x.x:9380
 INFO:werkzeug:Press CTRL+C to quit

如果跳过此确认步骤直接登录 RAGFlow,您的浏览器可能会提示网络异常错误

,因为此时 RAGFlow 可能尚未完全初始化。

5.在您的网络浏览器中,输入服务器的 IP 地址并登录 RAGFlow。

在默认设置下,只需输入 http://您的机器的IP

(不带端口号),因为默认的 HTTP 服务端口 80 在使用默认配置时可以省略。

6.在 service_conf.yaml [6]中,选择所需的 LLM 工厂,在 user_default_llm 中更新 API_KEY 字段,输入相应的 API 密钥。

有关更多信息,请参阅 llm_api_key_setup。

现在,一切就绪!

🔧 配置

在系统配置方面,您需要管理以下文件:

•.env[7]:包含系统的基本设置,例如 SVR_HTTP_PORT 、MYSQL_PASSWORD 和 MINIO_PASSWORD 。•service_conf.yaml[8]:配置后端服务。•docker-compose.yml[9]:系统依赖 docker-compose.yml 启动。

您必须确保对 .env 文件的更改与 service_conf.yaml 文件中的配置一致。

./docker/README[10]文件提供了环境设置和服务配置的详细说明,您必须确保

./docker/README文件中列出的所有环境设置与 service_conf.yaml` 文件中的相应配置一致。

要更新默认的 HTTP 服务端口(80),请前往 docker-compose.yml[11] 并将 80:80 更改为 <YOUR_SERVING_PORT>:80 。

对所有系统配置的更新需要系统重启才能生效:

$ docker-compose up -d

🛠️ 从源代码构建

要从源代码构建 Docker 镜像:


$ git clone https://github.com/infiniflow/ragflow.git
$ cd ragflow/
$ docker build -t infiniflow/ragflow:dev .
$ cd ragflow/docker
$ chmod +x ./entrypoint.sh
$ docker compose up -d

🛠️ 从源代码启动服务

要从源代码启动服务:

1.克隆仓库:

$ git clone https://github.com/infiniflow/ragflow.git
$ cd ragflow/

2.创建虚拟环境,确保已安装 Anaconda 或 Miniconda:


$ conda create -n ragflow python=3.11.0
$ conda activate ragflow
$ pip install -r requirements.txt

如果您的 CUDA 版本高于 12.0,请运行以下附加命令:
$ pip uninstall -y onnxruntime-gpu
$ pip install onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/

3.复制入口脚本并配置环境变量:


获取 Python 路径:
$ which python
获取 ragflow 项目路径:
$ pwd

复制并编辑 entrypoint.sh:
$ cp docker/entrypoint.sh .
$ vi entrypoint.sh

根据实际情况调整配置(以下两个 export 命令是新添加的):
将 which python 的结果分配给 PY。
将 pwd 的结果分配给 PYTHONPATH。
如果配置了 LD_LIBRARY_PATH,请将其注释掉。
可选:添加 Hugging Face 镜像。
PY=${PY}
export PYTHONPATH=${PYTHONPATH}
export HF_ENDPOINT=https://hf-mirror.com

4.启动第三方服务(MinIO、Elasticsearch、Redis 和 MySQL):

$ cd docker
$ docker compose -f docker-compose-base.yml up -d

5.检查配置文件,确保:

·docker/.env 中的设置与conf/service_conf.yaml 中的设置一致。

· service_conf.yaml 中相关服务的 IP 地址和端口与本地机器 IP 和容器暴露的端口匹配。

6.启动 RAGFlow 后端服务:

$ chmod +x ./entrypoint.sh
$ bash ./entrypoint.sh

7.启动前端服务:


$ cd web
$ npm install --registry=https://registry.npmmirror.com --force
$ vim .umirc.ts
更新 proxy.target 为 http://127.0.0.1:9380:
$ npm run dev

8.部署前端服务:


$ cd web
$ npm install --registry=https://registry.npmmirror.com --force
$ umi build
$ mkdir -p /ragflow/web
$ cp -r dist /ragflow/web
$ apt install nginx -y
$ cp ../docker/nginx/proxy.conf /etc/nginx
$ cp ../docker/nginx/nginx.conf /etc/nginx
$ cp ../docker/nginx/ragflow.conf /etc/nginx/conf.d
$ systemctl start nginx

📚 文档

•快速开始[12]•用户指南[13]•参考文献[14]•常见问题[15] #### 📜 路线图

请参阅 RAGFlow 2024 路线图[16] #### 🏄 社区

•Discord•Twitter[17]•GitHub Discussions

更多信息

本文由三人行AI整理自:https://github.com/infiniflow/ragflow?tab=readme-ov-file,如对您有帮助,请帮忙点赞、转发、关注。

References

[1] RAGFlow: https://ragflow.io/
[2] BCE : https://github.com/netease-youdao/BCEmbedding
[3] RAPTOR : https://arxiv.org/html/2401.18059v1
[4] 深度文档理解: https://github.com/infiniflow/ragflow/blob/main/deepdoc/README.md
[5] 安装 Docker 引擎: https://docs.docker.com/get-docker/
[6] service_conf.yaml : https://github.com/infiniflow/ragflow/blob/main/docker/service_conf.yaml
[7] .env: https://github.com/infiniflow/ragflow/blob/main/docker/.env
[8] service_conf.yaml: https://github.com/infiniflow/ragflow/blob/main/docker/service_conf.yaml
[9] docker-compose.yml: https://github.com/infiniflow/ragflow/blob/main/docker/docker-compose.yml
[10] ./docker/README: https://github.com/infiniflow/ragflow/blob/main/docker/README.md
[11] docker-compose.yml: https://github.com/infiniflow/ragflow/blob/main/docker/docker-compose.yml
[12] 快速开始: https://ragflow.io/docs/dev/
[13] 用户指南: https://ragflow.io/docs/dev/category/user-guides
[14] 参考文献: https://ragflow.io/docs/dev/category/references
[15] 常见问题: https://ragflow.io/docs/dev/faq
[16] RAGFlow 2024 路线图: https://github.com/infiniflow/ragflow/issues/162

[17] Twitter: https://x.com/infiniflowai

更多AI工具,参考Github-AiBard123国内AiBard123

可关注我们的公众号:每天AI新工具