Large language models reason step by step in mathematics and code, but in clinical differential diagnosis (DDx) they still map notes straight to answers. One reason is that the supervision needed to teach clinical reasoning is largely missing, because clinical notes record conclusions rather than the reasoning traces behind them. We present a four-stage generator-verifier pipeline that builds this supervision. It generates diagnostic reasoning traces over real hospital admissions and checks the structured answer of every intermediate step against an external clinical reference (WikiDoc) and the recorded patient outcome (MIMIC-IV). The result is MERLIN-DDx, a dataset of 124,510 stage records over 10,400 admissions whose discharge diagnosis WikiDoc covers, of which 117,580 carry a verifier score; clinicians confirm the reference diagnosis in 77% of reviewed cases (inter-rater kappa = 0.91). We evaluate two admission-time tasks, differential diagnosis and ICD coding, predicting discharge codes from what was known on arrival. This is harder than coding finished discharge summaries, and closer to real decision support. Fine-tuning Qwen3 models (0.6B-32B) on MERLIN-DDx improves long-tail ICD performance (macro-F1) over the untuned base at every scale. Case-matched label-only controls, trained on the same cases and gold codes without traces, isolate what the traces add: 1.7 to 6.9 macro-F1 points at every scale, though not consistently on micro-F1. A data ablation at 8B shows macro-F1 rising with verifier-filter strictness, although stricter filtering retains fewer traces. An error analysis shows the gain reaches every frequency stratum and is especially large on low-frequency codes, which are improved but not solved. We release the dataset, pipeline, and prompts.
Figures & tables
Figure 1: Fine-tuning on MERLIN-DDx improves ICD macro-F1 at every scale, beyond a label-only control. Untuned Qwen3 bases compared with the same models fine-tuned on MERLIN-DDx traces or on a case-matched label-only control (same cases and codes, no traces), evaluated on the test split using our primary metric. Means over three evaluation repeats (8B fine-tuned bars: three training seeds), whiskers std. The 0.6B base bar is 0.1 .
Figure 2: The MERLIN-DDx generator–verifier pipeline. An admission note enters a loop in which a generator LLM samples candidate reasoning traces and a verifier scores each against an external reference target. A trace scoring at or above that stage’s threshold passes on; below it, the stage regenerates, until the round budget is spent and the stage falls back to a label-only target. The loop runs over four stages: symptom extraction ( V1 ), diagnosis ranking ( V2 ), lab-based reranking ( V3 ) and ICD-code prediction ( V4 ). Accepted stage outputs and label-only fallbacks are assembled into the MERLIN-DDx dataset and used to fine-tune a student model. Our contribution is the construction loop rather than any individual stage. Because each accepted trace retains its verifier score, the released dataset can be re-filtered using alternative thresholds (§ 6.1 ). Prompts, thresholds and per-stage verifier metrics: § 3.2 and Appendix I .
Diagnosis ranking
ICD codes
Model
R@1
R@3
F1mic
F1mac
Rmac
Pmac
Untuned baselines
MedGemma-27B
51.8± 0.2
74.5± 0.3
29.4± 0.2
7.6± 0.1
9.1± 0.3
11.8± 0.3
Llama-3.3-70B-Instruct
51.1± 0.5
72.5± 0.6
29.7± 0.6
11.8± 0.7
14.4± 0.5
18.0± 0.4
Baichuan-M2-32B
49.6± 0.3
71.8± 0.7
32.4± 1.1
11.1± 0.9
14.8± 1.1
13.2± 1.0
Qwen3 base and fine-tuned
Table 1: Main results on the held-out test split ( n=2,184 ), all rows under the same admission-time protocol: no lab values, no reranking, dev-selected best epoch. Bold marks the best value in each column and underline the second best; F1mac is the primary metric (§ 1 ). Rows marked ∗ are mean ± std over three training seeds, each evaluated once; every other model row is mean ± std over three evaluation repeats of one checkpoint, capturing decoding stochasticity but not training-seed variance (§ 5.3 ). R@1 / R@3 are the shares of cases whose confirmed diagnosis is ranked first / in the top three (the two come apart at 32B, § 5.2 ). ICD columns are micro- and macro-F1 over three-character codes, then macro-averaged recall and precision. † Label-only control: same cases, instructions, gold outputs and ICD-row oversampling, traces removed. At 0.6B and 32B the label-only controls produce valid diagnosis-stage JSON for only about 21% and 46% of cases, which lowers their R@1 and R@3. ‡ Strongest of three encoder classifiers retrained on our MIMIC-IV subset ( F.3 ); its ± is over three training seeds and so is the stricter quantity, and it emits no ranked differential, hence the dashes. LoRA is in G.2 .
Figure 3: Filtering traces by verifier score and oversampling ICD rows each improve long-tail ICD performance. Qwen3-8B, full fine-tuning, dev split, dev-selected best epoch. Left to right: label-only (no traces), traces with no score threshold, then traces clearing half and all stage thresholds. Blue is without and orange with duplicated ICD-coding rows. The open circle drops below-threshold cases instead of using the label-only fallback; half thresholds were not run with ICD-row duplication. Macro-F1 (left) rises with filter strictness at both oversampling settings, while micro-F1 (right) is matched by oversampling alone. Diagnosis Recall@3 stays within two points of the best result across the trace-based variants. Exact values, including the two controls the markers do not separate, in Appendix G.1 .
Recall / F1 by code class (%)
F1 by train. frequency
Full code
Size
Primary
Hist. F1
Med. F1
Chron. F1
Head
Body
Tail
F1mac
0.6B
base
1.1
0.0
0.0
3.2
0.3
0.1
0.0
0.0
+ label-only †
52.1
35.3
56.6
43.4
16.3
1.1
0.0
1.0
+ Merlin
63.0
44.1
65.1
57.5
31.6
9.4
0.6
1.5
8B
base
39.9
8.5
0.0
35.8
12.4
5.5
0.9
0.4
+ label-only †
62.1
45.1
65.0
57.4
30.8
11.4
2.4
3.1
Table 2: Where the ICD gain comes from , three cuts of the base, label-only and Merlin comparison (test split, n=2,184 , seed-42 evaluation runs). All figures are exact set operations over gold and predicted codes; definitions in Appendix H . Primary : share of cases whose predicted codes cover the first gold code, taken as principal; Hist./Med./Chron. : class-conditional F1 over personal-history, long-term-medication and Elixhauser comorbidity codes. Frequency strata: head ( ≥100 ), body ( 10 – 99 ), tail ( <10 ) training occurrences, scored over each stratum’s 153 / 349 / 328 test-gold codes (§ 6.3 ). Full code: untruncated granularity, macro-F1 only. † Label-only control of Table 1 : same cases and gold codes, no traces. Bold : best per column, underline : second best.
Appendix figures & tables17 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 4: WikiDoc mapping quality per chief complaint (share of rows: exact / near / fuzzy match to the disease row).
Complaint
Candidates
Retained
Excl. %
Abdominal pain
11,587
3,316
71.4
Back pain
2,626
1,063
59.5
Chest pain
5,095
1,970
61.3
Cough
2,126
1,110
47.8
Diarrhea
2,059
448
78.2
Dyspnea
8,067
4,239
47.5
Appendix
Table 3: WikiDoc mapping attrition per chief complaint , before the split and the one-complaint-per-subject assignment that yields the 10,400 released admissions. An admission can be a candidate for several complaints, hence pairs vs. unique admissions.
Chief complaint
#Cases
#Sympt.
#Diag.
Dyspnea
3,012
23
74
Abdom. pain
2,641
24
67
Chest pain
1,921
27
48
Cough
1,072
21
31
Back pain
1,040
30
64
Diarrhea
443
17
58
Appendix
Table 4: MERLIN-DDx dataset composition. Each chief complaint maps to one WikiDoc table, from which #Sympt. is the number of distinct symptom features that table tracks and #Diag. the number of candidate diagnoses it lists; a single complaint therefore spans many of both, and the two counts are not comparable to #Cases . The Overall row sums the per-table counts; tables share some features and diagnoses. The long-tail distribution of the discharge ICD labels is in Appendix F.4 (Figure 9 , Table 9 ), alongside the head/body/tail breakdown it motivates.
Sympt.
Diagn.
Lab
ICD
All splits: 10,400 adm., 31,200 chains
Stage records
30,910
31,200
31,200
31,200
scored
24,782
31,198
30,543
31,057
Train split: 7,299 adm., 21,897 chains
Scored records
17,098
21,897
21,897
21,897
accepted
12,918
18,813
15,566
8,677
Appendix
Table 5: Dataset accounting by stage. Stage records are generated outputs; scored are those a verifier could score; accepted are those clearing the stage threshold, with the remainder replaced by the label-only fallback . Row totals: 124,510 stage records, 117,580 scored, 82,789 train-split records, 55,974 accepted, 26,815 fallbacks. The ICD stage accepts least often ( 39.6% ) and so does most of the filtering, consistent with its threshold sitting furthest above its stage average (§ 3.2 ).
Figure 5: Implementation view of the MERLIN-DDx pipeline , expanding Figure 2 . Each stage assembles a structured context (the stage instruction, the admission note, the previous stage’s accepted trace, and the stage’s JSON output schema and example) and passes it to one of three generator LLMs, which samples N candidate traces per round. The verifier scores each against that stage’s reference target and keeps the top-1 ( WikiDoc symptoms by NormDot for V1 , WikiDoc differentials by RR for V2 / V3 , MIMIC-IV discharge codes by F1 for V4 ). Scores below threshold trigger regeneration at raised temperature and token budget; scores above threshold pass the trace on, while exhausting the budget replaces the trace with the label-only fallback. Lower left: the WikiDoc disease × manifestation table that defines the V1 output schema and supplies the reference vectors ( + present, - absent, ± variable). Upper right: an excerpt of an accepted V2 trace for an abdominal-pain case; highlighting marks manifestations shared between the trace’s justification and the matched WikiDoc row. Both panels are illustrative rather than a verbatim record.
Figure 6: Iterative improvement of verifier scores across generation-budget steps (abdominal-pain cases). As sub-threshold traces are regenerated, verifier scores rise consistently across pipeline stages.
Model
Mode
Hardware
Eff. bs
LR
0.6B
LoRA r=128
1 × H200
64
1×10−4
0.6B
Full
1 × B200
128
1×10−4
8B
LoRA r=128
2 × B200
64
1×10−4
8B
Full
2 × B200
256
1×10−4
14B
LoRA r=128
2 × B200
64
5×10−5
14B
Full (FSDP)
2 × B200
256
5×10−5
Appendix
Table 6: Per-run fine-tuning configuration.
Figure 7: Selecting checkpoints by ICD macro-F1 costs upstream quality (§ 5.2 ). Dev-split epoch sweeps of the full fine-tuning runs, one line per model size; rings mark the epoch selected for Table 1 . Left: the selection metric, which keeps rising into late epochs at every size. Middle and right: diagnosis Recall@3 and diagnosis-stage JSON validity, which do not. The trade is mild at 0.6B and 8B and severe at 14B, where the two right-hand panels track each other closely. A trace with unparseable diagnosis-stage output has no ranked list and scores zero on Recall@ k .
Figure 8: Training-seed robustness for the 8B headline recipe (left, with reasoning traces) and its label-only control (right, no traces), each retrained end-to-end under seeds 42/43/44 and evaluated once on the test split, on a shared y -axis. Bars: mean ± std; markers: individual seeds (colored, star for seed 42); per-seed ICD macro-F1 for seeds 42/43/44 is 13.9 / 11.6 / 13.6 with traces and 11.4 / 11.2 / 11.4 label-only. The label-only control is far more stable on ICD F1 (macro CV ∼1% vs. ∼10% for the reasoning recipe) but less stable on diagnosis Recall@3 ( 68.7±1.3 vs. 76.3±0.4 ); the ICD F1 micro gap between arms even points the opposite direction from macro on the seed-averaged mean, so the reasoning-supervision claim is scoped to macro-F1, not read as a uniform win.
Chief complaint
n
NormDot
R@1
R@3
F1mic
F1mac
Dyspnea
612
56.3
31.5
81.2
53.6
22.5
Abdominal Pain
558
60.5
40.9
76.7
49.0
20.8
Chest Pain
409
55.1
33.5
70.2
52.2
22.1
Back Pain
244
78.5
28.7
63.5
45.6
21.7
Cough
195
53.9
36.4
80.5
48.4
21.6
Diarrhea
99
53.2
38.4
67.7
43.9
22.9
Appendix
Table 7: Chief-complaint breakdown of the 32B + Merlin checkpoint (test split, n=2,184 ), same metrics as Table 1 . Single evaluation seed ( 42 ), since the repeats in Table 1 were not broken down by complaint, so the All row reads slightly differently from the three-repeat mean there. ICD macro-F1 is nearly flat across complaints ( 20.6 – 22.9 ) while the other columns vary far more (NormDot 53 – 79 , R@1 29 – 41 , R@3 64 – 81 ), so long-tail coding difficulty does not track complaint-level symptom or diagnosis quality. Back pain’s high NormDot ( 78.5 ) should be read with care: it has the longest symptom vector ( 30 dims against 13 – 27 elsewhere), a scale effect not controlled for here, and it pairs with the lowest R@1 ( 28.7 ) and R@3 ( 63.5 ).
Encoder
F1 mic
F1 mac
Matched data ( 10,400 admissions, 3 seeds)
BioClin. ModernBERT
26.4±0.8
8.2±0.1
S-Proto
29.8±0.8
4.5±0.2
PubMedBERT
16.2±9.5
4.3±1.5
Full MIMIC-IV ( CliniBench )
GatorTronS-345M
29.3
25.5
Appendix
Table 8: Encoder ICD-prediction baselines on the same MIMIC-IV subset (test split, n=2,184 ): mean ± std over 3 training seeds, scored with the same metric as the ICD columns of Table 1 . BioClinical ModernBERT has the best macro-F1 and is the row promoted into Table 1 . S-Proto has the best micro-F1 ( 29.8 ) but a macro-F1 of only 4.5 : it wins on frequent codes and loses on the tail, the macro/micro trade discussed in § 5 . All three trade precision for recall at the per-code level, over-predicting frequent codes rather than discriminating the tail; even the strongest reaches macro recall 13.8 against macro precision 7.0 . PubMedBERT is the least seed-stable by a wide margin (micro-F1 std 9.5 vs. ≤0.8 for the other two). The CliniBench rows ( Grundmann et al., 2026 ) are the full- MIMIC-IV ceiling, trained on 50 – 80× more admissions under a top-20 ranked-list protocol rather than our threshold-based full-label prediction.
Size
Head
Body
Tail
#labels
153
349
328
0.6B base
0.3
0.1
0.0
0.6B + Merlin
31.6
9.4
0.6
8B base
12.4
5.5
0.9
8B + Merlin
32.4
15.3
3.6
14B base
24.3
12.0
3.6
Appendix
Table 9: Head, body and tail, full detail. Companion to the “F1 by train. frequency” block of Table 2 (§ 6.3 ), with the same test-split F1 numbers at every model size plus #labels , the count of each stratum’s codes present in the test gold. Strata are three-character codes grouped by MERLIN-DDx training frequency: head ≥100 admissions ( 153 codes, 82.8% of all training code occurrences), body 10 – 99 ( 15.0% ), tail <10 including codes never seen ( 2.1% ). These 830 gold-present codes are the macro-F1 universe of Table 1 : predicted codes outside it are discarded before scoring, so the strata average back, weighted by #labels, to the macro-F1 of the same seed-42 evaluation runs (Table 12 ). Counting discarded codes as false positives over the union of gold and predicted codes instead lowers macro-F1 by up to 3.1 points, most for the larger untuned models, and narrows the Merlin –label-only gap of the seed-42 runs from 2.5 – 6.5 to 1.5 – 6.0 points without reversing it at any scale.
Figure 9: Label-frequency distribution. Three-character ICD discharge codes across all 10,400 admissions, rank-ordered, log-scaled. Shading applies the ≥100 / 10 – 99 / <10 admission thresholds: 201 head codes carry 87.4% of the 123,133 admission–code pairs, while 567 tail codes share 1.4% . Table 9 applies the same thresholds to training frequency alone, giving 153 / 359 / 583 codes over the full label space, of which 153 / 349 / 328 occur in the test gold labels that Tables 2 and 9 score.
Checkpoint
Diag. ranking
ICD coding
Dev split, 8B data-construction recipes
No thresholds + ICD × 2
0
2
Full thresholds
3
14
Half thresholds
100
100
Full thresholds + ICD × 2
1
100
Test split, checkpoints of Table 1
Appendix
Table 10: Reasoning-free rate (%) at the diagnosis-ranking and ICD-coding stages. A valid generation is reasoning-free when fewer than ten words of reasoning precede the templated summary that closes every training trace’s reasoning block or, if no summary is written, the JSON answer; outputs with invalid JSON are excluded from the denominator. Two routes reach it: writing only the summary (nearly all cases at 8B–32B and in the dev recipes) or answering straight into the JSON (all cases at 0.6B). Top: 8B data-construction recipes on the dev split, at their dev-selected epochs; full thresholds + ICD × 2 is the Merlin recipe. Bottom: the checkpoints of Table 1 on the test split (seed-42 evaluation run). Label-only controls are not shown: their text before the JSON is mostly echoed prompt sections, which word counts cannot tell from reasoning.
Symptoms
Diagnosis ranking
ICD codes
Training data
NormDot
R@1
R@3
F1mic
F1mac
Rmac
Pmac
8B base (untuned)
53.6
45.5
64.7
19.2
5.5
5.3
9.8
No reasoning traces (label-only)
label-only
56.5
53.3
72.3
38.1
9.5
9.8
11.8
label-only + ICD × 2
58.9
49.8
68.3
43.8
12.5
12.1
15.4
Reasoning traces, unfiltered
Appendix
Table 11: Data-construction ablation, exact values (Qwen3-8B, full fine-tuning, dev split, dev-selected best epoch), plotted in Figure 3 . Eight variants span two construction factors, how traces are filtered (row groups) and whether ICD-coding rows are duplicated ( + ICD × 2), plus one drop-vs-fallback control. ICD columns are micro- and macro-F1 over three-character codes, then macro-averaged recall and precision.
Sympt.
Diagn.
ICD codes
Model
NormDot
R@1
R@3
F1mic
F1mac
Rmac
Pmac
Qwen3-0.6B
51.3
34.4
53.2
1.2
0.1
0.1
0.4
+ Merlin (full)
61.6
51.1
73.8
43.7
10.0
9.9
11.8
+ Merlin (LoRA r=128 )
61.4
52.5
74.2
43.2
9.8
9.9
11.5
Qwen3-8B
53.9
45.6
67.1
19.5
4.9
4.7
8.9
+ Merlin (full)
59.1
53.4
75.8
43.5
13.9
13.5
17.6
Appendix
Table 12: LoRA vs. full fine-tuning and the untuned base, held-out test split, columns as in Table 1 . Single evaluation run per model, so no ± is given. ∗ The 8B r=128 adapter stays at base-level ICD macro-F1 with 70% coding-stage JSON validity; r=256 was lower at every epoch.
Role
JF
DF
CF
Conceptualization
E
E
E
Methodology
E
E
S
Software
L
S
S
Data curation
S
E
E
Investigation
L
S
S
Formal analysis
L
S
–
Appendix
Table 13: CRediT roles of the equal-contribution authors.
A correct diagnosis can still be reached for the wrong reasons. In clinical reasoning, every disease hypothesis creates obligations: key evidence must be checked, alternatives must be ruled out, contradictions must be resolved, useful tests must be considered, and closure must be justified. Current evaluations of medical LLMs mostly focus on final answers, local steps, or isolated facts, and therefore miss these hypothesis-induced commitments. We introduce VeriDx, a disease-centric verification framework that links free-form diagnostic reasoning to structured disease profiles. VeriDx tracks whether each hypothesis is satisfied, unresolved, or violated its clinical obligations, exposing failures such as missing critical tests, unresolved differentials, ignored contradictions, unsupported claims, and premature closure. We instantiate VeriDx for complex respiratory diagnosis using guideline-derived disease profiles and expert-annotated longitudinal cases. Our results show that many diagnostic errors are not isolated mistakes, but broken commitments made earlier in the reasoning process.
Zhong Cao, Shuying Chen
Heidelberg University · University of International Business and Economics
Clinical diagnosis is fundamentally interactive and incremental, yet the dominant paradigm for evaluating Large Language Models (LLMs) in medicine remains static QA benchmarks or template-based dialogues. These benchmarks say little about whether a model can serve as a diagnostic agent in a dynamic clinical encounter, with LLMs showing significant accuracy and reliability degradation in multi-turn settings. To address this issue, we present MTDiag, a large multi-turn diagnostic dialogue dataset constructed from three heterogeneous sources: DDXPlus, MIMIC-IV, and published case reports (AJCR), covering common ED presentations as well as long-tail rare and atypical conditions. All cases are normalized into a canonical schema anchored in the most comprehensive and widely-adopted medical knowledge bases (UMLS concept identifiers, with ICD-10 diagnosis codes). We release the schema, a UserLM-8B-based utterance-generation pipeline, and the physician-validated dataset that converts structured clinical evidence into natural-language utterances. Importantly, we introduce and motivate clinical knowledge-grounded metrics for evaluating LLMs as diagnostic agents, beyond diagnostic accuracy, for the task of multi-turn differential diagnosis.
Pia Chouayfati, Alexander M. Fichtl, Miriam Anschütz +2
Technical University of Munich · Department of Internal Medicine, UT Southwestern
Clinical diagnosis at hospital admission must be made rapidly from limited, incomplete evidence. Existing diagnosis-prediction benchmarks are poorly suited to this setting: they restrict prediction to closed code sets, exclude free-text notes, and supervise with discharge diagnoses that incorporate the full inpatient course. We introduce EarlyDx, a large-scale benchmark for open-ended early diagnosis, built from 154,834 emergency department encounters in MIMIC-IV. Each encounter is restricted to records available at admission time t0 and supervised by the diagnoses recorded during the ED encounter rather than at discharge. An LLM auditor further verifies every free-text label as supported, partially supported, or unsupported by that evidence; the primary evaluation scores only fully supported labels. Under a semantic LLM-as-judge protocol, no evaluated system --- frontier general, medical-specialized, or in-domain post-trained --- synthesizes admission-time evidence reliably. Zero-shot models score largely by extraction, recovering only 3-31% of diagnoses that must be inferred rather than read from the record; post-training raises inference-dependent recall to 56%, but a sizeable margin remains, and on time-critical conditions no system attains a clinician's balance of sensitivity and precision. We release the full construction and evaluation pipeline at here.
Jiahui Li, Ruili Fang, Zishuai Liu +5
University of Georgia Athens, USA · Beijing Luhe Hospital Beijing, China