MHSAN: Multi-Head Self-Attention Network for Visual Semantic Embedding

Geondo Park, Chihye Han, Daeshik Kim, Wonjun Yoon

Abstract

This paper introduces the Multi-Head Self-Attention Network (MHSAN), a novel approach for visual-semantic embedding (VSE) that represents images and sentences as collections of diverse semantic components. By utilizing multiple attention heads and a diversity regularization loss, MHSAN captures the multi-faceted nature of visual and textual data without the need for computationally expensive object proposals. The model achieves state-of-the-art results on the MS-COCO and Flickr30K benchmarks, demonstrating significant improvements in image-text retrieval tasks.

Introduction

Visual-Semantic Embedding (VSE) aims to map images and text into a shared mathematical space where semantically similar items are positioned closely together. Traditional "two-path" models often collapse the rich, multi-faceted information of an image or a complex sentence into a single vector, leading to a loss of detail. While some recent approaches use cross-attention to focus on specific regions, they frequently rely on pre-trained object detectors like Faster R-CNN, which are limited by fixed object categories and high computational costs. MHSAN addresses these challenges by employing a self-attention mechanism that discovers important semantic regions and words purely through training signals.

The MHSAN Architecture

The MHSAN framework consists of two parallel paths for feature extraction and a joint embedding space for similarity measurement.

MHSAN Architecture Overview

Feature Extraction

  • Images: A ResNet-152 backbone is used to extract spatial feature maps ($V$). These maps are flattened into a sequence of vectors ($V_f$) representing different spatial locations.
  • Text: Sentences are processed using word embeddings followed by Simple Recurrent Units (SRU). Unlike standard RNN approaches that use only the final hidden state, MHSAN retains all hidden states ($H$) to preserve the context of every word.

Multi-Head Self-Attention

Instead of a single attention filter, MHSAN employs $r$ "heads" (typically 10). Each head learns to focus on different semantic components. For an image, one head might attend to a specific object, while another focuses on the background or a secondary subject. The resulting attention weight vectors ($M$ for images, $Q$ for text) are used to compute weighted sums of the features, creating an embedding matrix ($F$ for images, $G$ for text).

Diversity Regularization

A key innovation in MHSAN is the Diversity Loss ($Loss_D$). Without this constraint, multiple attention heads might converge on the same prominent features. The diversity loss penalizes overlap between the attention maps of different heads, forcing the network to seek out distinct and diverse semantic components across the scene or sentence.

Experimental Results

MHSAN was evaluated on the MS-COCO and Flickr30K datasets, setting new state-of-the-art records at the time of publication:

  • Flickr30K: The model achieved a 25.4% relative increase in Sentence Retrieval (R@1) and a 27.5% increase in Image Retrieval (R@1) over previous leading methods.
  • MS-COCO: On the challenging 5K test set, MHSAN reached an R@1 of 49.3 for sentence retrieval, significantly outperforming the previous best of 42.8.

Visualizing Attention

The interpretability of MHSAN is a major advantage. By visualizing the attention maps, we can see how the model prioritizes specific regions or words to make a match.

Attention Map Comparison

As shown in the visualization, standard spatial pooling often results in a "blurred" focus across the scene. In contrast, even a single head of the MHSAN attention mechanism provides more localized and relevant focus on key semantic elements, such as the person riding the bicycle. When expanded to multiple heads, the model can simultaneously pinpoint several distinct objects, such as the train and the rider.

Conclusion

MHSAN demonstrates that multi-head self-attention is a powerful tool for visual-semantic embedding. By forcing the model to look at data from multiple perspectives and regularizing for diversity, MHSAN captures complex relationships between images and text more effectively than single-vector or object-proposal-based methods. Future work may explore inter-modal attention mechanisms where textual and visual heads interact earlier in the encoding process.

Summary updated

BibTeX
@inproceedings{park2020mhsan,
  author = {Geondo Park and Chihye Han and Daeshik Kim and Wonjun Yoon},
  title = {{MHSAN: Multi-Head Self-Attention Network for Visual Semantic Embedding}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2020},
  url = {https://openreview.net/forum?id=nuOhtVaLj0},
}
Figure