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 supporting multiple retrieval strategies.
How RAG worksâ
- User asks a question
- Retriever searches your knowledge base for relevant documents
- Context is assembled from retrieved chunks
- LLM generates an answer grounded in the retrieved context
Knowledge base typesâ
DB-GPT supports multiple knowledge base types out of the box:
| Type | Storage | Best for |
|---|---|---|
| Vector | ChromaDB, Milvus, OceanBase | Semantic similarity search |
| Knowledge Graph | TuGraph, Neo4j | Entity relationships, structured Q&A |
| Keyword (BM25) | Built-in | Exact keyword matching |
| Hybrid | Combines multiple | Best-of-both retrieval |
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, and other source files
RAG pipelineâ
The full RAG pipeline in DB-GPT:
Key stepsâ
- Parsing â Extract text from uploaded documents
- Chunking â Split text into manageable segments
- Embedding â Convert chunks into vector representations
- Storage â Store vectors in a vector database
- Retrieval â Find relevant chunks for a given query
- Re-ranking â Optionally re-rank results for better relevance
- Generation â Feed context + query to the LLM
Quick start with RAGâ
- Open the DB-GPT Web UI
- Navigate to Knowledge Base in the sidebar
- Create a new knowledge base
- Upload your documents
- Wait for processing to complete
- Start chatting with your knowledge base
For programmatic access, see the RAG Cookbook.
What's nextâ
- 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