Finetuning CLIP to Reason about Pairwise Differences

Dylan Sam, Devin Willmott, Joao D. Semedo, J. Zico Kolter
9/15/2024
cs.LGcs.CV

No official code found. Best implementation: dsam99/pc_clip (21 stars, last commit 2024-10-01).

Abstract

Vision-language models (VLMs) such as CLIP are trained via contrastive learning between text and image pairs, resulting in aligned image and text embeddings that are useful for many downstream tasks. A notable drawback of CLIP, however, is that the resulting embedding space seems to lack some of the structure of its purely text-based alternatives. For instance, while text embeddings have long been noted to satisfy analogies in embedding space using vector arithmetic, CLIP has no such property. In this paper, we propose an approach to natively train CLIP in a contrastive manner to reason about differences in embedding space. We finetune CLIP so that text descriptions of differences between images correspond to their difference in image embedding space, using synthetically generated data with large language models on image-caption paired datasets. We first demonstrate that our approach yields significantly improved capabilities in ranking images by a certain attribute (e.g., elephants are larger than cats), which is useful in retrieval or constructing attribute-based classifiers, and improved zeroshot classification performance on many downstream image classification tasks. In addition, our approach enables a new mechanism for inference that we refer to as comparative prompting, where we leverage prior knowledge of text descriptions of differences between classes of interest, achieving even larger performance gains in classification. Finally, we illustrate that the resulting embeddings obey a larger degree of geometric properties in embedding space, such as in text-to-image generation.

View on arXivView PDF

Code Implementations(1)

dsam99/pc_clipCommunity100%

Code for the paper "Finetuning CLIP to Reason about Pairwise Differences"

211PythonSep 13, 20242 years ago

Similar Papers

Cite this paper

@article{sam2024finetuning,
  title  = {Finetuning CLIP to Reason about Pairwise Differences},
  author = {Dylan Sam and Devin Willmott and Joao D. Semedo and J. Zico Kolter},
  year   = {2024},
  eprint = {2409.09721},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2409.09721v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2409.09721.svg)](https://codeofpaper.com/paper/2409.09721)

Discussion