Skip to main content
Version: dev

Graph RAG

Graph RAG is the retrieval mode that uses DB-GPT's knowledge-graph index. When you enable the KnowledgeGraph index method on a knowledge space, DB-GPT builds a family of graphs and retrieves by graph traversal instead of (or in addition to) vector / keyword search.

What gets built​

GraphBuilt forCaptures
LLM triplet graphany text(subject, predicate, object) facts and relations
Document–paragraph graphany documentdocument → chunk → chunk structure (include / next)
Markdown heading graph.md filesfile → H1 → H2 → H3 heading hierarchy (contains)
Code graphcode files / GIT_REPO spacescode AST parsed with tree-sitter → function / class / method nodes with file → defines edges

All four share one build path and write into the configured graph store (TuGraph / Neo4j / Memgraph).

How retrieval works​

The GraphRetriever matches graph nodes by keyword, by vector similarity on node embeddings, by natural-language-to-graph-query (Text2GQL), and via document–graph associations — then expands along edges. Every edge remembers the chunk it came from, so answers remain citable.

note

The retriever can traverse CALLS / INHERITS / IMPLEMENTS edges, but the current code-graph builder only emits contains and defines. Call-chain and inheritance queries will be empty unless those edges were produced by another builder.

Learn more​