Skip to content

LearnGraphs & hierarchy

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
Four sentences from four documents become one connected graphLeft, four source sentences. 1, growth-plan-2027.pdf page 12: the London launch is led by the COO. 2, charter-agreement.pdf page 2: wheels-up within three hours of a request, the COO flies on the Learjet charter. 3, travel-desk-guide.pdf page 7: the exec assistant books every Learjet charter with catering and a car. 4, board-update-2026.pdf page 9: the CFO pre-approves every Learjet charter over $40k, per the travel policy. Right, the extracted graph: London launch, led by, COO (from sentence 1); COO, flies on, Learjet charter (2); Exec assistant, books, Learjet charter (3); CFO, pre-approves, Learjet charter (4). A highlighted path answers "Who approves the jet for the London launch lead?": London launch to COO to Learjet charter to CFO, three hops across three documents. No single sentence contains that answer.1growth-plan-2027.pdf · p.12The London launch is led bythe COO.2charter-agreement.pdf · p.2Wheels-up within three hours of a request,the COO flies on the Learjet charter.3travel-desk-guide.pdf · p.7The exec assistant books everyLearjet charter with catering and a car.4board-update-2026.pdf · p.9The CFO pre-approves every Learjet charterover $40k, per the travel policy.1led by2flies on3books4pre-approvesLondon launchCOOLearjet charterExec assistantCFOA question no chunk answersWho approves the jet forthe London launch lead?CFO · 3 hops, 3 documents
Each edge comes from one sentence; the answer comes from the path. Sentences 1, 2 and 4 each hold one link. Walking London launch → COO → Learjet charter → CFO joins them into a fact none of them states. The last hop runs against the arrow: traversal can follow edges in either direction.

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.pdf p. 12: the London launch is led by the COO.
  • charter-agreement.pdf p. 2: the COO flies on the Learjet charter.
  • board-update-2026.pdf p. 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.

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.pdf p. 2 for the middle hop.

How the graph gets built

Nobody hand-writes these graphs for a document corpus. They are extracted:

  1. Entity extraction. A model reads a passage and returns typed entities and subject-predicate-object triples.
  2. 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.
  3. 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.
  4. 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.

Sources

Jump to