Learning to Compose Soft Prompts for Compositional Zero-Shot Learning

Nihal V. Nayak, Peilin Yu, Stephen H. Bach

Abstract

We introduce compositional soft prompting (CSP), a parameter-efficient learning technique to improve the zero-shot compositionality of large-scale pretrained vision-language models (VLMs) like CLIP. We develop CSP for compositional zero-shot learning, the task of predicting unseen attribute-object compositions (e.g., old cat and young tiger). VLMs have a flexible text encoder that can represent arbitrary classes as natural language prompts but they often underperform task-specific architectures on the compositional zero-shot benchmark datasets. CSP treats the attributes and objects that define classes as learnable tokens of vocabulary. During training, the vocabulary is tuned to recognize classes that compose tokens in multiple ways (e.g., old cat and white cat). At test time, we recompose the learned attribute-object vocabulary in new combinations to recognize novel classes. We show that CSP outperforms the CLIP on benchmark datasets by an average of 10.9 percentage points on AUC. CSP also outperforms CoOp, a soft prompting method that fine-tunes the prefix context tokens, by an average of 5.8 percentage points on AUC. We perform additional experiments to show that CSP improves generalization to higher-order attribute-attribute-object compositions (e.g., old white cat) and combinations of pretrained attributes and fine-tuned objects.

Introduction

Humans possess a remarkable ability for compositional reasoning: if one understands the concept of "red" and the object "bus," identifying a "red bus" is intuitive, even if never encountered before. This task, known as Compositional Zero-Shot Learning (CZSL), remains a significant challenge for artificial intelligence. While large-scale Vision-Language Models (VLMs) like CLIP demonstrate broad world knowledge, they often struggle with fine-grained compositions, frequently underperforming compared to smaller, task-specific architectures on standard benchmarks.

Existing approaches to improve CZSL often involve training complex new layers from scratch, which is computationally intensive and can lead to brittle models. This research introduces Compositional Soft Prompting (CSP), a method to enhance CLIP’s compositional abilities without redesigning the model or requiring extensive fine-tuning.

Compositional Soft Prompting (CSP)

CSP builds upon the concept of "Soft Prompting." Unlike previous methods like CoOp, which tune the context prefix (e.g., "A photo of a..."), CSP focuses on the core components of the class description.

Overview of the CSP framework showing how attribute and object tokens are learned and recomposed for unseen classes.

Methodology

The CSP approach treats attributes (e.g., old, furry) and objects (e.g., cat, tiger) as learnable tokens within a vocabulary. The process follows three main stages:

  1. Initialization: The learnable tokens are initialized using CLIP’s original word embeddings.
  2. Training: During training on "seen" classes (e.g., old cat), the model updates only the specific embeddings for the constituent tokens ("old" and "cat"). This allows the model to learn how these tokens should behave when paired.
  3. Inference: To recognize an "unseen" class like old tiger, the model recomposes the fine-tuned "old" token with the fine-tuned "tiger" token in a standard prompt: A photo of [ATTRIBUTE] [OBJECT].

This method is highly parameter-efficient, as it only updates the small subset of vocabulary tokens relevant to the dataset while keeping the massive underlying VLM frozen.

Experimental Setup

The effectiveness of CSP was evaluated on three primary CZSL benchmarks:

  • MIT-States: Natural objects paired with adjectives (e.g., ripe apple).
  • UT-Zappos: Fine-grained shoe types paired with materials or states (e.g., leather slipper).
  • C-GQA: A complex dataset featuring a wide variety of object-state pairs.

The authors also introduced AAO-MIT-States, a challenge subset designed to test higher-order compositions, such as Attribute-Attribute-Object (e.g., old white cat).

Results and Discussion

CSP demonstrated significant performance improvements across all benchmarks. As shown in the results table below, CSP consistently outperforms both vanilla CLIP and the CoOp baseline.

Performance comparison of CSP against CLIP and CoOp across MIT-States, UT-Zappos, and C-GQA datasets.

Key Findings

  • Superior Generalization: CSP improved the Area Under the Curve (AUC) by an average of 10.9 percentage points over vanilla CLIP and 5.8 percentage points over CoOp.
  • Vocabulary vs. Context: The results suggest that for compositional tasks, tuning the "nouns and adjectives" themselves is more effective than tuning the sentence prefix. This allows the model to learn modular representations that generalize when tokens are swapped.
  • Higher-Order Composition: Despite being trained only on pairs, CSP tokens proved robust enough for triplets (Attribute-Attribute-Object), improving unseen accuracy on the AAO-MIT-States challenge by 9.9 percentage points over CLIP.

Conclusion and Future Work

Compositional Soft Prompting provides a simple yet powerful way to leverage the knowledge within large VLMs for specialized compositional tasks. While highly effective, the authors noted that CSP can sometimes lead to a slight trade-off in isolated object recognition accuracy. Future work may explore mitigating this trade-off and improving the model's ability to distinguish between feasible and infeasible "open-world" compositions.

The code for CSP is available at https://github.com/BatsResearch/csp.

Summary updated

Abstract

We introduce compositional soft prompting (CSP), a parameter-efficient learning technique to improve the zero-shot compositionality of large-scale pretrained vision-language models (VLMs) like CLIP. We develop CSP for compositional zero-shot learning, the task of predicting unseen attribute-object compositions (e.g., old cat and young tiger). VLMs have a flexible text encoder that can represent arbitrary classes as natural language prompts but they often underperform task-specific architectures on the compositional zero-shot benchmark datasets. CSP treats the attributes and objects that define classes as learnable tokens of vocabulary. During training, the vocabulary is tuned to recognize classes that compose tokens in multiple ways (e.g., old cat and white cat). At test time, we recompose the learned attribute-object vocabulary in new combinations to recognize novel classes. We show that CSP outperforms the CLIP on benchmark datasets by an average of 10.9 percentage points on AUC. CSP also outperforms CoOp, a soft prompting method that fine-tunes the prefix context tokens, by an average of 5.8 percentage points on AUC. We perform additional experiments to show that CSP improves generalization to higher-order attribute-attribute-object compositions (e.g., old white cat) and combinations of pretrained attributes and fine-tuned objects. The code is available at https://github.com/BatsResearch/csp.
BibTeX
@inproceedings{nayak2023learning,
  author = {Nihal V. Nayak and Peilin Yu and Stephen H. Bach},
  title = {{Learning to Compose Soft Prompts for Compositional Zero-Shot Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=S8-A2FXnIh},
}
Figure