Language Models for Image Captioning: The Quirks and What Works

Jacob Devlin, Hao Cheng, Hao Fang, Saurabh Gupta, Li Deng, Xiaodong He, Geoffrey Zweig, Margaret Mitchell

Introduction

Recent progress in automatic image captioning has shown that an image-conditioned language model can be very effective at generating captions. Two leading approaches have been explored for this task. The first decomposes the problem into an initial step that uses a convolutional neural network to predict a bag of words that are likely to be present in a caption; then in a second step, a maximum entropy language model (ME LM) is used to generate a sentence that covers a minimum number of the detected words [Fang et al. (2015]. The second approach uses the activations from final hidden layer of an object detection CNN as the input to a recurrent neural network language model (RNN LM). This is referred to as a Multimodal Recurrent Neural Network (MRNN) [Karpathy and Fei-Fei (2015, Mao et al. (2015, Chen and Zitnick (2015]. Similar in spirit is the the log-bilinear (LBL) LM of ?).

In this paper, we study the relative merits of these approaches. By using an identical state-of-the-art CNN as the input to RNN-based and ME-based models, we are able to empirically compare the strengths and weaknesses of the language modeling components. We find that the approach of directly generating the text with an MRNNIn our case, a gated recurrent neural network (GRNN) is used [Cho et al. (2014], similar to an LSTM. outperforms the ME LM when measured by BLEU on the COCO dataset [Lin et al. (2014],This is the largest image captioning dataset to date. but this recurrent model tends to reproduce captions in the training set. In fact, a simple kk-nearest neighbor approach, which is common in earlier related work [Farhadi et al. (2010, Mason and Charniak (2014], performs similarly to the MRNN. In contrast, the ME LM generates the most novel captions, and does the best at captioning images for which there is no close match in the training data. With a Deep Multimodal Similarity Model (DMSM) incorporated,As described by ?). the ME LM significantly outperforms other methods according to human judgments. In sum, the contributions of this paper are as follows:

We compare the use of discrete detections and continuous valued CNN activations as the conditioning information for language models trained to generate image captions.

We show that a simple kk-nearest neighbor retrieval method performs at near state-of-the-art for this task and dataset.

We demonstrate that a state-of-the-art MRNN-based approach tends to reconstruct previously seen captions; in contrast, the two stage ME LM approach achieves similar or better performance while generating relatively novel captions.

We advance the state-of-the-art BLEU scores on the COCO dataset.

We present human evaluation results on the systems with the best performance as measured by automatic metrics.

We explore several issues with the statistical models and the underlying COCO dataset, including linguistic irregularities, caption repetition, and data set overlap.

Models

All language models compared here are trained using output from the same state-of-the-art CNN. The CNN used is the 16-layer variant of VGGNet [Simonyan and Zisserman (2014] which was initially trained for the ILSVRC2014 classification task [Russakovsky et al. (2015], and then fine-tuned on the Microsoft COCO data set [Fang et al. (2015, Lin et al. (2014].

We study the effect of leveraging an explicit detection step to find key objects/attributes in images before generation, examining both an ME LM approach as reported in previous work [Fang et al. (2015], and a novel LSTM approach introduced here. Both use a CNN trained to output a bag of words indicating the words that are likely to appear in a caption, and both use a beam search to find a top-scoring sentence that contains a subset of the words. This set of words is dynamically adjusted to remove words as they are mentioned.

We refer the reader to ?) for a full description of their ME LM approach, whose 500-best outputs we analyze here.We will refer to this system as D-ME. We also include the output from their ME LM that leverages scores from a Deep Multimodal Similarity Model (DMSM) during nn-best re-ranking. Briefly, the DMSM is a non-generative neural network model which projects both the image pixels and caption text into a comparable vector space, and scores their similarity.

In the LSTM approach, similar to the ME LM approach, we maintain a set of likely words D\mathcal{D} that have not yet been mentioned in the caption under construction. This set is initialized to all the words predicted by the CNN above some threshold α\alpha.In all experiments in this paper, α\alpha=0.5. The words already mentioned in the sentence history hh are then removed to produce a set of conditioning words D{h}\mathcal{D}\setminus\{{\bf h}\}. We incorporate this information within the LSTM by adding an additional input encoded to represent the remaining visual attributes D{h}\mathcal{D}\setminus\{{\bf h}\} as a continuous valued auxiliary feature vector [Mikolov and Zweig (2012]. This is encoded as f(sh1+vD{h}gv+Uqh,D)f({\bf s}_{h_{-1}}+\sum_{v\in\mathcal{D}\setminus\{{\bf h}\}}{\bf g}_{v}+{\bf U}{\bf q}_{{\bf h},\mathcal{D}}), where sh1{\bf s}_{h_{-1}} and gv{\bf g}_{v} are respectively the continuous-space representations for last word h1h_{-1} and detector vD{h}v\in\mathcal{D}\setminus\{{\bf h}\}, U{\bf U} is learned matrix for recurrent histories, and f()f(\cdot) is the sigmoid transformation.

2 Multimodal Recurrent Neural Network

In this section, we explore a model directly conditioned on the CNN activations rather than a set of word detections. Our implementation is very similar to captioning models described in ?), ?), ?), and ?). This joint vision-language RNN is referred to as a Multimodal Recurrent Neural Network (MRNN).

In this model, we feed each image into our CNN and retrieve the 4096-dimensional final hidden layer, denoted as fc7. The fc7 vector is then fed into a hidden layer HH to obtain a 500-dimensional representation that serves as the initial hidden state to a gated recurrent neural network (GRNN) [Cho et al. (2014]. The GRNN is trained jointly with HH to produce the caption one word at a time, conditioned on the previous word and the previous recurrent state. For decoding, we perform a beam search of size 10 to emit tokens until an END token is produced. We use a 500-dimensional GRNN hidden layer and 200-dimensional word embeddings.

3 k𝑘k-Nearest Neighbor Model

Both ?) and ?) present a 1-nearest neighbor baseline. As a first step, we replicated these results using the cosine similarity of the fc7 layer between each test set image tt and training image rr. We randomly emit one caption from tt’s most similar training image as the caption of tt. As reported in previous results, performance is quite poor, with a BLEU score of 11.2%.

However, we explore the idea that we may be able to find an optimal kk-nearest neighbor consensus caption. We first select the k=90k=90 nearest training images of a test image tt as above. We denote the union of training captions in this set as C=c1,...,c5kC=c_{1},...,c_{5k}.Each training image has 5 captions. For each caption cic_{i}, we compute the n-gram overlap F-score between cic_{i} and each other caption in CC. We define the consensus caption cc^{*} to be caption with the highest mean n-gram overlap with the other captions in CC. We have found it is better to only compute this average among cic_{i}’s m=125m=125 most similar captions, rather than all of CC. The hyperparameters kk and mm were obtained by a grid search on the validation set.

A visual example of the consensus caption is given in Figure 1. Intuitively, we are choosing a single caption that may describe many different images that are similar to tt, rather than a caption that describes the single image that is most similar to tt. We believe that this is a reasonable approach to take for a retrieval-based method for captioning, as it helps ensure incorrect information is not mentioned. Further details on retrieval-based methods are available in, e.g., [Ordonez et al. (2011, Hodosh et al. (2013].

Experimental Results

We work with the Microsoft COCO dataset [Lin et al. (2014], with 82,783 training images, and the validation set split into 20,243 validation images and 20,244 testval images. Most images contain multiple objects and significant contextual information, and each image comes with 5 human-annotated captions. The images create a challenging testbed for image captioning and are widely used in recent automatic image captioning work.

2 Metrics

The quality of generated captions is measured automatically using BLEU [Papineni et al. (2002] and METEOR [Denkowski and Lavie (2014]. BLEU roughly measures the fraction of NN-grams (up to 4 grams) that are in common between a hypothesis and one or more references, and penalizes short hypotheses by a brevity penalty term.We use the length of the reference that is closest to the length of the hypothesis to compute the brevity penalty. METEOR [Denkowski and Lavie (2014] measures unigram precision and recall, extending exact word matches to include similar words based on WordNet synonyms and stemmed tokens. We also report the perplexity (PPLX) of studied detection-conditioned LMs. The PPLX is in many ways the natural measure of a statistical LM, but can be loosely correlated with BLEU [Auli et al. (2013].

3 Model Comparison

In Table 1, we summarize the generation performance of our different models. The discrete detection based models are prefixed with “D”. Some example generated results are show in Table 2.

We see that the detection-conditioned LSTM LM produces much lower PPLX than the detection-conditioned ME LM, but its BLEU score is no better. The MRNN has the lowest PPLX, and highest BLEU among all LMs studied in our experiments. It significantly improves BLEU by 2.1 absolutely over the D-ME LM baseline. METEOR is similar across all three LM-based methods.

Perhaps most surprisingly, the kk-nearest neighbor algorithm achieves a higher BLEU score than all other models. However, as we will demonstrate in Section 3.5, the generated captions perform significantly better than the nearest neighbor captions in terms of human quality judgements.

4 n𝑛n-best Re-Ranking

In addition to comparing the ME-based and RNN-based LMs independently, we explore whether combining these models results in an additive improvement. To this end, we use the 500-best list from the D-ME and add a score for each hypothesis from the MRNN.The MRNN does not produce a diverse nn-best list. We then re-rank the hypotheses using MERT [Och (2003]. As in previous work [Fang et al. (2015], model weights were optimized to maximize BLEU score on the validation set. We further extend this combination approach to the D-ME model with DMSM scores included during re-ranking [Fang et al. (2015].

Results are show in Table 3. We find that combining the D-ME, DMSM, and MRNN achieves a 1.6 BLEU improvement over the D-ME+DMSM.

5 Human Evaluation

Because automatic metrics do not always correlate with human judgments [Callison-Burch et al. (2006, Hodosh et al. (2013], we also performed human evaluations using the same procedure as in ?). Here, human judges were presented with an image, a system generated caption, and a human generated caption, and were asked which caption was “better”.The captions were randomized and the users were not informed which was which. For each condition, 5 judgments were obtained for 1000 images from the testval set.

Results are shown in Table 4. The D-ME+DMSM outperforms the MRNN by 5 percentage points for the “Better Or Equal to Human” judgment, despite both systems achieving the same BLEU score. The kk-Nearest Neighbor system performs 1.4 percentage points worse than the MRNN, despite achieving a slightly higher BLEU score. Finally, the combined model does not outperform the D-ME+DMSM in terms of human judgments despite a 1.6 BLEU improvement.

Although we cannot pinpoint the exact reason for this mismatch between automated scores and human evaluation, a more detailed analysis of the difference between systems is performed in Sections 4 and 5.

Language Analysis

Examples of common mistakes we observe on the testval set are shown in Table 5. The D-ME system has difficulty with anaphora, particularly within the phrase “on top of it”, as shown in examples (1), (2), and (3). This is likely due to the fact that is maintains a local context window. In contrast, the MRNN approach tends to generate such anaphoric relationships correctly.

However, the D-ME LM maintains an explicit coverage state vector tracking which attributes have already been emitted. The MRNN implicitly maintains the full state using its recurrent layer, which sometimes results in multiple emission mistakes, where the same attribute is emitted more than once. This is particularly evident when coordination (“and”) is present (examples (4) and (5)).

All of our models produce a large number of captions seen in the training and repeated for different images in the test set, as shown in Table 6 (also observed by ?) for their LSTM-based model). There are at least two potential causes for this repetition.

First, the systems often produce generic captions such as “a close up of a plate of food”, which may be applied to many publicly available images. This may suggest a deeper issue in the training and evaluation of our models, which warrants more discussion in future work. Second, although the COCO dataset and evaluation serverhttp://mscoco.org/dataset/ has encouraged rapid progress in image captioning, there may be a lack of diversity in the data. We also note that although caption duplication is an issue in all systems, it is a greater issue in the MRNN than the D-ME+DMSM.

Image Diversity

The strong performance of the kk-nearest neighbor algorithm and the large number of repeated captions produced by the systems here suggest a lack of diversity in the training and test data.This is partially an artifact of the manner in which the Microsoft COCO data set was constructed, since each image was chosen to be in one of 80 pre-defined object categories.

We believe that one reason to work on image captioning is to be able to caption compositionally novel images, where the individual components of the image may be seen in the training, but the entire composition is often not.

In order to evaluate results for only compositionally novel images, we bin the test images based on visual overlap with the training data. For each test image, we compute the fc7 cosine similarity with each training image, and the mean value of the 50 closest images. We then compute BLEU on the 20% least overlapping and 20% most overlapping subsets.

Results are shown in Table 7. The D-ME+DMSM outperforms the kk-nearest neighbor approach by 2.5 BLEU on the “20% Least” set, even though performance on the whole set is comparable. Additionally, the D-ME+DMSM outperforms the MRNN by 2.1 BLEU on the “20% Least” set, but performs 2.1 BLEU worse on the “20% Most” set. This is evidence that D-ME+DMSM generalizes better on novel images than the MRNN; this is further supported by the relatively low percentage of captions it generates seen in the training data (Table 6) while still achieving reasonable captioning performance. We hypothesize that these are the main reasons for the strong human evaluation results of the D-ME+DMSM shown in Section 3.5.

Conclusion

We have shown that a gated RNN conditioned directly on CNN activations (an MRNN) achieves better BLEU performance than an ME LM or LSTM conditioned on a set of discrete activations; and a similar BLEU performance to an ME LM combined with a DMSM. However, the ME LM + DMSM method significantly outperforms the MRNN in terms of human quality judgments. We hypothesize that this is partially due to the lack of novelty in the captions produced by the MRNN. In fact, a kk-nearest neighbor retrieval algorithm introduced in this paper performs similarly to the MRNN in terms of both automatic metrics and human judgements.

When we use the MRNN system alongside the DMSM to provide additional scores in MERT re-ranking of the nn-best produced by the image-conditioned ME LM, we advance by 1.6 BLEU points on the best previously published results on the COCO dataset. Unfortunately, this improvement in BLEU does not translate to improved human quality judgments.

References