OTTER: Improving Zero-Shot Classification via Optimal Transport

Changho Shin, Jitian Zhao, Sonia Cromp, Harit Vishwakarma, Frederic Sala · DOI

Introduction

Zero-shot models, such as CLIP, have revolutionized computer vision and natural language processing by enabling classification without task-specific training. However, these models often suffer from a significant "prior bias." Because they are trained on massive, uncurated web datasets, they tend to over-predict classes that were more frequent during pretraining. This leads to a "label shift" when the model is applied to a downstream task with a different distribution (e.g., a balanced test set).

Label distribution mismatch in zero-shot classification. Models like CLIP often exhibit biased predictions toward classes that were more frequent in their pretraining data, such as Abyssinian cats over Persian cats.

Existing solutions to this problem typically require access to the pretraining distribution or labeled data from the target task—neither of which is available in a true zero-shot setting. To address this, we introduce OTTER (Optimal TransporT adaptER), a lightweight, tuning-free post-processing method that corrects label distribution bias using the principles of optimal transport.

Methodology

OTTER treats zero-shot classification as an optimal transport (OT) problem. Instead of classifying each sample independently, OTTER processes a batch of test samples and attempts to "transport" them into class "buckets" defined by a target label distribution (e.g., a uniform distribution for balanced datasets).

The objective is to minimize the transport cost, defined as the negative log-probability of the model's predictions, while ensuring the final class proportions match the target estimate. This mathematically principled approach effectively "deflates" the inflated confidence scores of over-represented classes.

Key Variants

  • OTTER (Batch-based): The standard algorithm that processes samples in batches to perform the transport optimization.
  • R-OTTER (Reweighting): Designed for online or streaming scenarios, this version learns adjustment factors from a small validation set, using OTTER's predictions as pseudo-labels to enable sample-by-sample inference.

Experimental Results

OTTER was evaluated across 17 image datasets (including ImageNet and specialized benchmarks like Oxford-IIIT Pet) and 4 text datasets. The results demonstrate substantial performance gains:

  • Image Classification: OTTER improved accuracy by an average of 4.8%.
  • Text Classification: The method achieved a staggering 15.5% average improvement.
  • Large Language Models: OTTER successfully mitigated selection bias in LLMs, boosting accuracy on benchmarks like ARC-Challenge by up to 10.6%.

OTTER outperformed the strong "Prior Matching" baseline in 17 out of 21 datasets, often by significant margins, without requiring any hyperparameter tuning.

Synergy with Few-Shot Learning

While primarily a zero-shot method, OTTER also shows remarkable synergy with few-shot learning. When a small number of labels are available, OTTER can be combined with standard label-shift estimation techniques. As shown in the figure below, the combination of Linear Probing (LP) and OTTER consistently outperforms standard linear probing across various sample sizes.

Accuracy comparison showing that combining Linear Probing with OTTER (LP+OTTER) significantly improves performance over standard Linear Probing (LP) and zero-shot (ZS) baselines as the number of samples per class increases.

Conclusion and Limitations

OTTER provides a simple yet powerful post-processing step to improve zero-shot models. Its primary requirement is an estimate of the target label distribution. While assuming a uniform distribution is often a successful heuristic for balanced benchmarks, the method's performance is tied to the accuracy of this estimate. Future work will explore more robust ways to estimate target distributions in the wild and further refine the theoretical error bounds for high-dimensional settings.

Summary updated

BibTeX
@inproceedings{shin2024otter,
  author = {Changho Shin and Jitian Zhao and Sonia Cromp and Harit Vishwakarma and Frederic Sala},
  title = {{OTTER: Improving Zero-Shot Classification via Optimal Transport}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=RsawwSBCs7},
}
Figure