What is the Role of Recurrent Neural Networks (RNNs) in an Image Caption Generator?

Marc Tanti, Albert Gatt, Kenneth P. Camilleri

TL;DR

This paper investigates two distinct ways of integrating image features into RNN-based image captioning models: "injecting" image features at each step of the RNN, or "merging" them at a later stage. They find that the "merge" approach, where the RNN acts primarily as a language model encoder, generally outperforms the "inject" approach, suggesting RNNs are better suited as encoders rather than direct generators in this context.

What Problem Does This Paper Address?

Image captioning, the task of generating a textual description for an image, has seen significant advancements with the use of deep learning, particularly recurrent neural networks (RNNs). A common paradigm involves using an RNN to generate the caption word by word, conditioned on visual features extracted from the image. However, there's a fundamental question about how these visual features should be integrated into the RNN. Should they be "injected" at every step of the RNN's processing, influencing each word prediction directly? Or should the RNN first process the linguistic context (the caption generated so far) independently, and then have the visual information merged with its final representation before making a prediction? This paper aims to systematically compare these two architectural choices and understand the implications for the RNN's role in caption generation.

Methods

The paper proposes and compares two main architectural paradigms for image captioning:

  • Inject Architecture: In this approach, image features are concatenated with the word embeddings at each time step of the RNN. This means the RNN receives both linguistic and visual information at every step, effectively treating them as a combined input. The authors refer to this as "conditioning-by-inject."
  • Merge Architecture: Here, the RNN acts solely as a language model, encoding the sequence of previously generated words. The image features are then merged with the final hidden state of the RNN in a separate "multimodal layer" before predictions are made. This is termed "conditioning-by-merge."

The authors implemented these architectures using a standard LSTM (Long Short-Term Memory) network. They conducted experiments varying layer sizes, vocabulary sizes, and evaluated performance using standard metrics.

Datasets

The experiments were conducted on two widely used image captioning datasets:

  • Flickr8k: Consists of 8,000 images, each with five captions.
  • Flickr30k: A larger dataset with 31,000 images, each with five captions.

The authors used splits provided by Karpathy and Fei-Fei (2015). Image features were pre-extracted using a VGG CNN.

Key Insights and Ideas

  • RNNs as Encoders, Not Generators: The most significant insight is that RNNs seem to perform better when tasked with encoding linguistic sequences, rather than directly generating captions while simultaneously processing image features. The "merge" architecture, which separates these roles, consistently outperforms the "inject" architecture.
  • Handling Variation: The "merge" architecture appears to handle variation more effectively. By keeping image and linguistic features separate until a later stage, it avoids overcomplicating the RNN's encoding task. The "inject" architecture, by contrast, has to compress combined visual and linguistic information, potentially leading to a larger effective vocabulary that the RNN must handle.
  • Efficiency and Capacity: The "merge" architecture demonstrates a better performance-to-model-size ratio. It can achieve comparable or better results with smaller layer sizes compared to the "inject" architecture, suggesting it's a more efficient use of resources.
  • Vocabulary Usage: The "merge" models tend to use a greater proportion of the training vocabulary on test captions, though overall vocabulary usage remains relatively low, especially for larger vocabularies. This suggests that reducing training vocabulary size might have minimal performance impact.

Key Results

  • Across both Flickr8k and Flickr30k datasets, the merge architecture consistently outperformed the inject architecture on most evaluation metrics, particularly CIDEr (which is specifically designed for captioning).
  • While the margin of improvement was sometimes narrow, the results were consistent across multiple training runs.
  • For Flickr8k, the best-performing models were merge architectures with a state size of 256. For Flickr30k, merge with a state size of 128 performed best.
  • The paper notes that the "inject" architecture requires a larger capacity (layer size) to match the performance of the "merge" architecture.

Limitations and Future Work

  • Dataset Consistency: The authors acknowledge that results on Flickr8k and Flickr30k were not entirely consistent, suggesting that Flickr8k might be too easy or Flickr30k too hard compared to larger datasets like MSCOCO. They are extending their experiments to MSCOCO.
  • Generalizability: The paper invites future research into the general applicability of the "merge" architecture in other sequence-to-sequence tasks, such as machine translation, where a target language model could be conditioned on sentences from a source language.
  • Transfer Learning: The "merge" architecture's separation of image and language processing offers potential advantages for transfer learning. The RNN component, trained as a language model, could potentially be initialized from a general-purpose neural language model, a feat not possible with the "inject" architecture.
  • Attention Mechanisms: While not the focus of this paper, the authors note that both architectures are compatible with attention mechanisms, which could further enhance performance.

Summary updated

Abstract

In neural image captioning systems, a recurrent neural network (RNN) is typically viewed as the primary `generation' component. This view suggests that the image features should be `injected' into the RNN. This is in fact the dominant view in the literature. Alternatively, the RNN can instead be viewed as only encoding the previously generated words. This view suggests that the RNN should only be used to encode linguistic features and that only the final representation should be `merged' with the image features at a later stage. This paper compares these two architectures. We find that, in general, late merging outperforms injection, suggesting that RNNs are better viewed as encoders, rather than generators.
BibTeX
@inproceedings{tanti2017what,
  author = {Marc Tanti and Albert Gatt and Kenneth P. Camilleri},
  title = {{What is the Role of Recurrent Neural Networks (RNNs) in an Image Caption Generator?}},
  booktitle = {INLG},
  year = {2017},
  url = {https://openreview.net/forum?id=OSSpRngzzZ},
}
Figure