Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. ---
  2. sidebar_position: 0
  3. slug: /
  4. ---
  5. # Quick start
  6. import Tabs from '@theme/Tabs';
  7. import TabItem from '@theme/TabItem';
  8. RAGFlow is an open-source RAG (Retrieval-Augmented Generation) engine based on deep document understanding. When integrated with LLMs, it is capable of providing truthful question-answering capabilities, backed by well-founded citations from various complex formatted data.
  9. This quick start guide describes a general process from:
  10. - Starting up a local RAGFlow server,
  11. - Creating a knowledge base,
  12. - Intervening with file parsing, to
  13. - Establishing an AI chat based on your datasets.
  14. ## Prerequisites
  15. - CPU ≥ 4 cores;
  16. - RAM ≥ 16 GB;
  17. - Disk ≥ 50 GB;
  18. - Docker ≥ 24.0.0 & Docker Compose ≥ v2.26.1.
  19. > If you have not installed Docker on your local machine (Windows, Mac, or Linux), see [Install Docker Engine](https://docs.docker.com/engine/install/).
  20. ## Start up the server
  21. This section provides instructions on setting up the RAGFlow server on Linux. If you are on a different operating system, no worries. Most steps are alike.
  22. <details>
  23. <summary>1. Ensure <code>vm.max_map_count</code> &ge; 262144:</summary>
  24. `vm.max_map_count`. This value sets the maximum number of memory map areas a process may have. Its default value is 65530. While most applications require fewer than a thousand maps, reducing this value can result in abmornal behaviors, and the system will throw out-of-memory errors when a process reaches the limitation.
  25. RAGFlow v0.13.0 uses Elasticsearch for multiple recall. Setting the value of `vm.max_map_count` correctly is crucial to the proper functioning of the Elasticsearch component.
  26. <Tabs
  27. defaultValue="linux"
  28. values={[
  29. {label: 'Linux', value: 'linux'},
  30. {label: 'macOS', value: 'macos'},
  31. {label: 'Windows', value: 'windows'},
  32. ]}>
  33. <TabItem value="linux">
  34. 1.1. Check the value of `vm.max_map_count`:
  35. ```bash
  36. $ sysctl vm.max_map_count
  37. ```
  38. 1.2. Reset `vm.max_map_count` to a value at least 262144 if it is not.
  39. ```bash
  40. $ sudo sysctl -w vm.max_map_count=262144
  41. ```
  42. :::caution WARNING
  43. This change will be reset after a system reboot. If you forget to update the value the next time you start up the server, you may get a `Can't connect to ES cluster` exception.
  44. :::
  45. 1.3. To ensure your change remains permanent, add or update the `vm.max_map_count` value in **/etc/sysctl.conf** accordingly:
  46. ```bash
  47. vm.max_map_count=262144
  48. ```
  49. </TabItem>
  50. <TabItem value="macos">
  51. If you are on macOS with Docker Desktop, run the following command to update `vm.max_map_count`:
  52. ```bash
  53. docker run --rm --privileged --pid=host alpine sysctl -w vm.max_map_count=262144
  54. ```
  55. :::caution WARNING
  56. This change will be reset after a system reboot. If you forget to update the value the next time you start up the server, you may get a `Can't connect to ES cluster` exception.
  57. :::
  58. To make your change persistent, create a file with proper settings:
  59. 1.1. Create a file:
  60. ```shell
  61. sudo nano /Library/LaunchDaemons/com.user.vmmaxmap.plist
  62. ```
  63. 1.2. Open the file:
  64. ```shell
  65. sudo launchctl load /Library/LaunchDaemons/com.user.vmmaxmap.plist
  66. ```
  67. 1.3. Add settings:
  68. ```xml
  69. <?xml version="1.0" encoding="UTF-8"?>
  70. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  71. <plist version="1.0">
  72. <dict>
  73. <key>Label</key>
  74. <string>com.user.vmmaxmap</string>
  75. <key>ProgramArguments</key>
  76. <array>
  77. <string>/usr/sbin/sysctl</string>
  78. <string>-w</string>
  79. <string>vm.max_map_count=262144</string>
  80. </array>
  81. <key>RunAtLoad</key>
  82. <true/>
  83. </dict>
  84. </plist>
  85. ```
  86. 1.4. After saving the file, load the new daemon:
  87. ```shell
  88. sudo launchctl load /Library/LaunchDaemons/com.user.vmmaxmap.plist
  89. ```
  90. :::note
  91. If the above steps do not work, consider using [this workaround](https://github.com/docker/for-mac/issues/7047#issuecomment-1791912053), which employs a container and does not require manual editing of the macOS settings.
  92. :::
  93. </TabItem>
  94. <TabItem value="windows">
  95. #### If you are on Windows with Docker Desktop, then you *must* use docker-machine to set `vm.max_map_count`:
  96. ```bash
  97. $ docker-machine ssh
  98. $ sudo sysctl -w vm.max_map_count=262144
  99. ```
  100. #### If you are on Windows with Docker Desktop WSL 2 backend, then use docker-desktop to set `vm.max_map_count`:
  101. 1.1. Run the following in WSL:
  102. ```bash
  103. $ wsl -d docker-desktop -u root
  104. $ sysctl -w vm.max_map_count=262144
  105. ```
  106. :::caution WARNING
  107. This change will be reset after you restart Docker. If you forget to update the value the next time you start up the server, you may get a `Can't connect to ES cluster` exception.
  108. :::
  109. 1.2. If you do not wish to have to run those commands each time you restart Docker, you can update your `%USERPROFILE%.wslconfig` as follows to keep your change permanent and globally for all WSL distributions:
  110. ```bash
  111. [wsl2]
  112. kernelCommandLine = "sysctl.vm.max_map_count=262144"
  113. ```
  114. *This causes all WSL2 virtual machines to have that setting assigned when they start.*
  115. :::note
  116. If you are on Windows 11 or Windows 10 version 22H2, and have installed the Microsoft Store version of WSL, you can also update the **/etc/sysctl.conf** within the docker-desktop WSL distribution to keep your change permanent:
  117. ```bash
  118. $ wsl -d docker-desktop -u root
  119. $ vi /etc/sysctl.conf
  120. ```
  121. ```bash
  122. # Append a line, which reads:
  123. vm.max_map_count = 262144
  124. ```
  125. :::
  126. </TabItem>
  127. </Tabs>
  128. </details>
  129. 2. Clone the repo:
  130. ```bash
  131. $ git clone https://github.com/infiniflow/ragflow.git
  132. ```
  133. 3. Build the pre-built Docker images and start up the server:
  134. > The command below downloads the dev version Docker image for RAGFlow slim (`dev-slim`). Note that RAGFlow slim 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 **docker/.env** to your desired version. For example, `RAGFLOW_IMAGE=infiniflow/ragflow:v0.13.0-slim`. After making this change, rerun the command above to initiate the download.
  140. > - To download the dev version of RAGFlow Docker image *including* embedding models and Python libraries, update the `RAGFlow_IMAGE` variable in **docker/.env** to `RAGFLOW_IMAGE=infiniflow/ragflow:dev`. After making this change, rerun the command above to initiate the download.
  141. > - To download a specific version of RAGFlow Docker image *including* embedding models and Python libraries, update the `RAGFlow_IMAGE` variable in **docker/.env** to your desired version. For example, `RAGFLOW_IMAGE=infiniflow/ragflow:v0.13.0`. After making this change, rerun the command above to initiate the download.
  142. :::tip NOTE
  143. A RAGFlow Docker image that includes embedding models and Python libraries is approximately 9GB in size and may take significantly longer time to load.
  144. :::
  145. 4. Check the server status after having the server up and running:
  146. ```bash
  147. $ docker logs -f ragflow-server
  148. ```
  149. _The following output confirms a successful launch of the system:_
  150. ```bash
  151. ____ ___ ______ ______ __
  152. / __ \ / | / ____// ____// /____ _ __
  153. / /_/ // /| | / / __ / /_ / // __ \| | /| / /
  154. / _, _// ___ |/ /_/ // __/ / // /_/ /| |/ |/ /
  155. /_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/
  156. * Running on all addresses (0.0.0.0)
  157. * Running on http://127.0.0.1:9380
  158. * Running on http://x.x.x.x:9380
  159. INFO:werkzeug:Press CTRL+C to quit
  160. ```
  161. > If you skip this confirmation step and directly log in to RAGFlow, your browser may prompt a `network anomaly` error because, at that moment, your RAGFlow may not be fully initialized.
  162. 5. In your web browser, enter the IP address of your server and log in to RAGFlow.
  163. :::caution WARNING
  164. With the default settings, you only need to enter `http://IP_OF_YOUR_MACHINE` (**sans** port number) as the default HTTP serving port `80` can be omitted when using the default configurations.
  165. :::
  166. ## Configure LLMs
  167. RAGFlow is a RAG engine and needs to work with an LLM to offer grounded, hallucination-free question-answering capabilities. RAGFlow supports most mainstream LLMs. For a complete list of supported models, please refer to [Supported Models](./references/supported_models.mdx).
  168. :::note
  169. RAGFlow also supports deploying LLMs locally using Ollama, Xinference, or LocalAI, but this part is not covered in this quick start guide.
  170. :::
  171. To add and configure an LLM:
  172. 1. Click on your logo on the top right of the page **>** **Model Providers**:
  173. ![add llm](https://github.com/infiniflow/ragflow/assets/93570324/10635088-028b-4b3d-add9-5c5a6e626814)
  174. > Each RAGFlow account is able to use **text-embedding-v2** for free, an embedding model of Tongyi-Qianwen. This is why you can see Tongyi-Qianwen in the **Added models** list. And you may need to update your Tongyi-Qianwen API key at a later point.
  175. 2. Click on the desired LLM and update the API key accordingly (DeepSeek-V2 in this case):
  176. ![update api key](https://github.com/infiniflow/ragflow/assets/93570324/4e5e13ef-a98d-42e6-bcb1-0c6045fc1666)
  177. *Your added models appear as follows:*
  178. ![added available models](https://github.com/infiniflow/ragflow/assets/93570324/d08b80e4-f921-480a-b41d-11832489c916)
  179. 3. Click **System Model Settings** to select the default models:
  180. - Chat model,
  181. - Embedding model,
  182. - Image-to-text model.
  183. ![system model settings](https://github.com/infiniflow/ragflow/assets/93570324/cdcc1da5-4494-44cd-ad5b-1222ed6acc3f)
  184. > Some models, such as the image-to-text model **qwen-vl-max**, are subsidiary to a specific LLM. And you may need to update your API key to access these models.
  185. ## Create your first knowledge base
  186. You are allowed to upload files to a knowledge base in RAGFlow and parse them into datasets. A knowledge base is virtually a collection of datasets. Question answering in RAGFlow can be based on a particular knowledge base or multiple knowledge bases. File formats that RAGFlow supports include documents (PDF, DOC, DOCX, TXT, MD), tables (CSV, XLSX, XLS), pictures (JPEG, JPG, PNG, TIF, GIF), and slides (PPT, PPTX).
  187. To create your first knowledge base:
  188. 1. Click the **Knowledge Base** tab in the top middle of the page **>** **Create knowledge base**.
  189. 2. Input the name of your knowledge base and click **OK** to confirm your changes.
  190. _You are taken to the **Configuration** page of your knowledge base._
  191. ![knowledge base configuration](https://github.com/infiniflow/ragflow/assets/93570324/384c671a-8b9c-468c-b1c9-1401128a9b65)
  192. 3. RAGFlow offers multiple chunk templates that cater to different document layouts and file formats. Select the embedding model and chunk method (template) for your knowledge base.
  193. :::danger IMPORTANT
  194. Once you have selected an embedding model and used it to parse a file, you are no longer allowed to change it. The obvious reason is that we must ensure that all files in a specific knowledge base are parsed using the *same* embedding model (ensure that they are being compared in the same embedding space).
  195. :::
  196. _You are taken to the **Dataset** page of your knowledge base._
  197. 4. Click **+ Add file** **>** **Local files** to start uploading a particular file to the knowledge base.
  198. 5. In the uploaded file entry, click the play button to start file parsing:
  199. ![file parsing](https://github.com/infiniflow/ragflow/assets/93570324/19f273fa-0ab0-435e-bdf4-a47fb080a078)
  200. _When the file parsing completes, its parsing status changes to **SUCCESS**._
  201. :::caution NOTE
  202. - If your file parsing gets stuck at below 1%, see [FAQ 4.3](https://ragflow.io/docs/dev/faq#43-why-does-my-document-parsing-stall-at-under-one-percent).
  203. - If your file parsing gets stuck at near completion, see [FAQ 4.4](https://ragflow.io/docs/dev/faq#44-why-does-my-pdf-parsing-stall-near-completion-while-the-log-does-not-show-any-error)
  204. :::
  205. ## Intervene with file parsing
  206. RAGFlow features visibility and explainability, allowing you to view the chunking results and intervene where necessary. To do so:
  207. 1. Click on the file that completes file parsing to view the chunking results:
  208. _You are taken to the **Chunk** page:_
  209. ![chunks](https://github.com/infiniflow/ragflow/assets/93570324/0547fd0e-e71b-41f8-8e0e-31649c85fd3d)
  210. 2. Hover over each snapshot for a quick view of each chunk.
  211. 3. Double click the chunked texts to add keywords or make *manual* changes where necessary:
  212. ![update chunk](https://github.com/infiniflow/ragflow/assets/93570324/1d84b408-4e9f-46fd-9413-8c1059bf9c76)
  213. :::caution NOTE
  214. You can add keywords to a file chunk to increase its relevance. This action increases its keyword weight and can improve its position in search list.
  215. :::
  216. 4. In Retrieval testing, ask a quick question in **Test text** to double check if your configurations work:
  217. _As you can tell from the following, RAGFlow responds with truthful citations._
  218. ![retrieval test](https://github.com/infiniflow/ragflow/assets/93570324/c03f06f6-f41f-4b20-a97e-ae405d3a950c)
  219. ## Set up an AI chat
  220. Conversations in RAGFlow are based on a particular knowledge base or multiple knowledge bases. Once you have created your knowledge base and finished file parsing, you can go ahead and start an AI conversation.
  221. 1. Click the **Chat** tab in the middle top of the mage **>** **Create an assistant** to show the **Chat Configuration** dialogue *of your next dialogue*.
  222. > RAGFlow offer the flexibility of choosing a different chat model for each dialogue, while allowing you to set the default models in **System Model Settings**.
  223. 2. Update **Assistant Setting**:
  224. - Name your assistant and specify your knowledge bases.
  225. - **Empty response**:
  226. - If you wish to *confine* RAGFlow's answers to your knowledge bases, leave a response here. Then when it doesn't retrieve an answer, it *uniformly* responds with what you set here.
  227. - If you wish RAGFlow to *improvise* when it doesn't retrieve an answer from your knowledge bases, leave it blank, which may give rise to hallucinations.
  228. 3. Update **Prompt Engine** or leave it as is for the beginning.
  229. 4. Update **Model Setting**.
  230. 5. Now, let's start the show:
  231. ![question1](https://github.com/infiniflow/ragflow/assets/93570324/bb72dd67-b35e-4b2a-87e9-4e4edbd6e677)
  232. ![question2](https://github.com/infiniflow/ragflow/assets/93570324/7cc585ae-88d0-4aa2-817d-0370b2ad7230)
  233. :::tip NOTE
  234. RAGFlow also offers HTTP and Python APIs for you to integrate RAGFlow's capabilities into your applications. Read the following documents for more information:
  235. - [Acquire a RAGFlow API key](./guides/develop/acquire_ragflow_api_key.md)
  236. - [HTTP API reference](./references/http_api_reference.md)
  237. - [Python API reference](./references/python_api_reference.md)
  238. :::