Evaluated on 100 held-out synthetic patient presentations (25 per class).
The model never misses a genuine life-threatening EMERGENCY case.
The URGENT class is frequently over-triaged to EMERGENCY —
a conservative error that is clinically safer than the reverse.
1from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
2import torch
3
4model_id = "Milon96/phi3-medical-triage"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 device_map="auto",
10 torch_dtype=torch.float16,
11 trust_remote_code=True,
12)
13pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
14
15instruction = """You are a medical triage assistant. Classify the following
16patient presentation into: EMERGENCY, URGENT, SEMI-URGENT, NON-URGENT.
17EMERGENCY: Life-threatening — call 999 immediately.
18URGENT: Serious — same-day care required.
19SEMI-URGENT: Needs care within 24-48 hours.
20NON-URGENT: Routine — GP appointment within a week."""
21
22patient = "72-year-old male with sudden chest pain radiating to his left arm, sweating and nausea. Started 15 minutes ago."
23
24prompt = f"<|system|>\n{instruction}<|end|>\n<|user|>\n{patient}<|end|>\n<|assistant|>\n"
25result = pipe(prompt, max_new_tokens=150, do_sample=False, temperature=1.0)
26response = result[0]["generated_text"].split("<|assistant|>")[-1].replace("<|end|>","").strip()
27print(response)
28# Triage Level: EMERGENCY
29# Symptoms are consistent with acute myocardial infarction (heart attack).
30# Immediate emergency services required. Call 999 now.
200 synthetic patient presentations generated using Claude (Anthropic)
covering realistic clinical scenarios. Each example includes patient age,
gender, and symptom description in natural language.
Full training code, dataset pipeline, and evaluation scripts:
github.com/Milonahmed96/medical-triage-llm
1@misc{phi3-medical-triage,
2 author = {Milon Ahmed},
3 title = {Phi-3-mini Medical Triage Assistant},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/Milon96/phi3-medical-triage}
7}