Organizations: Andie · Massey University Palmerston North, New Zealand · South China Normal University Guangzhou, China · University of Otago Dunedin, New Zealand
Generative approaches to automatic International Classification of Diseases (ICD) coding use large language models (LLMs) to predict ICD codes from clinical documents. However, original ICD code strings are not ideal generation targets because the ICD hierarchy does not always reflect clinical relationships, and LLMs struggle to interpret and generate these codes. We introduce SemICD, a framework that trains LLMs to generate Semantic IDs (SIDs) instead. SemICD constructs SIDs by hierarchically clustering embeddings of textual code profiles, allowing semantically related codes to share prefixes while each complete SID uniquely identifies one ICD code. To align the SID tokens with clinical semantics, we employ two auxiliary tasks for bidirectional generation between textual code profiles and SIDs. Experiments on MIMIC-III and MIMIC-IV with four LLMs show that SemICD outperforms direct code generation, improving Micro-F1 by 1.34-8.00 points. Our code is available at https://github.com/youwillbethebest/SemICD.
Figures & tables
Figure 1: Two pairs of causally related diseases. The ICD-10-CM coding instructions require the two codes in each pair to be coded together, but the codes are unrelated at every level of the ICD hierarchy.
Figure 2: Overview of SemICD. (a) ICD code profiles are encoded by the Qwen3 embedding model and clustered using hierarchical K -means to create Semantic IDs. (b) A language model learns to map clinical notes to SID sequences, along with auxiliary tasks for profile-to-SID and SID-to-profile predictions. (c) During inference, beam search generates SID sequences, which are then mapped back to ICD codes through the SID codebook.
Figure 3: Shared SID prefixes and code-specific branches in the experimental codebook. HF denotes heart failure.
MIMIC-III ICD-9
MIMIC-IV ICD-10-CM
#Docs
52,723
122,304
#Patients
41,126
65,675
#Codes
8,929
16,155
Table 1: Dataset statistics for MIMIC-III v1.4 and MIMIC-IV v2.2.
MIMIC-III ICD-9
MIMIC-IV ICD-10-CM
Backbone
Method
Micro-F1
Macro-F1
Precision
Recall
Micro-F1
Macro-F1
Precision
Recall
Qwen3-0.6B
Raw
50.15 ± 0.47
5.64 ± 0.16
50.65 ± 0.48
49.65 ± 0.50
53.40 ± 0.42
6.29 ± 0.24
53.38 ± 0.38
53.43 ± 0.44
SemICD
53.65 ± 0.21
7.14 ± 0.27
55.29 ± 0.51
52.10 ± 0.59
56.35 ± 0.20
8.10 ± 0.15
58.53 ± 0.36
54.33 ± 0.35
Qwen3-4B
Raw
55.41 ± 0.57
10.12 ± 0.28
55.13 ± 0.48
55.69 ± 0.40
58.17 ± 0.25
10.96 ± 0.28
59.56 ± 0.42
56.85 ± 0.34
SemICD
57.69 ± 0.21
11.50 ± 0.21
59.22 ± 0.47
56.23 ± 0.36
59.51 ± 0.43
12.17 ± 0.21
61.35 ± 0.36
57.77 ± 0.37
Gemma3-1B
Raw
49.16 ± 0.43
6.26 ± 0.12
48.45 ± 0.53
49.89 ± 0.57
48.54 ± 0.40
4.14 ± 0.43
46.60 ± 0.34
50.65 ± 0.42
Table 2: Generative ICD coding results on MIMIC-III ICD-9 and MIMIC-IV ICD-10-CM. Raw generates ICD codes directly, whereas SemICD generates SIDs and maps them back to ICD codes. Scores are percentages; precision and recall are micro-averaged. Subscripts indicate 95% confidence interval half-widths.
Train freq.
#Codes
Raw
SemICD
Δ
>500
444
60.75
63.24
+2.49
101–500
887
37.66
41.73
+4.07
51–100
760
25.33
29.12
+3.79
11–50
2,711
16.01
19.03
+3.02
1–10
11,279
3.53
4.15
+0.62
Table 3: Micro-F1 by training-set code frequency on MIMIC-IV ICD-10-CM using Qwen3-0.6B. #Codes is the number of distinct codes in each group. Δ denotes the improvement. Bold marks the largest gain.
Variant
Micro-F1
Macro-F1
SemICD (full)
56.35
8.10
Output representation
Atomic ID
54.00 − 2.35
6.92 − 1.18
Random SID
53.74 − 2.61
6.44 − 1.66
Auxiliary tasks
w/o Profile → SID
55.22 − 1.13
7.45 − 0.65
Table 4: Ablations of the output representation and the auxiliary tasks on MIMIC-IV ICD-10-CM using Qwen3-0.6B.
SID construction
Micro-F1
Macro-F1
HKM
56.35
8.10
RK-Means
55.42
7.54
RQ-VAE
53.96
6.41
Table 5: ICD coding performance of different SID constructions on MIMIC-IV ICD-10-CM using Qwen3-0.6B. Bold indicates the highest F1.
Figure 4: Structural properties of native SID paths in the ICD-10-CM. Semantic Purity refers to chapter taxonomy purity; RQ-VAE is assessed using native nearest-neighbor assignments.
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
Figure 5: Hyperparameter tuning on the MIMIC-IV ICD-10-CM validation set using Qwen3-0.6B. Each panel varies one hyperparameter while fixing the others to K=128 , L=3 , α=0.1 , and B=4 . Auxiliary-task weights are (1−2α,α,α) . Values are mean Micro-F1 percentages over five random seeds.
Automated International Classification of Diseases (ICD) coding is a core medical-coding task for billing, epidemiology, and clinical decision support. Generative large language models (LLMs) are often reported as weak medical coders, but this finding mainly comes from inference-time settings such as prompting, retrieval, reranking, or tool use, leaving the role of task-specific post-training underexplored. We present a controlled empirical study of post-training for generative ICD coding, comparing discriminative baselines with LLM coders across prompting, supervised fine-tuning, and reinforcement learning under a common protocol and metric set. To our knowledge, this is the first study to evaluate RL-based post-training for generative LLM coders in ICD coding. We further introduce PHI, a diagnostic curriculum that extends GRPO to refine missed-code cases. Our results show that prompting-only evaluation substantially underestimates the potential of LLMs for ICD coding. SFT provides the main capability jump, GRPO further improves code-set prediction beyond SFT, and PHI provides targeted gains on macro-level performance. These findings suggest that the main bottleneck is not the generative formulation alone, but how the model is adapted and optimized for full-taxonomy recall. We release our code, data splits, and checkpoints at https://github.com/AlexandreWANG915/LLM4ICD.
Automatic medical coding assigns ICD codes to clinical notes, but it remains challenging due to long documents, imbalanced label distributions, and diverse terms. These challenges are especially severe for rare codes, which have limited training instances and are easily confused with semantically similar labels. We introduce CoLa-ICD, a knowledge-enhanced framework for long-tail prediction. CoLa-ICD enriches ICD labels with external terms, models dependencies among related codes, and learns stronger alignment between label semantics and clinical evidence for long-tail prediction. Experiments show that CoLa-ICD improves long-tail prediction with larger gains in larger and sparser label spaces and achieves state-of-the-art performance in AUC, F1, and P@k. Our code is available at https://github.com/youwillbethebest/Cola-ICD.
Accurate International Classification of Diseases (ICD) coding is crucial for large-scale clinical research, documentation, and billing. There are three primary problems with current ICD prediction methods: (1) They are unable to comprehend multimodal patient data because they rely on either structured EHR data or unstructured clinical notes. (2) They also struggle with scalability to a larger amount of ICD codes (9K+ codes in ICD-9), as traditional classifiers need dense output layers and often do not generalize well to long tail rare diseases. (3) They lack transparency for clinical use. To address these challenges, this research proposes a two-stage framework that first retrieves ICD codes using a multimodal dual-encoder retrieval model, where structured and unstructured patient data are integrated through gated fusion. The second stage refines the top-k retrieved candidates with an LLM-based re-ranker that provides ranked codes with clinically relevant explanations. Our experiments show that the proposed approach improves Micro-F1 and Precision over a multimodal dual-fusion classifier baseline. These improvements demonstrate that combining a gated multimodal retrieval system with LLM-based re-ranking is a practical alternative to dense multi-label classification for automated ICD coding.
Abhinav Bohra, Anuj Bohra
Amazon Seattle, USA · Rutgers University New Jersey, USA