Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/avnlp/agentic-med-diag/llms.txt

Use this file to discover all available pages before exploring further.

Agentic Graph RAG for Medical Diagnosis is a multi-hop, agentic Retrieval-Augmented Generation system built specifically for clinical question answering. Unlike single-pass retrieval systems that fetch a fixed context window and generate an answer in one shot, this system iteratively decomposes complex clinical questions into sub-queries, retrieves evidence from both a semantic channel and a relational knowledge-graph channel, and synthesizes a final answer only after multiple reasoning hops. It was built because real-world clinical questions — spanning symptoms, biomarkers, treatments, and multi-step differential diagnoses — cannot be reliably answered by simple RAG; they demand traversal across a structured medical knowledge graph.

Agentic Multi-Hop Reasoning

Iterative sub-query decomposition with back-references across hops — the system keeps reasoning until it has gathered sufficient evidence, not just until it hits a context limit.

Dual Retrieval Channels

Parallel semantic (text) and relational (knowledge-graph triple) channels run simultaneously inside a LangGraph state machine, then their outputs are fused into a single answer.

Four Swappable Backends

LightRAG, MiniRAG, PathRAG, and HyperGraphRAG are all supported and switchable at runtime, letting you trade off between retrieval depth, efficiency, and graph expressiveness.

LangGraph Orchestration

The entire pipeline is a hierarchical LangGraph state machine with stateful subgraphs, conditional loop edges, and fan-out/fan-in — giving you full observability and control over every reasoning step.

The Problem: Simple RAG Fails on Complex Clinical Questions

Standard RAG retrieves a handful of the most semantically similar document chunks and hands them to a language model. This works for simple factual lookups, but clinical reasoning routinely requires connecting information scattered across multiple documents and relationships. A question like “Which treatment is contraindicated for a patient presenting with symptom X, comorbidity Y, and biomarker Z?” requires the system to:
  1. Identify the relevant entities (symptom, comorbidity, biomarker, drug classes).
  2. Traverse the knowledge graph to find pairwise and higher-order relationships among them.
  3. Reconcile evidence from both structured graph triples and unstructured text passages.
  4. Iterate if the first retrieval pass is insufficient.
Single-pass retrieval collapses all of this into one step, producing answers that miss critical relational context. This system solves that by running two parallel iterative retrieval-and-reasoning loops — a semantic channel and a relational channel — orchestrated by a parent LangGraph graph that fans out, waits for both channels to converge, and then synthesizes their outputs.

Graph RAG Backends

Each backend builds and queries a knowledge graph differently. All four are supported and can be swapped at runtime.
BackendSummary
LightRAGBuilds a dual-level knowledge graph (local entity mentions + global concept clusters) and retrieves context in hybrid mode via keyword-based KG traversal and dense vector search simultaneously.
MiniRAGA lightweight Graph RAG designed for resource-constrained settings; uses a simpler flat graph construction and a "light" retrieval mode that prioritises efficiency over exhaustive traversal.
PathRAGOrganises the knowledge graph into a two-tier hierarchy (global abstract entities and local fine-grained mentions) and retrieves reasoning paths between entities rather than isolated nodes or edges.
HyperGraphRAGExtends the standard pairwise-edge graph model with hyperedges — edges connecting more than two entities at once — enabling a single relationship to capture group interactions among multiple medical concepts simultaneously.

Storage Layer

The system relies on two complementary storage backends that serve the two retrieval channels:
  • Neo4j — stores the entity/relationship knowledge graph built from ingested medical documents. The relational channel queries Neo4j to retrieve structured KG triples and multi-hop paths.
  • Milvus — stores dense vector embeddings for semantic retrieval over document chunks. The semantic channel performs hybrid search over Milvus to ground sub-queries in text evidence.

Evaluation

All four agentic pipelines are evaluated against their corresponding baseline (non-agentic) backends using DeepEval metrics. Metrics: Contextual Recall, Contextual Precision, Contextual Relevancy, Answer Relevancy, Faithfulness Medical Benchmarks:
DatasetDescription
HealthBenchMulti-turn medical AI benchmark with expert rubric evaluations
MedCaseReasoningMedical case studies with detailed reasoning processes
MetaMedQAMedical QA based on USMLE textbook content
PubMedQABiomedical QA based on PubMed articles

Quickstart

Install dependencies, start Neo4j and Milvus, and run your first multi-hop medical query in under ten minutes.

Architecture

Dive deep into the LangGraph state machine, the dual retrieval channels, and how each backend plugs into the pipeline.

Build docs developers (and LLMs) love