|
Download README.md from whosouravsharma/Medical-Assistant-ChatBot: direct link, hf CLI and curl.
- Browser
- Download file 5.15 kB
-
https://huggingface.co/spaces/whosouravsharma/Medical-Assistant-ChatBot/resolve/main/README.md
- Command line
-
hf download hf://spaces/whosouravsharma/Medical-Assistant-ChatBot/README.md
-
curl -L -o README.md https://huggingface.co/spaces/whosouravsharma/Medical-Assistant-ChatBot/resolve/main/README.md
5.15 kB
| title: Medical Assistant UI | |
| emoji: π©Ί | |
| colorFrom: blue | |
| colorTo: purple | |
| sdk: docker | |
| app_port: 8501 | |
| short_description: RAG-grounded medical Q&A chat over the MedQuAD dataset | |
| tags: | |
| - streamlit | |
| - rag | |
| - medical | |
| - healthcare | |
| - question-answering | |
| - faiss | |
| - sentence-transformers | |
| models: | |
| - sentence-transformers/all-MiniLM-L6-v2 | |
| pinned: false | |
| # Medical Assistant | |
| Ask a medical question and get an answer grounded in retrieved source | |
| passages from the MedQuAD dataset, with the sources cited under every | |
| response. The answer comes from retrieved text, not from the model's own | |
| memory. | |
| > **Not a substitute for professional medical advice, diagnosis, or treatment.** | |
| This Space is the **frontend** of a two-Space system. Retrieval and | |
| generation run in the | |
| [`medical-assistant-ai-backend`](https://huggingface.co/spaces/whosouravsharma/medical-assistant-ai-backend) | |
| Space. | |
| ## How it works | |
| 1. You type a question into the chat. | |
| 2. This Space sends it to the backend's `POST /ask` endpoint. | |
| 3. The backend embeds the question and retrieves the top 5 most similar | |
| passages from a FAISS index built over MedQuAD. | |
| 4. Those passages go into a prompt that tells the model to answer **only** | |
| from the retrieved context, to avoid diagnosis and prescriptions, and to | |
| say so when the context isn't enough to answer. | |
| 5. A hosted LLM generates the answer, and the backend returns it along with | |
| its sources. | |
| 6. This Space shows the answer with the cited sources underneath. | |
| ``` | |
| User βββΆ Streamlit UI (this Space) ββPOST /askβββΆ FastAPI backend | |
| β | |
| embed (MiniLM) βββ€ | |
| FAISS top-k ββββββ€ (MedQuAD index) | |
| grounded prompt ββ€ | |
| hosted LLM βββββββ | |
| βββββββββββββ answer + sources ββββββββββββ | |
| ``` | |
| ## Components | |
| | Component | Role | | |
| |---|---| | |
| | **This Space** (`Medical-Assistant-ChatBot`) | Streamlit chat UI. Its only dependencies are `streamlit` and `requests`, and it holds no model logic | | |
| | [`medical-assistant-ai-backend`](https://huggingface.co/spaces/whosouravsharma/medical-assistant-ai-backend) | FastAPI service exposing `GET /health` and `POST /ask` | | |
| | `whosouravsharma/medical-assistant-data` (private) | Prebuilt FAISS index and chunk metadata, pulled by the backend at startup | | |
| | [MedQuAD](https://www.kaggle.com/datasets/pythonafroz/medquad-medical-question-answer-for-ai-research) | Source corpus of medical questionβanswer pairs | | |
| ## Models | |
| No model in this project is trained or fine-tuned. The system is built from | |
| off-the-shelf components: | |
| | Stage | Model / method | Notes | | |
| |---|---|---| | |
| | Embedding | [`sentence-transformers/all-MiniLM-L6-v2`](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) | Small (~90 MB), CPU-friendly, used unmodified. Loaded once per backend process | | |
| | Retrieval | FAISS `IndexFlatIP` on L2-normalized vectors | Exact cosine-similarity search, top-k = 5 | | |
| | Generation | `gpt-5.6-luna` via the OpenAI API | Hosted remotely. No generation model runs inside either Space | | |
| ## Data | |
| The index is built offline from MedQuAD: | |
| - Remove exact duplicates and records with no answer | |
| - Join each question and answer into one text field | |
| - Split the text into 500-word chunks with a 50-word overlap | |
| - Store each chunk with its source, focus area, and original question so | |
| every answer can cite where it came from | |
| ## Intended use | |
| **Use it for** general, informational questions about conditions, symptoms, | |
| and treatments that MedQuAD covers. | |
| **Don't use it for** diagnosis, treatment or medication decisions, | |
| emergencies, or questions about a specific patient. | |
| ## API | |
| The backend can also be called directly: | |
| ```bash | |
| curl -X POST https://whosouravsharma-medical-assistant-ai-backend.hf.space/ask \ | |
| -H "Authorization: Bearer $HF_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"question": "What are the symptoms of glaucoma?"}' | |
| ``` | |
| The response contains `query`, `answer`, and `sources`. Each source has its | |
| rank, similarity score, source name, focus area, original question, and the | |
| chunk text. | |
| ## Setup (for forks / redeploys) | |
| Set these as Space secrets or variables: | |
| | Name | Purpose | | |
| |---|---| | |
| | `BACKEND_URL` | Backend Space URL: `https://whosouravsharma-medical-assistant-ai-backend.hf.space` | | |
| | `HF_TOKEN` | Sent as a bearer token to the backend. Authentication is token-based and there is no user login | | |
| ## Limitations | |
| - Answers are limited to what MedQuAD covers. For questions outside it, the | |
| model is told to say the retrieved information is insufficient rather | |
| than guess. | |
| - The grounding prompt reduces hallucination risk but doesn't remove it, | |
| and it hasn't been formally evaluated. | |
| - Generation depends on a third-party hosted model. Its behaviour can only | |
| be shaped through the prompt. | |
| - No latency, cost, or accuracy benchmarks have been published yet. | |
| - The embedding model is general-purpose and hasn't been tuned for medical | |
| text. | |