Controlling Length in Image Captioning

Ruotian Luo, Greg ShakhnarovicharXiv 2020

TL;DR

Researchers from TTI-Chicago have adapted length-control techniques from text summarization to image captioning, allowing models to generate descriptions ranging from short and simple to long and detailed. Their "LenEmb" approach successfully follows specific length constraints while maintaining caption quality, proving that length is a powerful lever for controlling the descriptiveness and style of AI-generated image summaries.

What Problem Does This Paper Address?

Most modern image captioning models use autoregressive architectures (like LSTMs or Transformers) that generate text one word at a time until they hit an "End of Sentence" (<eos>) token. In this setup, the length of the caption is a byproduct of the generation process rather than a controllable parameter.

This lack of control is a problem for two reasons:

  1. User Experience: Different applications require different lengths (e.g., a quick mobile notification vs. a detailed accessibility description).
  2. Descriptiveness: Length is often a proxy for detail. Standard models tend to cluster around average lengths, making it difficult to force the model to be more concise or more descriptive without changing the underlying image features.

Methods

The authors treat length ($l$) as an intermediate variable in the probability chain: $P(caption | image) = P(caption | image, l) * P(l | image)$. They implemented two primary methods borrowed from the field of abstractive summarization:

  • LenEmb (Length Embedding): At each time step $t$, the model calculates the remaining length ($T - t$, where $T$ is the target length). This value is converted into a vector (embedding) and added to the current word embedding before being fed into the LSTM. This acts as a "countdown" signal for the model.
  • Marker: The desired length is treated as a special "first word" token. The model learns to condition the entire subsequent sentence on this initial length marker.
  • Length Prediction Module: To handle cases where a user doesn't specify a length, the authors added a classification module that predicts the "optimal" length based on averaged image region features.

Datasets

The models were trained and evaluated using the MS COCO dataset, specifically following the standard Karpathy split. The authors used "bottom-up" image features (pre-extracted region features) as the visual input for their base model, Att2in.

Key Insights and Ideas

  • LenEmb is the Superior Controller: While both methods work, LenEmb is significantly more robust at following length constraints. As shown in the LenMSE (Length Mean Square Error) plot in Figure 2, LenEmb maintains near-zero error across all lengths, whereas the Marker method begins to fail for captions longer than 20 words, likely due to vanishing long-term dependencies.
  • Length as a Proxy for Detail: Increasing the target length doesn't just add "fluff." Qualitative results show that as the length increases, the model shifts from identifying a single object to describing the environment, background, and specific actions.
  • The Failure of Standard RL Optimization: A surprising finding was that Self-Critical Sequence Training (SCST)—a standard reinforcement learning technique used to boost CIDEr scores—performed poorly with length-controlled models. It led to repetitive words (e.g., "a a") and "bad endings" (sentences ending abruptly with "with a"). This suggests that optimizing for a metric like CIDEr, which naturally penalizes length deviations, conflicts with the goal of explicit length control.

Key Results

The authors demonstrated that their models could generate fluent captions ranging from 7 to 28 words.

Figure 2: Performance metrics across different desired lengths. Note how LenEmb (blue line) maintains zero LenMSE (bottom right) while Marker (orange) spikes at higher lengths.
  • Controllability: LenEmb achieved a length mean square error of 0 when using predicted lengths, meaning it perfectly obeyed the predicted constraint.
  • Quality at Scale: For longer captions (length > 20), LenEmb outperformed the base model on metrics like mCIDEr (a modified CIDEr without length penalties) and SPICE, indicating it successfully captured more information from the reference captions.
  • Visual Examples: In Figure 3 and 4, we see the model's progression. A 7-word caption might be "a motorcycle parked on a dirt road," while a 28-word version of the same image describes the "dirt field," "lot of sheep," and the "sunny day."
Figure 3: Qualitative examples showing how increasing the target length (left column) results in more descriptive captions for the same image.

Limitations and Future Work

The primary limitation identified is the incompatibility with standard SCST optimization. The authors had to rely on cross-entropy loss because the reinforcement learning approach degraded the fluency of the length-constrained captions.

Future work could involve developing new reward functions for reinforcement learning that respect length constraints without sacrificing grammatical fluency. Additionally, while this paper focused on LSTMs, applying these length-embedding techniques to Transformer-based architectures is a natural next step.

Summary updated

BibTeX
@misc{luo2020controlling,
  author = {Ruotian Luo and Greg Shakhnarovich},
  title = {{Controlling Length in Image Captioning}},
  year = {2020},
  eprint = {2005.14386},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2005.14386},
}
Figure