CoolFace
Apppublic

AkashKaralingannavar/sequential-medical-triage-ai

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

๐Ÿฅ AI Medical Triage Assistant โ€” OpenEnv RL Environment

Real-World Motivation

In low-resource healthcare settings worldwide, patients face critical delays in receiving appropriate care. This OpenEnv simulates a first-level AI triage assistant that must make sequential decisions under partial observability โ€” a genuine real-world problem.

Unlike simple classifiers, this is a true sequential decision-making RL environment where the agent must:

  • โ€”Decide what information to gather (at a cost)
  • โ€”Balance investigation thoroughness vs. time pressure
  • โ€”Handle patients who deteriorate if not triaged quickly

Observation Space (TriageObservation)

FieldTypeDescription
patient_idstrUnique patient identifier
ageintPatient age
genderstrPatient gender
medical_historystrPre-existing conditions
chief_complaintstrInitial reason for visit
discovered_symptomsstrSymptoms uncovered through investigation
discovered_vitalsstrVital signs uncovered through investigation
step_numberintCurrent step (1-indexed)
max_stepsintMaximum steps allowed
task_instructionsstrTask-specific instructions

Action Space (TriageAction)

FieldTypeDescription
action_type`"investigate" \"triage"`Choose to gather info or make final decision
investigation_target`"symptoms" \"vitals"`What to investigate (if investigating)
urgency_level`"low" \"medium" \"high"`Urgency classification (if triaging)
recommended_action`"self_care" \"clinic_visit" \"emergency_room"`Care recommendation (if triaging)
reasoningstrBrief justification

Reward Design

  • โ€”Urgency match: up to 0.45 points (partial credit for being 1 level off)
  • โ€”Action match: up to 0.45 points (partial credit for adjacent actions)
  • โ€”Investigation bonus: +0.05 for thorough information gathering
  • โ€”Time penalty: -0.06 per investigation step (-0.10 in time-critical)
  • โ€”Deterioration penalty: -0.10 if volatile patient worsens
  • โ€”All scores clamped to strict (0.01, 0.99) โ€” never 0.0 or 1.0

Tasks & Difficulty

1. direct_triage โ€” Easy

Full patient information (symptoms + vitals) is visible from the start. The agent simply needs to classify urgency and recommend an action.

2. investigative_triage โ€” Medium

Only the chief complaint is visible. The agent must spend investigate actions to uncover symptoms and vitals. Each investigation incurs a time penalty (-0.06). Blind guessing is penalized.

3. time_critical_triage โ€” Hard

High-volatility patients deteriorate over time. Investigation costs more (-0.10 per step). If the agent takes too long, the patient's condition worsens, potentially changing the correct answer. The agent must triage quickly while still gathering minimum critical info.


Setup & Usage

Docker (recommended)

bash
docker build -t openenv-triage .
docker run -p 7860:7860 openenv-triage

Access the API at http://localhost:7860/

API Endpoints

  • โ€”GET / โ€” Health check (returns 200)
  • โ€”GET/POST /reset?task_name=direct_triage&case_index=0 โ€” Reset environment
  • โ€”POST /step โ€” Submit an action (JSON body matching TriageAction)
  • โ€”GET /state โ€” Get current environment state

Run Inference

bash
export HF_TOKEN="your_api_key"
export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct"
python inference.py

Run a specific task

bash
export TASK_NAME="investigative_triage"
python inference.py

Baseline Scores (Heuristic Agent)

TaskAvg ScoreDescription
direct_triage~0.55Medium accuracy with keyword heuristic
investigative_triage~0.40Investigate-then-guess strategy
time_critical_triage~0.35Fast triage with partial info

Scores improve significantly with capable LLMs (GPT-4, Qwen-72B).


Grader Verification

bash
python grader.py

All scores will be printed and verified to be in the strict (0.0, 1.0) range.