Knowledge graph
KG · Entity graph
A network of entities (nodes) joined by named relationships (edges), extracted from text so facts spread across documents can be connected.
In DocSlurpIllustrated explainer
On this page
The problem: facts that live in no single chunk
Ask the Meridian & Co. corpus “Who approves the jet for the exec leading the London launch?” Search splits documents into chunks and looks for the chunks most like the question. None of them is. The answer is spread across three documents:
growth-plan-2027.pdfp. 12: the London launch is led by the COO.charter-agreement.pdfp. 2: the COO flies on the Learjet charter.board-update-2026.pdfp. 9: the CFO pre-approves every Learjet charter over $40k.
Each chunk holds one link of the chain. Keyword search for “approves” and “London” finds no passage containing both. Vector search might return the board update page, but nothing tells the model that this charter is the one the launch lead flies on. A chunk index treats every passage as an island.
The idea: store the links, not just the passages
A knowledge graph stores facts as nodes (entities: a person, a project, an aircraft, a company) joined by edges (named relationships). Each edge is a triple, the same shape the W3C’s RDF standard uses:
(London launch) --led by--> (COO)
(COO) --flies on--> (Learjet charter)
(CFO) --pre-approves--> (Learjet charter)
Once the three sentences become three edges, the question is a walk. Start at London launch, follow led by to COO, follow flies on to Learjet charter, then follow pre-approves backwards to CFO. Three hops, three source documents, one answer. The figure shows the walk; each numbered edge points back to the sentence it came from.
Notice two properties that make this work:
- Entities are shared across documents. “Learjet charter” in the agreement and “Learjet charter” in the board update become the same node. That merge is what joins the documents. Without it you’d have two disconnected fragments.
- Edges keep their evidence. A good graph records which chunk and page each edge came from, so an answer assembled from a path can still cite
charter-agreement.pdfp. 2 for the middle hop.
How the graph gets built
Nobody hand-writes these graphs for a document corpus. They are extracted:
- Entity extraction. A model reads a passage and returns typed entities and subject-predicate-object triples.
- Merging. Mentions that refer to the same thing are combined into one node. The simplest rule is “same normalized name and type”; better systems also use aliases.
- Weighting. An edge stated in five documents is more trustworthy than one stated once, so edges carry a weight, often the count of supporting passages.
- Linking back. Each node records the chunks that mention it, which is what lets search turn “reached this entity” into “return these passages”.
Many systems also add cheap co-mention edges: two entities that appear in the same chunk are probably related, even if no sentence states how.
How search uses it
A graph rarely replaces chunk search. It feeds it. The common patterns:
- Graph expansion. Find the entities a query names, walk one or two hops, and add the chunks that mention what you reached to the candidate list.
- Community summaries. Cluster the graph into topics and summarize each one, which helps with questions about the whole corpus. This is the core of GraphRAG.
- Explicit traversal. An agent or query language walks typed edges directly (“everything the CFO pre-approves”). This needs a clean schema and is more common in curated enterprise graphs than in graphs extracted from documents.
Where it breaks
- Extraction errors become structure. If the model misses “flies on”, the path is cut and the answer is unreachable. If it invents an edge, the graph states it with the same confidence as a real one.
- Merging is hard. “Learjet charter”, “the jet” and “N750MC” may be one node or three. Merge too eagerly and unrelated “Mercury” projects collapse into one.
- Hubs swamp the walk. The company name or “CFO” connects to hundreds of nodes. Two hops from a hub is most of the corpus, so expansion must stay shallow and be reranked.
- It costs model calls at ingest. Every document is read by an extraction model before it is searchable through the graph. Re-extraction is needed when the entity vocabulary changes.
- Not the HNSW graph. Vector indexes such as HNSW are also graphs, but their edges mean “these vectors are close”, not “this executive leads that launch”. The two are unrelated.
When to reach for it
Build a graph when questions hop between named things across documents: which executives lead which launches, who approves what, which contracts mention which parties. Skip it when questions are answered by one passage, which is most lookup traffic; plain vector search plus keyword search is cheaper and easier to keep correct.
In DocSlurp, each project can build one graph. It is off by default and turned on per project. Extraction runs in the graph-enrich stage one document at a time, so the graph grows during long runs (core/worker/src/stages/graph-enrich.ts). Nodes merge on normalized name and entity type, edge weight is the sum of per-document evidence, and every node, edge and community is scoped to the project (core/worker/src/graph/graph-store.ts).
In DocSlurp
In DocSlurp
Each project can build one graph, off by default: entities, typed relationships, chunk mentions and communities, all scoped by project (core/worker/src/stages/graph-enrich.ts, core/worker/src/graph/graph-store.ts). Search uses it for graph expansion and community summaries.