RAG (Retrieval-Augmented Generation)
RAG enhances LLM responses by retrieving relevant context from your own data before generating an answer. DB-GPT provides a comprehensive RAG framework with multiple indexing and retrieval strategies, and runs knowledge-base chat as an agentic RAG loop.
Two phases: indexing and conversationโ
INDEXING (document-sync time) CONVERSATION (chat time)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโ
upload โ chunk โ indexes question
โ โ
vector / keyword / agentic RAG loop:
knowledge-graph rewrite โ retrieve
(+ structural tree, (maybe repeat) โ
+ code graph for code) fuse + rerank โ
cited answer
These two phases are decoupled โ indexing runs once at sync time; chat only retrieves and never re-indexes.
How the conversation works (agentic RAG)โ
DB-GPT does not do a single retrieve-then-generate. An agent drives the loop:
The agent can rewrite the query, retrieve multiple times, fuse and rerank results, and produce a cited answer โ letting it handle complex or multi-part questions that one-shot RAG cannot. Full detail: Agentic RAG Conversation Principles.
Indexesโ
All indexes operate on the same chunks, so chunking quality is the foundation.
| Index | What it gives you | Built |
|---|---|---|
| Vector | semantic similarity via embeddings + cosine | at sync time |
| Keyword (BM25) | exact term matching | at sync time |
| Knowledge Graph | graph traversal over entities, document structure, headings, and code | at sync time |
| Structural | markdown-header tree / parent-child navigation | at query time (from chunk heading metadata) |
| Code graph | code AST as function / class nodes (for code files / git repos) | at sync time |
The Knowledge Graph index is a family of graphs: LLM-extracted triplets, a documentโparagraph structure graph, a Markdown heading-hierarchy graph, and a code AST graph (parsed with tree-sitter). See Knowledge Base Indexing Principles.
Supported file formatsโ
Upload and process a wide variety of document formats:
- Documents: PDF, Word (.docx), Markdown, TXT
- Spreadsheets: Excel (.xlsx), CSV
- Web: HTML, URLs
- Code: Python, Java, JavaScript, TypeScript, Go, Rust, C/C++ โ parsed into the code graph
Quick start with RAGโ
- Open the DB-GPT Web UI
- Navigate to Knowledge Base in the sidebar
- Create a new knowledge base (choose index methods: Vector / Knowledge Graph / Full Text โ combinable)
- Upload your documents
- Wait for processing to complete
- Start chatting with your knowledge base (runs the agentic RAG loop)
For programmatic access, see the RAG Cookbook.
What's nextโ
- Knowledge Base Indexing Principles โ how a document becomes searchable
- Agentic RAG Conversation Principles โ how a question becomes a cited answer
- Knowledge Base UI โ Manage knowledge bases in the Web UI
- Graph RAG โ Knowledge graph-based retrieval
- RAG Module โ Deep dive into the RAG framework
- RAG Development Guide โ Build RAG apps programmatically