vadimbelsky commited on
Commit
6fc17a7
·
verified ·
1 Parent(s): 5949a0b

Update model card: v4 eval results (75% acc, 92% high-risk recall)

Browse files
Files changed (1) hide show
  1. README.md +165 -7
README.md CHANGED
@@ -1,21 +1,179 @@
1
  ---
2
- base_model: vadimbelsky/qwen3.5-medical-ft-stage3-dpo
3
  tags:
4
  - text-generation-inference
5
  - transformers
6
  - unsloth
7
  - qwen3_5
 
 
 
 
 
8
  license: apache-2.0
9
  language:
10
  - en
11
  ---
12
 
13
- # Uploaded finetuned model
14
 
15
- - **Developed by:** vadimbelsky
16
- - **License:** apache-2.0
17
- - **Finetuned from model :** vadimbelsky/qwen3.5-medical-ft-stage3-dpo
18
 
19
- This qwen3_5 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
20
 
21
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ base_model: vadimbelsky/qwen3.5-medical-ft-stage2
3
  tags:
4
  - text-generation-inference
5
  - transformers
6
  - unsloth
7
  - qwen3_5
8
+ - medical
9
+ - triage
10
+ - emergency-medicine
11
+ - dpo
12
+ - rlhf
13
  license: apache-2.0
14
  language:
15
  - en
16
  ---
17
 
18
+ # Qwen3.5-9B Medical Triage — Stage 3 DPO (v4)
19
 
20
+ Emergency department triage model fine-tuned on Qwen3.5-9B via a 3-stage pipeline:
21
+ **Stage 1** (general medical SFT) → **Stage 2** (ED intake SOAP → ESI decision SFT) → **Stage 3** (DPO alignment to reduce over-triage, this model).
 
22
 
23
+ Quantized to **Q4_K_M GGUF** for on-device inference.
24
 
25
+ ---
26
+
27
+ ## Model Description
28
+
29
+ Given an ED SOAP intake note, the model outputs a structured triage decision:
30
+ - **ESI level** (1–5) with justification
31
+ - Key clinical findings
32
+ - Time-to-provider target
33
+ - Immediate interventions required
34
+
35
+ **ESI Scale:** 1 = Immediate life threat · 2 = Emergent high-risk · 3 = Urgent stable · 4 = Less urgent · 5 = Non-urgent
36
+
37
+ ---
38
+
39
+ ## Training Pipeline
40
+
41
+ | Stage | Method | Objective |
42
+ |-------|--------|-----------|
43
+ | 1 | SFT (LoRA r=16) | General medical knowledge (PubMed, clinical guidelines) |
44
+ | 2 | SFT (LoRA r=16) | SOAP note → structured ESI triage decision |
45
+ | 3 | DPO (LoRA r=8) | Reduce over-triage · preserve ESI 1/2 high-risk recall |
46
+
47
+ ### Stage 3 DPO Details
48
+
49
+ - **Base:** Stage 2 LoRA checkpoint (`vadimbelsky/qwen3.5-medical-ft-stage2`)
50
+ - **Dataset:** `dpo_dataset_v4.jsonl` — 5,413 raw pairs → 7,789 weighted pairs
51
+ - **Loss:** Combined `apo_down × 0.3 + sft × 1.0` (MPO-style)
52
+ - **Beta:** 0.5 · **LR:** 5e-5 · **Epochs:** 0.1 (47 steps)
53
+ - **Batch:** 2 × 8 gradient accumulation = effective 16
54
+ - **ESI label prepending:** All chosen/rejected completions prefixed with explicit ESI label (e.g. `ESI 2 — Emergent (high risk)\n\n...`) to anchor preference signal at token position 0
55
+
56
+ ### Dataset Sources (v4)
57
+
58
+ | Source | Description | Raw pairs | Weight | Weighted |
59
+ |--------|-------------|-----------|--------|---------|
60
+ | A | Anti-overtriage synthetic (ESI 3→1/2 rejected) | 2,388 | 1× | 2,388 |
61
+ | B | Anti-overtriage synthetic (ESI 4/5→1/2 rejected) | 1,500 | 1× | 1,500 |
62
+ | C / C-haiku | Edge cases (Claude Haiku generated) | 39 | 1× | 39 |
63
+ | D | ESI 1/2 anchor pairs (high-risk recall preservation) | 890 | 3× | 2,670 |
64
+ | E-over | ESI 3 bidirectional — anti-overtriage | 297 | 2× | 594 |
65
+ | E-under | ESI 3 bidirectional — anti-undertriage | 299 | 2× | 598 |
66
+ | **Total** | | **5,413** | | **7,789** |
67
+
68
+ ---
69
+
70
+ ## Evaluation Results
71
+
72
+ Evaluated on **MIMIC-IV-Ext Triage Instruction Corpus** (MIETIC) — 36 human-expert validated RETAIN cases.
73
+
74
+ ### v4 vs Previous Stages
75
+
76
+ | Metric | Stage 2 (SFT) | v1 DPO | v2 DPO | v3 DPO | **v4 DPO** | Target |
77
+ |--------|--------------|--------|--------|--------|-----------|--------|
78
+ | Accuracy | ~68% | 55.6% | 50.0% | 27.8% | **75.0%** | >82% |
79
+ | Over-triage rate | ~22% | 22.2% | 30.6% | 0% | **13.9%** | <10% |
80
+ | Under-triage rate | ~8% | 36.1% | 41.7% | 72.2% | **11.1%** | <6% |
81
+ | High-risk recall (ESI 1+2) | ~84% | 76% | 64% | 40% | **92%** | 100% |
82
+ | ESI 3 accuracy | ~45% | ~40% | ~30% | ~0% | **60%** | >65% |
83
+
84
+ ### v4 Detailed Results (MIETIC, n=36)
85
+
86
+ ```
87
+ Samples evaluated : 36
88
+ ESI level parsed : 36 / 36
89
+ Correct : 27
90
+ Accuracy : 75.0%
91
+ Under-triage rate : 11.1% (4 cases)
92
+ Over-triage rate : 13.9% (5 cases)
93
+ High-risk recall : 92.0% (ESI 1+2, n=25)
94
+ ```
95
+
96
+ **Per-ESI Accuracy:**
97
+
98
+ | ESI Level | N | Correct | Accuracy |
99
+ |-----------|----|---------|----------|
100
+ | ESI 1 | 14 | 12 | 85.7% |
101
+ | ESI 2 | 11 | 9 | 81.8% |
102
+ | ESI 3 | 5 | 3 | 60.0% |
103
+ | ESI 4 | 4 | 2 | 50.0% |
104
+ | ESI 5 | 2 | 1 | 50.0% |
105
+
106
+ **Confusion Matrix** (rows = ground truth, cols = predicted):
107
+
108
+ ```
109
+ GT \ Pred ESI 1 ESI 2 ESI 3 ESI 4 ESI 5
110
+ ESI 1 12 2 0 0 0
111
+ ESI 2 0 9 2 0 0
112
+ ESI 3 0 2 3 0 0
113
+ ESI 4 0 0 2 2 0
114
+ ESI 5 0 0 0 1 1
115
+ ```
116
+
117
+ All remaining errors are ±1 ESI boundary confusions — no catastrophic mis-triage.
118
+
119
+ ---
120
+
121
+ ## Key Lessons from DPO Iteration
122
+
123
+ - **v1–v3 failure:** IPO/sigmoid loss collapsed when dataset direction was 100% anti-overtriage → catastrophic under-triage regression (40% high-risk recall at worst)
124
+ - **v4 fix:** (1) ESI label prepended at token position 0 for unambiguous preference signal; (2) `apo_down + sft` combined loss preserves ESI 1/2 recall via SFT component; (3) Sources D (ESI 1/2 anchors ×3) + E (ESI 3 bidirectional ×2) balance dataset direction
125
+
126
+ ---
127
+
128
+ ## Usage
129
+
130
+ ```python
131
+ # Requires llama.cpp server running with the Q4_K_M GGUF
132
+ # llama-server --model qwen3.5-medical-ft-stage3-dpo-q4km.gguf --port 8080 -c 4096
133
+
134
+ from openai import OpenAI
135
+ client = OpenAI(base_url="http://localhost:8080/v1", api_key="none")
136
+
137
+ SYSTEM_PROMPT = (
138
+ "You are an expert emergency medicine triage nurse. "
139
+ "Given a SOAP intake note, provide a structured triage decision including "
140
+ "ESI level with justification, key clinical findings, time-to-provider target, "
141
+ "and any immediate interventions required."
142
+ )
143
+
144
+ response = client.chat.completions.create(
145
+ model="local",
146
+ messages=[
147
+ {"role": "system", "content": SYSTEM_PROMPT},
148
+ {"role": "user", "content": "<SOAP intake note here>"},
149
+ ],
150
+ temperature=0.1,
151
+ max_tokens=512,
152
+ )
153
+ print(response.choices[0].message.content)
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Limitations & Safety
159
+
160
+ > ⚠️ **This model is for research purposes only. It must NOT be used for clinical decision-making without licensed clinician oversight.**
161
+
162
+ - Evaluated on 36 MIETIC validation cases — not a clinical trial
163
+ - 11.1% under-triage rate means critical patients may be down-triaged
164
+ - 92% high-risk recall means ~8% of ESI 1/2 patients may be missed
165
+ - Model has not been validated on real ED populations
166
+ - Fine-tuned on synthetic + MIMIC-IV derived data only
167
+
168
+ ---
169
+
170
+ ## Training Infrastructure
171
+
172
+ - **Hardware:** NVIDIA GB10 (121 GB VRAM), 1 GPU
173
+ - **Framework:** Unsloth 2026.3.4 + TRL DPOTrainer + Transformers 5.2.0
174
+ - **Training time:** ~2 hours (47 steps)
175
+ - **Quantization:** GGUF Q4_K_M via llama.cpp
176
+
177
+ ---
178
+
179
+ *Fine-tuned with [Unsloth](https://github.com/unslothai/unsloth) 🦥*