Create README.md

#1
by player1537 - opened
Files changed (1) hide show
  1. README.md +149 -0
README.md ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: cc-by-nc-nd-4.0
5
+ library_name: pytorch
6
+ tags:
7
+ - transformer
8
+ - character-level
9
+ - medical-coding
10
+ - icd-10-cm
11
+ - healthcare
12
+ - gpt
13
+ - nanogpt
14
+ - visualization
15
+ - sequence-modeling
16
+ datasets:
17
+ - MIMIC-IV
18
+ - NHDS
19
+ - NHCS
20
+ metrics:
21
+ - perplexity
22
+ pipeline_tag: text-generation
23
+ ---
24
+
25
+ # DgPg: Diagnosis Progression Transformer
26
+
27
+ **DgPg** ("**D**ia**g**nosis **P**ro**g**ression") is a compact (~2.5 MB) character-level, GPT-style transformer that learns representative *ordering patterns* of ICD-10-CM diagnostic (DX) codes within single-visit medical records. Given a "seed" diagnosis code, DgPg generates the codes most likely to precede or follow it, which can be rendered as graph-based visual summaries of an organization's coding practices.
28
+
29
+ DgPg was introduced in the paper [*Visualizing Medical Coding Practices Using Transformer Models*](https://doi.org/10.5220/0013257800003905) (Hobson & Huang, ICPRAM 2025), from the Department of Electrical Engineering and Computer Science at the University of Tennessee, Knoxville.
30
+
31
+ > ⚠️ **DgPg is an organizational-analytics tool, not a clinical or coding-assistance model.** It is not intended to improve medical coding, predict diagnoses, or support clinical decisions. Its purpose is to let hospital administrators, lead physicians, and other stakeholders *see* how coding is actually practiced in a given corpus of records.
32
+
33
+ ## Model Details
34
+
35
+ | | |
36
+ |---|---|
37
+ | **Model type** | Decoder-only transformer (modified [nanoGPT](https://github.com/karpathy/nanoGPT)), character-level |
38
+ | **Task** | Next-character prediction over 4-character-normalized ICD-10-CM code sequences |
39
+ | **Parameters** | 1.3 M (recommended configuration, `T1.3M`) |
40
+ | **Architecture** | 3 layers, 3 attention heads, 192 embedding dims |
41
+ | **Precision** | float16 |
42
+ | **Model size on disk** | ~2.5 MB |
43
+ | **Training hardware** | Single NVIDIA T4 (Google Colab) |
44
+ | **Training time / cost** | ~1,092 s (~18 min), β‰ˆ $0.05 per model |
45
+ | **License** | Paper published under CC BY-NC-ND 4.0 |
46
+ | **Authors** | Tanner Hobson, Jian Huang (University of Tennessee, Knoxville) |
47
+
48
+ ### Base training configuration
49
+
50
+ ```text
51
+ learning_rate = 1e-3 dropout = 0.2
52
+ lr_decay_iters = 30000 min_lr = 1e-4
53
+ beta2 = 0.99 max_iters = 30000
54
+ batch_size = 256 n_layer = 3
55
+ n_head = 3 n_embd = 192
56
+ ```
57
+
58
+ ## How It Works
59
+
60
+ ICD-10-CM codes are inherently hierarchical: the first character encodes the top level of the hierarchy, the second character the next level, and so on (e.g., `S` β†’ `S5` β†’ `S52` β†’ `S52.5` traces an injury from "injury/poisoning" all the way down to a specific radius fracture). DgPg exploits this by modeling code sequences **character by character** rather than treating each code as an atomic token.
61
+
62
+ - Every DX code is normalized to **4 characters** (truncated and/or padded with hyphens).
63
+ - Records are converted to training sequences of consecutive code pairs, e.g. the record `N12,Q610,N179` becomes `β€’----N12-`, `β€’N12-Q610`, `β€’Q610N179`, `β€’N179----`.
64
+ - At inference, the model is used **iteratively**: given a seed code, it predicts the next code one character at a time, naturally respecting the coding hierarchy.
65
+
66
+ Compared to a traditional code-level transition matrix (12,309 Γ— 12,309 codes β‰ˆ 290 MB in float16), the character-level formulation is >100Γ— smaller and generalizes across code hierarchies rather than memorizing pairs.
67
+
68
+ ### Visualization use case
69
+
70
+ The authors pair the model with a generative graph-building algorithm: starting from a seed code, a breadth-first search exhaustively scores candidate following (or preceding) codes by perplexity, keeps the top *k* = 3 at each step, and recurses to depth *n* = 3. The result is a left-to-right graph of the most representative code orderings around a diagnosis (e.g., what typically precedes and follows a sepsis code `A41.9`), generated in ~2 minutes per graph.
71
+
72
+ ## Training Data
73
+
74
+ Four model variants were trained, one per dataset plus a combined corpus:
75
+
76
+ | Source | Dataset | # Records | # Patients (weighted) | Notes |
77
+ |---|---|---:|---:|---|
78
+ | MIT | [MIMIC-IV](https://physionet.org/content/mimiciv/) | 430,812 | 430,812 | Beth Israel Deaconess Medical Center; ICD-10-CM, truncated to 4 chars |
79
+ | CDC | NHDS | 756,953 | 111,514,788 | 1996–2010; ICD-9-CM converted to ICD-10-CM via the NBER crosswalk |
80
+ | CDC | NHCS | 123,565 | 33,595,765 | 2020 survey |
81
+ | β€” | Combined | 1,277,400 | 145,507,435 | Union of the above |
82
+
83
+ CDC survey records carry a frequency weight *w*; each record is emitted *w* times during training. Only ordered DX-code sequences are required β€” the framework applies to any corpus with ordered diagnosis codes.
84
+
85
+ **Note on data access:** MIMIC-IV is a restricted-access dataset requiring credentialed access via PhysioNet. No patient-level data is contained in the model weights beyond learned sequence statistics, but users retraining DgPg must obtain the datasets under their respective terms.
86
+
87
+ ## Evaluation
88
+
89
+ Performance is measured as fixed-length sequence perplexity (PERF) on the second code of a two-code sequence, averaged over 10 K validation samples.
90
+
91
+ ### Model size ablation
92
+
93
+ | Model | Layers | Heads | Embd | Size | Loss |
94
+ |---|---:|---:|---:|---:|---:|
95
+ | T11M | 6 | 6 | 384 | 20 MB | 1.16 |
96
+ | **T1.3M** β˜… | 3 | 3 | 192 | **2.5 MB** | 1.17 |
97
+ | T230K | 2 | 2 | 96 | 440 KB | 1.19 |
98
+ | T30K | 1 | 1 | 48 | 58 KB | 1.25 |
99
+
100
+ T1.3M matches the 10Γ—-larger T11M and is the recommended configuration. Model sizes were capped at 10% of the equivalent transition-matrix size to ensure generalizable (not memorized) patterns.
101
+
102
+ ### Cross-dataset transferability
103
+
104
+ Evaluating each trained model against each dataset shows that models perform best on their own training distribution β€” evidence that **coding practices are provider- and scenario-specific**. The Combined model performs well across all constituent datasets; the NHDS-only model transfers worst, indicating NHDS coding patterns are the most dataset-unique. MIMIC and NHCS models are the most generalizable.
105
+
106
+ ## Intended Uses
107
+
108
+ **Direct intended uses**
109
+
110
+ - Visualizing an organization's representative diagnostic-coding patterns (which codes typically precede/follow a given code; which codes tend to be coded first or last in a visit).
111
+ - Comparing coding practices across institutions, units, or clinical scenarios.
112
+ - Scoring how representative a given code sequence is relative to a corpus (classification use case).
113
+ - Operational insight for administrators: quality control, process improvement, burnout-related workflow analysis.
114
+
115
+ **Out-of-scope uses**
116
+
117
+ - ❌ Automated medical coding or coding suggestions for billing.
118
+ - ❌ Clinical diagnosis, prediction, or decision support.
119
+ - ❌ Auditing individual coders or labeling any coding practice as "good" or "bad" β€” the model summarizes shared practice; it does not evaluate deviations.
120
+ - ❌ Any use that would alter coding to affect claim payment. Modifying codes to increase reimbursement is fraudulent; any coding revision requires proper documentation.
121
+
122
+ ## Limitations
123
+
124
+ - **4-character truncation.** For cross-dataset comparability, all codes are normalized to 4 characters, discarding finer ICD-10-CM specificity (the framework itself is not limited to 4 characters).
125
+ - **ICD-9 β†’ ICD-10 crosswalk noise.** NHDS codes were converted via the NBER crosswalk, which is not lossless.
126
+ - **Single-visit scope.** DgPg models intra-visit code ordering only, not longitudinal, multi-visit patient trajectories.
127
+ - **Dataset-specific patterns.** A model trained on one provider's records does not transfer reliably to another's β€” this is by design, but means checkpoints are not general-purpose.
128
+ - **Hallucination.** As a generative model, DgPg can produce plausible-looking but unrepresentative sequences; the authors flag hallucination analysis as future work.
129
+ - **DX codes only.** Procedure and other medical code types are not yet covered.
130
+
131
+ ## Citation
132
+
133
+ ```bibtex
134
+ @inproceedings{hobson2025dgpg,
135
+ author = {Tanner Hobson and Jian Huang},
136
+ title = {Visualizing Medical Coding Practices Using Transformer Models},
137
+ booktitle = {Proceedings of the 14th International Conference on Pattern
138
+ Recognition Applications and Methods (ICPRAM 2025)},
139
+ pages = {725--732},
140
+ year = {2025},
141
+ publisher = {SCITEPRESS},
142
+ doi = {10.5220/0013257800003905},
143
+ isbn = {978-989-758-730-6}
144
+ }
145
+ ```
146
+
147
+ ## Acknowledgments
148
+
149
+ Built on [nanoGPT](https://github.com/karpathy/nanoGPT) by Andrej Karpathy. Data courtesy of MIT-LCP (MIMIC-IV) and the US CDC National Center for Health Statistics (NHDS, NHCS).