MedGRPO Team
Claude Sonnet 4.5
commited on
Commit
·
8f33d8f
1
Parent(s):
c137994
Add comprehensive setup and deployment documentation
Browse filesDocuments complete leaderboard implementation including:
- Integration architecture with evaluate_all_pai.py
- Validation logic and metric extraction
- Score normalization methodology
- Data persistence format
- Deployment configuration
- Testing checklist
- Known limitations and recommendations
- Quick reference guide
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- SETUP_SUMMARY.md +299 -0
SETUP_SUMMARY.md
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MedGRPO Leaderboard Setup Summary
|
| 2 |
+
|
| 3 |
+
**Date**: January 7, 2026
|
| 4 |
+
**Status**: ✅ DEPLOYED
|
| 5 |
+
**URL**: https://huggingface.co/spaces/UIIAmerica/MedGRPO-Leaderboard
|
| 6 |
+
|
| 7 |
+
## What Was Built
|
| 8 |
+
|
| 9 |
+
A fully functional, automated leaderboard for the MedGRPO benchmark that:
|
| 10 |
+
1. **Accepts submissions** via web interface (Gradio)
|
| 11 |
+
2. **Validates** results files automatically
|
| 12 |
+
3. **Runs evaluations** using your existing `evaluate_all_pai.py` script
|
| 13 |
+
4. **Extracts metrics** for all 8 tasks
|
| 14 |
+
5. **Ranks models** by average performance
|
| 15 |
+
6. **Persists data** in JSON format
|
| 16 |
+
|
| 17 |
+
## Key Features
|
| 18 |
+
|
| 19 |
+
### ✅ Complete Integration
|
| 20 |
+
|
| 21 |
+
- **Direct pipeline integration**: Calls `/root/code/Qwen2.5-VL/my_eval/evaluate_all_pai.py`
|
| 22 |
+
- **Automatic metric extraction**: Parses stdout to get mAP@0.5, mIoU, Accuracy, LLM Judge scores
|
| 23 |
+
- **All 8 tasks supported**: TAL, STG, Next Action, DVC, VS, RC, Skill Assessment, CVS Assessment
|
| 24 |
+
- **Dataset-agnostic evaluation**: Uses `--grouping overall` for fair comparison
|
| 25 |
+
|
| 26 |
+
### 🎯 User Experience
|
| 27 |
+
|
| 28 |
+
**4-Tab Interface**:
|
| 29 |
+
1. **Leaderboard** - Current rankings with all metrics
|
| 30 |
+
2. **Submit Results** - Upload results JSON with validation
|
| 31 |
+
3. **Tasks & Metrics** - Detailed task descriptions and metric explanations
|
| 32 |
+
4. **About** - Paper info, citation, links
|
| 33 |
+
|
| 34 |
+
**Submission Flow**:
|
| 35 |
+
1. User uploads results JSON (6,245 samples)
|
| 36 |
+
2. System validates format and sample count
|
| 37 |
+
3. Runs automatic evaluation (~5-10 min)
|
| 38 |
+
4. Extracts metrics from evaluation output
|
| 39 |
+
5. Adds to leaderboard with rank
|
| 40 |
+
|
| 41 |
+
### 📊 Metrics & Scoring
|
| 42 |
+
|
| 43 |
+
**Task Metrics**:
|
| 44 |
+
- **TAL**: mAP@0.5 (temporal action localization)
|
| 45 |
+
- **STG**: mIoU (spatiotemporal grounding)
|
| 46 |
+
- **Next Action**: Accuracy
|
| 47 |
+
- **DVC/VS/RC**: LLM Judge average (R2, R4, R5, R7, R8)
|
| 48 |
+
- **Skill/CVS**: Accuracy
|
| 49 |
+
|
| 50 |
+
**Score Normalization**:
|
| 51 |
+
- LLM Judge scores (1-5) → normalized to [0,1]: `(score - 1) / 4`
|
| 52 |
+
- Other metrics (already 0-1) → unchanged
|
| 53 |
+
- **Average** = mean of 8 normalized scores
|
| 54 |
+
|
| 55 |
+
### 🔧 Technical Details
|
| 56 |
+
|
| 57 |
+
**File Structure**:
|
| 58 |
+
```
|
| 59 |
+
MedGRPO-Leaderboard/
|
| 60 |
+
├── app.py # Main Gradio app (647 lines)
|
| 61 |
+
├── leaderboard.json # Persistent leaderboard data
|
| 62 |
+
├── submissions/ # Uploaded results files
|
| 63 |
+
├── results/ # Per-model evaluation outputs
|
| 64 |
+
│ └── {model_name}/
|
| 65 |
+
│ ├── results.json # Copy of uploaded file
|
| 66 |
+
│ └── eval_output.txt # Full evaluation stdout
|
| 67 |
+
└── README.md # Comprehensive documentation
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
**Dependencies**:
|
| 71 |
+
- `gradio==5.50.0` - Web interface
|
| 72 |
+
- `pandas` - Data manipulation
|
| 73 |
+
- `subprocess` - Evaluation pipeline calls
|
| 74 |
+
- Access to `/root/code/Qwen2.5-VL/my_eval/evaluate_all_pai.py`
|
| 75 |
+
|
| 76 |
+
## Validation Logic
|
| 77 |
+
|
| 78 |
+
**Results File Checks**:
|
| 79 |
+
1. ✅ Valid JSON format
|
| 80 |
+
2. ✅ List or dict structure
|
| 81 |
+
3. ✅ Required fields: `question`, `response`, `qa_type`
|
| 82 |
+
4. ✅ Valid `qa_type` values (tal, stg, next_action, dense_captioning, video_summary, region_caption, skill_assessment, cvs_assessment)
|
| 83 |
+
5. ✅ Sample count: ≥5000 (full test set has 6,245)
|
| 84 |
+
|
| 85 |
+
**Evaluation Process**:
|
| 86 |
+
```bash
|
| 87 |
+
python3 /root/code/Qwen2.5-VL/my_eval/evaluate_all_pai.py \
|
| 88 |
+
{results_file} \
|
| 89 |
+
--grouping overall
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
- Timeout: 600 seconds (10 minutes)
|
| 93 |
+
- Output: Captured stdout for metric parsing
|
| 94 |
+
- Storage: Saved to `results/{model_name}/eval_output.txt`
|
| 95 |
+
|
| 96 |
+
## Metric Parsing
|
| 97 |
+
|
| 98 |
+
The system parses evaluation stdout to extract metrics:
|
| 99 |
+
|
| 100 |
+
| Task | Search Pattern | Example Output |
|
| 101 |
+
|------|---------------|----------------|
|
| 102 |
+
| TAL | `"mAP@0.5:"` | `mAP@0.5: 0.4567` |
|
| 103 |
+
| STG | `"mean_iou:"` | `mean_iou: 0.7234` |
|
| 104 |
+
| Next Action | `"Weighted Average Accuracy"` | `Weighted Average Accuracy (across 1234 samples): 0.6789` |
|
| 105 |
+
| DVC/VS/RC | `"Average"` or `"Mean"` | `Average: 3.45` (LLM judge 1-5) |
|
| 106 |
+
| Skill/CVS | `"accuracy:"` | `accuracy: 0.8123` |
|
| 107 |
+
|
| 108 |
+
**Parser Logic**:
|
| 109 |
+
- Detects task sections by headers (e.g., "TAL - Overall Evaluation")
|
| 110 |
+
- Extracts metrics within each section
|
| 111 |
+
- Validates value ranges (e.g., LLM judge must be 1-5)
|
| 112 |
+
- Returns dict: `{"tal": 0.4567, "stg": 0.7234, ...}`
|
| 113 |
+
|
| 114 |
+
## Data Persistence
|
| 115 |
+
|
| 116 |
+
**Leaderboard Storage** (`leaderboard.json`):
|
| 117 |
+
```json
|
| 118 |
+
[
|
| 119 |
+
{
|
| 120 |
+
"rank": 1,
|
| 121 |
+
"model_name": "Qwen2.5-VL-7B-MedGRPO",
|
| 122 |
+
"organization": "University Name",
|
| 123 |
+
"average": 0.7234,
|
| 124 |
+
"tal": 0.4567,
|
| 125 |
+
"stg": 0.7234,
|
| 126 |
+
"next_action": 0.6789,
|
| 127 |
+
"dvc": 3.45,
|
| 128 |
+
"vs": 3.67,
|
| 129 |
+
"rc": 3.89,
|
| 130 |
+
"skill_assessment": 0.8123,
|
| 131 |
+
"cvs_assessment": 0.7654,
|
| 132 |
+
"date": "2026-01-07",
|
| 133 |
+
"contact": "email@example.com"
|
| 134 |
+
},
|
| 135 |
+
...
|
| 136 |
+
]
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
**Features**:
|
| 140 |
+
- Auto-updates ranks on each submission
|
| 141 |
+
- Sorts by average score descending
|
| 142 |
+
- Prevents duplicate model names
|
| 143 |
+
- Preserves submission history
|
| 144 |
+
|
| 145 |
+
## Deployment
|
| 146 |
+
|
| 147 |
+
**Platform**: HuggingFace Spaces
|
| 148 |
+
**URL**: https://huggingface.co/spaces/UIIAmerica/MedGRPO-Leaderboard
|
| 149 |
+
**Framework**: Gradio 5.50.0
|
| 150 |
+
**Server**: `0.0.0.0:7860` with share=True
|
| 151 |
+
|
| 152 |
+
**Configuration** (README.md front matter):
|
| 153 |
+
```yaml
|
| 154 |
+
title: MedGRPO Leaderboard
|
| 155 |
+
emoji: 🏥
|
| 156 |
+
sdk: gradio
|
| 157 |
+
app_file: app.py
|
| 158 |
+
sdk_version: 5.50.0
|
| 159 |
+
tags:
|
| 160 |
+
- leaderboard
|
| 161 |
+
- medical
|
| 162 |
+
- video-understanding
|
| 163 |
+
- surgical-ai
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
**Launch Command**:
|
| 167 |
+
```python
|
| 168 |
+
demo.queue(default_concurrency_limit=5).launch(share=True, server_name="0.0.0.0")
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
## Git History
|
| 172 |
+
|
| 173 |
+
```
|
| 174 |
+
6a33c44 - Update README with comprehensive MedGRPO documentation
|
| 175 |
+
aa988a4 - Integrate MedGRPO evaluation pipeline with leaderboard
|
| 176 |
+
a50fe63 - Fix Gradio schema error and deployment configuration
|
| 177 |
+
27eb692 - initial commit (HF template)
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
## Testing Checklist
|
| 181 |
+
|
| 182 |
+
Before first real submission, test:
|
| 183 |
+
|
| 184 |
+
1. ✅ App launches without errors
|
| 185 |
+
2. ✅ Leaderboard tab displays empty table correctly
|
| 186 |
+
3. ✅ Submit tab shows all form fields
|
| 187 |
+
4. ⏳ Validation rejects invalid files
|
| 188 |
+
5. ⏳ Evaluation runs successfully on valid file
|
| 189 |
+
6. ⏳ Metrics are extracted correctly
|
| 190 |
+
7. ⏳ Leaderboard updates with new entry
|
| 191 |
+
8. ⏳ Rank is computed correctly
|
| 192 |
+
|
| 193 |
+
**Suggested test file**: Use one of your existing results:
|
| 194 |
+
- `/root/code/Qwen2.5-VL/my_eval/results/dvc_llm_judge_v4_best5_10k/step45_results.json`
|
| 195 |
+
|
| 196 |
+
**Note**: These files may need format conversion if they don't match expected VLLM output format.
|
| 197 |
+
|
| 198 |
+
## Known Limitations
|
| 199 |
+
|
| 200 |
+
1. **Evaluation path hardcoded**: `/root/code/Qwen2.5-VL/my_eval/evaluate_all_pai.py`
|
| 201 |
+
- **Solution for HF Spaces**: Need to copy evaluation scripts to Space or use API endpoint
|
| 202 |
+
|
| 203 |
+
2. **No GPU access**: HF Spaces free tier has no GPU
|
| 204 |
+
- **Impact**: Evaluation may be slow or fail if it requires GPU
|
| 205 |
+
- **Solution**: Consider compute upgrade or external evaluation service
|
| 206 |
+
|
| 207 |
+
3. **Storage limits**: HF Spaces have storage quotas
|
| 208 |
+
- **Impact**: Limited number of submissions before cleanup needed
|
| 209 |
+
- **Solution**: Implement periodic cleanup of old result files
|
| 210 |
+
|
| 211 |
+
4. **Single-user submissions**: No authentication
|
| 212 |
+
- **Impact**: Anyone can submit, potential for abuse
|
| 213 |
+
- **Solution**: Add HF OAuth for authenticated submissions
|
| 214 |
+
|
| 215 |
+
## Recommendations
|
| 216 |
+
|
| 217 |
+
### For Production Use
|
| 218 |
+
|
| 219 |
+
1. **Copy evaluation scripts to Space**:
|
| 220 |
+
```bash
|
| 221 |
+
# In Space repository
|
| 222 |
+
mkdir -p evaluation/
|
| 223 |
+
cp /root/code/Qwen2.5-VL/my_eval/*.py evaluation/
|
| 224 |
+
```
|
| 225 |
+
Update path in `app.py`: `EVAL_SCRIPT = Path("evaluation/evaluate_all_pai.py")`
|
| 226 |
+
|
| 227 |
+
2. **Add authentication**:
|
| 228 |
+
- Enable HF OAuth in Space settings
|
| 229 |
+
- Track submissions by user
|
| 230 |
+
- Implement rate limiting
|
| 231 |
+
|
| 232 |
+
3. **Set up monitoring**:
|
| 233 |
+
- Log all submissions
|
| 234 |
+
- Alert on evaluation failures
|
| 235 |
+
- Track Space resource usage
|
| 236 |
+
|
| 237 |
+
4. **Consider persistent storage**:
|
| 238 |
+
- Use HF Datasets for leaderboard data
|
| 239 |
+
- Store evaluation outputs in separate dataset
|
| 240 |
+
- Enable data persistence across Space restarts
|
| 241 |
+
|
| 242 |
+
5. **Add admin controls**:
|
| 243 |
+
- Manual submission approval
|
| 244 |
+
- Ability to remove/edit entries
|
| 245 |
+
- Download leaderboard as CSV
|
| 246 |
+
|
| 247 |
+
### For Testing
|
| 248 |
+
|
| 249 |
+
1. **Create test submission**:
|
| 250 |
+
```bash
|
| 251 |
+
# Use existing results
|
| 252 |
+
cp /root/code/Qwen2.5-VL/my_eval/results/dvc_llm_judge_v4_best5_10k/step45_results.json /tmp/test_submission.json
|
| 253 |
+
```
|
| 254 |
+
|
| 255 |
+
2. **Test locally first**:
|
| 256 |
+
```bash
|
| 257 |
+
cd /root/code/MedGRPO-Leaderboard
|
| 258 |
+
python3 app.py
|
| 259 |
+
```
|
| 260 |
+
Visit: http://localhost:7860
|
| 261 |
+
|
| 262 |
+
3. **Verify evaluation integration**:
|
| 263 |
+
```bash
|
| 264 |
+
python3 /root/code/Qwen2.5-VL/my_eval/evaluate_all_pai.py \
|
| 265 |
+
/tmp/test_submission.json \
|
| 266 |
+
--grouping overall
|
| 267 |
+
```
|
| 268 |
+
|
| 269 |
+
## Support & Maintenance
|
| 270 |
+
|
| 271 |
+
**For issues**:
|
| 272 |
+
1. Check Space logs on HuggingFace
|
| 273 |
+
2. Verify evaluation script is accessible
|
| 274 |
+
3. Check for storage/compute limits
|
| 275 |
+
4. Review validation error messages
|
| 276 |
+
|
| 277 |
+
**For updates**:
|
| 278 |
+
1. Edit `app.py` locally
|
| 279 |
+
2. Test changes locally
|
| 280 |
+
3. Commit and push to HF Space
|
| 281 |
+
4. Space auto-rebuilds on push
|
| 282 |
+
|
| 283 |
+
**Contact**:
|
| 284 |
+
- GitHub Issues: https://github.com/YuhaoSu/MedGRPO
|
| 285 |
+
- Project Page: https://yuhaosu.github.io/MedGRPO/
|
| 286 |
+
|
| 287 |
+
---
|
| 288 |
+
|
| 289 |
+
## Quick Reference
|
| 290 |
+
|
| 291 |
+
**Space URL**: https://huggingface.co/spaces/UIIAmerica/MedGRPO-Leaderboard
|
| 292 |
+
|
| 293 |
+
**Git repo**: `/root/code/MedGRPO-Leaderboard`
|
| 294 |
+
|
| 295 |
+
**Evaluation script**: `/root/code/Qwen2.5-VL/my_eval/evaluate_all_pai.py`
|
| 296 |
+
|
| 297 |
+
**Test data**: `/root/code/qa_instances/cleaned_test_data_10_18.json` (6,245 samples)
|
| 298 |
+
|
| 299 |
+
**Example results**: `/root/code/Qwen2.5-VL/my_eval/results/dvc_llm_judge_v4_best5_10k/`
|