asadsandhu commited on
Commit
ff04da1
Β·
1 Parent(s): 8690055

README.md Updated.

Browse files
Files changed (1) hide show
  1. README.md +130 -1
README.md CHANGED
@@ -11,4 +11,133 @@ license: mit
11
  short_description: Clinical Query Answering with RAG + MIMIC-IV Notes.
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  short_description: Clinical Query Answering with RAG + MIMIC-IV Notes.
12
  ---
13
 
14
+ # 🩺 RAGnosis – Clinical Reasoning via Retrieval-Augmented Generation
15
+
16
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
17
+ [![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/)
18
+ [![Hugging Face](https://img.shields.io/badge/HuggingFace-RAGnosis-blue?logo=huggingface)](https://huggingface.co/spaces/asadsandhu/RAGnosis)
19
+ [![GitHub Repo](https://img.shields.io/badge/GitHub-asadsandhu/RAG--Diagnostic--Assistant-black?logo=github)](https://github.com/asadsandhu/RAG-Diagnostic-Assistant)
20
+
21
+ > βš•οΈ A fully offline-capable, Gradio-powered RAG assistant trained on **annotated clinical notes** from the [MIMIC-IV-Ext-DiReCT](https://github.com/asadsandhu/RAG-Diagnostic-Assistant/blob/main/mimic-iv-ext-direct-1.0.0.zip) dataset to perform explainable diagnostic reasoning.
22
+
23
+ ---
24
+
25
+ ## πŸ–ΌοΈ Demo
26
+
27
+ Try it live on **Hugging Face Spaces** πŸ‘‰
28
+ πŸ”— https://huggingface.co/spaces/asadsandhu/RAGnosis
29
+
30
+ <p align="center">
31
+ <img src="assets/demo.png" alt="Demo" width="750">
32
+ </p>
33
+
34
+ ---
35
+
36
+ ## βš™οΈ Tech Stack
37
+
38
+ | Layer | Details |
39
+ |--------------|-------------------------------------------------------------------------|
40
+ | 🧠 Model | [`Nous-Hermes-2-Mistral-7B-DPO`](https://huggingface.co/NousResearch/Nous-Hermes-2-Mistral-7B-DPO) |
41
+ | πŸ₯ Dataset | [`MIMIC-IV-Ext-DiReCT`](https://github.com/asadsandhu/RAG-Diagnostic-Assistant/blob/main/mimic-iv-ext-direct-1.0.0.zip) |
42
+ | πŸ” Retriever | FAISS + SentenceTransformers (`all-MiniLM-L6-v2`) |
43
+ | πŸ’» Frontend | Gradio (Hugging Face Spaces) |
44
+ | 🧠 Backend | PyTorch + Transformers + BitsAndBytes |
45
+
46
+ ---
47
+
48
+ ## πŸš€ Features
49
+
50
+ - πŸ”Ž Top-k document retrieval from real annotated clinical notes
51
+ - πŸ“‹ Reasoning based on structured diagnostic chains
52
+ - 🧠 GPT-style generation from LLM (Mistral 7B) without internet dependency
53
+ - 🧾 Clean Gradio interface for natural medical queries
54
+ - 🧠 Answers explained like a clinical reasoning expert
55
+
56
+ ---
57
+
58
+ ## ⚑ Example Prompt
59
+
60
+ > *Patient presents with fatigue, orthopnea, and lower extremity edema.*
61
+
62
+ πŸ’¬ **Model response:**
63
+ > Based on the patient's symptoms and context, the most likely diagnosis is **congestive heart failure (CHF)**...
64
+
65
+ ---
66
+
67
+ ## πŸ›  How It Works
68
+
69
+ ### βœ… Step 1: Preprocessing
70
+ - Extract chains from `samples/` and `diagnostic_kg/`
71
+ - Build retrievable clinical observations + diagnoses
72
+
73
+ ### βœ… Step 2: Retrieval (FAISS)
74
+ - Embed notes using `MiniLM-L6-v2`
75
+ - Save as FAISS index β†’ [`faiss_index.bin`](https://github.com/asadsandhu/RAG-Diagnostic-Assistant/blob/main/faiss_index.bin)
76
+ - Paired with β†’ [`retrieval_corpus.csv`](https://github.com/asadsandhu/RAG-Diagnostic-Assistant/blob/main/retrieval_corpus.csv)
77
+
78
+ ### βœ… Step 3: Generation
79
+ - Format prompt in `[INST]` syntax
80
+ - Generate diagnosis using `Nous-Hermes-2-Mistral-7B-DPO`
81
+
82
+ ---
83
+
84
+ ## πŸ§ͺ Run Locally
85
+
86
+ ```bash
87
+ # 1. Clone the repository
88
+ git clone https://github.com/asadsandhu/RAG-Diagnostic-Assistant.git
89
+ cd RAG-Diagnostic-Assistant
90
+
91
+ # 2. Install dependencies
92
+ pip install -r requirements.txt
93
+
94
+ # 3. Run the app
95
+ python app.py
96
+ ````
97
+
98
+ βœ”οΈ Required files:
99
+
100
+ * [`retrieval_corpus.csv`](https://github.com/asadsandhu/RAG-Diagnostic-Assistant/blob/main/retrieval_corpus.csv)
101
+ * [`faiss_index.bin`](https://github.com/asadsandhu/RAG-Diagnostic-Assistant/blob/main/faiss_index.bin)
102
+
103
+ ---
104
+
105
+ ## πŸ“ Folder Structure
106
+
107
+ ```
108
+ RAG-Diagnostic-Assistant/
109
+ β”œβ”€β”€ app.py
110
+ β”œβ”€β”€ faiss_index.bin
111
+ β”œβ”€β”€ retrieval_corpus.csv
112
+ β”œβ”€β”€ requirements.txt
113
+ β”œβ”€β”€ assets/
114
+ β”‚ └── demo.png
115
+ └── README.md
116
+ ```
117
+
118
+ ---
119
+
120
+ ## πŸ‘€ Author
121
+
122
+ Built with ❀️ by **Asad Ali**
123
+ πŸ”— [LinkedIn – @asadsandhu0](https://www.linkedin.com/in/asadsandhu0)
124
+ πŸ”— [Hugging Face – RAGnosis](https://huggingface.co/spaces/asadsandhu/RAGnosis)
125
+
126
+ ---
127
+
128
+ ## πŸ“„ License
129
+
130
+ This project is under the [MIT License](LICENSE).
131
+
132
+ ---
133
+
134
+ ## πŸ™ Acknowledgments
135
+
136
+ * MIMIC-IV-Ext-DiReCT: Annotated diagnostic data
137
+ * Hugging Face Transformers + Gradio
138
+ * Facebook Research – FAISS
139
+ * Nous Research – Instruction-tuned Mistral model
140
+
141
+ ---
142
+
143
+ > ⚠️ *Disclaimer: This project is for research/demo use only. Not intended for clinical decision-making.*