NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Sparseformer: a Transferable Transformer with Multi-granularity Token Sparsification for Medical Time Series Classification

Jiexia Ye, Weiqi Zhang, Ziyue Li, Jia Li, Fugee Tsung · DOI

Abstract

Classifying medical time series (MedTS) data, such as ECGs and EEGs, presents significant challenges due to multi-scale temporal dependencies, high signal redundancy, and the scarcity of expert-labeled datasets. We present MedSpaformer, a novel Transformer architecture designed for robust and transferable medical classification. By employing a Token-Sparse Dual Attention (TSDA) mechanism and an adaptive label encoder, MedSpaformer effectively filters noise and enables zero-shot transfer across heterogeneous medical datasets. Our results demonstrate state-of-the-art performance across seven public datasets in supervised, few-shot, and zero-shot settings.

Introduction

Medical time series analysis is critical for modern diagnostics, yet it remains a difficult domain for deep learning. Pathological patterns often manifest at varying scales—from millisecond-level spikes to minute-long oscillations—and are distributed across multiple sensors or channels. Furthermore, MedTS data is inherently noisy, containing long stretches of irrelevant information that can dilute diagnostic signals.

Existing models are often "rigid," constrained by fixed signal lengths or a specific number of input channels (e.g., a 12-lead ECG model cannot easily adapt to a 3-lead wearable). This lack of flexibility hinders the transfer of knowledge between datasets. MedSpaformer addresses these issues by introducing a flexible, transferable backbone that leverages domain knowledge to focus on the most informative parts of the signal.

Methodology

The core innovation of MedSpaformer is the Token-Sparse Dual Attention (TSDA) block. This component mimics a physician’s diagnostic process through a two-stage approach:

  1. Global Contextualization: Standard self-attention is used to capture the broad temporal structure of the entire sequence.
  2. Dynamic Refinement (Sparsification): The model utilizes a set of learnable queries, informed by a frozen Language Model (ClinicalBERT), to selectively attend to informative signal segments. This sparsification discards redundant data and compresses variable-length inputs into a fixed-size representation.
The MedSpaformer architecture, featuring the TSDA block and multi-granularity hierarchical encoding.

This TSDA block is embedded within a Multi-granularity Hierarchical Scheme that operates at three levels:

  • Intra-granularity: Captures patterns at different time scales using varying window sizes.
  • Inter-granularity: Models the relationships between these different scales.
  • Cross-channel: Integrates information across sensors while suppressing channel-specific noise.

To enable transferability, an Adaptive Label Encoder uses ClinicalBERT to project textual disease descriptions into a shared latent space. By understanding the semantics of a label (e.g., "Myocardial Infarction") rather than treating it as a discrete integer, the model can perform zero-shot classification on unseen tasks.

Experimental Results

MedSpaformer was evaluated on seven public datasets spanning Alzheimer’s Disease (EEG), Epilepsy (EEG), and Heart Disease (ECG).

Supervised and Few-Shot Performance

MedSpaformer consistently outperformed 13 baseline models, including PatchTST, Crossformer, and Medformer. In few-shot scenarios (e.g., 5-shot or 10-shot), the model maintained a significant performance lead, suggesting that its sparsification mechanism is particularly effective when data is scarce.

Representation Learning

Qualitative analysis via t-SNE visualizations reveals that MedSpaformer learns more discriminative features than traditional models. While baselines like DLinear and FEDformer often produce overlapping clusters for different pathologies, MedSpaformer achieves clear separation between classes such as "Normal ECG" and "Myocardial Infarction."

t-SNE visualization of latent representations across different models, showing superior class separation for MedSpaformer.

Zero-Shot Capabilities

The model demonstrated impressive in-domain zero-shot performance (e.g., training on one Alzheimer's dataset and testing on another). While a performance gap remains for cross-domain transfer (e.g., ECG to EEG), MedSpaformer still outperformed supervised linear models on several tasks without having seen the target domain during training.

Discussion and Conclusion

MedSpaformer proves that "less is more" in medical time series analysis; by intentionally discarding redundant tokens, the model improves both accuracy and transferability. Its architecture-agnostic nature allows it to process varying channel counts and signal lengths without modification, making it a highly practical tool for real-world clinical applications.

Future work will focus on narrowing the cross-domain gap and optimizing the multi-stage attention mechanism for real-time deployment on edge devices. By aligning signal embeddings with clinical language priors, MedSpaformer represents a significant step toward universal medical time series foundation models.

Summary updated

BibTeX
@inproceedings{ye2026sparseformer,
  author = {Jiexia Ye and Weiqi Zhang and Ziyue Li and Jia Li and Fugee Tsung},
  title = {{Sparseformer: a Transferable Transformer with Multi-granularity Token Sparsification for Medical Time Series Classification}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2026},
  doi = {10.1609/aaai.v40i33.40001},
}
Figure