How Deep is the Signal? Time-Context up to 30 Years for Colorectal Cancer Prediction in a Primary-Care EHR Model
Organizations: I-X, Imperial College London, United Kingdom · Sorbonne Université, AP-HP, France
Abstract
EHR foundation models read medical events within a fixed context window, and long context has so far been measured only in tokens. How far back in time a model must look to capture the earliest predictive signal is unknown. We introduce time-context, the calendar lookback window before the prediction point, and provide, to our knowledge, the first systematic evaluation of decade-scale time-context for an EHR foundation model. We pretrained a decoder-only transformer (34.6M parameters) on 1.4B coded events from 3.6M primary-care patients in North West London and fine-tuned it to predict incident colorectal cancer under a 12-month pre-diagnostic buffer. A frozen cohort of 1,008 cases and 9,582 matched controls, all registered for at least 30 years, was evaluated at 15 nested lookback windows from 2 to 30 years, so that every truncation is compared within the same patients. Discrimination rose from an AUROC of 0.551 at 2 years to 0.590 at 18 years, then plateaued, with about 80% of the gain reached within 10 years; an XGBoost baseline converged to the same level (peak AUROC 0.589). A simulation further suggests that rotary position embeddings (RoPE) over elapsed time alias beyond about 20 years at the default base frequency, motivating a retuned . Time-context is a measurable design axis for clinical prediction models, distinct from token-context, and should be reported.
Figures & tables
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| Cohort | Cases | Controls | Ratio | Input |
|---|---|---|---|---|
| Pretraining | 3.6M patients | – | Full | |
| Fine-tuning | 13,490 | 37,321 | 1:2.77 | Full |
| Validation | 284 | 2,778 | 1:9.78 | 2–22y (6) |
| Evaluation | 1,008 | 9,582 | 1:9.51 | 2–30y (15) |
| Window (y) | Transformer | XGBoost |
|---|---|---|
| 2 | 0.5505 (0.5320–0.5691) | 0.5281 (0.5101–0.5481) |
| 4 | 0.5625 (0.5433–0.5812) | 0.5445 (0.5266–0.5650) |
| 6 | 0.5730 (0.5530–0.5922) | 0.5553 (0.5359–0.5731) |
| 8 | 0.5756 (0.5555–0.5950) | 0.5625 (0.5437–0.5809) |
| 10 | 0.5825 (0.5637–0.6003) | 0.5718 (0.5533–0.5902) |
| 12 | 0.5840 (0.5643–0.6020) | 0.5795 (0.5596–0.5981) |
| Window (y) | Transformer | XGBoost |
|---|---|---|
| 2 | 0.1128 (0.1026–0.1245) | 0.1082 (0.0982–0.1200) |
| 4 | 0.1169 (0.1062–0.1289) | 0.1133 (0.1022–0.1261) |
| 6 | 0.1206 (0.1098–0.1323) | 0.1162 (0.1060–0.1289) |
| 8 | 0.1239 (0.1118–0.1367) | 0.1176 (0.1074–0.1308) |
| 10 | 0.1259 (0.1141–0.1385) | 0.1193 (0.1093–0.1322) |
| 12 | 0.1265 (0.1144–0.1393) | 0.1225 (0.1120–0.1346) |
Longitudinal EHR Modeling
Longitudinal electronic health record modeling learns from patient histories over time to forecast outcomes, characterize disease trajectories, and guide care.
See all 169 papers