Spaces:
Running
Running
Commit
Β·
ecf4549
1
Parent(s):
41a9c31
Finalized.
Browse files- README.md +34 -34
- assets/pp.py +0 -0
- requirements.txt +1 -3
README.md
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
---
|
2 |
-
title: RAGnosis
|
3 |
-
emoji:
|
4 |
-
colorFrom: red
|
5 |
-
colorTo: indigo
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 5.35.0
|
8 |
-
app_file: app.py
|
9 |
pinned: false
|
10 |
-
license: mit
|
11 |
-
short_description: Clinical Query Answering with RAG
|
12 |
---
|
13 |
|
14 |
-
#
|
15 |
|
16 |
[](LICENSE)
|
17 |
[](https://www.python.org/)
|
18 |
[](https://huggingface.co/spaces/asadsandhu/RAGnosis)
|
19 |
[](https://github.com/asadsandhu/RAG-Diagnostic-Assistant)
|
20 |
|
21 |
-
> βοΈ A
|
22 |
|
23 |
---
|
24 |
|
@@ -37,21 +37,21 @@ Try it live on **Hugging Face Spaces** π
|
|
37 |
|
38 |
| Layer | Details |
|
39 |
|--------------|-------------------------------------------------------------------------|
|
40 |
-
| π§ Model | [`
|
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
|
45 |
|
46 |
---
|
47 |
|
48 |
## π Features
|
49 |
|
50 |
-
-
|
51 |
-
- π
|
52 |
-
- π§
|
53 |
-
-
|
54 |
-
-
|
55 |
|
56 |
---
|
57 |
|
@@ -59,25 +59,24 @@ Try it live on **Hugging Face Spaces** π
|
|
59 |
|
60 |
> *Patient presents with fatigue, orthopnea, and lower extremity edema.*
|
61 |
|
62 |
-
π¬ **Model response:**
|
63 |
-
> Based on the patient's symptoms and
|
64 |
|
65 |
---
|
66 |
|
67 |
## π How It Works
|
68 |
|
69 |
-
### β
Step 1:
|
70 |
-
-
|
71 |
-
-
|
|
|
72 |
|
73 |
-
### β
Step 2:
|
74 |
-
-
|
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 |
-
-
|
80 |
-
-
|
81 |
|
82 |
---
|
83 |
|
@@ -133,11 +132,12 @@ This project is under the [MIT License](LICENSE).
|
|
133 |
|
134 |
## π Acknowledgments
|
135 |
|
136 |
-
* MIMIC-IV-Ext-DiReCT: Annotated diagnostic
|
137 |
-
* Hugging Face Transformers
|
138 |
* Facebook Research β FAISS
|
139 |
-
*
|
|
|
140 |
|
141 |
---
|
142 |
|
143 |
-
> β οΈ *Disclaimer: This project is for
|
|
|
1 |
---
|
2 |
+
title: "RAGnosis"
|
3 |
+
emoji: "π§ "
|
4 |
+
colorFrom: "red"
|
5 |
+
colorTo: "indigo"
|
6 |
+
sdk: "gradio"
|
7 |
+
sdk_version: "5.35.0"
|
8 |
+
app_file: "app.py"
|
9 |
pinned: false
|
10 |
+
license: "mit"
|
11 |
+
short_description: "Clinical Query Answering with Retrieval-Augmented Generation (RAG) and MIMIC-IV Notes."
|
12 |
---
|
13 |
|
14 |
+
# π§ RAGnosis β Clinical Reasoning via Retrieval-Augmented Generation
|
15 |
|
16 |
[](LICENSE)
|
17 |
[](https://www.python.org/)
|
18 |
[](https://huggingface.co/spaces/asadsandhu/RAGnosis)
|
19 |
[](https://github.com/asadsandhu/RAG-Diagnostic-Assistant)
|
20 |
|
21 |
+
> βοΈ A CPU-ready, Gradio-powered RAG assistant for explainable **clinical diagnosis** using annotated 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.
|
22 |
|
23 |
---
|
24 |
|
|
|
37 |
|
38 |
| Layer | Details |
|
39 |
|--------------|-------------------------------------------------------------------------|
|
40 |
+
| π§ Model | [`BioMistral/BioMistral-7B`](https://huggingface.co/BioMistral/BioMistral-7B) |
|
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 (no quantization) |
|
45 |
|
46 |
---
|
47 |
|
48 |
## π Features
|
49 |
|
50 |
+
- π Top-k retrieval from real clinical notes and diagnostic pathways
|
51 |
+
- π Structured reasoning with evidence from retrieved facts
|
52 |
+
- π§ Generation powered by domain-specific BioMistral-7B LLM
|
53 |
+
- π¬ Natural question answering with clear clinical explanations
|
54 |
+
- βοΈ Hugging Face Spaces-friendly: runs on CPU within 16GB RAM
|
55 |
|
56 |
---
|
57 |
|
|
|
59 |
|
60 |
> *Patient presents with fatigue, orthopnea, and lower extremity edema.*
|
61 |
|
62 |
+
π¬ **Model response:**
|
63 |
+
> Based on the patient's symptoms and retrieved clinical facts, the most likely diagnosis is **congestive heart failure (CHF)**...
|
64 |
|
65 |
---
|
66 |
|
67 |
## π How It Works
|
68 |
|
69 |
+
### β
Step 1: Retrieval (FAISS)
|
70 |
+
- Sentence embeddings generated using `all-MiniLM-L6-v2`
|
71 |
+
- Indexed with FAISS (`faiss_index.bin`)
|
72 |
+
- Source corpus: `retrieval_corpus.csv`
|
73 |
|
74 |
+
### β
Step 2: Prompt Construction
|
75 |
+
- Query + top-5 chunks formatted into a clinical instruction prompt
|
|
|
|
|
76 |
|
77 |
+
### β
Step 3: Generation (LLM)
|
78 |
+
- Prompt fed to `BioMistral/BioMistral-7B`
|
79 |
+
- Diagnosis + explanation generated using `generate()` (no GPU needed)
|
80 |
|
81 |
---
|
82 |
|
|
|
132 |
|
133 |
## π Acknowledgments
|
134 |
|
135 |
+
* MIMIC-IV-Ext-DiReCT: Annotated diagnostic corpus
|
136 |
+
* Hugging Face Transformers & SentenceTransformers
|
137 |
* Facebook Research β FAISS
|
138 |
+
* Gradio for UI
|
139 |
+
* BioMistral for domain-aligned LLM
|
140 |
|
141 |
---
|
142 |
|
143 |
+
> β οΈ *Disclaimer: This project is for academic demonstration only. It is not approved for clinical use.*
|
assets/pp.py
ADDED
File without changes
|
requirements.txt
CHANGED
@@ -4,6 +4,4 @@ faiss-cpu
|
|
4 |
torch
|
5 |
gradio
|
6 |
accelerate
|
7 |
-
sentencepiece
|
8 |
-
bitsandbytes
|
9 |
-
blobfile
|
|
|
4 |
torch
|
5 |
gradio
|
6 |
accelerate
|
7 |
+
sentencepiece
|
|
|
|