Papers
Topics
Authors
Recent
Search
2000 character limit reached

SparseFormer: Efficient Sparse Transformer Models

Updated 30 June 2026
  • SparseFormer is a family of transformer architectures that uses a fixed set of learnable latent tokens and sparse attention to efficiently represent high-dimensional data.
  • It combines focusing transformer stages for token refinement with cortex transformer stages to achieve competitive accuracy (e.g., up to 82.6% top-1 on ImageNet) while reducing compute and memory usage.
  • Applied across vision, depth completion, and medical time series, SparseFormer can be bootstrapped from foundation models to enhance transferability and training efficiency.

SparseFormer is a family of sparse attention-based transformer architectures developed for efficiency and performance across vision, depth completion, and medical time series domains. All approaches share the core principle of representing complex high-dimensional data with a small number of informative, learnable latent tokens while leveraging sparse or dual-attention mechanisms. By limiting the number of tokens participating in the main self-attention computation, SparseFormer achieves reduced memory and computational requirements with minimal loss—or, in some domains, gains—in predictive accuracy.

1. Fundamental SparseFormer Architectures and Principles

SparseFormer fundamentally departs from dense paradigms (e.g., standard ViTs and CNNs) by processing only a fixed, limited set of tokens corresponding to salient regions of interest (RoIs) within the data. This is motivated by the biological plausibility of sparse visual recognition, where only a small subset of the perceptual field drives decision-making (Gao et al., 2023), and by application-specific requirements such as the extreme sparsity of measurable data (e.g., sparse landmarks in SLAM-derived 3D maps (Warburg et al., 2022)) or the need to compress biomedical signals (Ye et al., 19 Mar 2025).

Key architectural elements include:

  • Latent tokens: Each token tit_i carries both an embedding vector and a parameterized region of interest (b_i for images/videos; learned queries for time series).
  • Sparse sampling: Features are sampled from patch regions or irregular locations (e.g., within 3D RoIs or time series segmentations) and projected to token embeddings.
  • Attention mechanisms: Either self-attention over tokens (vision, video) or dual attention blocks (feature refinement after global modeling in time series).
  • Iterative refinement: RoIs or token queries are iteratively updated, allowing tokens to focus sequentially on more precise or relevant segments.

This design is instantiated in vision classification (Gao et al., 2023), visual bootstrapping (Gao et al., 2023), depth completion (Warburg et al., 2022), object detection in wide-field images (HRW shots) (Li et al., 11 Feb 2025), and hierarchical time series analysis (Ye et al., 19 Mar 2025).

2. SparseFormer in Vision: Sparse Token Representation and Training

SparseFormer for image classification represents an input as NHWN \ll H \cdot W latent tokens, each with an associated RoI. Tokens are initialized (e.g., in a grid or at learned positions) and each is updated through a “focusing transformer” stage, which alternates between RoI adjustment, sparse feature sampling, channel and spatial mixing, and token-level self-attention. This is followed by a “cortex transformer” stage: a standard transformer encoder processing only the NN tokens (Gao et al., 2023):

  • Token initialization: Uniform grid placement for RoIs; learnable random initialization for embeddings.
  • Sparse feature sampling: Bilinear interpolation at learned offsets within the RoI; e.g., PP sampling points per token, yielding O(NPC)O(NPC) cost independent of image size.
  • Adaptive feature decoding: Each token’s sampled region is adaptively mixed in channel and spatial dimensions, and fused to update the embedding.
  • Iterative RoI adjustment: Tokens predict deltas (tx,ty,tw,th)(t_x, t_y, t_w, t_h) and refine their location/scales.

Classification heads are standard: pooled tokens are passed through a classifier. Complexity is drastically reduced compared to dense ViTs, producing throughputs up to 1.3K images/sec (Tiny, 49 tokens) vs. 726 (Swin-T). SparseFormer attains ImageNet-1K top-1 accuracy of 81.0% (Tiny), 82.0% (Small), and 82.6% (Base), closely approaching or exceeding equivalently-sized dense models but at much lower FLOPs and parameter counts (Gao et al., 2023).

3. Bootstrapping SparseFormer from Foundation Models and Multimodal ViTs

SparseFormer architectures can be efficiently derived (“bootstrapped”) from large-scale pre-trained ViTs or CLIPs (Gao et al., 2023). Only the lightweight focusing transformer is trained from scratch; the remainder of the model inherits weights from a strong foundation model. The bootstrapping protocol involves:

  • Truncating the low-level blocks of a pre-trained encoder and replacing them with the focusing transformer.
  • Reusing the higher-level blocks as a fixed (or partially fine-tuned) cortex transformer.
  • Alignment training: Only a cosine alignment loss is minimized between the SparseFormer [CLS] embedding and that of the foundation model on unlabeled images (no labels, captions, or cross-entropy).
  • Token inflation: After initial alignment, increasing the number of tokens and further fine-tuning to approach the teacher’s performance.

Empirical results show that for IN-1K, bootstrapped SparseFormer inherited from AugReg-ViT-L/16 achieves 84.5% top-1 accuracy (with 49 tokens, 11.4G FLOPs, 1557 img/s) vs. the teacher’s 85.8% (61.6G FLOPs, 388 img/s). CLIP-bootstrapped SparseFormers maintain most zero-shot performance (e.g., IN-1K@1=73.6% for SF-L_CLIP, 64 tokens) while cutting compute and token count by 3–4×. The language-aligned SparseFormer can be directly substituted into multimodal LLMs (e.g., LLaVa) without LLM re-training, reducing LLM sequence length and compute (Gao et al., 2023).

4. SparseFormer in Sparse Depth Completion

The SparseFormer block for depth completion (fusing sparse 3D landmarks and RGB images) employs transformers to interpolate and denoise sparse geometric signals (Warburg et al., 2022):

  • Dual input: An RGB image IRH×W×3I \in \mathbb{R}^{H \times W \times 3} and a sparse set of 3D landmarks (typically N300N \sim 300, density <0.1%<0.1\%).
  • Positional encoding: 2D sinusoidal codes are appended to feature maps.
  • Global attention: A single or multi-head attention mechanism blends the NN landmarks to estimate every pixel’s depth; per-pixel weights are computed as NHWN \ll H \cdot W0, where NHWN \ll H \cdot W1 with NHWN \ll H \cdot W2 from landmarks and NHWN \ll H \cdot W3 from the dense feature map.
  • Outlier filtering: A refinement transformer operates on the NHWN \ll H \cdot W4 landmark features plus depths, learning to suppress outliers by inter-landmark self-attention.

SparseFormer achieves state-of-the-art or competitive depth completion accuracy on NYU Depth-v2 and MPSD. It outperforms NLSPN on ablation for very sparse points and shows robust recovery where prior methods collapse at extremely low N. The model’s limitations include NHWN \ll H \cdot W5 memory requirements and handling only static (not dynamic) inputs (Warburg et al., 2022).

5. Medical Time Series SparseFormer: Multi-granularity, Dual-attention, and Adaptive Labeling

SparseFormer is adapted to medical time series (MedTS) by a hierarchical architecture that addresses variable granularity, inter-channel correlation, feature redundancy, and label scarcity (Ye et al., 19 Mar 2025):

  • Parallel encoder structure: A time-series encoder produces a fixed-length embedding NHWN \ll H \cdot W6; an adaptive label encoder embeds class label texts (NHWN \ll H \cdot W7) into the same latent space for contrastive classification.
  • Multi-granularity token embedding: Each channel is partitioned into patches at multiple scales; each is embedded to NHWN \ll H \cdot W8 dimensions with positional codes.
  • Token-Sparse Dual-Attention (TSDA): Each stage applies global self-attention, followed by a sparsifying attention layer with learnable query vectors, reducing the sequence to NHWN \ll H \cdot W9 representative tokens.
  • Cross-channel encoding: TSDA fuses inter-channel structure and compresses to a fixed set of prototype tokens.
  • Contrastive loss: Output and label embeddings are aligned with a contrastive cross-entropy objective, facilitating zero-shot and few-shot transfer.

SparseFormer (“ZeroT”) outperforms 12 baselines across seven datasets (e.g., macro-F1=0.715). The design achieves strong results even with only five labeled samples per class and supports in-domain and cross-domain zero-shot diagnosis, demonstrating robustness and transferability (Ye et al., 19 Mar 2025).

6. Comparative Analysis and Empirical Results

Across application domains, SparseFormer delivers competitive or superior performance with substantially improved efficiency, as summarized in the following empirical comparisons:

Application Model/Setting Accuracy/F1 Throughput FLOPs/Params
Vision (IN-1K) SparseFormer-Tiny (49 tokens) 81.0% 1270 img/s 2.0G / 32M
Vision (Foundation) SF-L (49 tokens, bootstrapped) 84.5% 1557 img/s 11.4G / 213M
Depth Completion NYUv2 SparseFormer (N=32) REL=0.050
Depth Completion MPSD SparseFormer REL=0.011
MedTS (EEG/ECG) SparseFormer ZeroT (macro-F1) 0.715

Multiple ablations confirm key design choices:

  • Increased number of tokens improves accuracy but raises compute (e.g., Tiny: 49 tokens gives 81.0%, 81 gives 81.9%).
  • Repeats of the focusing transformer (up to 4) provide accuracy gains without significant compute increase; performance saturates beyond 4 (Gao et al., 2023).
  • Adaptive decoding and early convolution substantially improve convergence and accuracy compared to static or linear alternatives.
  • SparseFormer degrades gracefully as N decreases, unlike local diffusion models, supporting operation in extreme-sparsity regimes (Warburg et al., 2022).
  • In MedTS, removal of multi-granularity, channel attention, or adaptive label encoder each contributes to a distinct decrease in macro-F1 (Ye et al., 19 Mar 2025).

7. Strengths, Limitations, and Research Directions

Advantages:

  • Computational complexity is governed by token count (NN0), not by input size, with efficient sparse sampling and minimal self-attention overhead.
  • End-to-end differentiable and extensible to classification, detection, segmentation, and video modeling.
  • Transfer learning is facilitated by bootstrapping from pretrained foundation models, requiring only unlabeled data and no labels/captions for alignment.
  • In MedTS, hierarchical encoding with dual-attention and adaptive labeling enables cross-dataset/zero-shot generalization.

Limitations and Open Questions:

  • Fixed NN1 may not capture fine-detailed or highly crowded regions; an adaptive or data-driven token allocation is desirable (Gao et al., 2023).
  • Gradients for RoI adjustment (vision) or token queries (time series) can be noisy; better instability mitigation is needed.
  • Memory cost grows with token count and, for depth completion, with NN2, limiting scaling to large images or dense landmarks (Warburg et al., 2022).
  • Hyperparameters (token number, granularity levels, cross-attention depth) are manually chosen and may be suboptimal for new domains (Ye et al., 19 Mar 2025).

Future research directions include dynamic token allocation/pruning, combining sparse tokens with dense patch-based representations, unsupervised or self-supervised training regimes, domain-specific label embedding/fine-tuning, efficient decoding mechanisms (e.g., MLP-Mixtures), and online SLAM-style incremental updating (Gao et al., 2023, Gao et al., 2023, Ye et al., 19 Mar 2025).

SparseFormer represents a significant advancement in the design of efficient and transferable transformer-based models for sparse and structured data, with documented empirical benefits across vision, depth, and medical time series tasks (Gao et al., 2023, Warburg et al., 2022, Gao et al., 2023, Ye et al., 19 Mar 2025).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to SparseFormer.