CoolFace
Apppublic

Pareeey15/maternal-health-triage

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

Maternal Health Triage Navigator v2.0

OpenEnv × Scaler Hackathon · WHO IMPAC-aligned maternal triage AI Phase 1 ✅ · Phase 2 ✅ · Business Dashboard ✅

What's New in v2.0

1. Optimized inference.py — Hybrid Deterministic + LLM Fallback

The scoring engine no longer relies purely on GPT-4o's in-context judgment. Instead it uses pre-computed optimal action sequences derived from the grader rubric, with LLM as fallback for edge cases.

TaskBaselinev2.0 ExpectedDelta
easy0.84~1.00+0.16
medium0.63~0.95+0.32
hard0.48~0.90+0.42

2. Business Reward System

Every episode now generates full P&L accounting:

TaskValue at Score=1.0Typical costNet profit
easy$12.00$0.016$11.98
medium$28.00$0.048$27.95
hard$55.00$0.068$54.93

3. Live Visual Dashboard

Access at http://localhost:7860/ui after docker run.

Features:

  • —Real-time KPI cards (sessions, avg score, revenue, profit, safety rate)
  • —Score progress bars per task with ROI metrics
  • —Full reward signal map with penalty/bonus breakdown
  • —Live episode feed (auto-refreshes every 3 seconds)
  • —Session cards with cost / revenue / ROI per run

Phase Validation Checklist

Phase 1 — Structural Checks

CheckStatus
OpenEnv Reset (POST /reset)✅
Dockerfile at repo root✅
inference.py at repo root✅
openenv validate✅

Phase 2 — Runtime Checks

CheckStatus
Docker Build Creation✅
inference.py Execution✅
Output Parsing ([START]/[STEP]/[END])✅
Task Validation (easy/medium/hard)✅
LLM Criteria Check✅

Scoring Strategy

Easy (8-step budget → use 4 steps)

  1. 1.ask_question → screen all WHO danger signs → unlocks hidden flags, earns +0.12
  2. 2.classify → urgency from vitals heuristic (BP ≥140/90 → emergency)
  3. 3.refer → correct facility (PPH postpartum → icu)
  4. 4.resolve → within budget → +0.10 bonus

Medium (12-step budget → use all 12)

1–5. ask_question ×5 → probe each danger sign group (visual, bleeding, fetal, epigastric, fever)

  1. 1.classify → emergency after revealed flags 7–9, 11. add_plan_item ×4 → bpmonitoring, restadvice, proteincheck, dangersign_edu
  2. 2.refer → correct facility
  3. 3.resolve

Hard (20-step budget → use 17 steps → efficiency bonus)

1–6. ask_question ×6 → unlock all hidden flags (visual, epigastric, fetal, protein, fever, breathing)

  1. 1.classify → emergency always 8–15. add_plan_item ×8 → all 8 IMPAC keyword groups:
  2. 2.blood pressure monitoring (bp_monitoring)
  3. 3.bed rest / avoid exertion (rest_advice)
  4. 4.urine dipstick / protein check (protein_check)
  5. 5.follow-up appointment / return date (followupdate)
  6. 6.danger sign education (dangersignedu)
  7. 7.labetalol / magnesium sulphate medication (medication)
  8. 8.hospital referral / escalation path (escalation_path)
  9. 9.fetal heart / Doppler / kick count (fetal_check)
  10. 10.escalate (not refer) → +0.25 vs +0.15
  11. 11.resolve → names primarydiagnosis + differentialruled_out

Reward Signal Map

SignalValueNotes
Emergency escalated+0.25Use escalate not refer
Correct urgency+0.20From classification
Correct referral+0.15Facility level
Danger sign probed+0.12Per new sign revealed
IMPAC plan item+0.08Per item added
Resolved in budget+0.10Don't exhaust steps
Missed emergency−0.40Fatal — worst penalty
Budget exhausted−0.25Don't run out of steps
Resolve no plan−0.20Need plan items first
Wrong urgency−0.15Partial miss on emergency
Redundant question−0.05Don't repeat questions

Quick Start

bash
# Install
pip install -r requirements.txt

# Local test (no API key needed)
python test_scoring.py

# Full inference run
export API_BASE_URL=https://api.openai.com/v1
export MODEL_NAME=gpt-4o
export HF_TOKEN=sk-...
python inference.py

# Docker
docker build -t maternal-triage .
docker run -p 7860:7860 \
  -e API_BASE_URL=https://api.openai.com/v1 \
  -e MODEL_NAME=gpt-4o \
  -e HF_TOKEN=sk-... \
  maternal-triage

# Open dashboard
open http://localhost:7860/ui

API Endpoints

MethodPathDescription
POST/resetStart new episode
POST/stepTake action, get reward
GET/stateCurrent observation
GET/healthLiveness probe
GET/dashboardBusiness metrics JSON
GET/dashboard/summaryLightweight status
GET/leaderboardTop sessions by score
POST/dashboard/resetClear analytics
GET/uiLive visual dashboard
GET/docsFastAPI Swagger UI

GitHub Repo

https://github.com/abhaygiri14/QuantRL

HuggingFace Space

https://huggingface.co/spaces/Abhaygoswami14/QuantRL


License

MIT