Care operations · Research feature

New AI Model Unifies Three Key Functions for Electronic Health Records

A new foundation model for EHRs combines feature representation, zero-shot prediction, and synthetic data generation in a single framework.

Adapted from research by Chao Pang, Jiheum Park, Xinzhuo Jiang and colleagues.

arXiv preprint revision · 2025-09-05 · Attribution & reuse
In this article
Editorial illustration of stack of documents.

Editor’s introduction

The study presents CEHR-XGPT, a foundation model designed to perform three core tasks on electronic health record data: feature representation, zero-shot prediction, and synthetic data generation. It is evaluated against MOTOR, a leading EHR foundation model focused on representation learning, with comparisons limited to that task due to MOTOR’s lack of support for the other two functions. The results show CEHR-XGPT performs well across all three tasks, demonstrating broader versatility than prior models that specialize in single functions. The evidence confirms its ability to support diverse clinical applications without task-specific retraining, though the comparison with MOTOR does not include performance on zero-shot prediction or synthetic data generation.

Abstract

Electronic Health Records (EHRs) provide a rich, longitudinal view of patient health and hold significant potential for advancing clinical decision support, risk prediction, and data-driven healthcare research. However, most artificial intelligence (AI) models for EHRs are designed for narrow, single-purpose tasks, limiting their generalizability and utility in real-world settings. Here, we present CEHR-XGPT, a general-purpose foundation model for EHR data that unifies three essential capabilities - feature representation, zero-shot prediction, and synthetic data generation - within a single architecture. To support temporal reasoning over clinical sequences, CEHR-XGPT incorporates a novel time-token-based learning framework that explicitly encodes patients’ dynamic timelines into the model structure. CEHR-XGPT demonstrates strong performance across all three tasks and generalizes effectively to external datasets through vocabulary expansion and fine-tuning. Its versatility enables rapid model development, cohort discovery, and patient outcome forecasting without the need for task-specific retraining.

Introduction

Electronic health records (EHRs) capture rich, longitudinal information about patients across diverse clinical settings. This wealth of data presents significant opportunities to build generalizable and clinically useful AI models. However, it is highly challenging to model such data reliably. EHRs differ from typical sequential data in several important ways: they are irregularly sampled, temporally sparse, and often contain heterogeneous modalities such as diagnoses, procedures, lab results, and medications. Accurately modeling the temporality and structure of EHR data is essential to capture the underlying progression of patient health and produce reliable, context-aware predictions.

With the advent of general-purpose foundation models, such as ChatGPT—trained on large, diverse datasets using self-supervised learning rather than single-task objectives—researchers have begun developing analogous foundation models for EHRs. These EHR foundation models aim to capture the full potential of longitudinal patient data by learning generalizable representations that can support a variety of downstream tasks with improved performance.

Recent EHR foundation models have been applied to specific applications such as disease prediction, patient outcome forecasting, synthetic data generation, extracting patient representations, and propensity score modeling for causal effect estimation. However, most existing models have been designed and evaluated with a narrow focus—typically excelling at one task type, such as representation learning or predictive modeling, but not both.

We present CEHR-XGPT (pronounced “seer-ex-gpt”), a unified EHR foundation model that supports three core capabilities within a single framework: feature representation, zero-shot prediction, and synthetic data generation. By integrating all three, our model demonstrates a broader and more flexible utility compared to prior approaches.

Feature Representation: Recent works such as MOTOR, along with models like Llama and Mamba reported by Wornow et al., have focused on the feature representation capabilities of EHR foundation models using linear probing. Linear probing is a model evaluation technique in which a lightweight classifier (typically logistic regression) is trained on fixed patient representations generated by a pretrained foundation model. This approach allows researchers to assess how well the model’s learned embeddings encode clinically relevant information, without further training for specific tasks. In the context of EHR applications, linear probing offers several advantages: it requires only a single forward pass through the model, is computationally efficient, and avoids the need for fine-tuning, making it attractive for rapid evaluation and deployment. In contrast, other models such as MED-BERT, BEHRT, TransformerEHR, and EHRMamba require additional fine-tuning for each downstream task after pretraining. These models differ in two main aspects. First, they adopt various architectural choices, including encoder-only, decoder-only, and encoder–decoder designs. Second, they incorporate temporal information in different ways, such as through positional embeddings, age embeddings, time embeddings, or, more recently, discrete time tokens.

Zero-Shot Prediction: Several EHR Foundation Models, such as Foresight and ETHOS, built on causal language model architectures, focus on zero-shot prediction without any task-specific training. In Foresight, the authors first used NLP tools to extract clinical concept codes from unstructured notes, which they combined with structured EHR data to construct full patient timelines. To encode demographic context, age tokens were inserted into the timeline, with a new token added whenever the patient’s age increased. Foresight achieved strong performance in forecasting future conditions, demonstrating high precision and recall across ranked predictions (e.g., top-1, top-5, top-10). A qualitative evaluation was also conducted, in which five clinicians assessed predictions generated from 34 synthetically constructed patient timelines. Foresight achieved a high relevance score, with 33 out of 34 predictions (95%) deemed clinically meaningful. Similarly, ETHOS, trained primarily on MIMIC-IV, demonstrated strong zero-shot capabilities, matching or surpassing prior SOTA models on several clinical prediction benchmarks. However, both models employed tokenization strategies that compromised temporal fidelity. In Foresight, age tokens served as coarse temporal markers, making it impossible to distinguish between events occurring 1 day apart versus 90 days apart if the patient’s age remained constant. In ETHOS, more granular time tokens (e.g., 6–12 hours, 3–6 months) were introduced to better model ICU timelines, but this approach still struggled to capture time gaps across discrete hospital admissions. While such models are well-suited for forecasting tasks that tolerate temporal compression, they are less appropriate for applications like synthetic data generation or fine-grained trajectory modeling, which require high temporal resolution.

Synthetic Data Generation: Structured EHRs are characterized as irregular time-series data with high-dimensional features at each time point. Most prior work has focused on deep learning-based methods without adequately preserving the temporal structure of clinical events. For example, HALO, a state-of-the-art (SOTA) model for generating synthetic EHR data, incorporates inter-visit time intervals but fails to represent inpatient visit durations. This omission makes it unsuitable for tasks that require accurate modeling of patient trajectories over time, such as identifying 30-day readmissions, thereby limiting its evaluation to simpler tasks like predicting the presence of medical codes rather than supporting more complex phenotype modeling. Moreover, HALO discretizes inter-visit intervals into coarse buckets and samples from a uniform distribution, which can distort realistic patient timelines. In real-world outpatient care, for instance, 7- and 14-day intervals are much more common. Finally, HALO was evaluated separately on inpatient and outpatient datasets rather than on a unified EHR dataset that spans both care settings, further limiting its generalizability.

These capabilities require varying levels of patient timeline preservation and generative capacity. For feature representation, full patient timelines are not strictly necessary—some foundation models are not generative and simply order medical events chronologically without modeling temporal dependencies. In zero-shot prediction, models are not required to reconstruct complete timelines; some degree of timeline shrinkage or abstraction can be tolerated without significantly impacting performance. In contrast, synthetic data generation requires high-fidelity modeling of entire patient trajectories. To generate realistic synthetic sequences, it is essential to preserve the full temporal structure and the sequence dependencies inherent in the original data. As a result, a strong synthetic data generator should, in theory, also perform well on zero-shot prediction and feature representation tasks; however, the reverse does not necessarily hold.

Evaluation Setup

We evaluated CEHR-XGPT for three capabilities: feature representation, zero-shot prediction, and synthetic data generation. To benchmark our model against existing approaches, we compare it with MOTOR, a SOTA EHR foundation model known for its strong performance in representation learning tasks. However, since MOTOR does not support zero-shot prediction or synthetic data generation, our comparison is limited to representation performance. Furthermore, we introduce an ablation baseline—GPT—which shares the same architecture as CEHR-XGPT but excludes the proposed TTE and TD learning objectives. This allows us to assess the contribution of our novel timeline design.

Zero-Shot Prediction

Our evaluation followed the zero-shot setup proposed by ETHOS, in which the patient sequence up to the prediction time was provided to CEHR-XGPT to generate 50 simulated patient trajectories. Generation was terminated when either of the following conditions was met: (1) the generated tokens exceeded the defined prediction window, or (2) the outcome event(s) occurred within the prediction time. If the [END] token was encountered within the prediction window—causing premature termination—we treated the simulation as censored and discarded it, replacing it with a new one. The probability of the predicted outcome was then estimated as the proportion of simulations in which the event occurred. Using these estimated probabilities and the corresponding ground-truth labels, we computed AUROC and AUPRC scores. The standard deviation of these estimates was assessed via bootstrapping. An illustrative example of this zero-shot prediction setup is provided in Supplementary Section 9.4. Due to the computational cost associated with the generative nature of zero-shot inference, we randomly sampled 5,000 test cases from each prediction task.

Synthetic Data Generation

In both cases, performance was measured on a real-world test set. Feature extraction followed a bag-of-words (BOW) approach, counting concept frequency within defined observation windows. Logistic regression models were trained using Scikit-Learn’s default settings. For real data baselines, we used the original train/test splits. The standard deviation was estimated through bootstrapping.

Finally, we evaluated the privacy risks associated with synthetic data sharing using the framework introduced by Yan et al.. This framework includes four types of attacks: Membership Inference, Attribute Inference, Meaningful Identity Disclosure, and Nearest Neighbor Adversary Attacks (NNAA). We adopted the evaluation metrics and decision thresholds directly from Yan et al., and provide additional implementation details in Supplementary Section 9.5.4.

Generalization on EHRShot Benchmark

To evaluate the generalizability of CEHR-XGPT, we utilized the ehrshot benchmarking dataset, which includes 6,739 comprehensive de-identified EHR records from Stanford Medicine. This dataset is structured into 15 manually created tasks—both binary and multi-class classification tasks—across three categories: Operational Outcomes (e.g., 30-day readmission), Assignment of New Diagnoses (e.g., 1-year risk of pancreatic cancer), and Anticipating Lab Test Results. Given that CEHR-XGPT was specifically pre-trained on visits, conditions, procedures, and medications, we excluded the Anticipating Lab Test Results category from our analysis.

For model comparisons, we included all models listed on the ehrshot leaderboard. Furthermore, we considered the best-performing model from a recent study by the authors of Context Clues, which evaluated several causal language model architectures (GPT2, Llama, Mamba, etc.) with various context windows on Stanford EHR data. Their findings, reported on the ehrshot, served as an additional baseline in our experiments.

Experiments and Results

Our model, CEHR-XGPT, demonstrates versatility across three key capabilities: feature representation, zero-shot prediction, and synthetic data generation. For comparison, we include MOTOR as a SOTA EHR foundation model focused on representation learning. Additionally, we evaluate a variant of CEHR-XGPT, referred to as GPT, which excludes TD and TTE learning objectives.

GPT is assessed under the same experimental conditions as CEHR-XGPT for the three aforementioned capabilities, except the large-scale synthetic data generation experiment, which was excluded due to the computational cost of generating 3.7 million synthetic patients. Instead, we evaluate its long-term generation ability through a targeted analysis of the treatment pathway using a smaller synthetic cohort of 100,000 patients.

Feature Representation

Under the linear probing setting, MOTOR achieved the highest AUROC and AUPRC across all tasks, outperforming both CEHR-XGPT-L and GPT-L. This may reflect differences in pretraining strategies, as MOTOR is explicitly optimized for representation learning (e.g., time-to-event prediction), whereas CEHR-XGPT is trained using next-token prediction.

With full model fine-tuning, both CEHR-XGPT-T and GPT-T showed substantial improvements across all tasks compared to their linear probing counterparts. Both models also outperformed MOTOR on several tasks, including HF Readmission, Hospitalization, AFib Ischemic Stroke, and CAD CABG. The largest gains were observed on the AFib Ischemic Stroke task, where fine-tuning improved AUROC by 7% and AUPRC by 45%. While MOTOR demonstrated minimal performance gains from fine-tuning in prior work, CEHR-XGPT showed competitive results, particularly when fine-tuned.

Generalization on EHR-SHOT Benchmark

More importantly, both fine-tuned and linear-probing versions of CEHR-XGPT demonstrated strong performance across these tasks, achieving the best results on New Diagnosis prediction compared to all other models. Notably, CEHR-XGPT outperformed models such as CLMBR, despite the latter being trained on data drawn from the same distribution (Stanford EHR data) as the ehrshot dataset. This suggests that simply extending the context window or adopting alternative architectures does not necessarily yield better performance on these tasks, and that CEHR-XGPT’s novel patient representation design and time-specific learning objectives may be key contributors to its improved performance.

Discussion

CEHR-XGPT is, to our knowledge, the first EHR foundation model comprehensively evaluated across three core capabilities: feature representation, zero-shot prediction, and synthetic data generation. While prior models typically specialize in one area, CEHR-XGPT demonstrates broad versatility, enabling a wide range of clinical tasks without requiring task-specific retraining. This flexibility is particularly valuable in real-world settings with limited labeled data, evolving populations, or rapidly changing outcome definitions.

A key enabler of this versatility is CEHR-XGPT’s use of time tokens, along with Time Decomposition (TD) and Time-to-Event (TTE) objectives. These mechanisms help encode temporal structure directly into patient sequences and appear to enhance generalizability—particularly in zero-shot and transfer settings. For example, in the external ehrshot benchmark, CEHR-XGPT achieved strong performance through vocabulary expansion and full fine-tuning. It matched top-reported models on Patient Outcome tasks and outperformed all previously reported models on New Diagnosis tasks. While MOTOR, CLMBR, Llama, and Mamba were evaluated using linear probing in prior studies, their performance could improve with fine-tuning.

In contrast to MOTOR, which consistently outperformed other models in linear probing, CEHR-XGPT’s representation performance was more modest. This may reflect differences in pretraining: MOTOR was trained to forecast thousands of future events across time intervals, promoting long-range structure learning. CEHR-XGPT, by comparison, was trained with next-token prediction and auxiliary temporal objectives—favoring sequential modeling over embedding quality. These results suggest that the alignment between pretraining and downstream tasks plays a critical role in determining the effectiveness of linear probing. Another factor is feature coverage: CEHR-XGPT currently excludes measurements and observations, domains used by MOTOR. Expanding CEHR-XGPT’s input domains may help close this gap.

Interestingly, GPT (CEHR-XGPT without time-specific learning objectives) demonstrated similar performance to CEHR-XGPT on in-distribution representation tasks, but underperformed in zero-shot prediction, treatment pathway analysis using synthetic data, and external validation. This suggests that time tokens act as a form of structural regularization—limiting overfitting to the training distribution while improving temporal generalization. Analogous to regularization in traditional models, the TD and TTE objectives guide the model to learn more transferable temporal representations, which is critical for generalization across health systems.

Simulation Study

In this simulation, the transformer models utilizing the summation strategy struggled to achieve rapid convergence, raising concerns about their capability to handle the more intricate patterns observed in patient trajectories within EHR data. The practice of merely adding time embeddings to concept embeddings does not appear to be the most effective approach for modeling longitudinal EHR records. This assertion is supported by an ablation study from our previous work, where the performance of the BERT model significantly deteriorated after the removal of time tokens from the patient sequences, whereas the elimination of the time embeddings had a less pronounced impact.

Model Training

Below, we summarize the pretraining configurations used for each model. For MOTOR, we adopted the optimal hyperparameters reported by the original authors. For CEHR-XGPT and GPT, we followed the parameter settings described in Pang et al.. All models were trained for up to 10 epochs with an early stopping criterion: training was halted if the evaluation loss did not improve by more than 0.1%. MOTOR used 5% of the training data for validation, while CEHR-XGPT and GPT used 10%.

Zero Shot Prediction Setup

Below, we provide two examples illustrating how zero-shot prediction is configured using CEHR-XGPT. Each task requires specifying a list of outcome events using OMOP concept IDs, along with the start and end points of the prediction window. Additionally, the optional parameter include_descendants can be set to True to leverage the OMOP vocabulary and automatically include all descendant concepts of the specified outcome events.