Paper commentary
Image Captioning with Semantic Attention
Attention over visual attributes lets captioners combine top-down and bottom-up cues
- Problem Top-down captioners squeeze the whole image into one vector, so fine detail is hard to reach. Bottom-up pipelines detect aspects but have no end-to-end link to a full sentence.
- Method The semantic attention model feeds a global CNN feature into an RNN captioner. The RNN attends over detected visual attributes at both its input and its output, so the two sources feed back into each other.
- Results With FCN-predicted attributes, the model reached B-4 0.304 and METEOR 0.243 on the MS-COCO validation set, above Google NIC and Toronto.
Why captioning needs both top-down and bottom-up cues
Captioning systems fall into two families. Top-down models start from a global impression of the image and decode it into words, and because the whole chain is a recurrent network, it can be trained end to end. Their weakness is that a single global representation makes fine detail hard to reach, even when that detail matters for the sentence.
Bottom-up systems can look at any region at any resolution, but they assemble words from detected aspects without a learned end-to-end link to the full sentence.
The paper asks whether the two families can be combined, and it treats feedback as the mechanism for doing so. The motivation comes from visual attention in primates, which selects part of an early representation under guidance from higher-level processing. Captions also mention only the semantically important objects, not everything in the scene.
Earlier work with attention for captioning, by Xu et al., attends over fixed spatial locations at one resolution. The approach here instead draws concepts from anywhere in the image, including concepts without direct visual presence. It also feeds the global visual feature into the same loop as the concepts, which the earlier spatial model does not do.
How the global feature and attributes enter the captioner
Two kinds of evidence are extracted from each image. A GoogleNet classification network gives a global visual description, and a set of attribute detectors gives attributes, each tied to an entry of the word dictionary. The global description enters only once, as the initial input, so the recurrent state starts from a whole-image summary.
After that the state chooses among the attributes through attention. The initial input is \( x_0 = W^{x,v} v \), and the recurrence is \( h_t = \mathrm{RNN}(h_{t-1}, x_t) \).
At each step a word \( Y_t \) is drawn from a distribution \( p_t \) that depends on the hidden state and the attributes. The drawn word is embedded and combined with the attributes to form the next input. Attention therefore sits on both sides of the recurrence, on the input that feeds the state and on the output that reads the state. This is the feedback loop the paper describes between the global feature and the attributes.
Input and output attention scores
On the input side, each attribute \( A_i \) gets a score \( \alpha_{it} \) from its relevance to the previous word \( Y_{t-1} \). Both are one-hot vectors over the dictionary, so the score is computed in a low-dimensional word space after projection with the embedding matrix \( E \in \mathbb{R}^{d \times |Y|} \), where \( d \ll |Y| \). The score is a bilinear form normalized with a softmax over all attributes: \[ \alpha_{it} \propto \exp\big(y_{t-1}^T E^T U E\, y_i\big) \] Here \( U \) is a \( d \times d \) matrix, so the parameters are kept small compared with a full \( |Y| \times |Y| \) matrix.
The weights then form a weighted sum of attribute embeddings. A learned vector \( w^{x,A} \) scales that sum dimension by dimension before it is added to the embedded previous word, and a projection maps the result into the input space: \[ x_t = W^{x,Y}\Big(E y_{t-1} + \mathrm{diag}(w^{x,A}) \sum_i \alpha_{it} E y_i\Big) \] The matrix \( W^{x,Y} \in \mathbb{R}^{m \times d} \) is the projection, and \( w^{x,A} \) indicates how much each word dimension relies on the attributes.
The output side scores attributes against the current hidden state, because attributes can be used in a different order when reading the state than when producing the sentence. The score is \( \beta_{it} \propto \exp(h_t^T V \sigma(E y_i)) \), where \( V \in \mathbb{R}^{n \times d} \) is a bilinear matrix. Here \( \sigma \) is the activation that connects the input to the hidden state.
It is applied to the attribute vectors so they undergo the same nonlinear transform before comparison, and the setup uses tanh.
The weighted attribute activations are added to the hidden state before a linear map to the vocabulary and a softmax: \[ p_t \propto \exp\Big(E^T W^{Y,h}\big(h_t + \mathrm{diag}(w^{Y,A}) \sum_i \beta_{it}\, \sigma(E y_i)\big)\Big) \] The factor \( E^T \) reuses the word embedding in the output projection. The paper takes this from a transposed weight-sharing idea that reduces the parameter count.
Training objective and attention regularization
Training minimizes the negative log-likelihood of the caption words plus two penalties on the attention matrices: \[ \min_{\Theta_A,\Theta_R} -\sum_t \log p(Y_t) + g(\alpha) + g(\beta) \] \( \Theta_A \) collects the attention parameters and \( \Theta_R \) the RNN parameters, and both are learned jointly over the training set.
Each penalty is a mixed norm: \[ g(\alpha) = \|\alpha\|_{1,p} + \|\alpha^T\|_{q,1} = \Big[\sum_i \Big[\sum_t \alpha_{it}\Big]^p\Big]^{1/p} + \sum_t \Big[\sum_i (\alpha_{it})^q\Big]^{1/q} \] The first term, with \( p > 1 \), penalizes large total attention on one attribute accumulated over the caption. The second term, with \( 0 < q < 1 \), penalizes spreading attention over many attributes at a single step.
The reported setting is \( p = 2 \) and \( q = 0.5 \).
Optimization uses stochastic gradient descent with an adaptive learning rate. The mini-batch updates are carried out with RMSProp and a mini-batch size of 256.
Retrieval and parametric routes to attributes
The non-parametric route retrieves visually similar training images with GoogleNet features, then takes the most frequent words in their ground-truth captions as the query's attributes. The authors expect a larger web-scale database to improve attribute accuracy, but that was not tested here.
The parametric route first builds a fixed set of attributes from the most common caption words and treats each as a class. RK learns a multi-label classifier with a ranking loss, and FCN learns attribute relevance from local patches. Both parametric models output a relevance score per image and attribute, and the top ranked attributes are passed to the captioner.
The attribute task is multi-label rather than multi-class, because an image usually contains several concepts. The two routes are complementary and can be used together.
Datasets and training conditions
Flickr30k has 31,783 images and MS-COCO has 123,287. Each image has at least five captions, and the public training, testing and validation splits are used.
The captioner is an LSTM with \( n = m = 512 \) for the input and hidden layers and tanh as the activation, with GloVe embeddings of \( d = 300 \) dimensions. The image feature is taken from the last 1024-dimensional convolutional layer of GoogleNet. In the best attention setting the top 10 attributes form the set \( \{A_i\} \).
Every reported result comes from an ensemble of five identical models trained from different initializations. The regularization settings are \( p = 2 \) and \( q = 0.5 \). Variants are labeled by attribute source (k-NN, RK or FCN) and by how attributes are used (ATT for attention, MAX for element-wise max, CON for concatenation).
Upper bound with ground-truth attributes
Ground-truth attributes are the most common words in each image's reference captions, and they are treated as an upper bound. With these attributes the attention variant reached CIDEr 1.685 on MS-COCO, with B-4 at 0.534, and CIDEr 0.949 on Flickr30k, with B-4 at 0.412.
Under the same setting MAX reached CIDEr 1.161 and CON reached 1.237 on MS-COCO, both below the attention variant. The authors read these numbers as evidence that the attributes can help a great deal when they are of high quality.
Predicted attributes on MS-COCO and Flickr30k
On the MS-COCO validation set, the attention model with FCN attributes reached B-4 0.304 and METEOR 0.243. Google NIC scored B-4 0.203 and Toronto scored B-4 0.250 and METEOR 0.230 under the same benchmark.
The B-1 score is the exception on MS-COCO, where the attention model scores 0.709 against 0.718 for Toronto. The authors suggest the gap may come from different word-vocabulary preprocessing, which they did not check.
On Flickr30k the attention model with FCN attributes reached B-4 0.230 and METEOR 0.189, and it leads the baselines in the table on every metric except B-1. Its B-1 is 0.647 against 0.669 for Toronto.
Across the fusion variants, MAX and CON with FCN attributes are reported to outperform the compared methods on most metrics. The top three attributes gave the best MAX and CON results. RK attributes scored below k-NN attributes for CON on MS-COCO B-4, at 0.237 against 0.279. The authors tentatively link this to a lack of local features in ranking-loss training.
Online test server ranking
Ours-ATT-FCN was scored on the MS COCO c5 and c40 test sets through the official server. Its ATT entry reached CIDEr 0.9431 on c5, equal to the OV entry and above MSR Cap at 0.9313 and mRNN at 0.9174.
The authors say the entry held the top position on many metrics at submission time, and that it ranked higher than the two other leading entries across metrics.
Input and output attention ablation
The ablation keeps ATT-FCN and trains on MS-COCO with ground-truth attributes. The input-only variant reached CIDEr 1.56 and the output-only variant 1.58, while the full model reached 1.68. On B-4 the input-only and output-only variants both reach 0.50, and the full model reaches 0.53.
Output-only is slightly better than input-only on some metrics, but combining both improves almost every metric. The authors attribute this to the two sides attending to different aspects of the attributes.
Attention weights across a caption
For example images, the input weights α and the output weights β are plotted at each generation step, for the three top attributes of each example. In the swimming example, attention on swimming peaks after ducks is generated, on both α and β.
In the motorcycle example, the motorcycle attribute draws strong attention on both sides, and β peaks twice, once near the opening phrase and once near riding a.
The authors read the difference this way: β follows the output words more closely, while α spreads over background context such as the plate and the group.
Where attributes help and where they mislead
The qualitative comparison sets ATT against Google NIC on examples where the attributes help (green examples) and on two where incorrect attributes appear (red examples). These are example captions with their top attributes, not a scored comparison.
In one red example the attribute clock draws the model toward a tower in the background rather than the main foreground objects. In the rightmost red example, tower may be the cause of building in the predicted caption.
Limitations
The ground-truth results show a ceiling rather than the setting used in the main comparisons, which rely on predicted attributes.
Experiments cover only MS-COCO and Flickr30k. The authors note that other attribute predictors may do better but were outside the scope of this work.
The B-1 score is lower than Toronto's on both benchmarks, and the authors' explanation for the MS-COCO gap was not verified.
The test-server ranking is a snapshot at submission time and depends on the entries present then. The tables report no variance or significance measure for the comparisons.
Paper info
- Authors
- Quanzeng You, Hailin Jin, Zhaowen Wang, Chen Fang, Jiebo Luo
- Venue
- arXiv · Preprint
- First published
- 2016-3-12
- Added
- 2026-11-12
- Updated
- 2016-3-12
- Version
- v1
- arXiv
- 1603.03925
- 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
Quanzeng You, Hailin Jin, Zhaowen Wang, Chen Fang, Jiebo Luo (2016). Image Captioning with Semantic Attention. arXiv:1603.03925v1. https://arxiv.org/abs/1603.03925v1
BibTeX
@misc{you2016image,
title = {{Image Captioning with Semantic Attention}},
author = {Quanzeng You and Hailin Jin and Zhaowen Wang and Chen Fang and Jiebo Luo},
year = {2016},
eprint = {1603.03925},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1603.03925v1}
}