Artificial Intelligence 11 min read

How to Build a Retrieval‑Augmented Generation Knowledge Base with DeepSeek and RAGFlow

This guide walks you through the fundamentals of Retrieval‑Augmented Generation, introduces the open‑source RAGFlow framework, details installation steps, shows how to integrate DeepSeek LLMs, and explores practical application scenarios such as intelligent customer service and enterprise document QA.

Data Thinking Notes
Data Thinking Notes
Data Thinking Notes
How to Build a Retrieval‑Augmented Generation Knowledge Base with DeepSeek and RAGFlow

RAG Basic Concepts

RAG Core Principle

Retrieval‑Augmented Generation (RAG) combines knowledge retrieval with model generation to address hallucination and outdated knowledge in large language models. The RAG workflow includes:

Document preprocessing: text chunking and vector storage

Real‑time retrieval: matching relevant document fragments to the input query

Enhanced generation: merging retrieved results with prompts to produce final answers

RAG Technical Advantages

Compared with traditional QA systems, RAG offers:

Knowledge traceability : each answer links back to source documents

Dynamic knowledge updates : modify the knowledge base to refresh model knowledge

Cost‑effectiveness : domain expertise without fine‑tuning

Safety and control : content filtering via the retrieval module

RAGFlow Framework Introduction

RAGFlow is an open‑source RAG engine built on deep document understanding, providing a streamlined workflow for enterprises and individuals. It supports various data formats and offers reliable Q&A with verifiable citations.

Key Features

"Quality in, quality out" based on deep document understanding, extracting insights from complex unstructured data

Fast unlimited‑context (token) testing for needle‑in‑haystack scenarios

Template‑based text slicing for controllable, explainable outputs

Support for multiple text templates

Evidence‑backed answers with citation snapshots

Compatibility with heterogeneous data sources (Word, PPT, Excel, txt, images, PDF, web pages, etc.)

Fully automated RAG workflow suitable for personal to enterprise‑scale ecosystems

Configurable LLM and vector models

Multi‑stage retrieval, fusion re‑ranking, and easy‑to‑use APIs

RAGFlow Installation

Environment Requirements

CPU >= 4 cores

RAM >= 16 GB

Disk >= 50 GB

Docker >= 24.0.0 and Docker Compose >= v2.26.1

Ensure

vm.max_map_count

is at least 262144 on Linux servers:

<code>sysctl vm.max_map_count</code>
<code>sudo sysctl -w vm.max_map_count=262144</code>

Docker Installation

If Docker is not installed, follow the official documentation:

https://docs.docker.com/engine/install/

Configure a domestic mirror source after installation.

<code>{
  "builder":{
    "gc":{
      "defaultKeepStorage":"20GB",
      "enabled":true
    }
  },
  "debug":false,
  "experimental":false,
  "features":{
    "buildkit":true
  },
  "insecure-registries":["registry.docker-cn.com","docker.mirrors.ustc.edu.cn"],
  "registry-mirrors":[
    "https://mirror.aliyuncs.com",
    "https://dockerproxy.com",
    "https://mirror.baidubce.com",
    "https://docker.m.daocloud.io",
    "https://docker.nju.edu.cn",
    "https://docker.mirrors.sjtug.sjtu.edu.cn",
    "https://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com",
    "http://mirrors.ustc.edu.cn/",
    "https://mirrors.tuna.tsinghua.edu.cn/"
  ]
}</code>

Start the Docker service after modifying the image tag in

docker/.env

if needed:

<code>$ cd ragflow/docker
# Use CPU for embedding and DeepDoc tasks:
$ docker compose -f docker-compose.yml up -d</code>

If image pulling fails, choose a Huawei Cloud or Alibaba Cloud mirror as indicated in the

docker/.env

comments.

Huawei Cloud image: swr.cn-north-4.myhuaweicloud.com/infiniflow/ragflow Alibaba Cloud image: registry.cn-hangzhou.aliyuncs.com/infiniflow/ragflow

Verify container startup:

<code>$ docker logs -f ragflow-server</code>

Access the RAGFlow service via a browser at the server’s address (default HTTP port 80). To change the port, edit

docker-compose.yml

and replace

80:80

with

&lt;your_port&gt;:80

, then restart:

<code>$ docker compose -f docker-compose.yml up -d</code>

Login with the first registered user (admin) and note that data is stored locally.

DeepSeek + RAGFlow Usage

Configure LLM Models

Click the avatar in the top‑right corner, then select “System Model Settings” to set the default Chat model, Embedding model, and Image‑to‑Text model. The Embedding model can be the built‑in BAAI model or a custom one.

Create a Knowledge Base

Navigate to “Knowledge Base → Create Knowledge Base”, choose an embedding model and chunk method. Once set, the parameters cannot be changed.

Upload documents in the “Dataset” page and start parsing; successful parses show a “Success” status.

View chunk details and perform retrieval verification on parsed documents.

Build a Q&A Service from the Knowledge Base

In “Chat → Create Assistant”, configure the assistant to reference the desired knowledge base and select the appropriate Chat model.

Test the service; answers include citation details indicated by an exclamation mark.

Application Scenarios

Intelligent customer service: real‑time retrieval from enterprise knowledge bases for accurate, personalized responses.

Enterprise technical document Q&A: retrieve and generate structured summaries from multiple internal data sources.

Medical decision support: quickly locate relevant medical literature and case data for clinicians.

Financial research report analysis: integrate and distill large volumes of material to produce investment analysis reports.

- End -

AILLMRAGDeepSeekknowledge baseRetrieval-Augmented GenerationRAGFlow
Data Thinking Notes
Written by

Data Thinking Notes

Sharing insights on data architecture, governance, and middle platforms, exploring AI in data, and linking data with business scenarios.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.