2026
ClinicalRAG
Answers questions using an indexed set of clinical guidelines. Each sentence links back to its source, and unsupported questions return a refusal.
- Role
- Sole engineer
- Stack
- Python, LangGraph, FastAPI, ChromaDB, ONNX, Groq, React, Docker
- Links

The problem
A retrieval system can still produce an answer that is not supported by what it retrieved. For clinical questions, showing the source is only useful if the answer itself stays within that source.
ClinicalRAG answers from a fixed set of ingested guidelines and tracks source support at the sentence level. Questions outside the domain or without enough supporting evidence return a refusal. It is an educational project and has not been clinically validated.
How a query is handled
Physician console
React. Sends the question, collection and source limit.
Query API
FastAPI, POST /api/v1/query, with rate limiting, request IDs and typed models.
Guard
Checks whether the question is in-domain before retrieval.
Off-topic: return a refusal with reason off_topic.
Decompose
Splits compound questions using a term lexicon. No model call.
Retrieve
Multi-query ChromaDB search over MiniLM embeddings, deterministic rerank, merge cap.
Grade relevance
llama-3.1-8b-instant keeps chunks that can support the question.
No relevant chunks: skip generation and refuse.
Generate
llama-3.3-70b-versatile, or an extractive answer in mock mode.
Evaluate grounding
Checks sentence attribution, citation coverage and dosages against the retrieved sources.
Unsupported dosage: refuse.
Respond and audit
Returns the answer, citations and any refusal reason. A SHA-256 hash of the query is written to the audit log.
When it refuses
- The question falls outside the clinical domain.
- Retrieval does not return evidence relevant enough to answer it.
- The generated answer contains a dosage unsupported by the retrieved sources.
What you see
- Public demo: ONNX MiniLM retrieval with deterministic extractive responses.
- An answer with supporting citations, or a refusal with its reason.
- A grounding score for the generated answer.
- A deterministic mock mode for running tests without an API key.
Limits
- Educational software, not a medical device or clinically validated system.
- The demo uses a small guideline corpus.
- The refusal checks cover specific failure modes and do not establish that an answer is clinically correct.