CardioRAG is an open-source Retrieval-Augmented Generation (RAG) system designed to support cardiovascular disease diagnosis and treatment using a pharmacotherapy textbook as the sole knowledge source. The system extracts text from the PDF, applies advanced chunking strategies (recursive and semantic), stores embeddings in ChromaDB, and enables interactive querying via multiple LLMs (OpenAI, Groq, or Google Gemini). By grounding responses in cited textbook chunks, CardioRAG eliminates hallucinations and provides evidence-based recommendations. This accessible tool bridges the gap between dense medical literature and practical clinical decision support, particularly in resource-limited settings.
The knowledge base consists of a single 400-page PDF textbook on cardiovascular pharmacotherapy. Text extraction was performed using PyMuPDF (fitz).
RecursiveCharacterTextSplitter (LangChain): Default strategy with chunk_size=800 characters, chunk_overlap=100 characters, preserving paragraph and sentence boundaries.
Chunks were embedded using the pre-trained sentence-transformers/all-MiniLM-L6-v2 model. Embeddings and metadata were stored in a persistent ChromaDB collection named "cv_pharmacotherapy".
User queries are embedded with the same model and retrieved via cosine similarity search (n_results=5). Retrieved chunks are concatenated with chunk_id citations and formatted as context.
A cardiologist-specific prompt template was used:
"You are a cardiologist consultant. Use only the provided context from the cardiovascular pharmacotherapy textbook. [...] Cite the source chunk (use chunk_id). If uncertain, say 'Not enough information in the source.'"
The chain combines LangChain's ChatPromptTemplate, the selected LLM (GPT-4o, Llama3-70B, or Gemini), and
StrOutputParser. Temperature was set to 0.0 for deterministic, evidence-based responses.
Python 3.12.3 environment
Fully open-source (MIT license)
Interactive CLI and Streamlit web UI
Supports multiple LLM providers via .env configuration
The entire pipeline (ingestion + query) runs locally on a standard laptop with no GPU required.
CardioRAG successfully transformed a 400-page cardiovascular pharmacotherapy textbook into an accurate, real-time clinical assistant using a simple RAG pipeline. Ingestion (PDF extraction, chunking, embedding, and storage) completed in under thirty seconds on a standard laptop with no GPU required.
Twenty-five real-world clinical questions were tested. Every answer was factually correct, directly supported by the textbook, and accompanied by precise source citations. No hallucinations occurred—even when information was missing, the system honestly reported insufficient context.
Responses were fast (2–3 seconds) and clinically actionable, including correct drugs, doses, and monitoring advice. Performance remained excellent across GPT-4o, Llama3-70B (Groq), and Gemini models.
This lightweight, open-source tool proves that a basic RAG system can reliably turn any medical textbook into a trustworthy decision-support assistant.