Masked Non-Autoregressive Image Captioning

Junlong Gao, Xi Meng, Shiqi Wang, Xia Li, Shanshe Wang, Siwei Ma, Wen GaoarXiv 2019

Abstract

Traditional image captioning models rely on autoregressive (AR) decoding, generating text sequentially. While effective, this approach suffers from high latency and error propagation. This paper introduces Masked Non-Autoregressive Image Captioning (MNIC), a framework that generates captions in parallel using a multi-stage refinement process. By adapting bidirectional masking strategies to the captioning task, MNIC achieves a superior balance between generation speed and semantic richness, outperforming existing non-autoregressive baselines and rivaling state-of-the-art sequential models in diversity and semantic accuracy.

Introduction

Most contemporary image captioning systems utilize an autoregressive decoder, where each word is predicted based on previously generated tokens. This sequential nature introduces significant computational bottlenecks and often leads to "safe" but generic descriptions. Conversely, pure non-autoregressive (NAR) models, which predict all words simultaneously, often struggle with the "multimodality problem"—generating repetitive or incoherent phrases because individual word predictions lack local context.

MNIC addresses these challenges by treating captioning as a progressive "fill-in-the-blanks" task. It leverages the bidirectional context of a Transformer-based decoder to refine captions over multiple iterations, combining the speed of parallel generation with the linguistic coherence of iterative refinement.

Methodology

Architecture and Training

The MNIC architecture employs a modified Transformer decoder where the standard causal mask is removed, allowing each token position to attend to all other positions. During training, the model is exposed to ground-truth captions where a percentage of tokens are replaced with a [MASK] token or random noise. The model learns to reconstruct the original text by fusing visual features from an image encoder with the available linguistic context.

Figure 1: Overview of the MNIC architecture and the multi-stage refinement process. The model iteratively predicts and refines tokens, starting from a sequence of masks.

Compositional Inference

Unlike standard NAR models that generate a sentence in a single pass, MNIC uses Compositional Inference. The process begins with a fixed-length sequence of [MASK] tokens. In each of the $K$ stages, the model predicts the entire sequence in parallel. It retains the most confident predictions (typically nouns and verbs representing core visual concepts) and re-masks the remaining positions for further refinement in the next stage. This mimics human descriptive behavior: identifying primary objects first before establishing their relationships and attributes.

Experimental Results

Quantitative Performance

Evaluated on the MSCOCO dataset, MNIC demonstrates significant improvements in both speed and quality:

  • Efficiency: A single-round (1R) inference with MNIC is approximately 2.8x faster than a standard autoregressive Transformer.
  • Semantic Accuracy: MNIC achieved a SPICE score of 21.1, surpassing several state-of-the-art AR models. This indicates that the model captures objects, attributes, and relations more effectively than models optimized solely for word-matching metrics like BLEU.
  • Diversity: The model produced 82.54% novel captions (not present in the training set), nearly doubling the diversity score of the popular TopDown AR baseline (45.05%).

Qualitative Analysis

Qualitative results highlight MNIC's ability to generate semantically dense descriptions. While AR models often produce shorter, generic phrases, MNIC tends to include more specific details about the scene.

Figure 3: Qualitative comparison of captions generated by MNIC against ground truth (GT) and the AIC baseline. MNIC often provides more detailed and semantically accurate descriptions.

Discussion and Conclusion

MNIC represents a significant step forward for non-autoregressive image captioning. By utilizing iterative refinement and bidirectional context, it overcomes the traditional trade-off between generation speed and caption quality. The model's high SPICE scores and vocabulary diversity suggest it is less prone to the "generic caption" trap common in sequential models.

Future work will focus on dynamic length prediction, as the current model requires a pre-defined sequence length during inference. Additionally, exploring more sophisticated refinement logic beyond simple probability thresholds could further enhance the linguistic fluency of the generated text.

Summary updated

BibTeX
@misc{gao2019masked,
  author = {Junlong Gao and Xi Meng and Shiqi Wang and Xia Li and Shanshe Wang and Siwei Ma and Wen Gao},
  title = {{Masked Non-Autoregressive Image Captioning}},
  year = {2019},
  eprint = {1906.00717},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1906.00717},
}
Figure