Editor’s introduction
The research evaluates a Transformer-based surrogate model trained to mimic a foundation model for electronic health records (FEMR) across two clinical prediction tasks. By analyzing individual tokens, the study identifies which patient data features—such as numerical lab values and time deltas—most influence predictions, showing that these temporal and quantitative metrics are more clinically relevant than text or code features. The surrogate model demonstrates strong alignment with the FEMR’s behavior, and its token-level explanations correlate with known clinical events, offering insight into decision-making processes. The findings suggest that the model leverages longitudinal patient data in ways consistent with clinical understanding.
Introduction
Foundation models (FMs) are trained on large-scale and diverse datasets using self-supervised objectives, learning to acquire general-purpose representations that can be efficiently adapted to a wide range of downstream tasks. The use of abundant data, transformer-based architectures, and advances in optimization and model scaling has produced models with strong transferability and emergent capabilities. Consequently, FMs often outperform task-specific systems, reducing the need for extensive task-dependent supervision and making them well-suited for complex, data-rich domains, such as healthcare.
In the field of medical artificial intelligence (AI), FMs have primarily been developed along two major lines, reflecting the heterogeneous nature of clinical data. The first stream focuses on unstructured clinical text, creating Clinical Language Models (CLaMs), which are trained on narrative notes and reports. While CLaMs have demonstrated strong performance in extracting information from unstructured clinical narratives, a substantial portion of clinically relevant information is encoded in structured electronic health records (EHRs), which capture longitudinal diagnoses, procedures, medications, and their temporal relationships. Consequently, increasing attention has shifted toward FMs for structured EHR data. These models learn from longitudinal sequences of coded clinical events to capture temporal patterns in patient trajectories, which are referred to as FMs for EHRs (FEMRs), include ETHOS and CLMBR-T-Base.
Despite their strong empirical performance, the translation of FEMRs into clinical practice remains limited. First, their internal representations and decision mechanisms are largely opaque, limiting interpretability for clinicians and model developers. Second, while interpretability tools for clinical language models have rapidly matured, they mainly focus on traditional machine learning approaches, and thus comparable explainability frameworks for FEMRs are still underdeveloped. Third, FEMRs are typically trained on institution-specific datasets constrained by privacy and governance policies, which can encode local practice patterns and biases, thereby raising concerns regarding robustness and generalizability across healthcare settings. Consequently, there is limited understanding of how these models reason over patient histories and temporal event sequences. Together, these limitations motivate the need for explainable FEMRs that provide transparent and clinically meaningful explanations of their representations and predictions. Evaluations for explainability in FEMRs are also lacking due to the absence of explainable methods for FEMRs.
A broad range of explainable AI (XAI) techniques have been proposed to interpret complex machine learning models. Prominent examples include feature-attribution methods such as SHAP, which quantify the contribution of individual input features to model predictions, as well as gradient-based approaches like saliency maps, and perturbation-based methods like LIME. However, their effectiveness is substantially limited when applied to FMs. FMs operate on high-dimensional, distributed representations and often rely on complex internal interactions across long contexts, making it difficult to meaningfully attribute predictions to individual input features. Moreover, post hoc attribution methods typically assume a fixed input–output mapping, whereas FMs produce task-agnostic latent representations that are reused across multiple downstream tasks. As a result, existing XAI techniques often yield explanations that are unstable, difficult to interpret clinically, or misaligned with the reasoning processes of FMs. This highlights the need for explanation methods that are specifically designed for foundation-scale architectures.
Recent studies have begun to explore XAI techniques for FEMRs, but this line of work has mainly focused on Large Language Models (LLMs) for general purpose. Saraswat et al. proposed a four-axis taxonomy for XAI, encompassing data explainability, model explainability, post hoc explainability, and explanation assessment. Within this framework, recent XAI research has emphasized the role of proxy representations, interpretable surrogate models that approximate the behavior of black-box systems. As discussed by, proxy models served as intermediate, human-aligned representations that enabled inspection of how a deep model responds to clinically relevant features, even when its internal states are not directly accessible. By introducing an interpretable bottleneck or fitting transparent surrogates such as linear or additive models, proxy representations map complex temporal EHR inputs into a lower-dimensional semantic space that clinicians can reason about. This approach facilitates attribution analysis, detection of spurious feature dependencies, and assessment of whether model behavior aligns with established clinical reasoning. However, the current surrogate models, such as linear regression, and Decision tree (DT), generally assume that the data is smooth linear, which is not true for EHRs.
Despite advances in these surrogate models, most approaches still focus mainly on feature-level explanations. In contrast, FMs generate predictions one token at a time using an autoregressive learning process. This allows for token-level explainability, which can be especially useful in clinical settings. For example, knowing which specific words or values in a patient’s record influenced a model’s prediction can help clinicians better understand the reasoning behind AI recommendations and improve clinical scoring methods or practice guidelines. Some recent studies have explored token-level explanations in general LLMs using methods like Integrated Gradients (IG), a gradient-based technique that assigns importance scores to each token in a text. However, IG can be fragile in identifying the right features and may give inconsistent explanations. Despite its potential, token-level explainability remains rare in clinical applications, particularly for longitudinal EHRs.
Another challenge in explaining predictions from EHR data is their temporal nature. Beyond identifying which clinical variables are important, it is important to know when they influence the prediction. Token-level explainability offers this finer-grained insight, identifying the specific variables and time points that drive model outputs. However, common surrogate models, such as logistic regression, struggle to capture these temporal dynamics, limiting their effectiveness for interpretable predictions in longitudinal EHR data. Furthermore, the evaluation of explainability itself remains an open challenge, with few quantitative metrics available to assess whether explanations align with clinical knowledge or decision-making.
In this work, we propose the first token-level explainability approach for FEMRs. Specifically, we introduce a transformer-based surrogate model to approximate the input-output behavior of FEMRs, enabling the capture of temporal dynamics in EHRs for more reliable explanations. In addition, we develop a clinically validated evaluation metric that quantitatively measures the quality of the model explanations. Our experiments on two distinct clinical datasets and tasks show that the surrogate model closely approximates the behavior of FMs in EHRs while achieving comparable predictive performance. Moreover, token-level explainability demonstrates stronger alignment with clinical tasks with the ratio of 0.3, suggesting the effectiveness of our approach. This work lays the foundation for more interpretable and clinically actionable AI in longitudinal EHR analysis.
Related Work
FMs trained on structured EHR data, such as ETHOS, CLMBR-T-Base, and Med-BERT, have demonstrated strong performance on a range of clinical tasks. These models support applications including treatment recommendation and 30-day hospital readmission prediction, particularly after task-specific fine-tuning.
Traditional interpretable models, including probabilistic approaches such as Naïve Bayes and sequence models like Hidden Markov Models, provide intuitive explanations through explicit probability distributions and state transition structures. However, these models lack the capacity to capture the complexity of modern learning systems. Recent advances in explainable artificial intelligence have enabled post hoc interpretation of deep learning models, improving transparency and supporting clinical adoption. Common approaches include feature attribution methods, gradient based explanations, and surrogate models. Nonetheless, these techniques remain limited when applied to foundation scale models.
Research on the interpretability of FMs is still sparse and has largely focused on medical imaging. More specifically, prior work has explored explainability for vision FMs in retinal and breast imaging applications. However, explainability methods for FEMRs are largely unexplored, leaving their internal reasoning processes insufficiently understood.
Methodology
In this section, we present our explainability pipeline for analyzing FEMRs. We first describe its overall design, highlighting the integration of proxy representations with token-level interpretation. We then apply the pipeline to FEMRs on clinically relevant prediction tasks to assess their explainability.
Overview of Explainability Pipeline
To gain deeper insight into the FEMRs, we run the pipeline under two supervision settings. In the first setting, the surrogate is trained on the binary predictions of FEMRs as hard labels, capturing the model’s actual decisions. In the second, it is trained on the predicted probabilities as soft labels, reflecting the nuanced confidence of the models. Comparing token contributions and training dynamics across these settings allows us to distinguish the factors driving observed decisions from those influencing internal uncertainty, revealing where and how the model may deviate from optimal or clinically meaningful behavior. We will first present the data collection pipeline for the FMs, followed by the surrogate model development and explainability analyses.
Data format
The code refers to standardized medical terminologies and coding systems used to describe and categorize various types of health information, such as LOINC for laboratory tests and RxNorm for medications. The numeric and text fields contain additional information about the corresponding medical code.
Surrogate Model Development
EHR data is typically long and contains irregular, heterogeneous variables and nonlinear patterns, which simple surrogate models cannot capture effectively. Therefore, we employ a transformer-based surrogate model, which can represent these complex sequences and construct accurate proxy representations of the FEMR.
For encoding part, each event token is initialized with a learned code embedding, augmented with a text embedding. Numerical values are included via a gated injection mechanism, which means the projected numeric embedding is adjusted by a content-dependent gate computed from the current event representation. To encode temporal information, we project the normalised time-to-prediction feature of each event into the model dimension and adding it to the token representation. Learnable positional embeddings are added, followed by layer normalization and dropout.
The sequence of event embeddings is processed by a multi-layer transformer encoder to capture temporal dependencies among events. A [CLS] token is then prepended to summarize the sequence, and the final [CLS] representation is fed into a task-specific prediction head for hard-label or soft-label supervision.
Soft-label Supervision
In this approach, the surrogate model is trained to predict the raw probability outputs of the FEMR, enabling a more nuanced approximation of the confidence and internal decision-making process of the FMs. This extends beyond binary classification to suit multiclass classification and regression tasks.
This comparison further allows us to analyze how the choice of supervision influences the learned token importance patterns, providing insights into how closely the surrogate reflects the underlying decision logic of FMs. We use both surrogate models for subsequent SHAP-based token attribution analysis.
Token-Level Clinical Explainability
To evaluate how well the surrogate model explains the CLMBR-T-Base in a clinically meaningful way, we perform a token-level analysis using SHAP. The goal is to determine whether the token identified as important by the surrogate model correspond to known clinical predictors of downstream tasks.
Cohort
We used the EHRSHOT dataset due to its large-scale, longitudinal EHR records, which provide rich temporal information for modeling patient trajectories. The dataset contains records for 6,739 patients with a wide range of trajectory lengths. The longest patient sequence includes 199,913 events, reflecting the high variability and complexity of real-world EHR data. To ensure compatibility with transformer-based surrogate models to handle reasonable long sequences, we selected the top 75% of patient records based on trajectory length.
Tasks
We focus on two classification tasks: long length of stay(LOS) and ICU transfer. The first task including predicting whether a patient’s total LOS during a visit to the hospital will be at least 7 days. LOS is a key factor of both patient outcomes and healthcare costs. The prediction time is at 11:59pm on the day of admission, and visits that last less than one day (i.e. discharge occurs on the same day of admission) are excluded. The second task involves predicting whether a patient will be transferred to the ICU during their hospital stay. Predictions are made at 11:59 pm on the day of admission, and ICU transfers occurring on the admission day are excluded. Both tasks represent common clinical prediction problems that focus on forecasting patient outcomes.
Foundation Model
The FEMR used for our explainability analysis is CLMBR-T-Base, a 141M-parameter autoregressive model trained on 2.57 million de-identified longitudinal EHRs from the EHRSHOT dataset at Stanford Medicine. CLMBR-T-Base is currently the only FEMR with publicly available weights, enabling reproducible analyses.
Surrogate Model
To further improve surrogate model training with soft labels, we apply a logit transformation to the predicted probabilities produced by the CLMBR-T-Base. This transformation maps probability values into the log-odds space, expanding small differences that would otherwise be compressed near zero or one. By operating in the logit domain, the soft labels provide richer supervisory signals and yield more informative gradients during backpropagation, leading to more stable and effective surrogate model optimization.
SHAP Analysis Results
For four features of each event, we find that numerical values (e.g., laboratory measurements) and time delta (i.e., duration of events) contributed most significantly, while text and code contributed less. This is because these two features contain the patient’s clinical information: numerical values indicate whether the patient experienced the corresponding clinical event and the specific value of the event; time differences represent the patient’s medical history over time.
Discussion
Our surrogate design allows us to examine not only what the FEMR predicts, but how it uses different tokens to make those decisions. More importantly, this comparison moves beyond traditional performance metrics and provides an interpretable, token-level evaluations of how the surrogate model aligns with the FEMR. This clinical validated events ratio quantifies an approximate estimate of how many validated clinical events are involved in the model prediction, which helps selecting clinically meaningful events for model training in the future. However, the limitation in this study lies in the alignment problem between the original black box model and the surrogate model. This mismatch can be attributed to several factors: (1) longitudinal patient trajectories are highly complex and noisy, which contains multiple data modalities and irregular temporal information, (2) the patient trajectories are long, which makes sequence-level imitation challenging, and (3) the transformer-based surrogate model typically requires large amount of training data, while the number of available longitudinal EHRs is limited.
Another limitation of the current framework is that clinical events are represented by combining multiple feature channels into a single event-level token. Although effective, this design can result in the loss of fine-grained token-level information. Also, token-level explanations may overemphasize individual events while overlooking clinically meaningful trends used by FEMRs to perform prediction. Future work could explore alternative tokenization strategies that treat time as a primary modeling component. For instance, temporal information could be represented as a distinct token type in order to explicitly model the irregular intervals between events, in a manner similar to recent transformer approaches based on trajectories. In the future, as more FEMRs become publicly available, we will generalize our approach to other foundation models.
Conclusion
In this work, we present the first token-level explainability approach for FEMRs, providing insights into the specific tokens in EHR data that drive model predictions. We also introduce a novel clinical alignment metric to quantify how well the tokens identified by our surrogate model correspond to clinically validated features, evaluating the alignment of model explanations with established medical knowledge. Our approach addresses a critical gap in the literature on interpreting FEMRs and offers a foundation for future studies aimed at assessing the reliability and clinical trustworthiness of Foundation Models in healthcare.


