Hostname: page-component-74656f9884-c52kr Total loading time: 0 Render date: 2026-11-06T23:45:43.941Z Has data issue: false hasContentIssue false

Where to put the image in an image caption generator

Published online by Cambridge University Press:  23 April 2018

MARC TANTI
Affiliation:
Institute of Linguistics and Language Technology, University of Malta, Msida MSD, Malta e-mail: marc.tanti.06@um.edu.mt, albert.gatt@um.edu.mt
ALBERT GATT
Affiliation:
Institute of Linguistics and Language Technology, University of Malta, Msida MSD, Malta e-mail: marc.tanti.06@um.edu.mt, albert.gatt@um.edu.mt
KENNETH P. CAMILLERI
Affiliation:
Department of Systems and Control Engineering, University of Malta, Msida MSD, Malta e-mail: kenneth.camilleri@um.edu.mt
Rights & Permissions [Opens in a new window]

Abstract

When a recurrent neural network (RNN) language model is used for caption generation, the image information can be fed to the neural network either by directly incorporating it in the RNN – conditioning the language model by ‘injecting’ image features – or in a layer following the RNN – conditioning the language model by ‘merging’ image features. While both options are attested in the literature, there is as yet no systematic comparison between the two. In this paper, we empirically show that it is not especially detrimental to performance whether one architecture is used or another. The merge architecture does have practical advantages, as conditioning by merging allows the RNN’s hidden state vector to shrink in size by up to four times. Our results suggest that the visual and linguistic modalities for caption generation need not be jointly encoded by the RNN as that yields large, memory-intensive models with few tangible advantages in performance; rather, the multimodal integration should be delayed to a subsequent stage.

Information

Type
Articles
Copyright
Copyright © Cambridge University Press 2018 
Figure 0

Fig. 1. How RNN-based neural language models work. Legend: RNN – Recurrent Neural Network; FF – Feed-Forward layer; wordi – the ith generated word in the text; wordstart – the START token which is an artificial word placed at the beginning of every sentence in order to still have a prefix when predicting the first word (likewise there is an END token to predict the end of a sentence). Note that state1 represents the prefix ‘wordstart’, state2 represents the prefix ‘wordstart word1’, etc. After processing a prefix, the RNN passes its final state statet to a feed-forward layer, which then predicts how likely each known word is to be the next word in the prefix.

Figure 1

Fig. 2. The inject and merge architectures for caption generation. Legend: RNN – Recurrent Neural Network; FF – Feed-Forward layer.

Figure 2

Fig. 3. Different ways of conditioning a neural language model with an image. The feed-forward layer was left out to save space.

Figure 3

Fig. 4. An illustration of the main architecture schema that is instantiated in the four different architectures tested in this paper. Legend: ‘FF’ – fully connected layer with bias; ‘FFimg’ – layer projecting the image vector (may or may not have an activation function); ‘FFout’ – layer projecting into the softmax output; ‘l’ – the layer size (which is the same for three different layers); ‘v’ – the vocabulary size (which is different for different datasets). Only one of the dashed arrows is used depending on whether the architecture is one of merge or inject.

Figure 4

Table 1. The optimal hyperparameters found for each architecture, tuned on Flickr8K with CIDEr as an objective function. Each row is explained in Section 4.2

Figure 5

Table 2. Results of caption quality metrics (CIDEr, METEOR, and ROUGE-L). Best values are in bold.

Figure 6

Table 3. Results of caption quality metrics (BLEU-1, BLEU-2, BLEU-3, and BLEU-4). Best values are in bold.

Figure 7

Table 4. Results of the image retrieval metrics. Language model perplexity was also included here. Best values are in bold.

Figure 8

Table 5. Results of the caption diversity metrics. The metrics were also applied to the first caption of each image in the human written test set captions. Best values are in bold.

Figure 9

Fig. 5. Difference between multimodal vectors over time, when the caption is held constant but the image is changed. For a trained model, markers show mean absolute difference between multimodal vectors when a twenty-word caption is fed to the model with the original, versus a randomly chosen image. The marker at position 0 gives the multimodal vector difference after feeding in the START token whilst the marker at position twenty gives the multimodal vector difference after feeding in the last word in the caption.