Skip to main content
QUICK REVIEW

[Paper Review] Language Models Can See: Plugging Visual Controls in Text Generation

Yixuan Su, Lü Tian|arXiv (Cornell University)|May 5, 2022
Multimodal Machine Learning ApplicationsComputer Science38 citations
TL;DR

MAGIC is a training-free decoding scheme that grounds GPT-2 text generation with CLIP-based visual controls, enabling zero-shot image captioning and visually grounded story generation with state-of-the-art results and ~27x faster decoding.

ABSTRACT

Generative language models (LMs) such as GPT-2/3 can be prompted to generate text with remarkable quality. While they are designed for text-prompted generation, it remains an open question how the generation process could be guided by modalities beyond text such as images. In this work, we propose a training-free framework, called MAGIC (iMAge-Guided text generatIon with CLIP), for plugging in visual controls in the generation process and enabling LMs to perform multimodal tasks (e.g., image captioning) in a zero-shot manner. MAGIC is a simple yet efficient plug-and-play framework, which directly combines an off-the-shelf LM (i.e., GPT-2) and an image-text matching model (i.e., CLIP) for image-grounded text generation. During decoding, MAGIC influences the generation of the LM by introducing a CLIP-induced score, called magic score, which regularizes the generated result to be semantically related to a given image while being coherent to the previously generated context. Notably, the proposed decoding scheme does not involve any gradient update operation, therefore being computationally efficient. On the challenging task of zero-shot image captioning, MAGIC outperforms the state-of-the-art method by notable margins with a nearly 27 times decoding speedup. MAGIC is a flexible framework and is theoretically compatible with any text generation tasks that incorporate image grounding. In the experiments, we showcase that it is also capable of performing visually grounded story generation given both an image and a text prompt.

Motivation & Objective

  • Motivate how to guide language model generation with non-text modalities, specifically images.
  • Propose a training-free decoding framework (MAGIC) to ground text generation in visual content.
  • Demonstrate zero-shot performance on image captioning and visually grounded storytelling.
  • Show that MAGIC outperforms baselines and offers significant decoding speedups over gradient-based methods.

Proposed method

  • Introduce MAGIC Search, a decoding scheme that adds a CLIP-induced magic score to guide token selection.
  • Define the magic score as a CLIP-based image-text similarity distribution over top-k candidate tokens (Eq. 5).
  • Incorporate model confidence and a degeneration penalty alongside the magic score in the token selection objective (Eq. 4).
  • Fine-tune GPT-2 on the task-specific text corpus with a contrastive objective to calibrate representations (L_MLE + L_CL).
  • Do not require gradient updates during decoding, enabling efficient zero-shot multimodal generation.
  • Demonstrate compatibility with any text-generation task that can be visually grounded.

Experimental results

Research questions

  • RQ1Can a training-free decoding strategy effectively inject visual grounding into a pre-trained language model?
  • RQ2How does CLIP-grounded decoding affect zero-shot image captioning quality and speed compared to gradient-based methods?
  • RQ3Is MAGIC capable of other multimodal generation tasks beyond captioning, such as visually grounded storytelling?

Key findings

  • MAGIC achieves state-of-the-art performance on zero-shot image captioning benchmarks (MS-COCO and Flickr30k) across multiple metrics.
  • MAGIC attains ~27x faster decoding speed than the gradient-based ZeroCap approach.
  • MAGIC shows strong cross-domain robustness, outperforming baselines in cross-domain evaluation.
  • MAGIC extends to visually grounded story generation, delivering higher automatic and human-evaluated quality than baselines.
  • The method remains training-free during decoding, with only a short, negligible task-specific fine-tuning step.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.