Paper commentary
Deep Visual-Semantic Alignments for Generating Image Descriptions
- Problem Caption datasets pair one sentence with a whole image and do not say where each named entity sits. So region-level descriptions have no direct training signal.
- Method The authors infer word-to-region alignments with a bidirectional RNN embedding and a max-margin ranking objective. Then they train a multimodal RNN on the aligned snippets to generate text.
- Results The alignment model reaches R@1 of 22.2 for Flickr30K image annotation, against 19.2 for the authors' reimplemented DeFrag.
Why whole-image captions are weak supervision
Much of visual recognition work assigns images to a fixed set of categories, and a closed vocabulary is a narrow target next to the range of sentences people write about a scene. Earlier description systems leaned on hard-coded concepts and sentence templates, and usually compressed a whole scene into one sentence.
Caption corpora are large, but a single sentence can name several entities without saying where they sit in the picture. The approach treats each sentence as a weak label: a run of consecutive words points to some unknown image location, and the aim is to infer those locations and then learn a generator from them. The work therefore has two stages, an alignment model followed by a generator trained on the inferred pairs.
Scoring image-sentence pairs by region-word matches
Each image becomes 20 vectors: the whole image plus the top 19 region detections from an RCNN, where each crop passes through a CNN with about 60 million parameters. The 4096-dimensional fully connected activation of each crop is mapped by a learned matrix into an h-dimensional space, with h between 1000 and 1600 in the experiments.
Words are one-hot indices mapped to 300-dimensional word2vec vectors, and that embedding matrix is kept fixed. A bidirectional RNN runs one stream left to right and one right to left, and each word's vector combines both streams, so every word carries context of variable length without a dependency parser. The hidden size is 300 to 600 in the experiments, with ReLU as the activation.
Each image-sentence pair receives one score built from matches between its words and its regions. \[ S_{kl} = \sum_{t \in g_l} \max_{i \in g_k} v_i^{T} s_t \] Here g_k is the set of image fragments of image k, g_l the set of sentence fragments of sentence l, v_i a region vector and s_t a word vector, so each word contributes only its inner product with its best-matching region.
The earlier formulation summed positive dot products over all region-word pairs, and this simpler form also ranks better in the experiments. Training uses a max-margin objective with margin 1, applied in both the image-ranking and the sentence-ranking direction over the training pairs.
Choosing contiguous word-to-region assignments
Assigning each word independently to its highest-scoring region scatters neighbouring words across different regions. The model instead treats each word's region as a latent variable in a chain-structured Markov Random Field, where a pairwise term adds beta whenever neighbouring words choose the same region. \[ E(a) = \sum_{j=1}^{N} \psi^{U}_j(a_j) + \sum_{j=1}^{N-1} \psi^{B}_j(a_j, a_{j+1}) \] Here the unary term is the inner product of the region vector and the word vector, and the pairwise term equals beta times the indicator that the two neighbours share a region.
The value of beta sets how strongly phrases are kept together: at 0 each word picks its own region, and a large beta pushes the whole sentence onto one region. The energy is minimized with dynamic programming, which gives each word a region and so yields segments of text attached to image boxes.
Conditioning a recurrent generator on the image
The generator is a recurrent network whose hidden state combines the current word vector with the previous state, and the image enters only as a bias at the first step. \[ h_t = f(W_{hx} x_t + W_{hh} h_{t-1} + b_h + \mathbb{1}(t=1) \odot b_v), \qquad y_t = \mathrm{softmax}(W_{oh} h_t + b_o) \] Here b_v is the projected CNN vector of the image, and the output y_t has one extra dimension for an END token.
The hidden layer has 512 units.
Training starts from a START vector, predicts each next word of the target sentence, and ends on the END token, maximizing the log probability of the target labels. At test time a word is sampled or chosen by argmax, fed back as the next input, and the loop continues until END; beam search with beam size 7 improved the results.
The alignment model is trained with SGD on mini-batches of 100 image-sentence pairs with momentum 0.9, with the learning rate and weight decay cross-validated. The generator is harder to optimize because of the frequency gap between rare words and common words, and RMSprop gave the best results; gradients are clipped elementwise at 5 and dropout is applied everywhere except the recurrent layers.
Datasets and preprocessing
Flickr8K, Flickr30K and MSCOCO contain about 8,000, 31,000 and 123,000 images, each annotated with five sentences. Flickr8K and Flickr30K each use 1,000 images for validation and 1,000 for testing, with the rest for training, while MSCOCO uses 5,000 images each for validation and testing.
Sentences are lowercased and non-alphanumeric characters are dropped, and a word is kept only if it occurs at least 5 times in training. That filter leaves 2538 words for Flickr8K, 7414 for Flickr30K and 8791 for MSCOCO.
Image-sentence ranking results
On Flickr30K image annotation the BRNN model reaches R@1 22.2 and median rank 4.8, against 19.2 and median rank 6.0 for the authors' reimplementation of DeFrag. The reimplementation was needed because this work uses different word vectors, dropout and embedding sizes, so the reported DeFrag figure of 14.2 is a looser reference. Vinyals et al.
report R@1 23 on the same benchmark with a more powerful CNN, which the table marks as a different setting.
On Flickr30K image search the BRNN model reaches R@1 15.2, against 12.9 for the reimplemented DeFrag. Keeping the simpler max-based objective but using dependency tree edges gives R@1 20.0 for annotation, and the only change from the reimplemented DeFrag is that objective, so the authors attribute the rise from 19.2 to 20.0 to it. Replacing the dependency edges with the BRNN raises annotation R@1 from 20.0 to 22.2, which the authors take as evidence that the BRNN captures contexts longer than two words.
These table values are averages over the top five validation models, each evaluated on the test set, and the standard deviations of the recall values are roughly 0.5 to 1.0.
On 1K MSCOCO test images the model reaches R@1 38.4 for annotation and 27.4 for search, and on 5K test images the annotation R@1 is 16.5. The 5K numbers are lower because Recall@K depends on the size of the test set, and the authors report that no other published MSCOCO ranking results were available for comparison.
What the learned vector magnitudes encode
Because the score is built from inner products, the length of a learned word vector acts as a weight on that word's contribution. Visually discriminative words such as kayaking and pumpkins get long vectors and so a large influence on the score, while words such as now, simply, actually and but sit near the origin. The groundings also pick out small or rare objects such as an accordion, which the authors expect whole-image models to miss.
Full-image descriptions against retrieval
Full-image descriptions use VGGNet features, and BLEU, METEOR and CIDEr are computed with the coco-caption code against five human reference sentences per image. On 1,000 MSCOCO 2014 test images the model reaches CIDEr 66.0, B-4 23.0 and METEOR 19.5, with B-1 at 62.5 and B-2 at 45.0.
The retrieval baseline gives each test image the caption of its nearest training image under L2 distance on VGGNet fc7 features. That baseline reaches CIDEr 38.3 and B-4 10.0, and the authors argue that retrieval stays inadequate even with 113,000 training images. The generator needs only a fraction of a second per image.
The authors note that a sentence about a man playing guitar is absent from training while its phrases occur there, so the model may have recombined them.
Vinyals et al. feed the image as a first word, use an LSTM, GoogLeNet features and a model ensemble, and Donahue et al. use a two-layer factored LSTM on AlexNet features. The authors attribute the lower scores of the Donahue et al. model largely to its AlexNet features, and they say their own model trades a slight loss in performance for simplicity and speed.
Those Table 2 scores come from different setups and are not controlled comparisons with this model.
Describing single image regions
Annotators on Amazon Mechanical Turk drew five bounding boxes each on 200 MSCOCO test images and labelled each with text, with nine annotators per image. That gave 9,000 snippets, or 45 per image, with an average length of 2.3 words, and these snippets are used only at test time.
The region model is trained on the correspondences from the alignment model, while the full-frame model is trained on whole images. The ranking baseline returns training sentence substrings that the BRNN model judges most compatible with each region. On BLEU B-1 the region model reaches 35.2, against 22.9 for nearest neighbour and 14.2 for the full-frame model, and on B-4 it reaches 14.8 while both baselines score 0.0.
Human agreement on B-1 is 61.5.
The region model scores higher than the full-frame model on CIDEr (61.6 against 20.3), METEOR (15.8 against 13.3) and ROUGE (35.1 against 21.0).
Limitations
The model describes one pixel array at a fixed resolution, and the authors suggest that multiple glimpses of the image could capture entities, their interactions and wider context, which is not tested. Image information reaches the RNN only through additive bias interactions, which the authors state are less expressive than multiplicative interactions.
The approach uses two separate models, so going from image-sentence data to region annotations in a single end-to-end model remains open.
The region evaluation covers 200 MSCOCO test images, and the full-frame model's gap on small regions and the sensitivity of BLEU to sentence length mean that the BLEU comparisons carry a length caveat.
Paper info
- Authors
- Andrej Karpathy, Li Fei-Fei
- Venue
- arXiv · Preprint
- First published
- 2014-12-7
- Added
- 2026-11-12
- Updated
- 2015-4-14
- Version
- v2
- arXiv
- 1412.2306
- Category
- cs.CV
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Andrej Karpathy, Li Fei-Fei (2014). Deep Visual-Semantic Alignments for Generating Image Descriptions. arXiv:1412.2306v2. https://arxiv.org/abs/1412.2306v2
BibTeX
@misc{karpathy2014deep,
title = {{Deep Visual-Semantic Alignments for Generating Image Descriptions}},
author = {Andrej Karpathy and Li Fei-Fei},
year = {2014},
eprint = {1412.2306},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1412.2306v2}
}