Abstract
Cross-modal retrieval typically relies on two-stream architectures with disparate encoders for image and text, creating an "architectural gap" that hinders alignment. We present Hierarchical Alignment Transformers (HAT), a framework that unifies the underlying architecture using Transformer-based encoders for both modalities. By implementing a multi-level alignment strategy across intermediate network layers, HAT captures fine-grained semantic correspondences from low-level textures to high-level concepts. Evaluated on MSCOCO and Flickr30K, HAT achieves significant performance gains, including a 16.7% relative improvement in text-to-image retrieval on MSCOCO.
Introduction
In cross-modal retrieval tasks, such as searching for an image using a text description, most models utilize a "two-stream" approach: one branch for images and another for text. Historically, these branches have relied on fundamentally different architectures—Convolutional Neural Networks (CNNs) for images and Recurrent Neural Networks (RNNs) or Transformers for text.
This architectural discrepancy serves as a major bottleneck. Because CNNs and Transformers process data differently, they produce feature distributions that are difficult to align in a shared semantic space. Furthermore, traditional models often only compare the final outputs of these encoders, ignoring the rich, multi-level semantic information buried in intermediate layers. HAT addresses these issues by unifying the encoder architecture and introducing a hierarchical alignment strategy.
Methodology
The HAT framework introduces two primary innovations to bridge the gap between vision and language processing:
- Unified Transformer Encoders: HAT employs Transformers for both modalities, specifically using the Swin Transformer for images and BERT for text. By utilizing the same fundamental self-attention mechanism, the model produces representations with similar characteristics, making cross-modal alignment more intuitive.
- Hierarchical Alignment Module: Instead of matching only final global features, HAT aligns three distinct stages of the networks (low, middle, and high-level). It uses a stacked cross-attention mechanism to align "region tokens" from the image with word tokens from the text at each level. This allows the model to capture fine-grained correspondences, such as matching textures in shallow layers and complex contextual semantics in deeper layers.
The framework maintains a two-stream structure, ensuring it remains significantly faster for real-world applications compared to single-stream models that require heavy joint processing for every image-text pair.
Key Results and Evaluation
HAT was evaluated on the MSCOCO and Flickr30K benchmarks. The model outperformed existing state-of-the-art (SOTA) methods by a substantial margin:
- MSCOCO (5K test): Achieved a 7.6% relative improvement in Image-to-Text (Recall@1) and a 16.7% relative improvement in Text-to-Image (Recall@1).
- Flickr30K: Achieved 4.4% (I2T) and 11.6% (T2I) relative improvements in Recall@1.
Ablation studies confirmed that simply switching the image encoder from a CNN (ResNet) to a Transformer (Swin) while keeping the text encoder constant resulted in a significant performance jump, validating the unified architecture hypothesis. The results demonstrate that shallow layers capture static, local entities, while deeper layers capture complex contextual semantics, and aligning these levels separately leads to more robust retrieval.
Discussion and Future Work
While HAT offers superior performance and efficiency compared to single-stream models, the hierarchical cross-attention module introduces more computational complexity than simple global feature dot-products. Additionally, the selection of specific layers for alignment (currently the 4th, 10th, and 12th layers) remains empirical.
Future research could explore automated or learnable methods for selecting the most "alignable" layers. Furthermore, investigating how hierarchical alignment scales with larger Transformer variants (e.g., Swin-Large or BERT-Large) remains an open and promising question for the field.
Summary updated