[KongchangAI]
· 3 min read· 1,557 words

HEART: Hierarchical Expert Adaptive Refinement Transformer — A New Breakthrough in ECG Representation Learning

HEART: Hierarchical Expert Adaptive Refinement Transformer — A New Breakthrough in ECG Representation Learning

HEART improves ECG self-supervised pretraining with hierarchical MoE and token-level Top-1 routing, significantly boosting frozen-encoder AUROC.

The paper proposes HEART, an ECG foundation model that addresses the uniform dense refinement of all tokens in existing Transformers, which struggles to capture sparse diagnostic cues. It introduces hierarchical mixture of experts (MoE) during self-supervised pretraining: a local-level MoE processes patch representations before temporal modeling to capture morphological features, and a global-level MoE processes context tokens after self-attention to model rhythm patterns, with token-level Top-1 routing enabling sparse conditional computation. On PTB-XL's Form and Rhythm tasks, linear probing with frozen encoders improves AUROC by 6.76 percentage points each over the strongest baseline, and fine-tuning is also strong. Routing analysis confirms complementary specialization between local and global experts, and code and models are open-sourced.

Automated analysis of electrocardiograms (ECGs) is crucial in clinical diagnosis, but enabling models to learn robust representations from cardiac signals has long been a challenge. Cardiac cycles repeat continuously, while key diagnostic cues are sparsely hidden within local morphology and rhythm context. Most existing ECG foundation models adopt Transformer patch encoders and process all tokens through a uniformly shared dense refinement path, which limits the model's ability to adaptively process different ECG tokens. Recently, a paper titled "HEART: Hierarchical Expert Adaptive Refinement Transformer for ECG Representation Learning" proposed a new ECG foundation model, HEART, which achieves significant improvements on multiple public benchmarks by introducing hierarchical expert adaptive refinement.

HEART paper title screenshot

Limitations of Existing ECG Foundation Models

Current mainstream ECG foundation models are typically based on the Transformer architecture: they segment ECG signals into patches, feed them into an encoder, and refine the representations using a unified dense network during self-supervised pretraining. While this design is general-purpose, it ignores the fact that different segments of an ECG signal vary enormously in importance. Some regions contain critical diagnostic waveforms (such as ST-segment changes or QRS complex abnormalities), while others are relatively flat. Processing all tokens with the same set of parameters makes it difficult for the model to specifically capture sparse but important diagnostic cues.

Moreover, ECG local morphological features and global rhythm context require different handling. Local morphology determines the details of individual heartbeats, while rhythm context concerns the temporal relationships between heartbeats. Existing models often mix and process these two types of information within the same network layer, lacking a divide-and-conquer mechanism.

Mixture of Experts (MoE) and Sparse Activation: MoE is a conditional computation architecture consisting of multiple "expert" subnetworks and a router. The router decides which experts to activate based on the input (usually activating only a few), thereby greatly expanding model capacity without significantly increasing computation. Unlike dense models where every input passes through all parameters, MoE achieves "more parameters, less compute." In Transformers, MoE often replaces the feed-forward layer, with each token routed independently. HEART applies MoE to ECG patch and context tokens, leveraging exactly this property: different ECG segments can take different expert paths, and sparse activation maintains efficiency.

HEART's Core Design: Hierarchical Expert Adaptive Refinement

The key innovation of HEART lies in introducing stage-specific conditional expert refinement during self-supervised pretraining. Specifically, the model embeds Mixture-of-Experts (MoE) modules at two locations:

  • Local-level MoE: Before patch-level representations enter temporal context modeling, they first pass through a local-level MoE. This allows each patch to select the most suitable expert based on its own content, thereby better capturing local morphological features.
  • Global-level MoE: After the self-attention layer, a global-level MoE is applied to the token representations that have fused contextual information. At this point, each token already contains temporal context, and global experts can refine rhythm-level patterns.

This hierarchical design enables the model to handle local and global information separately at different stages, rather than pressing all tasks onto the same set of parameters.

Token-Level Top-1 Routing

HEART adopts a token-level Top-1 routing strategy: for each patch or context token, the router selects the single expert with the highest probability. This means different segments within the same ECG signal can activate different expert paths. For example, a patch containing an abnormal QRS wave may be routed to an expert skilled in morphological analysis, while a token reflecting rhythm changes may select an expert skilled in temporal patterns. This sparse activation mechanism both increases model capacity and maintains computational efficiency.

Top-1 Routing and Load Balancing: Top-1 routing means the router selects only the single expert with the highest probability for each token, the sparsest strategy in MoE. Compared with Top-2 or dense routing, Top-1 incurs the least computational overhead, but during training it is prone to "winner-takes-all" — a few experts are overused while the rest sit idle. Therefore, practical implementations usually introduce a load balancing loss to encourage the router to distribute tokens evenly among experts. HEART's adoption of Top-1 routing relies on such auxiliary losses to ensure expert utilization; otherwise, expert specialization could degenerate into dominance by a few experts. Understanding this helps assess the credibility of the expert division of labor in its routing analysis.

Training and Evaluation

HEART uses the above MoE structure during self-supervised pretraining, and can be evaluated on downstream tasks via linear probing or fine-tuning. In linear probing, the parameters of the pretrained encoder are frozen and only a linear classifier is trained, which tests the generality of the representations; fine-tuning allows the entire model to adapt to a specific task.

Linear Probing and Fine-Tuning: Linear probing is a common protocol for evaluating the quality of self-supervised representations: all parameters of the pretrained encoder are frozen, and only a linear classifier is trained on its output features. Because the classifier has extremely low capacity, performance depends almost entirely on the separability of the features themselves, thus testing the generality and transferability of the representations. Fine-tuning, in contrast, unfreezes the encoder and allows all parameters to update with the downstream task, usually yielding higher performance but depending more on the amount of task data. Comparing the two reveals how much "general knowledge" pretraining has learned and how much "task-specific adjustment" the downstream task requires. HEART reports improvements under both settings, indicating that its gains are not merely compensated by fine-tuning.

Experimental Results: Substantial Gains with Frozen Encoders

The paper conducted extensive experiments on public ECG benchmarks. On the Form and Rhythm tasks of the PTB-XL dataset, HEART improved AUROC by 6.76 percentage points each under the frozen-encoder (linear probing) setting compared with the strongest protocol-reproduced baseline. This magnitude of improvement is considerable in ECG representation learning, indicating that the features learned by HEART have stronger generalization ability.

Under the fine-tuning setting, HEART also performs excellently, demonstrating the robustness of its pretrained representations. Interestingly, these improvements were achieved without increasing downstream task complexity — the model simply makes the encoder itself more powerful through a smarter pretraining strategy.

PTB-XL and AUROC: PTB-XL is a public large-scale 12-lead ECG dataset containing about 20,000 records, with annotations spanning multiple levels including diagnostic, Form, and Rhythm. The Form task focuses on waveform morphology abnormalities (such as ST-T changes and QRS morphology), while the Rhythm task focuses on rhythm types (such as sinus rhythm and atrial fibrillation). AUROC (area under the receiver operating characteristic curve) measures the ranking ability for binary/multi-label classification, ranging from 0.5 for random to 1.0 for perfect, and is insensitive to class imbalance, hence commonly used in medical signal evaluation. Improvements of 6.76 percentage points in AUROC on Form and Rhythm respectively mean a substantive improvement in the model's ability to rank and distinguish positive from negative samples, rather than mere accuracy fluctuations from threshold adjustment.

Routing Analysis: Experts Indeed Have Distinct Specialties

To understand whether the MoE modules truly learned meaningful specialization, the authors analyzed routing decisions. Qualitative results show that local and global experts indeed exhibit complementary specialization patterns: local experts tend to focus on morphological details (such as waveform shape), while global experts focus more on rhythm and temporal relationships. This division of labor aligns with the design intent and provides interpretability evidence for the model's performance gains.

Implications for the Development of ECG Foundation Models

HEART's work shows that in ECG representation learning, simply scaling up models or adding data is not always the optimal solution. By introducing conditional computation and expert routing, the model can allocate capacity more effectively, letting different parameter subsets focus on different types of features. This approach aligns with the MoE trend in natural language processing and computer vision, but is still novel in the ECG domain.

For clinical ECG analysis, HEART's potential value lies in its generalization ability. The substantial gains of frozen encoders under linear probing imply that in the future, it may be possible to pretrain once and then quickly deploy on multiple downstream tasks (such as arrhythmia classification and morphological abnormality detection) without requiring large amounts of task-specific annotated data. This is particularly important in the medical field, where annotation costs are high.

Currently, the authors have open-sourced the code and pretrained models (links in the original article), which will promote further community research on ECG foundation models. In the future, how to extend HEART to multi-lead and multimodal scenarios (such as combining with electronic medical records), and how to reduce the additional memory overhead brought by MoE, are directions worth exploring.

One-line Summary

HEART improves ECG self-supervised pretraining with hierarchical mixture of experts and token-level Top-1 routing, significantly boosting AUROC with frozen encoders.

Paragraph Summary

The paper proposes an ECG foundation model, HEART, addressing the problem that existing Transformer models apply uniform dense refinement to all tokens and struggle to capture sparse diagnostic cues. It introduces hierarchical mixture of experts (MoE) during self-supervised pretraining: a local-level MoE processes patch representations before temporal modeling to capture morphological features, and a global-level MoE processes context tokens after self-attention to model rhythm patterns, with token-level Top-1 routing enabling sparse conditional computation. On the Form and Rhythm tasks of PTB-XL, linear probing with frozen encoders improves AUROC by 6.76 percentage points each over the strongest baseline, and fine-tuning is also strong. Routing analysis confirms that local and global experts form complementary specialization, and the code and models are open-sourced.

#ECG representation learning#HEART model#Mixture of Experts#self-supervised pretraining#PTB-XL#AUROC#Transformer
Share:

Related articles