arXiv:2610.16878cs.LGOct 2026

Manuscript Offprint

arXiv:2610.16878

Sequence Composition in EHR Foundation Model Pretraining

Joshua Placidi, Inigo Stibbe, Alfred J. Balston, Marek Rei, A. Aldo Faisal

ABSTRACT

Autoregressive electronic health record (EHR) foundation models predict the next event token in patient trajectories: sequences of structured medical events. A typical pretraining strategy is to concatenate all trajectories into a global stream and sample token windows from it. This gives patients with longer sequences more training exposure and allows tokens to attend across patient boundaries. We argue that these choices create a misalignment between pretraining and downstream clinical tasks. To explore this, we investigate how the composition of pretraining sequences affects clinical prediction performance. Using the global-stream approach as a baseline, we propose alternative sequence composition methods that control how patient trajectories contribute to pretraining sequences. Across four MIMIC-IV v2.2 tasks, our best method improves macro AUROC, AUPRC, F1, and balanced accuracy, with relative gains of 9.3% in F1 and 2.7% in AUPRC under a fixed training recipe. We find that these gains generalize across four additional evaluation settings, including the INSPIRE and eICU-CRD datasets, with improvements in macro AUROC, AUPRC, and F1 score. Our results show that simply changing how EHR data are presented to the model during pretraining can improve downstream performance, without changing the model or collecting additional data.

1 INTRODUCTION

Electronic health records (EHRs) represent medical histories as trajectories of events describing diagnoses, procedures, medications, laboratory measurements, and more. These histories vary widely in length and detail, reflecting differences in patient states and the type of care they require. EHR foundation models (EHR-FMs) aim to learn representations from these longitudinal records to support a range of clinical tasks. Autoregressive EHR-FMs represent each trajectory as a sequence of tokens and learn through next-token prediction, as shown in Figure 1. Architectures and training pipelines for these models are often adapted from language modeling frameworks, with medical event tokens replacing text tokens (Renc et al., 2024; Kraljevic et al., 2024; Fallahpour et al., 2025). Models are evaluated in a zero-shot setting by prompting them with a patient history and stochastically generating future rollouts. The fraction of rollouts containing an outcome provides an estimate

Figure

Figure 1: Autoregressive prediction from a patient trajectory. Medical events are encoded as discrete tokens, and the EHR-FM predicts the next token from the preceding clinical context.

Figure

(a) Patients and tokens.

(b) Clinical task instances.

(c) Outcome prevalence.

(d) Token composition.

Figure 2: Trajectory token length and clinical content in the training set of MIMIC-IV v2.2. (a) Distribution of patient trajectory lengths and tokens. Each token is represented by the length of its corresponding trajectory. (b) Distributions of hospital mortality and ICU readmission task instances by trajectory length. (c) Recorded outcome prevalence by trajectory length. (d) Token composition by trajectory length.

of that patient’s risk of that outcome (Renc et al., 2025). Pretraining therefore directly shapes how these models perform on downstream clinical tasks.

The method of composing pretraining sequences from a dataset of patient trajectories determines how each patient contributes to model training. This choice is particularly consequential for zero-shot EHR-FMs, because they do not undergo additional task fine-tuning. A common composition method is to concatenate patient trajectories into a global token stream and sample fixed-length windows from that combined stream (Renc et al., 2024; 2025). These windows can contain information from multiple patients packed together without any boundary masking, allowing tokens from one patient to attend to tokens from another. Allowing attention across unrelated documents can introduce distracting context and degrade downstream performance in language-model pretraining (Zhao et al., 2024). In EHR pretraining, this corresponds to conditioning on events from unrelated patients, despite downstream predictions being made from individual patient histories.

Using MIMIC-IV v2.2 (Johnson et al., 2023b;c;a), we observe that patient trajectory lengths span several orders of magnitude due to differences in duration and severity of condition. Sampling global-stream windows gives longer histories proportionally more next-token targets, so exposure follows the token rather than the patient distribution. Figure 2a shows that token exposure is shifted toward much longer trajectories than the patient distribution, peaking near 10410^{4} versus 10210^{2} tokens. Mortality prediction at hospital admission and readmission prediction at ICU discharge are common EHR-FM benchmarks. Figure 2b shows that instances for both tasks peak at trajectory lengths of approximately 10310^{3} tokens. Clinical content also varies with length. Recorded outcome prevalence rises in longer trajectories (Figure 2c), while the mix of token types changes (Figure 2d). Reweighting trajectories therefore changes both patient exposure and the clinical information encountered during pretraining.

We study sequence composition methods under a fixed model architecture and training recipe. We compare Global Stream (GS) with a masked version (GS+M) that prevents attention crossing patient boundaries. We then introduce three methods for controlling patient contribution: Patient Sampling (PS), Recursive Patient Sampling (RPS), and Ordered Global Stream (OGS). Figure 3 illustrates how composition methods can generate different sequences, modifying the token and patient contributions during training. This comparison allows us to examine the impact of cross-patient attention and sequence composition on zero-shot clinical prediction.

Across four MIMIC-IV v2.2 tasks, OGS achieves the highest mean performance on macro AUROC, AUPRC, F1, and balanced accuracy across five seeds. Relative to GS, OGS improves macro AUPRC by 2.7%, F1 by 9.3%, and balanced accuracy by 3.7%. We further evaluate OGS in four additional settings, including the INSPIRE and eICU-CRD datasets. Relative to GS+M, OGS improves mean macro AUROC, AUPRC, and F1 across these settings by 2.0%, 2.3%, and 8.2%, respectively, with gains in all three metrics in every setting. These findings establish pretraining sequence composition as an important design choice for EHR foundation models.

Figure

Figure 3: Sequence composition for four patients with unequal trajectory lengths. In the Global Stream example, each token appears once, so longer trajectories contribute more tokens. Ordered Global Stream ( α=0\alpha = 0) samples windows repeatedly to give patients approximately equal expected contributions.

References (45)