Abstract
Self-attention (SA) network has shown profound value in image captioning. In this paper, we improve SA from two aspects to promote the performance of image captioning. First, we propose Normalized Self-Attention (NSA), a reparameterization of SA that brings the benefits of normalization inside SA. While normalization is previously only applied outside SA, we introduce a novel normalization method and demonstrate that it is both possible and beneficial to perform it on the hidden activations inside SA. Second, to compensate for the major limit of Transformer that it fails to model the geometry structure of the input objects, we propose a class of Geometry-aware Self-Attention (GSA) that extends SA to explicitly and efficiently consider the relative geometry relations between the objects in the image. To construct our image captioning model, we combine the two modules and apply it to the vanilla self-attention network. We extensively evaluate our proposals on MS-COCO image captioning dataset and superior results are achieved when comparing to state-of-the-art approaches. Further experiments on three challenging tasks, i.e. video captioning, machine translation, and visual question answering, show the generality of our methods.
Introduction
The Transformer's Self-Attention (SA) mechanism has revolutionized natural language processing and computer vision. However, in the context of image captioning, it faces two significant hurdles: internal covariate shift and geometric blindness. Internal covariate shift occurs because the "queries" in a standard SA layer are fed into a dynamically computed fully-connected layer; as network parameters change during training, the distribution of these queries shifts, making training unstable. Geometric blindness refers to the fact that vanilla self-attention treats input features as a "bag-of-features," failing to inherently understand spatial relationships between objects (e.g., a "person" is on top of a "horse").
Methodology
To address these issues, the authors introduce NG-SAN (Normalized and Geometry-aware Self-Attention Network).
Normalized Self-Attention (NSA)
To combat internal covariate shift, NSA introduces Instance Normalization (IN) directly inside the self-attention block. While standard Transformers use Layer Normalization outside the block, NSA applies normalization to the hidden activations (the queries). This decouples the attention mechanism's parameters from shifting input distributions, leading to a better-conditioned optimization process.
Geometry-aware Self-Attention (GSA)
GSA extends standard content-based attention by incorporating a geometric bias based on the relative properties of bounding boxes. This includes relative distance between centers, relative scale (width/height ratios), and aspect ratios. The authors found that query-dependent geometry—where the importance of spatial relations is conditioned on the object being processed—was the most effective approach.
Experimental Results
The researchers evaluated NG-SAN on several high-profile benchmarks, including MS-COCO, VATEX (video captioning), WMT 2014 (machine translation), and VQA-v2.
Performance on MS-COCO
NG-SAN achieved a state-of-the-art CIDEr score of 128.6 on the official MS-COCO test server. Ablation studies showed that adding NSA alone to a 4-layer baseline improved the CIDEr score from 128.6 to 130.8.
Cross-Task Generalization
The model demonstrated strong performance beyond image captioning:
- Video Captioning: Improved CIDEr on VATEX by 3.7 points over a standard Transformer.
- Machine Translation: Increased BLEU score by 0.36 on WMT En-De.
- VQA: Boosted the accuracy of the MCAN model from 70.83% to 71.28%.
Conclusion
NG-SAN significantly improves the Transformer architecture for image captioning by stabilizing internal training dynamics and explicitly modeling spatial relationships. Despite these gains, the model remains efficient, with NSA requiring zero extra parameters and GSA adding a negligible amount. Future work may explore applying NSA to the decoder and incorporating more complex semantic geometry, such as object orientation or specific points of contact.
Summary updated