Spaces:
Running
A newer version of the Gradio SDK is available:
5.42.0
title: RAGnosis
emoji: π§
colorFrom: red
colorTo: indigo
sdk: gradio
sdk_version: 5.36.2
app_file: app.py
pinned: false
license: mit
short_description: Clinical Query Answering with RAG + MIMIC-IV Notes.
π§ RAGnosis β Clinical Reasoning via Retrieval-Augmented Generation
βοΈ A CPU-friendly RAG assistant for explainable clinical diagnosis, built using annotated notes from the MIMIC-IV-Ext-DiReCT dataset.
πΌοΈ Live Demo
Try it on Hugging Face Spaces (CPU-based, ~500s latency) π :
π https://huggingface.co/spaces/asadsandhu/RAGnosis
βοΈ Technical Stack
Component | Details |
---|---|
π§ Model | BioMistral/BioMistral-7B |
π₯ Dataset | MIMIC-IV-Ext-DiReCT |
π Retrieval | FAISS + SentenceTransformers (all-MiniLM-L6-v2 ) |
π¬ Interface | Gradio (Runs on Hugging Face Spaces) |
βοΈ Backend | PyTorch + Transformers (CPU inference) |
π©Ί Key Features
- π Top-k clinical note retrieval from structured diagnostic chains
- π§ Diagnosis generation using
BioMistral-7B
without GPU - ποΈ MIMIC-IV-Ext-DiReCT backed medical reasoning
- π¬ Natural query input and interpretable LLM output
- β Optimized for Hugging Face's free CPU tier (16GB RAM)
π§ͺ Example Prompt
patient is experiencing shortness of breath
π¬ Model response:
Shortness of breath is a common symptom that can be caused by a variety of respiratory conditions. The differential diagnosis for shortness of breath includes asthma, chronic obstructive pulmonary disease (COPD), congestive heart failure, pneumonia, and pneumothorax. In order to determine the cause of the shortness of breath, it is important to consider the patient's medical history, physical examination findings, and diagnostic testing results. For example, if the patient has a history of asthma and is experiencing wheezing and a prolonged expiratory phase on examination, this would suggest asthma as the cause of the shortness of breath. On the other hand, if the patient has a history of congestive heart failure and is experiencing orthopnea, crackles on auscultation, and a history of edema, this would suggest congestive heart failure as the cause of the shortness of breath.
π§ Under the Hood
π§ Step 1: Retrieval
- Sentence embeddings (
MiniLM-L6-v2
) - FAISS indexing β
faiss_index.bin
- Source:
retrieval_corpus.csv
π§± Step 2: Prompt Construction
- Clinical query + retrieved chunks form an instruction prompt
𧬠Step 3: Generation
- Uses
BioMistral/BioMistral-7B
- Generated on CPU (expect ~500 seconds)
β οΈ Note on Performance
Feature | Hugging Face (CPU) | Colab / Local (GPU) |
---|---|---|
Model Used | BioMistral-7B |
Nous-Hermes-2-Mistral-7B-DPO |
Speed | ~500 seconds/query π’ | ~10 seconds/query β‘ |
Accuracy | β Good | β Great |
Requirements | 1 CPU (free tier) | CUDA GPU (Colab/Kaggle/local) |
Want faster responses? Use the GPU version on GitHub with
app.py
.
βοΈ Run It Locally (GPU Recommended)
# 1. Clone the repository
git clone https://github.com/asadsandhu/RAG-Diagnostic-Assistant.git
cd RAG-Diagnostic-Assistant
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run the app (auto-detects GPU)
python app.py
Required files (already in repo):
π Project Structure
RAG-Diagnostic-Assistant/
βββ app.py
βββ faiss_index.bin
βββ retrieval_corpus.csv
βββ requirements.txt
βββ assets/
β βββ demo.png
βββ README.md
π€ Author
Built with β€οΈ by Asad Ali
- π§ Medium: @asadsandhu
- π» GitHub: @asadsandhu
- π€ Hugging Face: @asadsandhu
π License
MIT License β see LICENSE
π Acknowledgments
- MIMIC-IV-Ext-DiReCT β Annotated diagnostic dataset
- Hugging Face Transformers + Gradio
- SentenceTransformers + FAISS
- BioMistral + NousResearch
β οΈ Disclaimer: This is a research prototype and not intended for clinical decision-making.