You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <div align="center">
  2. <a href="https://demo.ragflow.io/">
  3. <img src="web/src/assets/logo-with-text.png" width="520" alt="ragflow logo">
  4. </a>
  5. </div>
  6. <p align="center">
  7. <a href="./README.md">English</a> |
  8. <a href="./README_zh.md">简体中文</a> |
  9. <a href="./README_ja.md">日本語</a> |
  10. <a href="./README_ko.md">한국어</a> |
  11. <a href="./README_id.md">Bahasa Indonesia</a>
  12. </p>
  13. <p align="center">
  14. <a href="https://x.com/intent/follow?screen_name=infiniflowai" target="_blank">
  15. <img src="https://img.shields.io/twitter/follow/infiniflow?logo=X&color=%20%23f5f5f5" alt="follow on X(Twitter)">
  16. </a>
  17. <a href="https://demo.ragflow.io" target="_blank">
  18. <img alt="Static Badge" src="https://img.shields.io/badge/Online-Demo-4e6b99">
  19. </a>
  20. <a href="https://hub.docker.com/r/infiniflow/ragflow" target="_blank">
  21. <img src="https://img.shields.io/badge/docker_pull-ragflow:v0.14.0-brightgreen" alt="docker pull infiniflow/ragflow:v0.14.0">
  22. </a>
  23. <a href="https://github.com/infiniflow/ragflow/releases/latest">
  24. <img src="https://img.shields.io/github/v/release/infiniflow/ragflow?color=blue&label=Latest%20Release" alt="Latest Release">
  25. </a>
  26. <a href="https://github.com/infiniflow/ragflow/blob/main/LICENSE">
  27. <img height="21" src="https://img.shields.io/badge/License-Apache--2.0-ffffff?labelColor=d4eaf7&color=2e6cc4" alt="license">
  28. </a>
  29. </p>
  30. <h4 align="center">
  31. <a href="https://ragflow.io/docs/dev/">Document</a> |
  32. <a href="https://github.com/infiniflow/ragflow/issues/162">Roadmap</a> |
  33. <a href="https://twitter.com/infiniflowai">Twitter</a> |
  34. <a href="https://discord.gg/4XxujFgUN7">Discord</a> |
  35. <a href="https://demo.ragflow.io">Demo</a>
  36. </h4>
  37. <details open>
  38. <summary></b>📕 Table of Contents</b></summary>
  39. - 💡 [What is RAGFlow?](#-what-is-ragflow)
  40. - 🎮 [Demo](#-demo)
  41. - 📌 [Latest Updates](#-latest-updates)
  42. - 🌟 [Key Features](#-key-features)
  43. - 🔎 [System Architecture](#-system-architecture)
  44. - 🎬 [Get Started](#-get-started)
  45. - 🔧 [Configurations](#-configurations)
  46. - 🔧 [Build a docker image without embedding models](#-build-a-docker-image-without-embedding-models)
  47. - 🔧 [Build a docker image including embedding models](#-build-a-docker-image-including-embedding-models)
  48. - 🔨 [Launch service from source for development](#-launch-service-from-source-for-development)
  49. - 📚 [Documentation](#-documentation)
  50. - 📜 [Roadmap](#-roadmap)
  51. - 🏄 [Community](#-community)
  52. - 🙌 [Contributing](#-contributing)
  53. </details>
  54. ## 💡 What is RAGFlow?
  55. [RAGFlow](https://ragflow.io/) is an open-source RAG (Retrieval-Augmented Generation) engine based on deep document
  56. understanding. It offers a streamlined RAG workflow for businesses of any scale, combining LLM (Large Language Models)
  57. to provide truthful question-answering capabilities, backed by well-founded citations from various complex formatted
  58. data.
  59. ## 🎮 Demo
  60. Try our demo at [https://demo.ragflow.io](https://demo.ragflow.io).
  61. <div align="center" style="margin-top:20px;margin-bottom:20px;">
  62. <img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
  63. <img src="https://github.com/user-attachments/assets/504bbbf1-c9f7-4d83-8cc5-e9cb63c26db6" width="1200"/>
  64. </div>
  65. ## 🔥 Latest Updates
  66. - 2024-11-22 Adds more variables to Agent.
  67. - 2024-11-01 Adds keyword extraction and related question generation to the parsed chunks to improve the accuracy of retrieval.
  68. - 2024-09-13 Adds search mode for knowledge base Q&A.
  69. - 2024-08-22 Support text to SQL statements through RAG.
  70. - 2024-08-02 Supports GraphRAG inspired by [graphrag](https://github.com/microsoft/graphrag) and mind map.
  71. ## 🎉 Stay Tuned
  72. ⭐️ Star our repository to stay up-to-date with exciting new features and improvements! Get instant notifications for new
  73. releases! 🌟
  74. <div align="center" style="margin-top:20px;margin-bottom:20px;">
  75. <img src="https://github.com/user-attachments/assets/18c9707e-b8aa-4caf-a154-037089c105ba" width="1200"/>
  76. </div>
  77. ## 🌟 Key Features
  78. ### 🍭 **"Quality in, quality out"**
  79. - [Deep document understanding](./deepdoc/README.md)-based knowledge extraction from unstructured data with complicated
  80. formats.
  81. - Finds "needle in a data haystack" of literally unlimited tokens.
  82. ### 🍱 **Template-based chunking**
  83. - Intelligent and explainable.
  84. - Plenty of template options to choose from.
  85. ### 🌱 **Grounded citations with reduced hallucinations**
  86. - Visualization of text chunking to allow human intervention.
  87. - Quick view of the key references and traceable citations to support grounded answers.
  88. ### 🍔 **Compatibility with heterogeneous data sources**
  89. - Supports Word, slides, excel, txt, images, scanned copies, structured data, web pages, and more.
  90. ### 🛀 **Automated and effortless RAG workflow**
  91. - Streamlined RAG orchestration catered to both personal and large businesses.
  92. - Configurable LLMs as well as embedding models.
  93. - Multiple recall paired with fused re-ranking.
  94. - Intuitive APIs for seamless integration with business.
  95. ## 🔎 System Architecture
  96. <div align="center" style="margin-top:20px;margin-bottom:20px;">
  97. <img src="https://github.com/infiniflow/ragflow/assets/12318111/d6ac5664-c237-4200-a7c2-a4a00691b485" width="1000"/>
  98. </div>
  99. ## 🎬 Get Started
  100. ### 📝 Prerequisites
  101. - CPU >= 4 cores
  102. - RAM >= 16 GB
  103. - Disk >= 50 GB
  104. - Docker >= 24.0.0 & Docker Compose >= v2.26.1
  105. > If you have not installed Docker on your local machine (Windows, Mac, or Linux),
  106. see [Install Docker Engine](https://docs.docker.com/engine/install/).
  107. ### 🚀 Start up the server
  108. 1. Ensure `vm.max_map_count` >= 262144:
  109. > To check the value of `vm.max_map_count`:
  110. >
  111. > ```bash
  112. > $ sysctl vm.max_map_count
  113. > ```
  114. >
  115. > Reset `vm.max_map_count` to a value at least 262144 if it is not.
  116. >
  117. > ```bash
  118. > # In this case, we set it to 262144:
  119. > $ sudo sysctl -w vm.max_map_count=262144
  120. > ```
  121. >
  122. > This change will be reset after a system reboot. To ensure your change remains permanent, add or update the
  123. `vm.max_map_count` value in **/etc/sysctl.conf** accordingly:
  124. >
  125. > ```bash
  126. > vm.max_map_count=262144
  127. > ```
  128. 2. Clone the repo:
  129. ```bash
  130. $ git clone https://github.com/infiniflow/ragflow.git
  131. ```
  132. 3. Build the pre-built Docker images and start up the server:
  133. > The command below downloads the dev version Docker image for RAGFlow slim (`dev-slim`). Note that RAGFlow slim
  134. Docker images do not include embedding models or Python libraries and hence are approximately 1GB in size.
  135. ```bash
  136. $ cd ragflow/docker
  137. $ docker compose -f docker-compose.yml up -d
  138. ```
  139. > - To download a RAGFlow slim Docker image of a specific version, update the `RAGFLOW_IMAGE` variable in *
  140. *docker/.env** to your desired version. For example, `RAGFLOW_IMAGE=infiniflow/ragflow:v0.14.0-slim`. After
  141. making this change, rerun the command above to initiate the download.
  142. > - To download the dev version of RAGFlow Docker image *including* embedding models and Python libraries, update the
  143. `RAGFLOW_IMAGE` variable in **docker/.env** to `RAGFLOW_IMAGE=infiniflow/ragflow:dev`. After making this change,
  144. rerun the command above to initiate the download.
  145. > - To download a specific version of RAGFlow Docker image *including* embedding models and Python libraries, update
  146. the `RAGFLOW_IMAGE` variable in **docker/.env** to your desired version. For example,
  147. `RAGFLOW_IMAGE=infiniflow/ragflow:v0.14.0`. After making this change, rerun the command above to initiate the
  148. download.
  149. > **NOTE:** A RAGFlow Docker image that includes embedding models and Python libraries is approximately 9GB in size
  150. and may take significantly longer time to load.
  151. 4. Check the server status after having the server up and running:
  152. ```bash
  153. $ docker logs -f ragflow-server
  154. ```
  155. _The following output confirms a successful launch of the system:_
  156. ```bash
  157. ____ ___ ______ ______ __
  158. / __ \ / | / ____// ____// /____ _ __
  159. / /_/ // /| | / / __ / /_ / // __ \| | /| / /
  160. / _, _// ___ |/ /_/ // __/ / // /_/ /| |/ |/ /
  161. /_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/
  162. * Running on all addresses (0.0.0.0)
  163. * Running on http://127.0.0.1:9380
  164. * Running on http://x.x.x.x:9380
  165. INFO:werkzeug:Press CTRL+C to quit
  166. ```
  167. > If you skip this confirmation step and directly log in to RAGFlow, your browser may prompt a `network anormal`
  168. error because, at that moment, your RAGFlow may not be fully initialized.
  169. 5. In your web browser, enter the IP address of your server and log in to RAGFlow.
  170. > With the default settings, you only need to enter `http://IP_OF_YOUR_MACHINE` (**sans** port number) as the default
  171. HTTP serving port `80` can be omitted when using the default configurations.
  172. 6. In [service_conf.yaml.template](./docker/service_conf.yaml.template), select the desired LLM factory in `user_default_llm` and update
  173. the `API_KEY` field with the corresponding API key.
  174. > See [llm_api_key_setup](https://ragflow.io/docs/dev/llm_api_key_setup) for more information.
  175. _The show is on!_
  176. ## 🔧 Configurations
  177. When it comes to system configurations, you will need to manage the following files:
  178. - [.env](./docker/.env): Keeps the fundamental setups for the system, such as `SVR_HTTP_PORT`, `MYSQL_PASSWORD`, and
  179. `MINIO_PASSWORD`.
  180. - [service_conf.yaml.template](./docker/service_conf.yaml.template): Configures the back-end services. The environment variables in this file will be automatically populated when the Docker container starts. Any environment variables set within the Docker container will be available for use, allowing you to customize service behavior based on the deployment environment.
  181. - [docker-compose.yml](./docker/docker-compose.yml): The system relies on [docker-compose.yml](./docker/docker-compose.yml) to start up.
  182. > The [./docker/README](./docker/README.md) file provides a detailed description of the environment settings and service
  183. > configurations which can be used as `${ENV_VARS}` in the [service_conf.yaml.template](./docker/service_conf.yaml.template) file.
  184. To update the default HTTP serving port (80), go to [docker-compose.yml](./docker/docker-compose.yml) and change `80:80`
  185. to `<YOUR_SERVING_PORT>:80`.
  186. Updates to the above configurations require a reboot of all containers to take effect:
  187. > ```bash
  188. > $ docker compose -f docker/docker-compose.yml up -d
  189. > ```
  190. ### Switch doc engine from Elasticsearch to Infinity
  191. RAGFlow uses Elasticsearch by default for storing full text and vectors. To switch to [Infinity](https://github.com/infiniflow/infinity/), follow these steps:
  192. 1. Stop all running containers:
  193. ```bash
  194. $ docker compose -f docker/docker-compose.yml down -v
  195. ```
  196. 2. Set `DOC_ENGINE` in **docker/.env** to `infinity`.
  197. 3. Start the containers:
  198. ```bash
  199. $ docker compose -f docker/docker-compose.yml up -d
  200. ```
  201. > [!WARNING]
  202. > Switching to Infinity on a Linux/arm64 machine is not yet officially supported.
  203. ## 🔧 Build a Docker image without embedding models
  204. This image is approximately 1 GB in size and relies on external LLM and embedding services.
  205. ```bash
  206. git clone https://github.com/infiniflow/ragflow.git
  207. cd ragflow/
  208. pip3 install huggingface-hub nltk
  209. python3 download_deps.py
  210. docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .
  211. ```
  212. ## 🔧 Build a Docker image including embedding models
  213. This image is approximately 9 GB in size. As it includes embedding models, it relies on external LLM services only.
  214. ```bash
  215. git clone https://github.com/infiniflow/ragflow.git
  216. cd ragflow/
  217. pip3 install huggingface-hub nltk
  218. python3 download_deps.py
  219. docker build -f Dockerfile -t infiniflow/ragflow:dev .
  220. ```
  221. ## 🔨 Launch service from source for development
  222. 1. Install Poetry, or skip this step if it is already installed:
  223. ```bash
  224. curl -sSL https://install.python-poetry.org | python3 -
  225. ```
  226. 2. Clone the source code and install Python dependencies:
  227. ```bash
  228. git clone https://github.com/infiniflow/ragflow.git
  229. cd ragflow/
  230. export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
  231. ~/.local/bin/poetry install --sync --no-root --with=full # install RAGFlow dependent python modules
  232. ```
  233. 3. Launch the dependent services (MinIO, Elasticsearch, Redis, and MySQL) using Docker Compose:
  234. ```bash
  235. docker compose -f docker/docker-compose-base.yml up -d
  236. ```
  237. Add the following line to `/etc/hosts` to resolve all hosts specified in **docker/.env** to `127.0.0.1`:
  238. ```
  239. 127.0.0.1 es01 infinity mysql minio redis
  240. ```
  241. In **docker/service_conf.yaml.template**, update mysql port to `5455` and es port to `1200`, as specified in **docker/.env**.
  242. 4. If you cannot access HuggingFace, set the `HF_ENDPOINT` environment variable to use a mirror site:
  243. ```bash
  244. export HF_ENDPOINT=https://hf-mirror.com
  245. ```
  246. 5. Launch backend service:
  247. ```bash
  248. source .venv/bin/activate
  249. export PYTHONPATH=$(pwd)
  250. bash docker/launch_backend_service.sh
  251. ```
  252. 6. Install frontend dependencies:
  253. ```bash
  254. cd web
  255. npm install --force
  256. ```
  257. 7. Configure frontend to update `proxy.target` in **.umirc.ts** to `http://127.0.0.1:9380`:
  258. 8. Launch frontend service:
  259. ```bash
  260. npm run dev
  261. ```
  262. _The following output confirms a successful launch of the system:_
  263. ![](https://github.com/user-attachments/assets/0daf462c-a24d-4496-a66f-92533534e187)
  264. ## 📚 Documentation
  265. - [Quickstart](https://ragflow.io/docs/dev/)
  266. - [User guide](https://ragflow.io/docs/dev/category/guides)
  267. - [References](https://ragflow.io/docs/dev/category/references)
  268. - [FAQ](https://ragflow.io/docs/dev/faq)
  269. ## 📜 Roadmap
  270. See the [RAGFlow Roadmap 2024](https://github.com/infiniflow/ragflow/issues/162)
  271. ## 🏄 Community
  272. - [Discord](https://discord.gg/4XxujFgUN7)
  273. - [Twitter](https://twitter.com/infiniflowai)
  274. - [GitHub Discussions](https://github.com/orgs/infiniflow/discussions)
  275. ## 🙌 Contributing
  276. RAGFlow flourishes via open-source collaboration. In this spirit, we embrace diverse contributions from the community.
  277. If you would like to be a part, review our [Contribution Guidelines](./CONTRIBUTING.md) first.