TriageSim¶
A Python framework for generating synthetic, multi-speaker spoken dialogues for emergency department triage.
TriageSim turns structured clinical vignettes into realistic nurse ↔ patient conversations. A ground-truth electronic health record — chief complaint, vitals, pain score, true acuity — is hidden from both agents. The nurse agent must elicit that information through dialogue, decide which vitals to check, log red flags, and commit to a triage level. The result is paired structured EHR → dialogue data with a full record of how the decision was reached.
Why it exists¶
Evaluating speech and language systems in clinical settings is hard: real triage recordings are scarce, sensitive, and almost never paired with reliable ground truth. TriageSim generates that pairing under controlled conditions, so you can vary one factor at a time — the patient's language proficiency, the nurse's risk tolerance, the underlying model — and measure what changes.
Because the ground truth is known by construction, every run is scorable. The framework ships metrics for triage accuracy, red-flag detection, belief coverage, and how well the nurse's stated reasoning is supported by what was actually elicited.
What you get¶
Agent dialogue
Nurse and patient agents backed by any OpenRouter-compatible model, each emitting schema-validated structured output rather than free text.
Two triage algorithms
The Emergency Severity Index (ESI) and the Australasian Triage Scale (ATS), selected per nurse agent and reflected in its reasoning prompt.
Persona conditioning
Patient and nurse personas defined in YAML — ethnicity, recall accuracy, pain expression, guideline adherence, verbosity, and more.
Replayable artifacts
Every run returns dialogue history, a per-turn cognition trace, the final belief state, and logged red flags — persisted in memory or Redis.
Built-in metrics
Triage correctness and over/under-triage, time-to-first-correct, red-flag precision/recall/F1, and explanation support statistics.
Optional speech synthesis
Render finished dialogues to multi-speaker audio with XTTS-v2 voice cloning, on CUDA, MPS, or CPU.
Install¶
Requires Python 3.11 or newer. See Installation
for the redis and audio extras.
A minimal run¶
from triagesim import TriageRunner, RunnerConfig
from triagesim.agents import OpenRouterLLM, NurseAgent, PatientAgent
from triagesim.core import NurseOutput, PatientOutput
from triagesim.personas import load_patient_personas, load_nurse_personas
patient_persona = load_patient_personas("patient.yaml")[0]
nurse_persona = load_nurse_personas("nurse.yaml")[0]
ground_truth = {
"chiefcomplaint": "Syncope",
"vitals": {"temperature": 99.1, "heartrate": 112, "resprate": 26,
"o2sat": 91, "sbp": 98},
"acuity": 2,
"pain": 7,
}
model = "anthropic/claude-sonnet-4-5"
patient = PatientAgent(
llm=OpenRouterLLM(model_name=model, output_type=PatientOutput),
persona=patient_persona,
)
nurse = NurseAgent(
llm=OpenRouterLLM(model_name=model, output_type=NurseOutput),
persona=nurse_persona,
algorithm="esi",
)
artifact = TriageRunner(
nurse_agent=nurse,
patient_agent=patient,
ground_truth=ground_truth,
config=RunnerConfig(max_turns=20, seed=42),
).run()
print(artifact["trace"][-1])
Walk through this line by line in the Quick start.
Citing¶
TriageSim accompanies a research paper. If you use it, please cite the work.
Research software
TriageSim generates synthetic data for research on speech and language systems. It is not a clinical decision support tool and must not be used to triage real patients.