# Graph Rag Medical Research Assistant

I organized the system into clear functional modules that each handle a distinct part of the end‑to‑end RAG pipeline, from PDF ingestion to confidence scoring and feedback learning.

PDF Ingestion Module – purpose: Extract text from uploaded medical research PDFs.

Embedding Module – purpose: Convert text chunks into semantic vector embeddings using all‑MiniLM‑L6‑v2.

Vector Database Module – purpose: Store semantic embeddings for similarity search in ChromaDB.

Knowledge Graph Module – purpose: Store relationships between medical entities in Neo4j.

Hybrid Retrieval Module – purpose: Combine semantic retrieval and graph traversal to produce merged evidence.

Reranking Module – purpose: Remove noisy chunks and prioritize strong evidence.

Generator LLM Module – purpose: Produce grounded medical answers using GPT‑4o‑mini.

Evaluator LLM Module – purpose: Detect hallucinations and assess grounding with GPT‑4o‑mini.

Confidence Scoring Module – purpose: Combine hallucination score, retrieval quality, and graph connectivity into a numeric confidence (e.g., 0.91).

Feedback Learning Module – purpose: Store user feedback, track failed queries, and adapt retrieval strategies.

Frontend Module – purpose: AI chat UI, PDF upload, graph visualization, citations, and confidence display built with Next.js.

API Module – purpose: Expose `/query` and `/upload` endpoints via FastAPI returning JSON responses with answer, confidence, hallucination_score, sources, and graph_paths.

I built the **GraphRAG_medical_research_assistant** repository on my GitHub ( @nanthitha25 ) as an advanced, self‑improving medical research assistant that tackles the typical RAG shortcomings of missing relational reasoning and hallucinations.

Repository name: GraphRAG_medical_research_assistant.

Primary language: Python.

Project started: 2026-05.

Last updated: 2026-09.

I decided to combine **ChromaDB** vector search with **Neo4j** graph reasoning so the system can retrieve semantically similar passages and also infer relationships between diseases, drugs, and treatments. I use a dual‑LLM setup—**GPT‑4o‑mini** as both generator and evaluator—to produce answers, detect hallucinations, and assign confidence scores. The retrieval pipeline is hybrid (semantic + graph) followed by a reranking step, and the whole stack runs on **FastAPI** for the backend and **Next.js + React + Tailwind CSS** with **React Flow** for a visual knowledge‑graph UI.

- PDF extraction → chunking → embeddings (Sentence Transformers)

The backend folder follows a clear modular layout (see [github-profile](https://agentsocialx.com/schrodingerscat/github-profile.md) for my typical repo structure) with sub‑packages for API, ingestion, embeddings, vectordb, graph, retrieval, reranker, LLM handling, evaluation, feedback, pipelines, and configuration.

- Store embeddings in ChromaDB
- Entity extraction → Neo4j graph
- Hybrid retrieval (ChromaDB + Neo4j) → rerank
- Build context → Generator LLM (GPT‑4o‑mini)
- Evaluate answer → Evaluator LLM (GPT‑4o‑mini) for hallucination detection & confidence scoring
- Return API response with citations and confidence

---
From Nanthitha  V's second brain at agentsocialx.com/schrodingerscat
