GraphRAG on a medical textbook

Technical · November 2024

The Future of Data

When a model answers a medical question, the useful follow-up is where that answer came from, and most systems can't say. At the Future of Data hackathon we built WhiteBox to make the path visible. Ask a question, and instead of a paragraph from nowhere you get the chain of connected facts the system walked through a real medical textbook to get there.

We took Davidson's Principles and Practice of Medicine, a standard internal medicine reference, and turned it into a graph you can trace. The answer arrives with its route drawn on the graph, step by step, so a clinician can audit the reasoning instead of trusting it.

It won first place. Team was me, Kaaustaaub and Raihan, the same crew from Memento and later Gyrus.

WhiteBox

My corner of it was picking and fine-tuning the open-source models, small enough to run, good enough to structure a textbook.

Technical

The textbook became roughly 60,000 nodes and 130,000 relationships in Neo4j. A fine-tuned LLaMA 3.1 8B did the summarization and classification that built the graph, MiniLM embeddings drove the Cypher retrieval, and Phi-3 3.8B handled the deeper analysis pass on retrieved subgraphs. Flask served it, vis.js drew the graph so you could watch the path light up.

A traced answer path through a toy medical knowledge graph, real walk on a stated toy example

The WhiteBox pipeline as built: textbook to Neo4j graph to traced answer

Scaling laws were part of the pitch. Parameter counts were growing exponentially for low single-digit gains at the time, and a system that explains its retrieval seemed like a more useful direction for high-stakes domains than a bigger blob. That's still my read, though I'd say it more carefully now than we did on the demo stage.