🌿freegardner

Synapse

Medical AI needs eighteen years of patient history

06 Nov 2026 · via Rss.arxiv

Medical AI needs eighteen years of patient history
Image: unbekannt / Wikimedia Commons (CC BY 4.0)

Medical AI needs eighteen years of patient history

A Design Axis Nobody Was Measuring

When a prediction model reads a patient’s medical history, someone has to decide how much of that history it gets to see. That decision — the lookback depth — has been treated as a technical afterthought, constrained by whatever a database happens to store and whatever a model can fit into memory. A team at Imperial College London has now put a number on the question for one disease.

The work, published on arXiv and headed by Achille Raviez with Lan Wang and Brendan Delaney, introduces what the authors call time-context: the calendar lookback window before a prediction point, measured in years rather than tokens. [1] Their central argument is that this is a distinct design axis from the context window that language models are usually described by, and that it can be measured directly rather than assumed. How Deep is the Signal? The distinction matters because the two quantities come apart in practice. A patient with dense recent contact can fill a large token window within a few years, while a sparsely recorded patient’s entire life might fit into a few hundred tokens. The operational questions — how long to retain records, how to curate data, how to design screening guidelines — are all denominated in years, not in tokens.

Thirty Years of Primary Care, Frozen and Sliced

The dataset behind the finding is unusual in a field that has leaned heavily on hospital records. The researchers used the Whole Systems Integrated Care database for North West London primary care, a frozen extract from August 2026 restricted to events from January 1990 onward: roughly six million patients and about two billion events coded in SNOMED CT and the dm+d prescription vocabulary.

From 18,104 incident colorectal cancer cases, 15,527 were registered at diagnosis, and 1,249 had at least thirty continuous years of registration before it. These “deep cases” form the heart of the study. The evaluation cohort is a frozen hash split of about 80 percent of them: 1,008 cases and 9,582 matched controls, matched on sex, birth year within two years, and available registration depth. Controls inherited their case’s index date, and no patient appears in two partitions.

A uniform twelve-month buffer before diagnosis was removed for every patient outside pretraining. That buffer is conservative by design — it exceeds published timings of the pre-diagnostic code surge for colorectal cancer, which runs up to eight to ten months — and it isolates pre-clinical signal from the diagnostic work-up itself. The end of the buffer is the prediction point.

One Model, Fifteen Windows, the Same Patients

The elegance of the design lies in what it holds constant. Evaluation patients were scored at fifteen nested windows — two, four, six years and so on up to thirty — obtained by deleting every event older than the window start. The same 10,590 patients, the same index dates, the same model applied to every window. Only the depth of history changes. That within-patient structure is what makes the resulting curve readable as a property of time rather than an artefact of cohort composition.

Discrimination climbed from an AUROC of 0.551 at two years to 0.583 at ten years, peaked at 0.590 at eighteen years, and then flattened. All deeper windows stayed within plus or minus 0.01 of the thirty-year value of 0.580. About 80 percent of the total gain — 0.032 of 0.040 AUROC — was realised within the first decade. The AUPRC tracked the same shape, rising from 0.113 to 0.132 against a prevalence of 0.095.

Medical AI needs eighteen years of patient history (Image 1)

The plateau rule was set in advance: the shallowest window within 0.001 of the maximum, whose paired difference against thirty years had a confidence interval containing zero, and whose point estimate lay within plus or minus 0.01. Eighteen years satisfied all three. The paired difference between eighteen and thirty years was minus 0.010, with an interval from minus 0.022 to 0.002. Between eighteen and two years it was plus 0.040, with an interval from 0.018 to 0.061.

The Baseline That Kept Pace

A gradient-boosted tree model on per-code event counts, trained on the same data and evaluated on the same nested windows, traced a curve of similar shape. XGBoost reached 0.528 at two years, peaked at 0.589 at fourteen years, and stayed flat thereafter. The transformer held a marginal edge at shallow windows — a paired difference of plus 0.022 at two years — but the two model classes converged from about twelve years and were statistically indistinguishable at depth, with a thirty-year paired difference of minus 0.004.

In this article’s view, that convergence is the most quietly important result in the paper. The transformer’s advantage is concentrated where records are sparse, and it evaporates once enough events accumulate for code counts alone to carry the signal. The measured depth curve, in other words, appears to be largely a property of the data rather than of a particular architecture. A model that knows nothing about sequence order and a model that attends across thirty years of it arrive at the same ceiling.

The authors are careful about what this does not mean. Absolute discrimination is modest for both models, which they attribute to the conservative buffer, disease-agnostic preprocessing without cancer-specific feature selection, and noisy primary-care data. Above all, matching on age and sex neutralises two of the strongest colorectal cancer predictors, so the figures are not comparable with clinical tools such as QCancer, which were developed with cohort designs. The 34.6-million-parameter trunk is probably under-sized; a larger model and task-specific features might lift the absolute numbers. The shape of the curve, replicated across two independent model classes, is unlikely to move.

Where the Tokens Stop Buying Anything

The token accounting sharpens the argument. Median tokens per evaluation patient grew from about 90 at two years to about 1,200 at thirty, but the tokens added per two-year step fell from roughly 180 to roughly 10. Between eighteen and twenty-four years, each step still contributed several tens of tokens per patient, and none of them bought any measurable discrimination. Additional history was not absent; it was simply uninformative for this task.

The authors read the plateau as a saturating signal rather than an artefact of thinning records, and they note that under data shift the curve is best treated as a lower bound on the long-range signal available. That framing is honest about the direction of the error: the true ceiling, if anything, sits above what this cohort could show.

An Engineering Detail With Decade-Scale Consequences

Buried in the methods is a finding that matters to anyone building time-aware models on long histories. The model applies rotary position embeddings over elapsed weeks rather than token index, so attention between two events depends on their time interval and irregular sampling is handled natively. At the default base frequency of 10,000, a simulation with 20,000 random vectors showed attention similarity rebounding beyond about twenty years: events twenty-five to thirty-five years apart appeared more alike than events twenty years apart. [1] Distant history was regaining spurious similarity once the faster rotations completed full turns.

Sweeping the base frequency between 10,000 and 100,000, the team selected 40,750, which maximises similarity spread across three months to thirty-five years subject to near-monotonic decay. [1] The authors are explicit that this justifies a parameter choice rather than demonstrating a performance effect, and that further ablations are needed. Still, the observation is a useful warning: a model can be given thirty years of context and quietly fail to distinguish the far end of it from the near end.

What Eighteen Years Is Compatible With

Medical AI needs eighteen years of patient history (Image 2)

The plateau depth lands close to a timescale that biology already suspected. The adenoma-carcinoma sequence in colorectal cancer can run from about ten to twenty-six years before diagnosis, and the authors note that a timescale of up to eighteen years is compatible with that dwell time. The curve does not prove that the model has learned the disease’s natural history, but it is consistent with a signal that reflects it, and the convergence with a count-based baseline suggests the signal lives in the record rather than in the architecture that reads it.

For early detection, that is the concrete gain: a transformer can capture long-range pre-diagnostic structure in ordinary primary-care codes, and the depth at which the structure saturates can be stated rather than guessed. For data curation, it is a citable bound. If most of the attainable discrimination arrives within a decade and none of it beyond eighteen years, then retention policies and preprocessing pipelines have a defensible target.

The Cohort That Made the Curve Possible

The study’s limitations are stated plainly and they shape how far the result travels. Registration depth is counted from 1990, so every deep-cohort index date falls between 2020 and 2026, and the evaluation cohort is therefore strongly selected: older, residentially stable, and likely less deprived than the broader population. Events recorded per year rose from about five million in the 1990s to about 130 million in the 2020s, and the number of distinct SNOMED codes per year grew roughly 2.5-fold, so the oldest history is both sparser and more coarsely coded. Some codes carry approximate dates, and registration depth was computed at year resolution. Results come from a single training run.

None of this undermines the central measurement, which is a within-patient comparison at fifteen depths. It does mean the curve describes a particular kind of patient in a particular region, and the authors say so. Future work they sketch includes other tumour sites such as lung and pancreas, evaluation at natural prevalence, scaling, explainability analysis, and architecture comparisons for long-range dependencies.

The Gain, Stated Plainly

What the work delivers is not a better cancer detector. It is a way of asking how much past a clinical prediction model needs, and an answer for one disease that can be checked, replicated, and argued with. The vocabulary of the field has been token counts; the vocabulary of clinical operations is years. Bridging the two required a cohort with three decades of continuous primary-care registration, a nested evaluation that compares every truncation within the same patients, and a baseline honest enough to show where the sophisticated model stops adding value.

The practical upshot is a reporting recommendation. Time-context should be reported alongside token-context, because the two answer different questions and only one of them is denominated in the units that retention policies, screening strategies, and guidelines are written in. The model that reads eighteen years and the model that reads thirty perform the same on this task. Knowing that is worth more than another layer of architecture.


Sources

  1. arXiv — Paper

Mentioned organisations (context, not sources)

← back to the garden