ConZIC: Controllable Zero-shot Image Captioning by Sampling-Based Polishing

Zequn Zeng, Hao Zhang, Zhengjue Wang, Ruiying Lu, Dongsheng Wang, Bo Chen · DOI

Abstract

Traditional image captioning models rely heavily on large-scale human-annotated datasets, making them expensive to train and brittle to domain shifts. While zero-shot methods offer a solution, current state-of-the-art approaches like ZeroCap suffer from slow inference speeds and low output diversity. We present ConZIC, a novel framework that treats image captioning as a sampling-based polishing process. By combining a non-autoregressive language model (Gibbs-BERT) with CLIP, ConZIC generates captions that are 5x faster, 1.5x more diverse, and highly controllable across various styles and sentiments without any paired training data.

Introduction

Image captioning (IC) has traditionally been a supervised learning task requiring massive datasets like MS-COCO. This dependency limits the model's ability to generalize to out-of-distribution images, such as sketches or stylized paintings. Zero-shot IC aims to leverage pre-trained vision-language models (e.g., CLIP) and large language models (e.g., GPT) to bypass this requirement. However, existing methods often use slow, gradient-directed searches and autoregressive generation, leading to repetitive sentence structures and high computational costs.

Methodology

ConZIC shifts the paradigm from left-to-right generation to iterative "polishing" of a draft.

Gibbs-BERT: The Sampling Engine

Instead of predicting the next word in a sequence, ConZIC utilizes Gibbs-BERT. This approach treats captioning as a sampling problem where a sentence initially composed of [MASK] tokens is iteratively refined. Because BERT is bidirectional, it can leverage both preceding and succeeding context to "self-correct" words during the polishing process. This bidirectional context is a key advantage over standard autoregressive models.

The Three-Way Guide

To ensure the generated captions are fluent, accurate, and controlled, ConZIC employs a three-way scoring mechanism to decide which word fits best in a [MASK] slot:

  1. Fluency ($p(x)$): Provided by BERT to ensure grammatical correctness.
  2. Visual Grounding ($p(I|x)$): Provided by CLIP, which measures the alignment between the candidate text and the input image.
  3. Control ($p(C|x)$): Provided by a task-specific Discriminator (e.g., a sentiment classifier) to ensure the caption meets desired constraints like style or sentiment.

Non-Autoregressive Polishing

By updating tokens in a non-fixed order, ConZIC avoids the "mode collapse" common in autoregressive models. This randomness allows the model to explore a wider variety of linguistic structures, significantly increasing diversity compared to traditional left-to-right generation.

Key Results and Discussion

ConZIC was evaluated on standard benchmarks (MS-COCO) and specialized datasets for sentiment (SentiCap), style (FlickrStyle10k), and domain shift (SketchyCOCO).

Figure 1: Examples of ConZIC's zero-shot performance on sketches and paintings (top) and its ability to control sentiment (bottom).

Efficiency and Diversity

ConZIC is approximately 5x faster than ZeroCap. Furthermore, it achieves 1.5x higher diversity scores (measured by vocabulary size and Self-CIDEr), avoiding the generic "average" captions produced by supervised models. This efficiency stems from using discrete sampling rather than computationally heavy gradient optimization at inference time.

Robustness and Control

The model demonstrates superior performance on "domain-shifted" images, such as hand-drawn sketches in SketchyCOCO, where supervised models trained on natural photos often fail. In controllable tasks, ConZIC achieved over 97% accuracy in matching target sentiments (positive/negative) while maintaining high image relevance.

Conclusion

ConZIC demonstrates that discrete sampling from a bidirectional distribution is a powerful alternative to gradient-based optimization for zero-shot image captioning. While the model occasionally struggles with fine-grained details, its speed, diversity, and modular controllability represent a significant step forward in flexible vision-language modeling. Future work will explore scaling with more powerful backbones like RoBERTa or ALIGN to further improve caption quality.

Summary updated

BibTeX
@inproceedings{zeng2023conzic,
  author = {Zequn Zeng and Hao Zhang and Zhengjue Wang and Ruiying Lu and Dongsheng Wang and Bo Chen},
  title = {{ConZIC: Controllable Zero-shot Image Captioning by Sampling-Based Polishing}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
  doi = {10.1109/cvpr52729.2023.02247},
}
Figure