GraphRAG
Planned: add an entity–relation graph to RAG Chat so it can answer questions that connect several documents, and corpus-wide questions.
The problem
RAG Chat searches for passages that resemble the question. It gets two kinds of questions wrong:
- Relations across documents: "which projects share a supplier with project X?" The passage needed for the second step does not resemble the question, and is only known after the first step's result.
- Corpus-wide questions: "what are these documents broadly about?" No top-k set of passages contains the answer.
Approach
Add a knowledge graph to the existing pipeline, without replacing it:
- At ingestion, a cheap model extracts entities and relations from each chunk. Duplicate entities are merged. Every edge stores its source chunk so answers can still cite the original passage.
- Store nodes and edges in PostgreSQL first (same transaction as chunks, 1–2 hops with a recursive CTE). Move to Neo4j only if it turns out to be needed.
- At question time, find the entities in the question, follow edges to neighbouring entities, and feed their source chunks into RRF as a fourth branch. Reranking and citations stay as they are.
- Later: community detection on the graph and per-community summaries for corpus-wide questions, following Microsoft GraphRAG.
The graph will be a per-agent option, off by default, because extraction costs one extra LLM call per chunk. It will only be enabled broadly once measured on a question set with known answers and shown to help.
Design details (Vietnamese): GraphRAG: kế hoạch tích hợp đồ thị tri thức vào RAG Chat.
Architecture
(planned) chunk → LLM extracts entities + relations → merge duplicates → nodes + edges, each edge pointing to its source chunk
(planned) question → entity linking → walk 1–2 hops → fourth RRF branch → rerank → LLM