Abstract
Large-scale pretraining has transformed modeling of language and other data types, but its potential remains underexplored in healthcare with structured electronic health records (EHRs). We present a novel generative pretraining strategy for sequential EHR data using next-visit event prediction. Our model, GPT-EHR, learns to autoregressively generate various tokenized clinical events for the next visit based on patient history and inherently handles the joint prediction of heterogeneous data types. Additionally, we introduce regularization on predicting repeated events and highlight a key pitfall in EHR-based foundation model evaluations: repeated event tokens can inflate performance metrics when new onsets are not distinguished from subsequent occurrences. Our model is evaluated via zero-shot prediction for forecasting dementia and knee osteoarthritis incidence within 2 and 5 years, and the model performance rivals a fully fine-tuned masked pretrained Transformer baseline, demonstrating that our approach captures complex clinical dependencies without requiring costly task-specific fine-tuning.
The Challenge of EHR Modeling
Predicting the onset of chronic diseases like dementia or osteoarthritis is a primary goal for modern healthcare. However, Electronic Health Records (EHRs) present significant modeling challenges: they are high-dimensional, irregular, and contain heterogeneous data types. Traditional approaches typically fall into two categories: task-specific models requiring expensive manual labeling, or BERT-style masked models that require extensive fine-tuning.
A critical issue in current EHR modeling is the "repeat token" problem. Chronic conditions appear repeatedly in a patient's record. Models can achieve deceptively high accuracy by simply predicting that a patient who had a condition in a previous visit will have it again. This "cheating" masks the model's true ability to detect the first onset of a new condition.
GPT-EHR: A Generative Foundation Model
To address these challenges, we developed GPT-EHR, a decoder-only Transformer architecture designed for health system scale data.
Key architectural innovations include:
- Next-Visit Multi-Label Prediction: Instead of predicting the next single token, the model predicts the entire set of events (diagnoses, medications, labs) for the next visit simultaneously.
- Time-Aware Embeddings: We use Rotary Positional Embeddings (RoPE) to explicitly encode the time elapsed between visits, capturing the temporal rhythm of a patient's history.
- Quantized Continuous Data: Numerical values like age and lab results are discretized into quantile-based bins, allowing them to be treated as tokens within a unified vocabulary.
Addressing the "Repeat Token" Pitfall
The "secret sauce" of GPT-EHR is Repeat Token Regularization. We introduced a power decay function that penalizes the loss for tokens that have appeared frequently in the patient's past. This forces the model to focus on learning transitions to new clinical states rather than simply echoing known ones.
We also propose a new metric: the "on-time rate". This measures the proportion of true positives that occur at or before the first recorded onset. This ensures the model provides an early warning rather than a late confirmation of an existing diagnosis. As shown in the figure above, increasing the decay factor $\delta$ improves the on-time rate, highlighting the trade-off between overall precision and the ability to detect new onsets.
Datasets and Evaluation
GPT-EHR was trained on a massive longitudinal EHR dataset from NYU Langone Health, encompassing ~1.29 million unique patients over 10 years (2013–2023). The model was evaluated on zero-shot forecasting for Dementia and Knee Osteoarthritis (OA) at 2-year and 5-year horizons.
Key Results
- Dementia Prediction: In a zero-shot setting, GPT-EHR achieved an AUROC of 0.814 for a 2-year horizon, significantly outperforming a BERT-based model that was fully fine-tuned for that specific task (AUROC 0.731).
- Osteoarthritis (OA): For Knee OA, the zero-shot model remained highly competitive, achieving an AUROC of 0.724 (2-year), nearly matching fine-tuned baselines.
- Foundation Model Advantage: We compared GPT-EHR against LLaMA-3.3-70B. Despite its size, the general-purpose LLM performed poorly on structured clinical data, underscoring the necessity of domain-specific foundation models.
Conclusion
GPT-EHR demonstrates that generative pretraining on structured EHR data can capture complex clinical dependencies without task-specific fine-tuning. By addressing the evaluation pitfalls of repeated events through novel regularization and metrics like the on-time rate, we provide a more robust framework for developing clinical foundation models. Future work will explore multi-step trajectory generation and the integration of non-EHR data sources.
Summary updated