Nested Hierarchical Transformer: Towards Accurate, Data-Efficient and Interpretable Visual Understanding

Zizhao Zhang, Han Zhang, Long Zhao, Ting Chen, Sercan Ö. Arik, Tomas Pfister

Introduction

Vision Transformers (ViT) have significantly advanced computer vision, yet they often face a "data tax" and a "compute tax." Standard ViTs lack the inductive biases—such as locality and translation equivariance—that make Convolutional Neural Networks (CNNs) effective, necessitating massive datasets for pre-training. Furthermore, global self-attention is computationally expensive for high-resolution images.

The Nested Hierarchical Transformer (NesT) addresses these limitations by nesting standard transformer blocks and connecting them through a simple, convolution-based aggregation function. This approach achieves state-of-the-art accuracy while remaining remarkably data-efficient—performing well even on small datasets like CIFAR—and introduces a novel "tree-traversal" method for interpreting model decisions.

Architecture and Methods

The core innovation of NesT is its hierarchical nesting strategy. Instead of a single global transformer, the model processes small, non-overlapping image blocks independently using canonical transformer layers.

  1. Hierarchical Nesting: The model begins with numerous small blocks. As the network deepens, groups of four spatially adjacent blocks are merged into a single larger block, creating a tree-like hierarchy.
  2. Block Aggregation: To facilitate communication between blocks, NesT employs a "Block Aggregation" step. Features are "unblocked" into a 2D image plane, processed via a $3 \times 3$ convolution and max pooling, and then "re-blocked" for the next level. This introduces spatial priors and local information exchange without altering the core self-attention mechanism.
  3. GradCAT (Gradient-based Class-Aware Tree-traversal): The hierarchical structure allows for a unique interpretability method. By tracing classification decisions from the root down to the leaf patches, researchers can visualize exactly which image regions contribute to a specific prediction.
NesT architecture overview and pseudo-code demonstrating the nesting and aggregation process.

Key Insights

  • The Image Plane Advantage: Performing aggregation on the holistic image plane (rather than just token sequences) naturally introduces spatial priors that transformers typically lack.
  • Decoupling Learning and Abstraction: Transformer layers focus on local feature learning, while aggregation layers handle global abstraction. This separation enhances both convergence speed and interpretability.
  • Efficiency and Convergence: NesT-B reaches 82.3% accuracy on ImageNet in 100 epochs, significantly faster than many contemporary models that require 300 epochs to reach similar performance.

Experimental Results

NesT demonstrates superior performance across various benchmarks:

  • ImageNet Accuracy: NesT-B achieves 83.8% Top-1 accuracy on ImageNet-1K with 68M parameters, outperforming the original ViT and Swin Transformer at similar scales.
  • Data Efficiency: On CIFAR-10, a compact NesT (6M parameters) achieved 96% accuracy trained from scratch. This is a significant win, as standard transformers typically struggle on small datasets without extensive pre-training.
  • Generative Performance: The Transposed NesT decoder is 8 times faster than previous state-of-the-art transformer generators while producing higher-quality images.
  • Interpretability: NesT CAM (Class Activation Mapping) provides cleaner, more localized visualizations compared to ResNet or DeiT, effectively identifying semantically relevant features (e.g., the head of a bird) while ignoring background noise.
Comparison of saliency maps across different architectures. NesT CAM shows superior localization of relevant features compared to ResNet50 GradCAM++ and DeiT Rollout.

Conclusion

NesT simplifies the hierarchical vision transformer by moving complexity out of the attention mechanism and into a simple spatial aggregation function. This results in a model that is easier to implement, faster to train, and more interpretable. Future work involves extending this nested hierarchy to non-grid domains like video and natural language processing, where hierarchical relationships are equally vital.

Summary updated

BibTeX
@inproceedings{zhang2022nested,
  author = {Zizhao Zhang and Han Zhang and Long Zhao and Ting Chen and Sercan Ö. Arik and Tomas Pfister},
  title = {{Nested Hierarchical Transformer: Towards Accurate, Data-Efficient and Interpretable Visual Understanding}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i3.20252},
}
Figure