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.