Spaces:
Sleeping
Sleeping
Delete README.md
Browse files
README.md
DELETED
@@ -1,353 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: BioGPT Medical Assistant
|
3 |
-
emoji: π₯
|
4 |
-
colorFrom: blue
|
5 |
-
colorTo: green
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 5.39.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
license: mit
|
11 |
-
hardware: cpu-basic
|
12 |
-
---
|
13 |
-
|
14 |
-
# π₯ BioGPT Medical Assistant
|
15 |
-
|
16 |
-
<div align="center">
|
17 |
-
|
18 |
-

|
19 |
-

|
20 |
-

|
21 |
-

|
22 |
-
|
23 |
-
**Professional AI Medical Chatbot powered by BioGPT-Large**
|
24 |
-
|
25 |
-
*Specialized in Pediatric Healthcare Information*
|
26 |
-
|
27 |
-
[π **Try the App**](https://huggingface.co/spaces) | [π **Documentation**](#usage) | [β οΈ **Disclaimer**](#medical-disclaimer)
|
28 |
-
|
29 |
-
</div>
|
30 |
-
|
31 |
-
---
|
32 |
-
|
33 |
-
## π Features
|
34 |
-
|
35 |
-
- π€ **Advanced AI Model**: Powered by Microsoft's BioGPT-Large, trained on biomedical literature
|
36 |
-
- πΆ **Pediatric Focus**: Specialized in children's health and medical conditions
|
37 |
-
- π **Intelligent Search**: FAISS vector database for precise medical information retrieval
|
38 |
-
- π‘ **Evidence-Based**: Responses grounded in uploaded medical literature
|
39 |
-
- π₯οΈ **GPU Optimized**: 8-bit quantization for efficient inference
|
40 |
-
- π± **Mobile Friendly**: Responsive design works on all devices
|
41 |
-
- π **Privacy Focused**: No permanent storage of uploaded medical data
|
42 |
-
|
43 |
-
## π Quick Start
|
44 |
-
|
45 |
-
### 1. Upload Medical Data
|
46 |
-
- Click **"Upload Medical Text File"**
|
47 |
-
- Select your `.txt` medical literature file (up to 50MB)
|
48 |
-
- Wait for processing confirmation β
|
49 |
-
|
50 |
-
### 2. Start Consulting
|
51 |
-
- Type your medical question in the chat box
|
52 |
-
- Get evidence-based responses from BioGPT
|
53 |
-
- Continue the conversation naturally
|
54 |
-
|
55 |
-
### 3. Example Questions
|
56 |
-
```
|
57 |
-
π "What causes fever in children?"
|
58 |
-
π "How should I treat my child's persistent cough?"
|
59 |
-
π "When should I be concerned about my baby's breathing?"
|
60 |
-
π "What are the signs of dehydration in infants?"
|
61 |
-
π "How to manage pediatric allergic reactions?"
|
62 |
-
```
|
63 |
-
|
64 |
-
## π― Use Cases
|
65 |
-
|
66 |
-
| Scenario | Example Query | Response Type |
|
67 |
-
|----------|---------------|---------------|
|
68 |
-
| **Symptom Assessment** | "My 3-year-old has a rash and fever" | Diagnostic guidance & urgency level |
|
69 |
-
| **Treatment Information** | "How to treat bronchiolitis in infants?" | Evidence-based treatment options |
|
70 |
-
| **Prevention Advice** | "How to prevent ear infections in children?" | Preventive measures & recommendations |
|
71 |
-
| **Emergency Guidance** | "When should I take my child to the ER?" | Clear emergency indicators |
|
72 |
-
| **Development Concerns** | "Is my baby's breathing pattern normal?" | Developmental milestones & red flags |
|
73 |
-
|
74 |
-
## π οΈ Technical Architecture
|
75 |
-
|
76 |
-
```mermaid
|
77 |
-
graph TD
|
78 |
-
A[User Upload] --> B[Text Processing]
|
79 |
-
B --> C[Medical Chunking]
|
80 |
-
C --> D[Embedding Generation]
|
81 |
-
D --> E[FAISS Vector Store]
|
82 |
-
|
83 |
-
F[User Query] --> G[Query Embedding]
|
84 |
-
G --> H[Vector Similarity Search]
|
85 |
-
H --> I[Context Retrieval]
|
86 |
-
I --> J[BioGPT Generation]
|
87 |
-
J --> K[Medical Response]
|
88 |
-
|
89 |
-
L[BioGPT-Large] --> J
|
90 |
-
M[8-bit Quantization] --> L
|
91 |
-
N[GPU/CPU Auto-detect] --> M
|
92 |
-
```
|
93 |
-
|
94 |
-
### Core Components
|
95 |
-
- **BioGPT-Large**: Microsoft's medical language model (1.5B parameters)
|
96 |
-
- **Sentence Transformers**: Medical text embeddings (384 dimensions)
|
97 |
-
- **FAISS**: High-performance vector similarity search
|
98 |
-
- **Gradio**: Interactive web interface
|
99 |
-
- **PyTorch**: Deep learning framework with CUDA support
|
100 |
-
|
101 |
-
## π Model Performance
|
102 |
-
|
103 |
-
| Metric | Value | Description |
|
104 |
-
|--------|-------|-------------|
|
105 |
-
| **Model Size** | 1.5B parameters | Large-scale biomedical language model |
|
106 |
-
| **Quantization** | 8-bit | Memory-efficient inference |
|
107 |
-
| **Context Window** | 1024 tokens | Maximum input length |
|
108 |
-
| **Response Length** | 150 tokens | Focused medical answers |
|
109 |
-
| **Embedding Dimension** | 384 | Vector search precision |
|
110 |
-
| **Search Results** | Top 3 chunks | Relevant context retrieval |
|
111 |
-
| **Hardware** | CPU Basic | Free tier with 2 vCPU, 16GB RAM |
|
112 |
-
|
113 |
-
## πΎ Supported File Formats
|
114 |
-
|
115 |
-
- **Text Files** (`.txt`): Plain text medical literature
|
116 |
-
- **Encoding**: UTF-8 recommended
|
117 |
-
- **Size Limit**: Up to 50MB (Hugging Face Spaces limit)
|
118 |
-
- **Content**: Medical textbooks, research papers, clinical guidelines
|
119 |
-
|
120 |
-
### Optimal File Structure
|
121 |
-
```
|
122 |
-
PEDIATRIC FEVER MANAGEMENT
|
123 |
-
|
124 |
-
SYMPTOMS:
|
125 |
-
- Temperature above 38Β°C (100.4Β°F)
|
126 |
-
- Irritability and fussiness
|
127 |
-
- Poor feeding or appetite loss
|
128 |
-
|
129 |
-
TREATMENT:
|
130 |
-
- Acetaminophen for children over 3 months
|
131 |
-
- Ibuprofen for children over 6 months
|
132 |
-
- Ensure adequate hydration
|
133 |
-
|
134 |
-
WHEN TO SEEK CARE:
|
135 |
-
- Fever in infants under 3 months
|
136 |
-
- Temperature above 40Β°C (104Β°F)
|
137 |
-
- Signs of dehydration
|
138 |
-
```
|
139 |
-
|
140 |
-
## βοΈ System Configuration
|
141 |
-
|
142 |
-
The app automatically optimizes based on available hardware:
|
143 |
-
|
144 |
-
| Setting | CPU Basic (Free) | With GPU Upgrade |
|
145 |
-
|---------|------------------|------------------|
|
146 |
-
| **Model Loading** | 16-bit precision | 8-bit quantization |
|
147 |
-
| **Device** | CPU | CUDA |
|
148 |
-
| **Inference Speed** | ~10-15 seconds | ~2-3 seconds |
|
149 |
-
| **Memory Usage** | ~8GB RAM | ~6GB VRAM |
|
150 |
-
| **Concurrent Users** | 2-3 users | 5-10 users |
|
151 |
-
|
152 |
-
## π§ͺ Example Interactions
|
153 |
-
|
154 |
-
<details>
|
155 |
-
<summary><b>Click to see sample conversations</b></summary>
|
156 |
-
|
157 |
-
**User**: "My 2-year-old has been coughing for 3 days. Should I be worried?"
|
158 |
-
|
159 |
-
**BioGPT**: "π©Ί **Medical Information:** A cough lasting 3 days in a 2-year-old can have several causes, including viral upper respiratory infections, which are common in young children. Monitor for additional symptoms such as fever, difficulty breathing, or changes in appetite. If the cough is accompanied by high fever (>39Β°C), rapid breathing, or the child appears unusually lethargic, medical evaluation is recommended.
|
160 |
-
|
161 |
-
β οΈ **Important:** This information is for educational purposes only. Always consult with qualified healthcare professionals for medical diagnosis, treatment, and personalized advice."
|
162 |
-
|
163 |
-
---
|
164 |
-
|
165 |
-
**User**: "What are the warning signs of dehydration in babies?"
|
166 |
-
|
167 |
-
**BioGPT**: "π©Ί **Medical Information:** Warning signs of dehydration in infants include decreased wet diapers (fewer than 6 per day), dry mouth and tongue, sunken fontanelle (soft spot), lethargy or excessive fussiness, and skin that remains "tented" when gently pinched. Severe dehydration may present with sunken eyes, rapid heartbeat, and decreased responsiveness, requiring immediate medical attention.
|
168 |
-
|
169 |
-
β οΈ **Important:** This information is for educational purposes only. Always consult with qualified healthcare professionals for medical diagnosis, treatment, and personalized advice."
|
170 |
-
|
171 |
-
---
|
172 |
-
|
173 |
-
**User**: "Hello!"
|
174 |
-
|
175 |
-
**BioGPT**: "π Hello! I'm BioGPT, your medical AI assistant specialized in pediatric medicine. Please upload your medical data file first, then ask me any health-related questions!"
|
176 |
-
|
177 |
-
</details>
|
178 |
-
|
179 |
-
## π Usage Guidelines
|
180 |
-
|
181 |
-
### β
Appropriate Uses
|
182 |
-
- Educational medical information and research
|
183 |
-
- Understanding pediatric symptoms and conditions
|
184 |
-
- Learning about evidence-based treatment options
|
185 |
-
- Knowing when to seek professional medical care
|
186 |
-
- Medical training and academic purposes
|
187 |
-
- Parent education and awareness
|
188 |
-
|
189 |
-
### β Inappropriate Uses
|
190 |
-
- Emergency medical situations (call 911/999/112)
|
191 |
-
- Replacing professional medical consultation
|
192 |
-
- Self-diagnosis or self-treatment decisions
|
193 |
-
- Medication dosing or prescription guidance
|
194 |
-
- Legal or insurance medical claims
|
195 |
-
- Critical care decision making
|
196 |
-
|
197 |
-
## π How It Works
|
198 |
-
|
199 |
-
1. **Document Processing**: Medical literature is intelligently chunked into semantically meaningful segments (~400 words each)
|
200 |
-
2. **Embedding Generation**: Each chunk is converted to 384-dimensional vectors using medical-optimized sentence transformers
|
201 |
-
3. **Vector Storage**: FAISS index enables millisecond similarity search across thousands of medical concepts
|
202 |
-
4. **Query Processing**: User questions are embedded and matched against the knowledge base using cosine similarity
|
203 |
-
5. **Context Retrieval**: Top 3 most relevant medical passages are extracted and ranked
|
204 |
-
6. **Response Generation**: BioGPT-Large synthesizes evidence-based answers from retrieved context with medical reasoning
|
205 |
-
7. **Safety Filtering**: All responses include appropriate medical disclaimers and professional consultation guidance
|
206 |
-
|
207 |
-
## π Deployment Information
|
208 |
-
|
209 |
-
This application is deployed on Hugging Face Spaces with the following configuration:
|
210 |
-
|
211 |
-
- **Platform**: Hugging Face Spaces
|
212 |
-
- **Hardware**: CPU Basic (2 vCPU, 16GB RAM) - FREE
|
213 |
-
- **Framework**: Gradio 4.44.0
|
214 |
-
- **Python**: 3.9+
|
215 |
-
- **Automatic Scaling**: Handled by Hugging Face infrastructure
|
216 |
-
- **Uptime**: 99.9% availability
|
217 |
-
- **Global CDN**: Fast loading worldwide
|
218 |
-
- **GPU Upgrade**: Available for faster inference (T4 Small: $0.60/hour)
|
219 |
-
|
220 |
-
## π§ For Developers
|
221 |
-
|
222 |
-
### Local Development
|
223 |
-
```bash
|
224 |
-
# Clone this space
|
225 |
-
git clone https://huggingface.co/spaces/your-username/biogpt-medical-assistant
|
226 |
-
cd biogpt-medical-assistant
|
227 |
-
|
228 |
-
# Install dependencies
|
229 |
-
pip install -r requirements.txt
|
230 |
-
|
231 |
-
# Run locally
|
232 |
-
python app.py
|
233 |
-
```
|
234 |
-
|
235 |
-
### File Structure
|
236 |
-
```
|
237 |
-
biogpt-medical-assistant/
|
238 |
-
βββ app.py # Main Gradio application
|
239 |
-
βββ requirements.txt # Python dependencies
|
240 |
-
βββ README.md # This documentation
|
241 |
-
```
|
242 |
-
|
243 |
-
### Key Dependencies
|
244 |
-
- `torch>=1.12.0` - PyTorch deep learning framework
|
245 |
-
- `transformers>=4.21.0` - Hugging Face transformers library
|
246 |
-
- `gradio>=4.0.0` - Web interface framework
|
247 |
-
- `sentence-transformers` - Text embedding models
|
248 |
-
- `faiss-cpu` - Vector similarity search
|
249 |
-
- `bitsandbytes` - 8-bit model quantization
|
250 |
-
|
251 |
-
## π Performance Monitoring
|
252 |
-
|
253 |
-
The application includes built-in performance tracking:
|
254 |
-
|
255 |
-
- **Response Time**: Average 10-15 seconds on CPU (2-3 seconds with GPU upgrade)
|
256 |
-
- **Context Retrieval**: Sub-second vector search
|
257 |
-
- **Memory Usage**: Optimized for 16GB RAM limit
|
258 |
-
- **Error Handling**: Graceful fallbacks and user feedback
|
259 |
-
- **Conversation History**: Session-based chat memory
|
260 |
-
- **CPU Optimization**: Automatic detection and CPU-optimized inference
|
261 |
-
|
262 |
-
## π‘οΈ Privacy & Security
|
263 |
-
|
264 |
-
- **No Data Storage**: Uploaded files are processed in memory only
|
265 |
-
- **Session Isolation**: Each user session is independent
|
266 |
-
- **No Logging**: Personal medical queries are not logged
|
267 |
-
- **HTTPS Encryption**: All communications are encrypted
|
268 |
-
- **EU GDPR Compliant**: No personal data retention
|
269 |
-
- **Medical Privacy**: Designed with HIPAA principles in mind
|
270 |
-
|
271 |
-
## π€ Community & Support
|
272 |
-
|
273 |
-
- **Discussions**: Use the Community tab above for questions and feedback
|
274 |
-
- **Issues**: Report bugs or request features in discussions
|
275 |
-
- **Medical Accuracy**: Healthcare professionals welcome to provide feedback
|
276 |
-
- **Updates**: Application is regularly updated with improvements
|
277 |
-
|
278 |
-
## π License & Attribution
|
279 |
-
|
280 |
-
This project is licensed under the MIT License.
|
281 |
-
|
282 |
-
### Model Attributions
|
283 |
-
- **BioGPT-Large**: Microsoft Research - [Paper](https://arxiv.org/abs/2210.10341)
|
284 |
-
- **Sentence Transformers**: UKP Lab - [Repository](https://github.com/UKPLab/sentence-transformers)
|
285 |
-
- **FAISS**: Facebook AI Research - [Repository](https://github.com/facebookresearch/faiss)
|
286 |
-
|
287 |
-
### Special Thanks
|
288 |
-
- **Hugging Face** for providing the infrastructure and hosting platform
|
289 |
-
- **Medical Community** for the knowledge that powers this assistant
|
290 |
-
- **Open Source Contributors** for the foundational libraries and tools
|
291 |
-
|
292 |
-
---
|
293 |
-
|
294 |
-
## β οΈ Medical Disclaimer
|
295 |
-
|
296 |
-
**IMPORTANT MEDICAL DISCLAIMER**
|
297 |
-
|
298 |
-
This AI assistant is designed for **educational and informational purposes only**. It is not intended to be a substitute for professional medical advice, diagnosis, or treatment.
|
299 |
-
|
300 |
-
### π¨ Emergency Situations
|
301 |
-
**Call emergency services immediately (911/999/112) if experiencing:**
|
302 |
-
- Difficulty breathing or shortness of breath
|
303 |
-
- Chest pain or pressure
|
304 |
-
- Severe bleeding or trauma
|
305 |
-
- Loss of consciousness or altered mental state
|
306 |
-
- Severe allergic reactions (anaphylaxis)
|
307 |
-
- Signs of stroke or heart attack
|
308 |
-
- Any life-threatening emergency
|
309 |
-
|
310 |
-
### π©Ί Professional Medical Care
|
311 |
-
**Always consult qualified healthcare professionals for:**
|
312 |
-
- Medical diagnosis and treatment decisions
|
313 |
-
- Medication prescriptions and dosing instructions
|
314 |
-
- Serious, persistent, or worsening symptoms
|
315 |
-
- Chronic condition management and monitoring
|
316 |
-
- Preventive care, screenings, and vaccinations
|
317 |
-
- Any concerns about your or your child's health
|
318 |
-
|
319 |
-
### πΆ Pediatric Emergency Signs
|
320 |
-
**Seek immediate pediatric medical attention for:**
|
321 |
-
- Infants under 3 months with any fever (>38Β°C/100.4Β°F)
|
322 |
-
- Difficulty breathing, wheezing, or rapid breathing in children
|
323 |
-
- Signs of severe dehydration (sunken fontanelle, no wet diapers)
|
324 |
-
- Unusual lethargy, excessive fussiness, or unresponsiveness
|
325 |
-
- Severe vomiting or inability to keep fluids down
|
326 |
-
- Any concerning changes in your child's behavior or condition
|
327 |
-
|
328 |
-
### π Information Accuracy
|
329 |
-
- Responses are based on the medical literature you upload and BioGPT's training data
|
330 |
-
- Information accuracy depends on the quality and currency of source materials
|
331 |
-
- Medical knowledge evolves rapidly - always verify with current medical sources
|
332 |
-
- This AI cannot replace clinical examination, laboratory tests, or imaging studies
|
333 |
-
|
334 |
-
### π₯ Limitations
|
335 |
-
- Cannot provide personalized medical advice for specific individuals
|
336 |
-
- Cannot interpret medical tests, lab results, or imaging studies
|
337 |
-
- Cannot prescribe medications or provide dosing instructions
|
338 |
-
- Cannot diagnose medical conditions or recommend specific treatments
|
339 |
-
- Should not be used for urgent or emergency medical situations
|
340 |
-
|
341 |
-
**By using this application, you acknowledge that you understand these limitations and will not rely solely on this AI assistant for medical decisions. Always prioritize professional medical care for health concerns.**
|
342 |
-
|
343 |
-
---
|
344 |
-
|
345 |
-
<div align="center">
|
346 |
-
|
347 |
-
**π₯ Your Health, Our Priority - But Always Consult the Professionals π₯**
|
348 |
-
|
349 |
-
*Empowering Health Education Through AI Technology*
|
350 |
-
|
351 |
-
**Made with β€οΈ for the medical community and caring parents worldwide**
|
352 |
-
|
353 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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