arXiv:2610.33964cs.LGOct 2026

Manuscript Offprint

arXiv:2610.33964

QECGBERT: A Scalable ECG Foundation Model Based on Self-Supervised Language Learning via VQ-VAE Waveform Tokenization

Aruna Mohan, Burcu Ozek, Or Zilbershot, Fatemeh Afghah

ABSTRACT

AI foundation models play a pivotal role in advancing heart disease diagnosis from electrocardiogram (ECG) data, particularly for rare diseases where the lack of sufficient labeled data hinders supervised learning. However, most self-supervised learning methods treat ECGs as generic sequence or image data without exploiting underlying physiological structure. To address this limitation, we propose QECGBERT, a self-supervised ECG language model that explicitly encodes physiological semantics by tokenizing the P, QRS, T, and isoelectric background waveforms. Vector-quantized variational autoencoder (VQ-VAE) tokenization is applied to each 12-lead ECG, with tokens enriched by continuous waveform features to preserve morphology lost during quantization without increasing sequence length. This design enables compact BERT masked language modeling with short sequences, improving scalability and reducing computational cost relative to long-sequence approaches. QECGBERT applies BERT pre-training to the MIMIC-IV dataset containing over 800,000 unlabeled ECG recordings, and fine-tuning on labeled PTB-XL, CPSC2018, and Chapman–Shaoxing–Ningbo datasets for evaluation. The results demonstrate that QECGBERT achieves comparable or superior performance to published benchmarks, offering a scalable, physiologically aware approach to ECG foundation modeling for cardiac diagnosis.

Index Terms— Electrocardiogram (ECG), Self-Supervised Learning, Representation Learning, Heart Disease Diagnosis.

1. INTRODUCTION

Electrocardiograms (ECG) are a crucial non-invasive tool for monitoring and diagnosing cardiovascular disease. AI foundation models trained on ECG signals are increasingly vital for enabling large-scale diagnostic support [1]. Their impact is particularly significant for rare cardiac conditions, where the paucity of labeled data constrains fully supervised approaches and underscores the need for self-supervised pretraining on large unlabeled ECG corpora to learn robust physiological representations.

ECG self-supervised learning (SSL) methods generally utilize contrastive or generative approaches. Contrastive methods [2] learn discriminative ECG features by distinguishing between positive and negative pairs, though poor pair selection may obscure key morphology [3]. The recent ECG-CPC model applied contrastive predictive coding to state-space models, better capturing temporal dependencies [4]. Multimodal contrastive learning has shown promise in zero-shot ECG classification [5, 6]. However, these models are predicated on textual ECG reports, which are often sparse.

Generative ECG SSL models learn by reconstructing original signals from their masked versions [7, 8]. Recent examples include ST-MEM [9], which patchified ECGs and reconstructed masked patches for 12-lead sequences, and HeartLang [10], which tokenized heartbeats based on QRS waveforms to generate 12-lead sequences. These models relied on long, costly sequences for masked token prediction. More recently, ECG2TOK [11] has demonstrated strong performance via self-distillation and online clustering of patchified 12-lead ECG data for masked sequence modeling. A different approach pioneered by ECGBERT [12] clustered P, QRS, T, and background waveforms from ECGs into vocabulary tokens. RhythmBERT [13] applied clustering to latent representations rather than raw waveforms to improve scalability, using lead II only. However, RhythmBERT decoupled clustering from autoencoder training, and its reliance on lead II alone left cross-lead morphology unaddressed.

In this work, we propose QECGBERT, a scalable self-supervised ECG language model that explicitly encodes physiological semantics by tokenizing the P, QRS, T, and isoelectric background waveforms of 12-lead ECGs, pre-trained on the MIMIC-IV dataset containing over 800,000 unlabeled ECGs. Our contributions are: (1) We apply vector-quantized variational autoencoder (VQ-VAE) tokenization [14] to each waveform, jointly learning the encoder and discrete codebook for each 12-lead segment type. This yields a compact, physiologically grounded wave vocabulary. (2) We enhance the discrete token embeddings with additional embeddings that capture intra-cluster variations, using either the latent waveform representations from the trained segment encoder or the untrained ROCKET model [15]. These complementary features retain waveform differences lost during quantization without increasing sequence length. (3) We pre-train a BERT transformer via masked language modeling (MLM) over short waveform sequences, improving scalability and

Figure

Fig. 1: An overview of our proposed QECGBERT model.

computational efficiency compared to long-sequence modeling. (4) We evaluate QECGBERT on multi-labeled PTB-XL, CPSC2018, and Chapman–Shaoxing–Ningbo datasets, demonstrating performance comparable or superior to published benchmarks despite using short sequences.

References (25)