Spaces:
Sleeping
Sleeping
File size: 7,337 Bytes
b7f3196 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# Medical Q&A Bot - UI Implementation Summary
## π¦ What Was Added
### New Files Created:
1. **`app.py`** - Main Gradio web interface (RECOMMENDED)
- Clean, modern UI with gradient header
- Dual-view mode (formatted HTML + JSON)
- Real-time classification and retrieval
- Example queries built-in
- Automatic API generation
2. **`app_streamlit.py`** - Alternative Streamlit interface
- Interactive sidebar with settings
- Card-based result display
- Progress bars for confidence scores
- More customizable styling options
3. **`QUICKSTART.md`** - Step-by-step setup guide
- Installation instructions
- How to launch both UIs
- Troubleshooting tips
- Demo tips for presentations
4. **`UI_README.md`** - Comprehensive documentation
- Feature descriptions
- Configuration options
- Advanced usage
- API information
5. **`setup_ui.py`** - Automated setup script
- Installs all dependencies
- Checks for required data files
- Verifies setup completeness
### Modified Files:
1. **`requirements.txt`** - Added:
- `gradio` - Main UI framework
- `streamlit` - Alternative UI framework
## π― Key Features
### Classification Display
- β
Shows query type (Medical/Administrative/Other)
- β
Confidence scores with visual indicators
- β
Color-coded results
### Document Retrieval
- β
Retrieves top N relevant documents (1-50)
- β
Shows BM25, Dense, and RRF scores
- β
Displays document preview with full metadata
- β
Optional reranker for better accuracy
### User Experience
- β
Clean, professional design
- β
Example queries for easy testing
- β
Formatted and raw JSON views
- β
Responsive layout
- β
Real-time processing
## π Quick Start (TL;DR)
```powershell
# 1. Install dependencies
pip install -r requirements.txt
# 2. Build data (if needed)
python -m adapters.build_corpora
# 3. Launch UI (choose one)
python app.py # Gradio (recommended)
streamlit run app_streamlit.py # Streamlit (alternative)
```
## π Which UI to Use?
### Use Gradio (`app.py`) if you want:
- Quick setup and deployment
- Clean, minimal interface
- Easy sharing (public links)
- Automatic REST API
- Better for demos and presentations
### Use Streamlit (`app_streamlit.py`) if you want:
- More interactive controls
- Sidebar with settings
- More customization options
- Data-science focused interface
**Recommendation:** Start with **Gradio** - it's simpler and looks very professional!
## π How It Works
```
User Input β Gradio/Streamlit Interface
β
Classifier (classify query as medical/admin/other)
β
If Medical β Retriever (BM25 + Dense + RRF)
β
Optional Reranker (cross-encoder)
β
Display Results (formatted cards + JSON)
```
## π For Your Presentation
### Demo Flow:
1. **Open the interface** - Show the clean design
2. **Enter a medical query** - e.g., "I have a rash on my hands"
3. **Show classification** - Highlight confidence scores
4. **Display results** - Show retrieved medical documents
5. **Try administrative query** - Show different handling
6. **Toggle settings** - Demonstrate reranker and result count
7. **Show JSON view** - For technical audience
### Key Talking Points:
- "We built a user-friendly web interface using Gradio"
- "The system classifies queries in real-time with confidence scores"
- "For medical queries, it retrieves relevant research from PubMed and Miriad"
- "Uses hybrid search combining BM25 and dense embeddings"
- "Optional reranker for improved accuracy"
## π¨ Customization Options
### Change Theme/Colors
Edit the CSS in `app.py`:
```python
custom_css = """
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
"""
```
### Add More Example Queries
Edit the `examples` list in `app.py`:
```python
gr.Examples(
examples=[
["Your custom query here"],
],
inputs=query_input,
)
```
### Change Port
```python
demo.launch(server_port=8080) # Default is 7860
```
### Enable Public Sharing
```python
demo.launch(share=True) # Creates 72-hour public link
```
## π§ Technical Details
### Gradio Version
- Framework: Gradio 4.x
- Features: Blocks API, custom CSS, examples, tabs
- Auto-generates REST API at `/docs`
### Streamlit Version
- Framework: Streamlit
- Features: Sidebar, caching, progress bars, metrics
- More suitable for data exploration
### Integration
- Uses existing classifier and retriever modules
- No changes to core logic
- Models loaded once and cached
- Async processing for better UX
## π File Structure
```
health-query-classifier/
βββ app.py # β Main Gradio UI
βββ app_streamlit.py # β Alternative Streamlit UI
βββ setup_ui.py # β Setup script
βββ QUICKSTART.md # β Quick start guide
βββ UI_README.md # β Detailed documentation
βββ requirements.txt # β Updated with gradio/streamlit
βββ classifier/
β βββ infer.py # Used by UI
β βββ ...
βββ retriever/
β βββ ...
βββ team/
βββ candidates.py # Used by UI
βββ ...
```
## π Common Issues & Solutions
### "Module not found: gradio"
```powershell
pip install gradio
```
### "No corpora files found"
```powershell
python -m adapters.build_corpora
```
### Models take long to load
- This is normal on first run
- Models are cached after initial load
- Consider using smaller models for faster demo
### Port already in use
- Change port in `app.py` (line ~255)
- Or kill the process using that port
## π Deployment Options
### Local (Current Setup)
- Best for development and demos
- Access via localhost
### Hugging Face Spaces (Free)
- Free hosting for Gradio apps
- Easy to deploy
- Public URL
### Cloud Platforms
- AWS, Google Cloud, Azure
- More control and scalability
- Requires more setup
## π Future Enhancements
Potential additions for future development:
- User authentication
- Query history
- Bookmarking results
- Export to PDF
- Multi-language support
- Voice input
- Mobile app
- Analytics dashboard
## π₯ Team Contributions
This UI implementation demonstrates:
- Full-stack development skills
- ML model integration
- User experience design
- Modern web frameworks
- Professional documentation
Perfect for showcasing in your group project presentation!
## π Support
For issues or questions:
1. Check `QUICKSTART.md` for setup issues
2. Check `UI_README.md` for feature documentation
3. Review error messages carefully
4. Contact team members
---
## β
Ready to Present!
Your medical Q&A bot now has a professional web interface that:
- β
Looks modern and clean
- β
Is easy to use
- β
Demonstrates your ML capabilities
- β
Provides clear results
- β
Is well-documented
- β
Can be easily deployed
**Great work, team!** π
---
*Created by: Tarak Jha, with contributions from the entire team*
*Team: David Gray β’ Tarak Jha β’ Sravani Segireddy β’ Riley Millikan β’ Kent R. Spillner*
|