Learning robust representations from electrocardiograms (ECGs) is challenging because repeated cardiac cycles coexist with subtle and sparse diagnostic cues in local morphology and rhythm-level context. Existing ECG foundation models commonly rely on Transformerbased patch encoders with uniformly shared dense refinement pathways, limiting adaptive processing across heterogeneous ECG tokens. We propose HEART (Hierarchical Expert Adaptive Refinement Transformer), an ECG foundation model that introduces stage-specific conditional expert refinement during self-supervised pre-training. HEART places a local-level MoE over patch-level representations before temporal contextualization and a global-level MoE over context-integrated token representations after self-attention. Token-level Top-1 routing allows different patches or contextual tokens within the same ECG to follow different expert pathways. On public ECG benchmarks, HEART achieves strong performance under both linear probing and fine-tuning, with particularly large frozen-encoder gains on PTB-XL Form and Rhythm (+6.76 AUROC points each over the strongest protocol-reproduced baseline). Routing analyses provide qualitative evidence of complementary local and global expert specialization. We release our code and pretrained models at https://anonymous.4open.science/r/HEART-5E9F.
Figures & tables
Figure 1. Overview of HEART. Local-level MoE refines patch embeddings, and global-level MoE refines final encoder tokens.
Dataset
Random Init.
ECGFounder †
SimCLR
CLoCS
COMET
ST-MEM
MAE
CREMA
CREMA-Max
HEART
PTB-XL Super
86.76
91.20
89.24
89.72
90.44
81.49
87.55
91.25
91.05
92.48 (81.73)
PTB-XL Sub
85.40
88.03
87.13
90.43
90.57
78.52
88.10
91.37
92.06
93.96 (54.04)
PTB-XL Form
63.05
82.52
74.75
77.49
75.01
66.25
77.39
80.14
81.58
88.34 (32.68)
PTB-XL Rhythm
86.08
93.61
83.07
86.34
86.00
82.53
87.07
88.92
87.18
95.68 (55.40)
PTB-XL Average
80.32
88.84
83.55
86.00
85.51
77.20
85.03
87.92
87.96
92.62 (55.96)
CPSC2018
74.30
83.18
87.03
90.24
90.28
79.05
87.72
92.78
92.16
96.50 (83.03)
Table 1. Linear-probing performance on PTB-XL and CPSC2018 (AUROC; AUPRC in parentheses where available). Linear classifiers are trained on frozen encoders; PTB-XL Average is the mean over four diagnostic subsets. Non-daggered baselines are protocol-reproduced under our setup. † marks external same-dataset references included only for context and not treated as protocol-matched comparisons. Bold and underline indicate the best and second-best results among protocol-reproduced methods only. CREMA-Max is a parameter-comparable dense CREMA variant.
Dataset
ECGFounder †
SimCLR
CLoCS
COMET
ECGFM †
ECG-FM †
ST-MEM
MAE
CREMA
CREMA-Max
HEART
PTB-XL Super
-
92.28
92.09
92.30
-
-
87.95
92.23
92.86
91.91
92.53 (82.77)
PTB-XL Sub
-
92.04
90.78
92.20
-
-
87.84
91.12
93.35
92.43
93.42 (51.90)
PTB-XL Form
-
84.66
80.43
78.98
-
-
72.98
85.81
87.07
83.70
88.40 (37.32)
PTB-XL Rhythm
-
91.04
91.14
91.88
-
-
90.68
91.29
91.94
90.48
95.09 (60.20)
PTB-XL Average
89.77
90.01
88.84
88.61
88.85
90.29
84.86
90.11
91.31
89.63
92.36 (58.05)
CPSC2018
-
94.33
93.87
94.21
91.91
-
93.20
95.04
95.77
95.05
97.34 (86.17)
Table 2. Fine-tuning performance on PTB-XL and CPSC2018 (AUROC; AUPRC in parentheses where available). For protocol-reproduced models, all parameters are optimized end-to-end. † marks external same-dataset references included only for context and not treated as protocol-matched comparisons. Bold and underline indicate the best and second-best results among protocol-reproduced methods only.
CPSC2018
AUROC
AUPRC
F1-score
Sensitivity (SPEC=0.98)
CREMA
95.77
81.15
76.67
76.44
Local-level MoE
96.30
85.34
79.26
77.45
Global-level MoE
96.04
83.59
77.83
76.78
HEART
97.34
86.17
80.55
79.67
Table 3. MoE placement ablation on CPSC2018 under fine-tuning. CREMA is the dense backbone. Local/Global variants add one MoE at the patch-embedding or context-integrated encoder stage, respectively. HEART uses both local- and global-level MoE modules. Sensitivity is evaluated at specificity = 0.98 .
Figure 2. Expert-count sensitivity on CPSC2018. Cells sweep local/global expert counts with all other settings fixed; AUROC (left) is stable, while AUPRC (right) is more capacity-sensitive.
Model
Params (M)
Size (MB)
Inference (ms)
AUROC
Δ
CREMA
22.09
96.34
3.26
87.92
+0.00
CREMA-Max
177.60
677.50
13.22
87.96
+0.04
HEART
161.83
633.52
9.33
92.62
+4.70
Table 4. Model size and inference cost for a 10-second 12-lead ECG. AUROC is PTB-XL Average under linear probing; Δ denotes the AUROC gain over CREMA. Parameter counts follow the pretrained model configuration; latency uses encoder-forward inference.
Figure 3. UMAP visualization of frozen HEART [CLS] embeddings and the output space of the trained linear-probing classifier on PTB-XL Rhythm.
Figure 4. Patch-wise expert allocation for one ECG example. The top panel overlays the 12-lead ECG waveform, and the lower panels show the Top-1 expert IDs assigned across overlapping temporal patches for the local- and global-level MoE modules. Changes along the temporal axis indicate that different patches or contextual tokens within the same ECG can be routed to different experts.
Figure 5. Jensen–Shannon divergence between expert-utilization distributions across PTB-XL Rhythm labels. For each target label, positive samples are ECGs annotated with that rhythm label, whereas negative samples are ECGs without that target label. Divergence values are computed from patch-aggregated expert-utilization distributions and shown separately for the local- and global-level MoE modules.
Figure 6. Representative ECG patch prototypes for each expert. Each panel shows an actual routed ECG patch selected near the expert-specific centroid, together with its normalized per-lead variance profile. The prototype is a real ECG segment rather than an averaged waveform, and the bar plot summarizes relative lead-wise variation rather than causal attribution.
(a) Local-level MoE utilization
(b) Global-level MoE utilization
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
Component
Hyperparameter
Distribution
Range / Categories
Network
resnet.kernel_size
choice
{3,7,15}
Network
resnet.dropout
choice
{0,0.1,0.2}
Network
resnet.num_blocks
choice
{2,4,8}
Network
encoder_depth
choice
{4,6,8}
Network
encoder_num_heads
choice
{16,32}
Network
decoder_depth
choice
{4,6,8}
Appendix
Table 5. Hyperparameter search space used for HEART.
Electrocardiography (ECG) analysis is crucial for cardiac diagnosis, yet existing foundation models often fail to capture the periodicity and diverse features required for varied clinical tasks. We propose ECG-MoE, a hybrid architecture that integrates multi-model temporal features with a cardiac period-aware expert module. Our approach uses a dual-path Mixture-of-Experts to separately model beat-level morphology and rhythm, combined with a hierarchical fusion network using LoRA for efficient inference. Evaluated on five public clinical tasks, ECG-MoE achieves state-of-the-art performance with 40% faster inference than multi-task baselines.
Yuhao Xu, Xiaoda Wang, Yi Wu +3
Department of Computer Science, Emory University, Atlanta, GA 30307 · School of Computer Science, University of Oklahoma, Norman, OK 73019 · Center of Data Science, Emory University, Atlanta, GA 30307
Tokenization determines both the physiological content presented to an ECG Transformer and the sequence over which attention operates. We compare eight tokenization strategies across Transformer, Informer, Reformer, and FEDformer on the nine-label CPSC2018 classification task. The input projection and principal backbone capacity are controlled to isolate the effect of token construction. Median-beat and HeartLang tokenization achieve mean macro-AUCs of 0.893 and 0.889 across the four backbones, compared with 0.822 and 0.824 for point-wise and patch-wise tokenization. Pooling the two physiology-aware representations yields an 8.2% relative improvement in macro-AUC. They also reduce mean sequence length from 1,250 to 158 tokens and mean peak training memory from 5.21 to 0.27 GB. The results show that aligning tokens with ECG morphology can improve both predictive performance and memory efficiency without increasing backbone capacity. The source code is available on https://github.com/LeeJarvis996/ecg_tokenizer.
Jiawei Li, Fabio Bonassi, Johan Sundström +2
Uppsala University, Uppsala, Sweden · Scilifelab, Uppsala, Sweden
Electrocardiograms (ECGs) are among the most widely available clinical signals and play a central role in cardiovascular diagnosis. While recent foundation models (FMs) have shown promise for learning transferable ECG representations, most existing pretraining approaches treat leads as independent channels and fail to explicitly leverage their strong structural redundancy. We introduce the latent attention masked autoencoder (LAMAE) FM that directly exploits this structure by learning cross-lead connection mechanisms during self-supervised pretraining. Our approach models higher-order interactions across leads through latent attention, enabling permutation-invariant aggregation and adaptive weighting of lead-specific representations. We provide empirical evidence on the Mimic-IV-ECG database that leveraging the cross-lead connection constitutes an effective form of structural supervision, improving representation quality and transferability. Our method shows strong performance in predicting ICD-10 codes, outperforming independent-lead masked modeling and alignment-based baselines.
Moritz Vandenhirtz, Samuel Ruipérez-Campillo, Simon Böhi +6
Department of Computer Science, ETH Zurich, Switzerland · Department of Biomedical Engineering, University of Basel, Switzerland