Executable Ontology Fixes Graph Retrieval Hallucinations
coldoven · reddit · 2026-07-13
The author tackles a classic graph retrieval issue: the graph contains an edge, but the edge type is incorrect, ultimately returning a highly confident but wrong answer.
Solution
- Transforms the ontology from a document into executable rules, explicitly declaring relationship domain/range in YAML.
- Validates edge legality on every traversal; if an invalid edge type is encountered, it throws a named error instead of silently returning the wrong node.
Additional Takeaways
The author discovered that the same declarations can be directly used for ranking:
- Models the query as a small circuit, with the starting entity and target category acting as two poles.
- Scores entities based on the current flowing through the nodes.
- This filters out incorrect paths while naturally surfacing relevant entities at the top.
Example
For queries like "Sci-Fi by Nolan," the system correctly ranks true matches while assigning a score of 0 to nodes like The Dark Knight (which is related to Nolan but the wrong category) without needing extra manual filters.
The author notes this method is essentially based on classic harmonic functions / current-flow centrality, with the novelty being the unification of these concepts with knowledge graph validity checks from a single source. The project offers an API compatible with 9 graph database backends and can run offline.
More from coding & agent
- A better path to agent autonomy is running waves, finding friction, and iterating — JnBrymn · 2026-07-22
- Coding agents are heading toward an AI-writes, AI-reviews, human-approves workflow — aftahi_ai · 2026-07-22
- oMLX 0.5.2 adds Mac menu-bar stats, low-bit decode kernels, and faster downloads — awnihannun · 2026-07-22
- GitHub review bot hits its PR limit and forces a 39-minute cooldown — DanielLockyer · 2026-07-22
- Max reasoning effort appears to be mobile-only in Codex Remote, not desktop — GabGarrett · 2026-07-22
- A Reddit demo argues online stores should expose carts and pricing through MCP — gelembjuk · 2026-07-22