An open-source knowledge graph-powered RAG system that combines a 7.1M-node Neo4j graph (35M relationships, 12M EXTRACTED_FROM edges) with UMLS clinical reasoning path traversal for precise retrieval over medical and scientific literature

I built an open-source knowledge graph-powered RAG system for medical and scientific literature. The retrieval pipeline runs on a Neo4j graph with 7.1M nodes, 35M relationships, and 12M EXTRACTED_FROM edges connecting concepts back to their source document chunks.

The core insight: pure vector semantic search degrades as you add documents. Upload a 10,000-page medical textbook and previously retrievable content falls below the similarity threshold because the embedding index shifts. The knowledge graph is immune to this — concept-to-chunk pointers are structural, not probabilistic.

The retrieval runs four concurrent Cypher traversal strategies per concept pair, ordered by clinical specificity: UMLS 1-hop (via SAME_AS bridges to 1.6M UMLS concepts), UMLS 2-hop (intermediate clinical reasoning paths), direct inter-concept edges, and shared EXTRACTED_FROM chunk co-occurrence. A 35-relationship-type whitelist filters out noise from the 13.9M available UMLS edges. All four strategies run via asyncio.gather so latency is bounded by the slowest query, not the sum.

Stack: Neo4j + Milvus + Python/FastAPI, with Ollama for local bridge generation and vision OCR. All Dockerized, runs fully locally.

Full write-up: https://dev.to/peter_wu_8ad6dcfb10c6f20d/how-i-built-a-rag-system-with-a-7-million-node-knowledge-graph-and-why-vector-search-alone-isnt-4f3e

Repo: GitHub - jeujai/Librarian · GitHub