Clinical notes (discharge summaries, progress notes, radiology reports) contain rich
information, but the structured billing / interoperability codes (ICD-10, SNOMED-CT,
LOINC) are usually entered manually by trained coders. This model automates that
extraction by reading the free-text narrative and generating the correct code list.
Code system
Typical use in EMR
How the model learns it
ICD-10-CM
Diagnosis billing, DRG grouping
Document-level multi-label classification from discharge summaries
SNOMED-CT
Clinical concept normalization, EHR interoperability
Entity linking from clinical mentions to concept IDs
LOINC
Lab test / observation identification
Terminology lookup from lab-mention text to LOINC codes
🏗️ Architecture decisions (literature-backed)
Generative SFT instead of multi-label classification heads
Landmark paper MedCodER (Baksi et al., 2024) showed that decomposing coding into
extraction → retrieval → reranking with an LLM outperforms vanilla classification
heads on large label spaces. We adopt the same generative paradigm but train it
end-to-end with SFT, which is simpler to deploy and does not require a separate
retrieval index at inference time.
Small instruction-tuned base (1.5 B → 3.8 B effective) PLM-ICD (Huang et al., 2022) demonstrated that domain-specific pre-training
(PubMed RoBERTa) is crucial. Rather than starting from scratch, we leverage
Qwen2.5-1.5B-Instruct, which is already instruction-tuned and generalises well
to medical prompts after light LoRA adaptation.
LoRA instead of full fine-tuning OpenMed-NER (Panahi, 2025) showed that lightweight domain-adaptive pre-training
LoRA achieves SOTA on 12 biomedical NER benchmarks while keeping training cost low.
We target all linear projection layers (q_proj, k_proj, v_proj, o_proj,
gate_proj, up_proj, down_proj) with rank 32.
Combined multi-task training
No single public dataset annotates all three code systems on the same documents.
We therefore concatenate:
Our generative SFT approach trades a few points of raw F1 for dramatically simpler
deployment (no label-vocabulary index, no attention mechanism, single forward pass).
For entity linking / normalization (SNOMED-CT, LOINC), the SOTA starting point
is SapBERT (Liu et al., 2020):
Convert your internal notes into the same conversational JSON format:
json
1{2"messages":[3{"role":"system","content":"You are an expert medical coding assistant."},4{"role":"user","content":"Discharge Summary:\n...\nICD-10-CM codes (comma-separated):"},5{"role":"assistant","content":"I21.0, I10, E11.9"}6],7"task":"icd10"8}
Then concatenate with the existing train set and resume training with
--resume_from_checkpoint.
Improve SNOMED / LOINC accuracy
The current synthetic SNOMED/LOINC rows are terminology lookups (mention → code).
For real-world EMR text, add mention-detection NER data (e.g. n2c2 tracks,
BC5CDR, NCBI Disease) and train a two-stage pipeline:
Stage 1 (NER):microsoft/BiomedNLP-PubMedBERT-base-uncased fine-tuned for
BIO tagging of conditions, procedures, drugs, lab tests.
Stage 2 (Linking): Use this generative model (or SapBERT) to map each detected
span to the correct SNOMED-CT / LOINC concept.
This two-stage design is the best-supported approach in the clinical-NLP literature
(Clinical NER Benchmark, 2024; OpenMed-NER, 2025).
Scale up
If you have A100 / H100 GPUs, increase the base model to:
yikuan8/Clinical-Longformer (149 M, 4 096 tokens, true long-document encoding)
emilyalsentzer/Bio_ClinicalBERT (110 M, BERT-based, excellent for NER as stage 1)
For 7 B+ models, switch to DeepSpeed ZeRO-3 or FSDP and increase lora_r to 64-128.
📜 Citation
If you use this model or code, please cite the key papers that informed the design:
bibtex
1@article{huang2022plmicd,
2 title={PLM-ICD: Automatic ICD Coding with Pretrained Language Models},
3 author={Huang, Kexin and Altosaar, Jaan and Ranganath, Rajesh},
4 journal={arXiv preprint arXiv:2207.05289},
5 year={2022}
6}
78@article{baksi2024medcoder,
9 title={MedCodER: A Generative AI Assistant for Medical Coding},
10 author={Baksi, Ankush and others},
11 journal={arXiv preprint arXiv:2409.15368},
12 year={2024}
13}
1415@article{liu2020sapbert,
16 title={Self-Alignment Pretraining for Biomedical Entity Representations},
17 author={Liu, Fangyu and others},
18 journal={arXiv preprint arXiv:2010.11784},
19 year={2020}
20}
2122@article{panahi2025openmedner,
23 title={OpenMed NER: Open-Source, Domain-Adapted State-of-the-Art Transformers for Biomedical NER Across 12 Public Datasets},
24 author={Panahi, A.},
25 journal={arXiv preprint arXiv:2508.01630},
26 year={2025}
27}
📄 License
Model weights: Apache-2.0 (inherited from Qwen2.5-1.5B-Instruct)
Training code: MIT
Data usage: Follow the licenses of each upstream dataset (MIMIC-IV requires
credentialed access via PhysioNet; synthetic datasets are CC-BY or MIT).
🤝 Acknowledgements
Built with 🤗 Transformers, 🤗 TRL, 🤗 PEFT, and the generous open-source clinical-NLP
community. MIMIC data is provided by the MIT Lab for Computational Physiology.