Building a retrieval layer that follows connections instead of matching resemblance
Twelve steps, four parts, three runnable labs.
- All 12 steps, read online
- Runnable labs to download (plain Python, runs offline)
- Free updates whenever it's revised
- 14-day refund (conditions)
Introduction
Your retrieval works and your answers are still wrong. You ask “what breaks if I change this”, “why did this start failing”, “what are we exposed to” — and get back documents that resemble the question instead of the facts connected to it.
Why tuning the retriever does not fix it
The reflex is to improve the search: a better embedding model, a reranker, a higher
k, hybrid keyword-plus-vector. Those help when the answer is ranked low. They
cannot help when the answer is ranked at zero — and on this kind of question it
is, because the document holding the answer was written by someone who was not thinking
about your question and shares no words with it.
In the three labs in this volume, the document that states the answer scores exactly zero against the question every time. No threshold promotes it. That is not a tuning problem, and recognizing it as a different problem is most of what this volume is for.
What graph engineering is
Graph engineering is the practice of converting documents into an explicit structure of entities and relations, so that retrieval can follow connections instead of matching resemblance.
Instead of storing documents and returning documents, you extract the facts inside them as triples — one subject, one relation, one object — and store how those facts connect. A question then starts at an entity and walks, one relation at a time, to facts no document mentioned alongside it.
You may know this as a knowledge graph. This volume just says graph: the compound adds nothing, and using both words invites the idea that they are two different things.Where it sits in what you already run
It does not replace your retriever. Finding where to start is still a similarity problem, and this volume keeps it that way — a graph layer takes over after the first step, not instead of it.
| the step | what does it | where it stops |
|---|---|---|
| 1. find the starting point | keyword or vector search, over your existing index | at resemblance — it can only return what looks like the question |
| 2. walk outward | a graph layer, following typed relations from there | at a hop budget you set, which is step 6 |
| 3. write it down | serialize the reached subgraph into text | at the size of the request block, which is step 7 |
So the honest framing is not “graphs instead of vector search”. It is: your search picks the starting point, and the graph decides what travels with it.
Is this for you?
It depends on the shape of your questions, not on the size of your corpus. Sort a few of your real ones:
| question shape | example | what it needs |
|---|---|---|
| descriptive | “what does verify_signature do?” | resemblance — you do not need this volume |
| descriptive | “summarize the incident report” | resemblance — a graph is pure overhead here |
| connective | “what breaks if I change verify_signature?” | connection — the answer is about a different entity |
| connective | “why did this test start failing?” | connection — the cause is hops from the symptom |
| connective | “which products are exposed to this outage?” | connection — the two ends share no vocabulary |
What it costs
Said before you are invested rather than after. A graph costs a vocabulary somebody maintains, an extraction pass over every document, and a rule for deciding when two names mean one thing. That last one is the hard part, and step 5 is about the two opposite ways it fails.
What you will build
A graph retrieval layer in eight stages, of which five are decisions you make and three are infrastructure you buy. Three runnable labs carry it — a test-failure triage, a code-and-git question, and a supply-chain exposure question. They share their core byte for byte, which is how the claim that the method is domain-independent is made checkable rather than asserted.
By the end you can tell which of your own questions need connection rather than resemblance, build the pipeline that answers them, and say what it cost.
What is original here, and what is not
The retrieval half of this volume is its own: the budget sweep, the hop sweep, the baseline comparison, and every measured figure. The construction half — schema design, extraction discipline, and the fusion pipeline — follows an established curriculum, and the steps that borrow from it carry a link to the source at the point they borrow. Full references are at the end of step 12.
How to read the source labels
Every step is labeled with where its content comes from, so you always know whether you are being told something or shown a measurement.
| label | means |
|---|---|
| concept | argued from first principles, quotes nothing from a lab |
| demonstrated | a lab prints the mechanism; quotes its own printed output |
| measured | a lab compares two things; quotes figures from the comparison |
| hands-on | you run it on your own material |