Use entity links to find candidate evidence while retaining the passage, relation type, revision and access rule that made each edge valid.
Knowledge graph retrieval: prove every edge in the path
Define the graph's evidence contract
Graph retrieval stores entities and typed relations so a question can follow connections that text similarity misses. Consider a service case linked to a replacement part, which is linked to a supplier bulletin. A bare edge saying that a case uses a part is insufficient: the edge also needs the source passage, relation type, effective time, extraction method and tenant. The graph is a navigation index, not an authority separate from its documents. Passage provenance lets a reviewer inspect the statement behind each edge.
Resolve entities before traversal
An identifier can be reused across tenants, and two supplier names can refer to one organization. Resolve an entity only within its namespace and permitted source set. Keep aliases as attributed claims rather than overwriting the canonical node. For an ambiguous name, return candidate entities with their disambiguating attributes; do not silently merge them. A false merge makes every later traversal look plausible. Exact identifiers should remain exact even when a semantic retriever proposes a near match.
Bound traversal and evidence assembly
Start from an authorized seed, expand only allowed relation types, cap hop count and degree, and reject a route if any edge lacks an active supporting passage. A popular supplier node may have thousands of neighbors; unrestricted breadth-first traversal can dominate latency and swamp the answer with irrelevant paths. Score the path by the weakest required edge and the question's relation sequence. Multi-hop stop rules should halt when the requested join is proven or the search budget expires.
Treat updates as graph operations
A document deletion must remove or invalidate all edges supported solely by that revision. If another active passage also supports an edge, the edge may survive with that other provenance. Keep an edge-to-passage reverse map to make revocation prompt. During a rebuild, compare node and edge counts by tenant, then test a set of known paths and forbidden paths before swapping the graph generation. Versioned ingestion prevents an old event from reviving a revoked relation.
Judge paths, not fluent answers
Create questions with known seed nodes, expected relation sequences and expected supporting passages. Report seed resolution, edge recall, valid-path recall and final claim support separately. Include a shared-name trap, a stale edge, a missing middle relation, a high-degree hub and a cross-tenant decoy. If the result uses a correct answer reached through unsupported edges, mark the path wrong: the route will fail on the next corpus revision.
Worked contract
from collections import deque
from dataclasses import dataclass
@dataclass(frozen=True)
class SupportedEdge:
source: str
target: str
relation: str
tenant: str
passage_id: str
def evidence_paths(edges: list[SupportedEdge], start: str, goal: str,
tenant: str, allowed: tuple[str, ...], degree_cap: int = 24):
adjacency: dict[str, list[SupportedEdge]] = {}
for edge in edges:
if edge.tenant == tenant and edge.passage_id:
adjacency.setdefault(edge.source, []).append(edge)
frontier = deque([(start, ())])
while frontier:
node, path = frontier.popleft()
if len(path) == len(allowed):
if node == goal:
return path
continue
candidates = [edge for edge in adjacency.get(node, ())
if edge.relation == allowed[len(path)]]
for edge in candidates[:degree_cap]:
if edge.target not in {start, *(part.target for part in path)}:
frontier.append((edge.target, path + (edge,)))
return ()
links = [SupportedEdge("case-47", "part-83", "uses", "north", "case-r2"),
SupportedEdge("part-83", "bulletin-29", "covered-by", "north", "notice-r4"),
SupportedEdge("part-83", "bulletin-91", "covered-by", "south", "private-r3")]
path = evidence_paths(links, "case-47", "bulletin-29", "north",
("uses", "covered-by"))
assert [edge.passage_id for edge in path] == ["case-r2", "notice-r4"]
assert evidence_paths(links, "case-47", "bulletin-91", "north",
("uses", "covered-by")) == ()Performance and operating cost
Building the in-memory adjacency map costs O(E) time and space for E eligible edges. A bounded traversal can still examine up to the degree cap raised to the hop count; keep both limits small and index relation plus tenant in persistent storage. The example returns the first valid path, not the globally best path, and production ranking needs judged evidence quality.
Common Mistakes
- Treating an extracted relation as fact after its supporting passage was deleted.
- Merging two tenants' same-named entities into one node.
- Allowing a high-degree node to expand without a cap.
- Citing only the final bulletin when the answer depends on two edges.
Validation drill
Construct 43 questions against a small case-part-bulletin graph. Remove six supporting passages and verify that the affected paths disappear, while paths with independent support remain.
Read next
- Multi-hop retrieval: build evidence chains with bounded searches
- Document extraction: preserve passage provenance through OCR and parsing
- Retrieval corpus contracts: identity, permissions and document lifecycle
- Claim-level citations: verify each answer against its passage
