
Overview
Standard vector RAG retrieves text that sounds like the question. It can't connect facts across documents, such as “What complications can result from the condition that the A1C test diagnoses?”, which needs A1C → diabetes → complications across two articles. This system extracts a knowledge graph from the same MedlinePlus articles and combines graph traversal with vector retrieval at query time.
Qwen3-1.7Blocal LLM via Ollama
1–2graph hops per query
3ablated retrieval modes
$0fully local, no API keys
How it works
- Ingestion: parse MedlinePlus, chunk and embed into Qdrant, and prompt the LLM to extract (entity, relation, entity) triples into Neo4j.
- Validated extraction: JSON output is checked against a fixed entity and relation vocabulary; off-vocabulary relations are dropped.
- Entity resolution: names are canonicalised against the source article title, so “HbA1C”, “A1C” and “Glycohemoglobin” become one node.
- Retrieval and synthesis: vector search always runs; entities from the question expand 1–2 hops in the graph. The answer uses only the merged context and says so when it's insufficient.
Design decisions
- Removed the multi-hop classifier. The 1.7B model reasoned about hops correctly in free text but was unreliable at one-word labels; running graph expansion always removed a silent failure mode.
- Deterministic evaluation. Vector-only, graph-only and hybrid run on the same pipeline with parts disabled, scored by keyword match rather than an LLM judge.
- No RAG framework. Plain Python, so every mechanism is visible and testable.
