arXiv:2611.07265cs.LGNov 2026

Manuscript Offprint

arXiv:2611.07265

How Deep is the Signal? Time-Context up to 30 Years for Colorectal Cancer Prediction in a Primary-Care EHR Model

Achille Raviez, Lan Wang, Brendan Delaney

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

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 θ\theta. Time-context is a measurable design axis for clinical prediction models, distinct from token-context, and should be reported.

Keywords: electronic health records (EHR), foundation model, primary care, time-context, lookback, colorectal cancer

Data and Code Availability The Discover dataset, a de-identified research mirror of the Whole Systems Integrated Care (WSIC) North West London database, is not publicly available; access is granted to approved researchers by the Discover-NOW Data

Access Committee. Code may be available from the authors on reasonable request, subject to approval by the data controller and Imperial College London.

Institutional Review Board (IRB) The study falls under the Discover-NOW research database ethics and HRA approval (REC 23/WM/0196) and was authorised by the North West London Data Access Committee; all analyses ran in a secure environment without export of patient-level data.

1. Introduction

Lookback depth – how much of a patient’s past a prediction model is allowed to see – is a weakly scrutinised design choice (Pungitore and Subbian, 2023), often constrained by technical limits and by shallow hospital datasets. In longitudinally sparse EHRs, calendar history is a correlated but distinct axis from the number of tokens a model reads, and it remains largely unexplored. Wornow et al. (2025) varied the context window of EHR foundation models from 512 to 16,384 tokens and showed that larger token counts improve prediction. However, a patient with dense recent contact can exhaust a large context window within a few years, while a sparsely recorded patient’s whole life can fit in a few hundred tokens. The questions that matter operationally – record retention, data curation, screening strategies, guidelines for clinical prediction models – are all denominated in years. The median context window of EHR models has roughly quadrupled since 2019 (Guo et al., 2026), making long medical sequences tractable. Yet the scarcity of accessible primary-care databases, highlighted in a recent taxonomy of EHR event-stream modelling (Zhu et al., 2026), has kept researchers on secondary-care data and prevented the field from exploiting long-range signal. The same re-

© 2026 A. Raviez, L. Wang & B. Delaney.

view identifies long context as an open challenge, and information sufficiency, i.e. how much history a reliable inference requires, as an unresolved question. Previous studies used fixed lookback windows of at most three years and did not encode event timing, using classical models (Hardin and Reps, 2021) or note encoders (Mohammadi et al., 2026).

The field has meanwhile moved towards generative decoder-only architectures in addition to classical encoders, with models such as Foresight (Kraljevic et al., 2024) and SurvivEHR (Gadd et al., 2026) built on causal pretraining, an approach shown to work at health-system scale (Rajamohan et al., 2025). Delphi-2M (Shmatko et al., 2025) models lifetime disease trajectories but from sparser data, including registries, rather than granular clinical event streams. The closest prior work on our data source selected three-year pathways with a 1-month buffer to predict lung cancer, using an encoder-only model in the BERT lineage (Wang et al., 2024; Devlin et al., 2019). Following the current state of the art, we trained a LLaMA-like decoder-only model (Llama Team, 2024), deliberately small (34.6M parameters, against 1.6B for Rajamohan et al., 2025) to fit our timeline, compute, and training sample.

CRC is a well-suited probe of how far back predictive signal carries for a specific disease in primary-care EHRs, as the adenoma–carcinoma sequence can run from about 10 to 26 years before diagnosis (Kuntz et al., 2011). A curve still rising at deep windows would indicate long-dwell prodromal signal of direct interest for early detection, whereas an early plateau would give a citable bound for data curation.

Our contributions are: (1) time-context, a design axis distinct from token-context, evaluated for the first time at decade scale through a CRC predictive-signal depth curve; (2) a within-patient nested design that isolates calendar time on a fixed cohort at fifteen windows; (3) the use of primary-care data, known to be understudied in the field, with more than 30 years of history (1990–2026); and (4) simulation results suggesting that RoPE over elapsed weeks at the default θ=10,000\theta = 10,000 may alias attention similarity beyond ∼\sim20-year gaps, and that a returned θ\theta restores near-monotonic decay up to 35 years.

References (22)