Skip to content
Aryagarg23Public

About

Traceable GraphRAG over a medical textbook — 60k-node Neo4j graph, every answer arrives with its reasoning path. 1st place, Future of Data 2024.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

WhiteBox

Turns a medical textbook into a graph so an AI's answer can be traced node by node instead of trusted as a black box.

Built in 36-ish hours at The Future of Data (Cincinnati, November 2024). 1st place.

What it does

WhiteBox takes Davidson's Principles and Practice of Medicine and breaks it into a Neo4j graph of about 60,000 nodes and 130,000 relationships. Ask it a medical question and instead of a model generating an answer from nowhere, it walks a path through that graph and shows you the path.

The bet behind it: in a field like medicine, "trust me" isn't good enough. If a model tells you a symptom points to a diagnosis and a diagnosis points to a treatment, you should be able to see the specific nodes and edges it walked to get there, not just the final sentence.

How it works

  • A question comes in through the /getNodes endpoint (server/Graph_RAG.py).
  • Each word in the question gets embedded with all-MiniLM-L6-v2 (sentence-transformers) and scored against the whole question by cosine similarity, so filler words drop out and only terms above a 0.25 threshold survive.
  • Those terms drive a Cypher query against Neo4j, pulling candidate Document nodes that touch them.
  • Candidates get re-ranked by cosine similarity between the question and each document's title + text, and the top 3 are kept.
  • Their graph neighborhoods get pulled and handed to microsoft/Phi-3-mini-4k-instruct, which generates the answer from that neighborhood instead of from general knowledge.
  • The same subgraph is returned as nodes and edges and rendered in the browser with vis.js, so the answer and the path it came from sit side by side.
  • Model selection and fine-tuning, including a LLaMA 3.1 8B fine-tune for summarization and classification, was Arya's part of the build, feeding the graph and the retrieval step above.
  • The graph dump is in Neo4j/neo4j.dump; Neo4j/load-data.sh contains the database restore command. scripts/DB_labels_fix.py merges near-duplicate labels after import.

Run the web demo

The UI and graph API are separate Flask processes. Set NEO4J_URI, NEO4J_USERNAME, and NEO4J_PASSWORD in the environment for the graph API, and point them at a Neo4j database restored from the included dump. For a local Neo4j instance, the URI is commonly bolt://localhost:7687. From the repository root, install each service's listed Python requirements and start the processes in separate terminals:

python3 -m pip install -r server/requirements.txt
python3 server/Graph_RAG.py
python3 -m pip install -r frontend/requirements.txt
python3 frontend/app.py

Open http://localhost:8080/. The UI sends graph questions to the API on port 8000. The server loads all-MiniLM-L6-v2 at startup and downloads Phi-3 when generating an answer; model weights and a populated Neo4j database are not bundled. server/main.py is a separate early /chat echo stub, not the graph endpoint used by this UI.

This is a hackathon research demo, not a clinically validated diagnostic or treatment tool. Its answers and retrieved paths require expert review.

Prototype

The real pipeline needs Neo4j loaded with the full graph and two models resident in memory, not something you casually clone and run. prototype/graph_qa_demo.py is a toy stand-in: a 25-node dict graph of symptoms, conditions, and treatments, walked with plain BFS instead of a model call. The point survives the downgrade: the answer is the path, and the path is the whole explanation.

No hackathon metrics were logged, so there are no charts of results here — just two explanatory diagrams. python prototype/graph_qa_demo.py regenerates both locally (numpy + matplotlib, nothing else).

The first is a real BFS walk on the toy graph, asking "what treats shortness of breath?" and tracing the shortest path to a treatment (the rest of the toy graph shown as hairlines for context):

Traced path from 'shortness of breath' to 'diuretics', 2 hops through a 25-node toy graph, rest of the graph shown as hairlines. Tagged "toy graph, real walk."

The second is a concept sketch of the real architecture as built at the hackathon: textbook to graph at build time, question to answer-with-path at query time.

Architecture diagram: Davidson's textbook chunked and classified by a fine-tuned LLaMA 3.1 8B into a Neo4j graph (~60k nodes / ~130k relationships, real figures from the build), then a clinician's question runs through MiniLM embedding, Cypher retrieval, and Phi-3-mini analysis to produce an answer returned with its graph path. Tagged "architecture as built at the hackathon."

Team

Originally hacked together in KaaustaaubShankar/WhiteBox.

Links

More hackathon builds

  • Gyrus — agentic browser that supports curiosity instead of replacing it (WeaveHacks 2025)
  • G-Code-Assembler — G-code assembly + STL visualization (MakeUC 2024, Kinetic Vision winner)
  • Terminally-Addicted — Spotify, GitHub, GPT and YouTube without leaving the terminal (HackOHI/O 2024)
  • Memento — digital memory journal for Alzheimer's patients and caregivers (RevolutionUC 2024, 3rd overall)
  • Buycott — barcode scan -> parent company -> NLP stance on social issues (MakeUC 2023, 1st overall)
  • SignLink — video calls with real-time ASL fingerspelling to text (BoilerMake X 2023)
  • Kuka Arm Viz — interactive 7-DOF robot arm in WebGL with inverse kinematics (RevolutionUC 2023)
  • Hi-Five — anonymous friend-matching on OCEAN personality vectors (SASEhack 2024)
  • Friction — speculative OS + hardware that protects flow state with physical friction (Fig Build 2026)

About

Traceable GraphRAG over a medical textbook — 60k-node Neo4j graph, every answer arrives with its reasoning path. 1st place, Future of Data 2024.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages