Hi-BEHRT: Hierarchical Transformer-based model for accurate prediction of clinical events using multimodal longitudinal electronic health records

Yikuan Li, Mohammad Mamouei, Gholamreza Salimi Khorshidi, Shishir Rao, Abdelaali Hassaïne, Dexter Canoy, Thomas Lukasiewicz, Kazem Rahimi

Abstract

Electronic health records represent a holistic overview of patients' trajectories. Their increasing availability has fueled new hopes to leverage them and develop accurate risk prediction models for a wide range of diseases. Given the complex interrelationships of medical records and patient outcomes, deep learning models have shown clear merits in achieving this goal. However, a key limitation of these models remains their capacity in processing long sequences. Capturing the whole history of medical encounters is expected to lead to more accurate predictions, but the inclusion of records collected for decades and from multiple resources can inevitably exceed the receptive field of the existing deep learning architectures. This can result in missing crucial, long-term dependencies. To address this gap, we present Hi-BEHRT, a hierarchical Transformer-based model that can significantly expand the receptive field of Transformers and extract associations from much longer sequences. Using a multimodal large-scale linked longitudinal electronic health records, the Hi-BEHRT exceeds the state-of-the-art BEHRT 1% to 5% for area under the receiver operating characteristic (AUROC) curve and 3% to 6% for area under the precision recall (AUPRC) curve on average, and 3% to 6% (AUROC) and 3% to 11% (AUPRC) for patients with long medical history for 5-year heart failure, diabetes, chronic kidney disease, and stroke risk prediction. Additionally, because pretraining for hierarchical Transformer is not well-established, we provide an effective end-to-end contrastive pre-training strategy for Hi-BEHRT using EHR, improving its transferability on predicting clinical events with relatively small training dataset.

Introduction

Deep learning, specifically Transformer-based models like BERT, has revolutionized risk prediction using Electronic Health Records (EHR). However, these models face a fundamental scaling bottleneck: the self-attention mechanism has a quadratic computational complexity ($O(L^2)$) relative to sequence length. In clinical practice, a patient’s journey can span decades and involve thousands of data points, such as diagnoses, lab tests, and medications. Standard Transformers are typically capped at a sequence length of 512 tokens, forcing researchers to truncate data and potentially discard crucial long-term historical dependencies. Hi-BEHRT addresses this "receptive field" limitation to ensure that a model can process the entire patient history without becoming computationally untreatable.

Methods

Hi-BEHRT (Hierarchical BEHRT) employs a two-tier architecture designed to overcome the memory limits of standard models when processing decades of patient medical history.

Comparison of the standard BEHRT architecture and the proposed Hi-BEHRT hierarchical architecture.

The architecture consists of two main components:

  1. Local Feature Extractor: A sliding window segments the full medical history into smaller chunks. A Transformer processes these segments locally to capture short-term temporal interactions, mirroring how clinicians review clusters of events during specific visits.
  2. Feature Aggregator: A second Transformer takes the latent representations from the local level and summarizes them globally to capture long-term dependencies across the entire history.

Unlike previous models, Hi-BEHRT integrates multimodal data, including medications, procedures, lab tests, blood pressure, BMI, and lifestyle factors. To handle the hierarchical latent space where standard Masked Language Modeling is difficult to apply, the authors adapted BYOL (Bootstrap Your Own Latent) for self-supervised pre-training. This technique ensures that two different augmentations (randomly masked or cropped versions) of the same patient record result in similar neural representations.

Results and Discussion

The study utilized the Clinical Practice Research Datalink (CPRD), representing approximately 7% of the UK population, to track 5-year risks for Heart Failure (HF), Diabetes, Chronic Kidney Disease (CKD), and Stroke.

Hi-BEHRT consistently outperformed the previous state-of-the-art (BEHRT), achieving a 1% to 5% absolute increase in AUROC and a 3% to 8% increase in AUPRC across all four diseases. The gains were most pronounced for patients with long medical histories (exceeding 256 tokens), where AUPRC improvements reached up to 11%.

Impact of BYOL pre-training on model performance (AUPRC and AUROC) relative to the percentage of training data used.

A key finding was the effectiveness of the BYOL pre-training strategy for data scarcity. As shown in the performance curves, a Hi-BEHRT model pre-trained with BYOL and fine-tuned on just 1% of labeled data performed as well as a non-pre-trained model using 5% of the data. Ablation studies further revealed that adding lab tests and blood pressure measurements provided a larger performance boost than lifestyle factors, likely due to their higher frequency and clinical precision.

Conclusion

Hi-BEHRT demonstrates that hierarchical architectures can effectively capture long-term clinical dependencies that standard Transformers miss. By segmenting long sequences and employing a novel contrastive pre-training strategy, the model achieves state-of-the-art accuracy while remaining computationally efficient. Future work will focus on improving the interpretability of hierarchical decisions and better integrating low-frequency clinical modalities to further reduce irreducible error.

Summary updated

Abstract

Electronic health records represent a holistic overview of patients' trajectories. Their increasing availability has fueled new hopes to leverage them and develop accurate risk prediction models for a wide range of diseases. Given the complex interrelationships of medical records and patient outcomes, deep learning models have shown clear merits in achieving this goal. However, a key limitation of these models remains their capacity in processing long sequences. Capturing the whole history of medical encounters is expected to lead to more accurate predictions, but the inclusion of records collected for decades and from multiple resources can inevitably exceed the receptive field of the existing deep learning architectures. This can result in missing crucial, long-term dependencies. To address this gap, we present Hi-BEHRT, a hierarchical Transformer-based model that can significantly expand the receptive field of Transformers and extract associations from much longer sequences. Using a multimodal large-scale linked longitudinal electronic health records, the Hi-BEHRT exceeds the state-of-the-art BEHRT 1% to 5% for area under the receiver operating characteristic (AUROC) curve and 3% to 6% for area under the precision recall (AUPRC) curve on average, and 3% to 6% (AUROC) and 3% to 11% (AUPRC) for patients with long medical history for 5-year heart failure, diabetes, chronic kidney disease, and stroke risk prediction. Additionally, because pretraining for hierarchical Transformer is not well-established, we provide an effective end-to-end contrastive pre-training strategy for Hi-BEHRT using EHR, improving its transferability on predicting clinical events with relatively small training dataset.
BibTeX
@article{li2023hi,
  author = {Yikuan Li and Mohammad Mamouei and Gholamreza Salimi Khorshidi and Shishir Rao and Abdelaali Hassaïne and Dexter Canoy and Thomas Lukasiewicz and Kazem Rahimi},
  title = {{Hi-BEHRT: Hierarchical Transformer-based model for accurate prediction of clinical events using multimodal longitudinal electronic health records}},
  journal = {IEEE J. Biomed. Health Informatics},
  year = {2023},
  url = {https://openreview.net/forum?id=MaXRfvEcDNr},
}
Figure