Standard Vision Transformers (ViTs) process images by slicing them into a flat grid of fixed-size patches (such as $16 \times 16$ pixels) and maintaining this uniform resolution across all self-attention layers. While this design is highly effective at capturing long-range dependencies and global context, it introduces a fundamental resolution dilemma.
For dense prediction tasks like semantic segmentation, object detection, or depth estimation, a fixed patch size acts as a blunt instrument. Small, fine-grained structures and sharp boundaries are collapsed into single token vectors early on, destroying local spatial details. Conversely, forcing every token to attend to every other token uniformly across a high-resolution image creates a massive computational bottleneck, as standard self-attention scales quadratically ($O(N^2)$) with the number of tokens.
To resolve this tension, a powerful paradigm shift has emerged: Hierarchical Vision Transformers. By reintroducing the spatial pyramid structure traditionally used in Convolutional Neural Networks (CNNs), these architectures dynamically balance fine-grained local precision with broad global context.
The Pyramid Structure: Simulating Spatial Inductive Bias
Instead of maintaining a constant token count throughout the network, a hierarchical transformer organizes its computation into multiple distinct stages.
Input Image
│
▼
Stage 1: High Resolution / Small Patches ──► Fine-grained local textures
│ (e.g., 4x4 patches)
▼ [Patch Merging / Downsampling]
Stage 2: Medium Resolution / Medium Patches
│
▼ [Patch Merging / Downsampling]
Stage 3: Low Resolution / Large Patches ──► Broad global semantics
In the initial stages, the network processes high-resolution feature maps using small patch sizes. As features flow deeper into the network, specialized patch-merging or downsampling layers progressively reduce the spatial dimensions while increasing the channel capacity.
As demonstrated by Enze Xie et al. in SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers, this multi-stage design generates a rich hierarchy of feature maps. The early, high-resolution maps preserve the precise geometric boundaries needed for dense pixel labeling, while the deeper, low-resolution maps aggregate the wide-receptive-field context required to understand the overall scene logic.
This structural adaptation bridges the gap between attention-based models and convolutional networks. For example, in remote sensing change detection, Wele Gedara Chaminda Bandara et al. show in A Transformer-Based Siamese Network for Change Detection that a hierarchical encoder allows the model to simultaneously isolate minute structural modifications and broad environmental context, mimicking a CNN's multi-scale extraction capabilities while retaining the long-range modeling strengths of self-attention.
Granularity Control via Variable Patching and Windowing
Processing high-resolution tokens in the early stages of a network requires mechanisms that keep computational costs manageable. Hierarchical architectures achieve this through localized attention windows or variable patch sizes.
One strategy is to vary the patch size dynamically across different stages of the model. In Pixel-Perfect Depth with Semantics-Prompted Diffusion Transformers, Gangwei Xu et al. employ a cascade architecture where early layers process large patches to anchor global, low-frequency structures, while subsequent layers transition to smaller patches to refine high-frequency, fine-grained details.
Another prevalent strategy restricts self-attention to localized, shifted windows rather than the entire image. Sangwon Kim et al. utilize this approach in ViT-NeT: Interpretable Vision Transformers with Neural Tree Decoder to capture features across multiple spatial scales, making it highly effective for isolating small, discriminative regions. Similarly, Reza Azad et al. demonstrate in TransDeepLab: Convolution-Free Transformer-based DeepLab v3+ for Medical Image Segmentation that a pyramid of transformer blocks utilizing varying window sizes ensures that local textures and global structural information are aggregated systematically.
Furthermore, the flexibility of tokenization allows models to break away from uniform square grids entirely. Single-author work by Wu Liu in CAViT: Contextual Alignment Vision Transformer for Video Object Re-identification shows that using multiple patch geometries simultaneously allows a vision transformer to capture features at different aspect ratios and granularities, optimizing the representation of objects with varying proportions.
Tapping into Intermediate Feature Hierarchies
In a standard flat transformer, downstream decoders typically rely only on the tokens emitted by the very last layer. Hierarchical models, by contrast, treat the transformer backbone as a continuous spectrum of abstraction. By extracting feature representations from multiple intermediate layers, downstream tasks gain access to a complete visual hierarchy.
Intermediate Layers ──► Early Stages ──► Low-level geometric details & textures
├──► Mid Stages ──► Mid-level object parts
└──► Late Stages ──► High-level semantic concepts
In identity-preserved image generation, Wei Liu demonstrates in DreamIdentity: Enhanced Editability for Efficient Face-Identity Preserved Image Generation that extracting features from multiple intermediate layers captures both high-level semantic identity and fine-grained facial details. For dense prediction tasks like monocular depth estimation in surgery, Beilei Cui et al. show in Surgical-DINO: Adapter Learning of Foundation Models for Depth Estimation in Endoscopic Surgery that extracting and aggregating features from multiple intermediate layers allows the model to combine high-level semantic information with low-level geometric details, providing the spatial resolution necessary for dense surface reconstruction.
To make these multi-scale transitions fluid, single author Xiangtian Xue introduces trainable patch expanding layers in ST-LDM: A Universal Framework for Text-Grounded Object Generation in Real Images. This allows for adaptable compression scales during feature extraction, maintaining high-fidelity latent representations across varying levels of granularity.
Why It Works: Inductive Bias Meets Global Reasoning
The core reason hierarchical vision transformers outperform flat architectures on dense spatial tasks comes down to how they manage computational complexity and spatial inductive bias.
As noted by Bin Xie et al. in SED: A Simple Encoder-Decoder for Open-Vocabulary Semantic Segmentation, replacing plain vision transformers with hierarchical backbones introduces a spatial inductive bias that naturally captures local textures and fine-grained details. Crucially, because the token count is systematically reduced in deeper layers via downsampling, these models maintain a linear or sub-quadratic computational complexity relative to image resolution.
By structuring the transformer as a multi-scale pyramid, the architecture eliminates the forced trade-off between spatial precision and global context, allowing self-attention to operate efficiently at every level of visual abstraction.