Paper commentary
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
Attention over image regions lets a caption model look at different parts per word
- Problem Earlier neural captioners squeeze the whole image into one top-layer vector. That vector drops detail that richer captions need.
- Method Show, Attend and Tell adds learned attention over image locations to an LSTM decoder. At each word it weights a grid of convolutional features instead of using one summary vector.
- Results The model reaches state-of-the-art results on Flickr8k, Flickr30k and MS COCO, and attention maps show it fixing on salient objects while writing.
Why one image vector limits captions
A captioning model has to name the objects in an image and also state how they relate in natural language. Most earlier neural captioners compress the whole image into one feature vector taken from the top layer of a pretrained convolutional network. That vector keeps the most salient objects, but it discards detail that could make a caption richer.
Some models also show the image only once, at the first step of the output sequence.
Human vision avoids a single static summary by letting attention bring salient features forward as they are needed. The authors borrow that idea and draw on attention in machine translation and object recognition. So the question is whether a decoder can learn where to look at each word, instead of relying on one summary vector.
Attention over convolutional locations
The key idea is to keep the image as a grid of spatial vectors and let the decoder take a weighted mix of them at each step. The encoder is a convolutional network that yields L annotation vectors, each D-dimensional, taken from a lower convolutional layer rather than a fully connected one. Each vector stays tied to one image location, so the decoder can focus on a subset of them.
At each step t, the attention model scores every annotation vector against the previous hidden state, as \(e_{ti}=f_{att}(a_i, h_{t-1})\). A softmax turns these scores into weights \(\alpha_{ti}=\exp(e_{ti})/\sum_{k=1}^{L}\exp(e_{tk})\) that sum to one. The context vector \(\hat{z}_t\) is the weighted combination of the annotation vectors under those weights.
Because the hidden state changes as the output advances, the next location the model looks at depends on the words already generated.
The decoder is an LSTM that takes the embedding of the previous word, the previous hidden state and the context vector. Its memory and hidden state follow the usual gates, with \(c_t = f_t \odot c_{t-1} + i_t \odot g_t\) and \(h_t = o_t \odot \tanh(c_t)\). The initial memory and hidden states come from an average of the annotation vectors passed through two separate MLPs.
Each word is then drawn from a deep output layer that combines the embedding, the hidden state and the context vector, with the K-word vocabulary.
Soft and hard training
The soft variant feeds in the expected context vector, which makes the whole model differentiable. It can therefore be trained end-to-end with standard backpropagation. The soft model also learns a gating scalar \(\beta_t=\sigma(f_\beta(h_{t-1}))\) that scales the context vector. Training adds a penalty, so the loss becomes \(L_d = -\log P(y|x) + \lambda \sum_i (1-\sum_t \alpha_{ti})^2\).
This term pushes each location's total attention over the steps toward one, which the authors say encourages equal attention across the image.
The hard variant treats the location \(s_t\) as a latent one-hot variable, sampled from a multinoulli distribution over the weights \(\alpha\). It maximizes a variational lower bound on the log-likelihood, and the gradient is estimated by Monte Carlo sampling, which the authors relate to REINFORCE. To reduce variance, a moving average baseline is updated as \(b_k = 0.9 \times b_{k-1} + 0.1 \times \log p(y|\tilde{s}_k, a)\).
An entropy term is added, and with probability 0.5 the sampled location is replaced by its expected value.
The soft model is trained with RMSProp on Flickr8k and with Adam on Flickr30k and MS COCO. Mini-batches of 64 captions share one sampled caption length, because training time grows with the longest sentence in an update. The authors use early stopping on BLEU, and dropout is the only other regularizer. On MS COCO the soft model took less than 3 days to train on one NVIDIA Titan Black GPU.
Benchmark caption scores
The two variants tie on BLEU-1, so the difference sits in the longer n-gram match of BLEU-4. The Flickr8k split is the predefined one, so these scores use the authors' own protocol. On the same split Hard-Attention also scored 20.30 METEOR, compared to 18.93 for Soft-Attention.
The gap is small here, so the two variants look close on this dataset. This split is the publicly available one from prior work, so these numbers are not from the Flickr8k split.
The authors present their results as state-of-the-art on the three benchmarks, within the comparison rows they chose. Those rows use GoogLeNet or Oxford VGG features, so the comparison keeps the encoder roughly matched. The COCO results come from a single model without an ensemble, which the authors state as a deliberate choice. The authors also report that their METEOR gain on MS COCO is large, which they link to their regularization and lower-level features.
Where the attention lands
To visualize the soft model, the authors upsample the 14×14 attention weights by a factor of 16 and smooth them with a Gaussian filter. The receptive fields of neighbouring 14×14 units overlap heavily, so the map is a coarse guide rather than a sharp mask. Figure 2 and Figure 3 show the attended region changing as each word is generated. The authors judge these alignments to match human intuition, and they say the mistake examples help explain why errors happened.
This evidence is visual, so it shows where attention falls on chosen examples rather than giving a measured score.
Limitations
BLEU is criticized, so the authors add METEOR as a second metric. The authors observed that validation log-likelihood stopped tracking BLEU in the later stages of training. Model selection therefore relies on BLEU, the most commonly reported metric.
The Flickr30k and MS COCO splits are not standardized, so the authors use the publicly available splits from prior work. The authors say split differences do not make a substantial difference in their experience, but they note the differences where they exist. All reported results come from a single model, so ensemble comparisons are not covered.
The experiments cover three caption datasets only, with the visual attention evidence kept qualitative. The hard variant's gradient is a Monte Carlo estimate, and the authors add variance-reduction terms to stabilize it.
Paper info
- Authors
- Kelvin Xu, Jimmy Ba, Ryan Kiros, Kyunghyun Cho, Aaron Courville, Ruslan Salakhutdinov, Richard Zemel, Yoshua Bengio
- Venue
- arXiv · Preprint
- First published
- 2015-2-10
- Added
- 2026-11-11
- Updated
- 2016-4-19
- Version
- v3
- arXiv
- 1502.03044
- Category
- cs.LG · 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
Kelvin Xu, Jimmy Ba, Ryan Kiros, Kyunghyun Cho, Aaron Courville, Ruslan Salakhutdinov, Richard Zemel, Yoshua Bengio (2015). Show, Attend and Tell: Neural Image Caption Generation with Visual Attention. arXiv:1502.03044v3. https://arxiv.org/abs/1502.03044v3
BibTeX
@misc{xu2015show,
title = {{Show, Attend and Tell: Neural Image Caption Generation with Visual Attention}},
author = {Kelvin Xu and Jimmy Ba and Ryan Kiros and Kyunghyun Cho and Aaron Courville and Ruslan Salakhutdinov and Richard Zemel and Yoshua Bengio},
year = {2015},
eprint = {1502.03044},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1502.03044v3}
}