Abstract
Electronic Health Records (EHRs) contain rich longitudinal data but are characterized by irregular temporal intervals and high-dimensional medical codes. We present TALE-EHR, a Transformer-based framework that incorporates a continuous, time-aware attention mechanism and semantic embeddings derived from Large Language Models (LLMs). By explicitly modeling the temporal decay of clinical events and utilizing textual descriptions of medical codes, TALE-EHR achieves state-of-the-art performance across multiple clinical benchmarks, including disease progression and hospital readmission prediction.
Introduction
Predictive modeling in healthcare relies heavily on Electronic Health Records (EHRs). However, EHR data presents two significant challenges: temporal irregularity and semantic sparsity. Unlike natural language sequences, clinical events occur at sporadic intervals—a patient may have frequent visits during an acute phase followed by years of absence. Standard deep learning architectures, such as LSTMs or vanilla Transformers, often fail to capture these nuances, either treating events as a uniform sequence or using coarse "time buckets." Furthermore, medical codes (e.g., ICD-10) are often treated as discrete, arbitrary identifiers, ignoring the rich clinical knowledge embedded in their textual descriptions.
TALE-EHR addresses these limitations by introducing a learnable temporal weighting function within the attention mechanism and leveraging pre-trained LLM embeddings to capture the semantic relationships between medical concepts.
Methodology
The TALE-EHR framework consists of several key components designed to handle the complexities of longitudinal patient data.
Time-Aware Attention Mechanism
At the core of TALE-EHR is a continuous time-aware attention mechanism. Instead of standard self-attention, the model employs a learnable temporal weighting function, $w(t)$, based on a 5th-order polynomial basis. This function dynamically adjusts attention scores according to the continuous time difference between events. This allows the model to learn specific decay rates for different clinical conditions—for instance, prioritizing recent events for acute conditions while maintaining long-term context for chronic diseases.
LLM-Enhanced Semantic Embeddings
To overcome the limitations of treating medical codes as simple IDs, TALE-EHR utilizes a pre-trained Large Language Model (BGE) to generate embeddings from the textual descriptions of over 12,000 medical codes. This approach provides the model with a robust, "pre-educated" understanding of clinical concepts, facilitating better generalization across different hospital systems and coding standards.
Joint Training Objective
The model is trained using a dual objective: it simultaneously learns to predict the timing of the next visit (using a temporal point process loss) and the specific medical codes likely to appear (using a focal loss to handle class imbalance).
Experimental Setup
The framework was evaluated on two large-scale datasets:
- MIMIC-IV: Over 360,000 adult patient records encompassing diagnoses, medications, and laboratory results.
- PIC (Paediatric Intensive Care): Approximately 13,000 records, used to assess the model's generalizability to a pediatric demographic.
Results and Discussion
TALE-EHR consistently outperformed state-of-the-art baselines, including HiTANet and Cehr_Bert, across various clinical tasks.
Performance Benchmarks
On the MIMIC-IV dataset, the model achieved an average AUROC of 0.926 across nine representative diseases. In clinical benchmark tasks, it set new records for predicting 30-day hospital readmission and Length of Stay (LOS) exceeding seven days. Notably, for next-visit code prediction, the model achieved an Acc@5 of 0.902, indicating that the correct medical code was within the top five predictions in over 90% of cases.
Interpretability and Ablation
Ablation studies highlighted that the time-aware attention mechanism is the most critical component of the architecture; its removal resulted in a more significant performance degradation than the removal of LLM-based embeddings. Furthermore, the model demonstrated an ability to learn disease-specific temporal patterns. For example, attention weights for Acute Kidney Injury decayed rapidly, whereas weights for Type 2 Diabetes showed a more gradual decay, reflecting the long-term nature of chronic disease management.
Conclusion
TALE-EHR represents a significant advancement in EHR modeling by integrating continuous temporal awareness with semantic LLM embeddings. While the current model focuses on structured data, future work will explore the integration of multimodal data, such as clinical notes and medical imaging, to provide a more holistic view of patient health. Additionally, improving the transparency of the semantic relationships captured by LLM embeddings remains a priority for clinical adoption.
Summary updated