Ontology-Compiled 2D Clinical State Fields with Bidirectional Diffusion Encoders for Zero-Training Cross-Ontology Medical Coding
Organizations: Department of Computer Science, University of Surrey, Guildford, United Kingdom
Abstract
Healthcare systems continually revise clinical taxonomies, update reimbursement schedules, and harmonize cross-border registries. Existing automated coding models bind clinical text understanding to fixed vocabulary-specific heads, requiring manual relabeling and retraining whenever code sets change. We introduce Ontology-Compiled 2D Clinical State Fields (OCSF), a vocabulary-free framework that decouples clinical document reading from target ontology indexing so one trained encoder can switch across arbitrary medical vocabularies in seconds without target training. A single-pass bidirectional diffusion-pretrained encoder and vocabulary-free decoder map each clinical note into a fixed-dimension two-dimensional state matrix with zero code-specific parameters. Any target ontology is compiled offline on CPU from public text descriptions into a scale-invariant Tikhonov deconvolution operator that suppresses sibling-code interference while preserving source decision thresholds. Trained solely on English MIMIC-IV ICD-9 discharge summaries and evaluated without target tuning across 58,706 held-out test notes and five unseen ontologies spanning English ICD-10, MS-DRG, Spanish, Greek, and Chinese (115-185,458 codes), OCSF reaches 63.15% Micro-F1 on in-domain ICD-9 (outperforming a matched closed-vocabulary classifier and eliminating late-epoch tail overfitting) and transfers directly to 26,085 English ICD-10 codes (29.23% recall at gold cardinality), MS-DRG groups, and multilingual terminologies, compiling up to 185,458 codes in under 10 seconds on CPU with sub-millisecond GPU readout.
Figures & tables
| Benchmark | Role | Language | Task Structure | (Codes) | Dev / Held-Out Test | Cohort Isolation & Evaluation Rule |
| MIMIC-IV ICD-9 | Source ( ) | English | Multi-label diag. + proc. | 11,324 (6,150 freq.) | 21,980 / 32,804 | Patient-disjoint splits; calibrates and |
| MIMIC-IV ICD-10 | Unseen ( ) | English | Multi-label CM + 7-axis PCS | 26,085 (18,143 rare) | 9,077 / 13,783 | Excludes all 82,284 source train/val patients |
| MIMIC-IV MS-DRG | Unseen ( ) | English | Single-label billing group | 1,581 (CMS v25–v37) | 7,875 / 11,869 | Excludes all 82,284 source train/val patients |
| CodiEsp | Unseen ( ) | Spanish | Multi-label ICD-10-ES | 185,458 (11,381 OR) | 250 / 250 | Independent Spanish clinical case corpus |
| ElCardioCC | Unseen ( ) | Greek | Single-label ICD-10 chapter | 115 (D50–D64) | 2,500 / — † | Independent Greek cardiology discharge notes |
| CHIP-CDN | Unseen ( ) | Chinese | Multi-label ICD-10-CN terms | 37,645 | 2,000 / — † | OOV gold labels retained in recall denominator |
| Algorithm 1: Offline Ontology Compilation and Online Clinical State Readout |
|---|
| Input: Frozen source anchors ; public target codebook ; shrinkage ; clinical note . |
| Output: Compiled readout operator and zero-training target predictions . |
| Offline Ontology Compilation (CPU, executed once per codebook ): |
| Encode public descriptions and assign channels . |
| for with do |
| Form . If , solve ; |
| ICD-9 | ICD-10 (Zero-Training, 26,085) | MS-DRG | CodiEsp | ElCardioCC | CHIP-CDN | ||||
| Method | F1 | All R@ | All F1 | CM R@ | PCS R@ | Top-1/5 | ES R@ | EL Top-1/5 | ZH R@ |
| Closed-Vocabulary Supervised Baselines (Bound to ICD-9 Head; Cannot Score Unseen Ontologies) | |||||||||
| PLM-ICD [ 9 ] (published) | 62.60 | — | — | — | — | — | — | — | — |
| Closed-Vocabulary LAAT (Diffusion-0.6B, matched) | 62.10 | — | — | — | — | — | — | — | — |
| Zero-Shot Bi-Encoder & 1D Cross-Ontology Projection Baselines | |||||||||
| Zero-Shot Bi-Encoder (Diffusion-0.6B) | 5.02 | 1.66 | 1.17 | — | — | 3.45/13.40 | 3.42 | 33.12/78.72 | 25.87 |
| Comparison | Cohort ( ) | (pp) | 95% CI | Cohen’s | -value |
| Panel A: Paired Bootstrap Significance and Standardized Effect Sizes (2,000 Resamples) | |||||
| OCSF (Diffusion-0.6B, Full-LoRA) vs. Closed LAAT | ICD-9 Freq Test (32,804) | +1.17 | [+1.05, +1.28] | +0.11 | |
| OCSF (Diffusion-0.6B, Half-Frozen) vs. Closed LAAT | ICD-9 Freq Test (32,804) | +0.27 | [+0.16, +0.39] | +0.03 | |
| Channel Expansion ( vs. , 0.6B) | ICD-9 Freq Test (32,804) | +22.02 | [+21.85, +22.18] | +1.44 | |
| Channel Expansion ( vs. , 0.6B) | ICD-10 All Test (13,783) | +10.37 | [+10.16, +10.58] | +0.81 | |
| Self-Norm. Deconv. vs. Cosine Readout (4B) | ICD-10 All Test (13,783) | +10.46 | [+10.26, +10.66] | +0.90 | |
| Diffusion-0.6B ( ) | Diffusion-4B ( ) | ||||
| Target Ontology | CPU Compile | GPU Readout | CPU Compile | GPU Readout | |
| ElCardioCC (Greek) | 115 | 0.016 s | 0.0596 ms | 0.028 s | 0.1316 ms |
| MIMIC-IV MS-DRG (English) | 1,581 | 0.031 s | 0.0583 ms | 0.040 s | 0.0481 ms |
| MIMIC-IV ICD-9 (Source) | 11,324 | 0.145 s | 0.1781 ms | 0.268 s | 0.1230 ms |
| MIMIC-IV ICD-10 (English) | 26,085 | 0.436 s | 0.1198 ms | 0.800 s | 0.1250 ms |
| CHIP-CDN (Chinese) | 37,645 | 0.799 s | 0.1208 ms | 1.430 s | 0.1218 ms |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Split | ICD-9 Full F1 | ICD-9 P@8 / P@15 | ICD-10 R@ | ICD-10 P@8 / MRR | ICD-10 Rare R@ | CodiEsp F1 / P@8 | CHIP-CDN F1 |
|---|---|---|---|---|---|---|---|---|
| Closed-Vocabulary LAAT (0.6B) | Val / Test | 61.69 / 61.90 | 69.51 / 69.68 | 53.30 / 53.44 | — | — | — | — | — |
| OCSF (Causal-0.6B, Half-Frozen) | Dev / Test | 57.53 / 57.52 | 65.87 / 65.97 | 50.25 / 50.33 | 22.97 / 23.14 | 30.23 / 30.26 | 71.93 / 71.71 | 4.02 / 3.56 | 4.92 / 5.71 | 9.00 / 8.85 | 12.11 / — |
| OCSF (Diffusion-0.6B, Half-Frozen) | Dev / Test | 61.90 / 62.04 | 70.13 / 70.21 | 53.50 / 53.54 | 27.86 / 27.97 | 35.99 / 35.95 | 76.73 / 76.62 | 6.04 / 5.53 | 7.36 / 7.21 | 12.75 / 13.50 | 7.64 / — |
| OCSF (Diffusion-0.6B, Full-LoRA) | Dev / Test | 62.82 / 62.94 | 70.93 / 70.98 | 54.18 / 54.23 | 28.64 / 28.66 | 36.79 / 36.82 | 77.66 / 77.59 | 5.89 / 5.52 | 7.20 / 7.29 | 12.50 / 12.55 | 7.98 / — |
| OCSF (Causal-4B, Half-Frozen) | Dev / Test | 58.92 / 58.91 | 67.15 / 67.19 | 51.30 / 51.32 | 26.58 / 26.55 | 34.48 / 34.34 | 75.88 / 75.79 | 5.14 / 4.25 | 7.89 / 7.68 | 14.15 / 13.85 | 17.63 / — |
| OCSF (Diffusion-4B, Half-Frozen) | Dev / Test | 59.89 / 59.88 | 68.02 / 68.05 | 51.99 / 52.00 | 28.82 / 29.05 | 37.05 / 37.13 | 78.20 / 78.32 | 5.05 / 5.19 | 8.12 / 8.15 | 13.30 / 14.05 | 15.05 / — |
| Paired Comparison ( ) | Benchmark Slice ( ) | (pp) | 95% CI (pp) | Cohen’s | Cohen’s | -value |
| OCSF (Diffusion-0.6B, Full-LoRA) vs. Closed LAAT | ICD-9 All Test (32,804) | +1.16 | [+1.04, +1.27] | +0.1089 | +0.0240 | |
| OCSF (Diffusion-0.6B, Half-Frozen) vs. Closed LAAT | ICD-9 All Test (32,804) | +0.27 | [+0.15, +0.38] | +0.0254 | +0.0056 | |
| Full-LoRA vs. Half-Frozen (Diffusion-0.6B) | ICD-9 Freq Test (32,804) | +0.90 | [+0.80, +1.00] | +0.0985 | +0.0186 | |
| Full-LoRA vs. Half-Frozen (Diffusion-0.6B) | ICD-10 All Test (13,783) | +0.69 | [+0.56, +0.82] | +0.0871 | +0.0153 | |
| Full-LoRA vs. Half-Frozen (Diffusion-0.6B) | CodiEsp ES Test (250) | [ , +0.07] | 0.0590 | |||
| Channel Capacity vs. (0.6B) | ICD-10 CM Test (13,782) | +11.53 | [+11.30, +11.77] | +0.8165 | +0.2687 |
| Panel A: Bidirectional Diffusion vs. Causal Encoding by Clinical Note Length (MIMIC-IV ICD-10 Dev) | |||||
| Length Stratum | Notes ( ) | Diffusion R@ | Causal R@ | Diffusion F1 | Gain R@ |
| Short ( tokens) | 1,857 | 32.02 | 27.38 | 23.02 | +4.64 |
| Medium ( tokens) | 4,846 | 28.08 | 23.05 | 23.16 | +5.03 |
| Long ( tokens) | 2,374 | 24.18 | 19.30 | 21.85 | +4.88 |
| Panel B: Calibration-Free mAP, Top-200 Micro-AUPRC, and Cardinality-Matched F1 ( , Diffusion-0.6B) | |||||
| Target Benchmark | Metric | 2D Cosine | Unnorm. Deconv. | Self-Norm. Deconv. | Rule-Compiled |
| Panel A: Temporal Stability Across 13 CMS MS-DRG Versions | Panel B: Target Codebook Perturbation Stress-Test (R@ %) | ||||||||
| CMS Ver. | Pure Deconv. Top-5 | Rule-Compiled Top-5 | Top-5 | Benchmark | Perturbation | 2D Cosine | Unnorm. | Self-Norm. | |
| v25 | 7,853 | 19.72 | 21.65 | +1.93 | ICD-10 (EN) | Clean descriptions | 18.23 | 25.81 | 27.36 |
| v26 | 7,869 | 19.65 | 21.55 | +1.90 | 50% text truncation | 14.33 | 14.99 | 15.84 | |
| v27 | 7,869 | 19.65 | 21.55 | +1.90 | 25% random word drop | 14.37 | 10.67 | 11.46 | |
| v28 | 7,875 | 19.66 | 21.60 | +1.94 | Gaussian noise ( ) | 4.78 | 1.85 | 2.13 | |
| v29 | 7,875 | 19.66 | 21.60 | +1.94 | CodiEsp (ES) | Clean descriptions | 6.50 | 9.01 | 9.66 |
| Panel A: 5-Seed Channel Partitioning ( , Seeds 42–46) | Panel B: End-to-End Inference Profile (NVIDIA GH200 BF16) | |||||||||||
| Partition Rule | Summary | ICD-9 R@ | ICD-10 R@ | Max | Empty | Scale | Batch | Enc. ms | Dec. ms | Tot. 26k ms | VRAM | |
| Spherical -Means | Mean SD | 73.78 0.71 | 48.44 0.80 | 654.2 106.5 | 17.8 | 0.6B | 1,024 | 1 | 23.22 | 1.54 | 24.85 | 2.66 GB |
| Hierarchical Ward | Mean SD | 74.83 0.32 | 47.85 0.88 | 677.0 0.0 | 10.0 | 0.6B | 2,048 | 16 | 18.67 | 0.14 | 18.89 | 2.86 GB |
| Uniform Random | Mean SD | 74.89 1.41 | 51.55 1.43 | 641.8 81.6 | 2.2 | 0.6B | 3,072 | 16 | 29.30 | 0.18 | 29.57 | 3.47 GB |
| Trained OCSF Hard Top-1 Routing | — | 27.36 | 583 | 19 | 4B | 1,024 | 1 | 32.02 | 1.65 | 33.76 | 12.66 GB | |
| Trained OCSF Soft Top-2 ( ) | — | 26.25 | 583 | 19 | 4B | 2,048 | 16 | 63.76 | 0.30 | 64.15 | 12.67 GB | |
Automated Medical Coding
Automated medical coding uses clinical records and coding rules to assign standardized diagnosis and procedure codes for billing, care, and research.
See all 28 papers