KREL: Automatic Medical Coding via Knowledge-Guided Reasoning over Clinical Evidence with LLMs
Authors: Xubin Chen, Yipeng Zhou, Wen Sun, Chengkai Huang, Xiaoming Fu, Quan Z. Sheng
Organizations: Macquarie University · Beijing Intelligent Decision Medical Technology Co. Ltd. · University of New South Wales · University of Göttingen · Beijing Normal-Hong Kong Baptist University
Automatic Medical Coding (AMC), which assigns standardized International Classification of Diseases (ICD) codes to clinical notes, is essential for medical reimbursement, quality reporting, and clinical research. Existing pre-trained language model (PLM)-based methods typically formulate AMC as an extreme multi-label classification problem over a predefined code set, while recent large language model (LLM)-based approaches instead frame it as generation or multi-step reasoning. However, key challenges remain, including the extreme length of clinical notes that hinders effective interpretation, the vast ICD label space, and complex coding rules that are not explicitly captured by LLMs. In this work, we propose Knowledge-Guided Reasoning over Clinical Evidence with LLMs (KREL), a framework that leverages LLMs for clinical text understanding and reasoning while integrating external ICD coding guidelines as structured knowledge. This design enables tight coupling between domain knowledge and LLM reasoning, reducing hallucinations and improving compliance with coding standards. Experiments on benchmark datasets show that KREL consistently outperforms strong PLM-based and state-of-the-art LLM-based baselines.
Figures & tables
Figure 1: The difference between our framework and existing approaches. Our method better leverages LLM reasoning capabilities by integrating external knowledge.
Figure 2: Overview of the KREL framework. (1) The query extractor reads the clinical note, identifies disease descriptions, and reformulates them into ICD-oriented queries (e.g., converting ”CKD stage 3b” into ”Chronic kidney disease stage 3b”). (2) The selector retrieves candidate ICD codes based on ICD hierarchy knowledge and converts structured coding relations into verification hints. (3) The verifier makes the final coding decisions by jointly considering the candidate codes and all available information and evidence.
(a) Benchmark-label-space setting
Method category
Model
MDACE (CM + PCS)
ACI-BENCH
Precision
Recall
F1
Precision
Recall
F1
PLM
ICD
0.49
0.47
0.48
0.43
0.41
0.42
CA
0.46
0.45
0.45
0.44
0.42
0.43
LLM prompting
CoT
0.30
0.31
0.30
0.35
0.50
0.41
CoT-SC
0.39
0.43
0.41
0.36
0.59
0.44
Table 1: Performance comparison under benchmark-label-space and full-label-space settings
Variant
Type
Precision
Recall
F1
KREL (full)
–
0.48
0.53
0.51
medSpaCy query
Replace
0.35
0.19
0.24
flat retrieval
Replace
0.46
0.50
0.48
w/o reranker
Remove
0.46
0.46
0.46
w/o rule injection
Remove
0.47
0.50
0.49
w/o verifier
Remove
0.11
0.62
0.19
Table 2: Ablation study on MDACE under the full-label-space setting.
Rule
GT (share)
KREL
CoT-SC
CLH
Pairwise
17 (3.14%)
12 / 70.6%
5 / 29.4%
2 / 11.8%
Combination
13 (2.40%)
8 / 61.5%
1 / 7.7%
1 / 7.7%
All
30 (5.55%)
20 / 66.7%
6 / 20.0%
3 / 10.0%
Table 3: Performance on rule-dependent ground-truth note–code pairs in MDACE. Model columns report correct predictions / recall.
Figure 3: Comparison of different strategies for candidate code retrieval on MDACE under the full-label-space setting.
Figure 4: Evolution of the candidate set size against recall and precision performance.
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
Dataset
Label-space setting (size)
Code type
Test clinical notes
Test unique GT codes
MDACE
Benchmark (350)
ICD-10-CM + PCS
122
CM: 312; PCS: 38
ACI-Bench
Benchmark (132)
ICD-10-CM
120
132
MDACE
Full (72750)
ICD-10-CM
61
282
MIMIC-IV-500
Full (72750)
ICD-10-CM
500
1,812
Appendix
Table 4: Dataset and evaluation scope.
Statistic
MIMIC-IV
MIMIC-IV-500
Clinical notes
122,288
500
Mean GT codes/note
14.435
14.894
Median GT codes/note
13
14
GT assignments
1,765,181
7,447
Unique GT codes
16,155
1,812
Rare GT share
1.77%
1.84%
Appendix
Table 5: Statistics of MIMIC-IV-500 and the full MIMIC-IV pool. Rare GT denotes assignments whose code frequency in the full pool is ≤10 .
Metric
LLM prompting
LLM-agent (CLH)
KREL
Average predicted codes per note
5.98
5.11
9.67
False positives
222
187
304
False negatives
398
416
255
Combination-code recall
0.077
0.077
0.615
Sibling-code FP rate
0.329
0.219
0.227
Appendix
Table 6: Comparison of error patterns across method families on MDACE ICD-10-CM discharge summaries under the full-label-space setting.
Figure 5: Performance by ICD-10-CM chapter on MDACE under the full-label-space setting. The figure compares recall and F1 for LLM prompting, the CLH LLM-agent baseline, and KREL across five ICD chapters.
Metric
Value
True-positive code pairs
286
Evidence coverage
100%
Mention-anchor coverage
90.6%
Mean semantic cosine
0.746
Appendix
Table 7: Evidence alignment analysis on MDACE full-label-space ICD-10-CM discharge-summary evaluation. Evidence quality is evaluated only for true-positive code predictions.
Figure 6: Prompt for extracting and formatting queries from clinical note samples.
Figure 7: Instruction for Qwen3-Embedding-8B
Figure 8: Instruction for Qwen3-Reranker-8B
Figure 9: Prompt for rule-aware and evidence-grounded verification samples.
Accurate medical coding requires consulting authoritative resources such as the ICD tabular list and coding guidelines. Existing LLM-based automated methods largely rely on LLMs' internal knowledge, which is prone to hallucination and cannot keep pace with guideline updates. We introduce RAG-Coding, an agentic, training-free method that augments LLMs with structured external knowledge: the tabular list is encoded as a knowledge graph capturing hierarchical and instructional code relationships, and the guidelines are distilled into concise, code-specific summaries rather than retrieved as raw text. To enable our study, we also introduce MDACE-2025, expert re-annotations of the MDACE dataset under the 2025 ICD-10-CM/PCS guidelines, adding code sequencing and justification comments. On MDACE, RAG-Coding outperforms the best LLM-based baseline by 3--13% in micro-F1 across five LLM backbones, and achieves comparable micro- and macro-F1 to the supervised state-of-the-art, with higher recall (+11%) at the cost of precision (−6%). On MDACE-2025, RAG-Coding outperforms all baselines, demonstrating effective generalisation to updated guidelines. Ablations confirm stepwise gains, highlighting the importance of integrating structured external knowledge for LLM-based medical coding.
Yidong Gan, David D. Nguyen, Yang Lin +4
Oracle Health and AI · The University of Sydney · CSIRO Data61
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.
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.