Chain of Thought Prompt Tuning in Vision Language Models

Jiaxin Ge, Hongyin Luo, Siyuan Qian, Yulu Gan, Jie Fu, Shanghang ZhangarXiv 2023

Abstract

Language-Image Pre-training has demonstrated promising results on zero-shot and few-shot downstream tasks by prompting visual models with natural language prompts. However, most recent studies only use a single prompt for tuning, neglecting the inherent step-to-step cognitive reasoning process that humans conduct in complex task settings, for example, when processing images from unfamiliar domains. Chain of Thought (CoT) is a simple and effective approximation to the human reasoning process and has been proven useful for natural language processing (NLP) tasks. Based on this cognitive intuition, we believe that conducting effective reasoning is also an important problem in visual tasks, and a chain of thought could be a solution to this problem. In this work, we propose a novel chain of thought prompt tuning for vision-language modeling. Extensive experiments show that our method not only generalizes better in image classification tasks, has greater transferability beyond a single dataset, and has stronger domain generalization performance, but also performs much better in image-text retrieval and visual question answering, which require more reasoning capabilities. We are the first to successfully adapt chain-of-thought prompting that combines visual and textual embeddings.

Introduction: The Need for Visual Reasoning

Vision-Language Models (VLMs) like CLIP have revolutionized zero-shot learning by aligning visual and textual representations. However, adapting these models to specific downstream tasks typically involves "prompt tuning," where a single context vector is learned to guide the model. Current methods like CoOp or CoCoOp treat this as a one-shot process, which contrasts sharply with human cognition.

When humans encounter complex or unfamiliar visual scenes, we often engage in a sequential reasoning process. For instance, identifying a specific animal might involve a series of mental steps: "It’s an animal... it has white fur... it has a black nose... it’s a dog." This "Chain of Thought" approach has been highly successful in Large Language Models (LLMs) for solving multi-step logic problems, but it has remained largely unexplored for visual tasks. Existing VLM prompt engineering often lacks this step-by-step logic, causing models to struggle when generalizing to new classes or out-of-distribution (OOD) domains.

Intuition of Chain-of-Thought reasoning in NLP versus visual understanding.

Proposed Architecture: Chain of Thought Prompt Tuning

To address this, we introduce a novel architecture that mimics human reasoning through three interconnected components designed to refine visual and textual embeddings sequentially.

1. Prompt Chaining

Instead of a static, single prompt, the model employs a series of $N$ prompts. Each step $j$ in the chain integrates information from the previous step $j-1$ using a weighted combination: $G(t_j) = (1 - \lambda_j) * G(t_{j-1}) + \lambda_j * G(t_j)$. This residual-like structure allows the model to incrementally refine its "thoughts" without losing the original context.

2. Meta-Nets Chaining

To ground these thoughts in visual context, the architecture uses a sequence of "Meta-Nets." These networks generate step-specific visual biases that are added to the text embeddings. By chaining these networks, visual information flows alongside textual reasoning, ensuring that the model's "logic" is constantly updated by the image features.

3. Self-Adaptive Chain Controller

Recognizing that not all images require the same cognitive load, we include a lightweight MLP-based controller. This module looks at the input image and dynamically predicts the weights ($\lambda$) for each step in the chain. This allows the model to decide how much to rely on previous steps versus the current one based on the complexity of the visual input.

The proposed architecture featuring Prompt Chaining, Meta-Nets Chaining, and a Self-Adaptive Chain Controller.

Experimental Evaluation

We evaluated our method across a massive battery of benchmarks, including 11 classification datasets (e.g., ImageNet, EuroSAT, Caltech101), cross-dataset transfer, and domain generalization tasks. We also tested on reasoning-heavy tasks like image-text retrieval (MSCOCO, Flickr30k) and Visual Question Answering (VQAv2).

Key Results

  • Generalization: Our method improved the Harmonic Mean (H-score) in base-to-new class generalization by 1.27% on average across 11 datasets compared to CoCoOp.
  • Reasoning Tasks: The most significant gains were seen in tasks requiring deeper logic. Image-text retrieval improved by 0.97% (R@1), and VQA performance increased by 1.07%.
  • Robustness: The model demonstrated superior performance under domain shifts, achieving a 0.26% gain in domain generalization across variants like ImageNet-Sketch and ImageNet-Adversarial.

Insights and Discussion

Through extensive ablation studies, we identified several key properties of visual CoT:

  • The "Sweet Spot" of Thinking: We found that a chain length of 3 is generally optimal. Shorter chains lack reasoning depth, while longer chains (4 or 5) can become unstable or overfit to specific datasets.
  • Structure Over Parameters: Simply adding more parameters in a parallel fashion does not yield the same benefits as the sequential chain structure. The flow of information through the chain is the primary driver of generalization.
  • Improved Confidence: The CoT approach improves the model's confidence, producing higher probability scores for correct choices compared to previous methods.

Conclusion

This work represents the first successful adaptation of Chain-of-Thought prompting to combined visual and textual embeddings. By structuring prompt tuning as a sequential reasoning process, our model achieves state-of-the-art generalization and reasoning capabilities across a wide array of VLM tasks, proving that visual CoT is a robust strategy for model adaptation.

Summary updated

BibTeX
@misc{ge2023chain,
  author = {Jiaxin Ge and Hongyin Luo and Siyuan Qian and Yulu Gan and Jie Fu and Shanghang Zhang},
  title = {{Chain of Thought Prompt Tuning in Vision Language Models}},
  year = {2023},
  eprint = {2304.07919},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.07919},
}
Figure