OTTER: Effortless Label Distribution Adaptation of Zero-shot Models

Changho Shin, Jitian Zhao, Sonia Cromp, Harit Vishwakarma, Frédéric Sala · DOI

Abstract: Popular zero-shot models suffer due to artifacts inherited from pretraining. One particularly detrimental issue, caused by unbalanced web-scale pretraining data, is mismatched label distribution. Existing approaches that seek to repair the label distribution are not suitable in zero-shot settings, as they have mismatching requirements, such as needing access to labeled downstream task data or knowledge of the true label balance in the pretraining distribution. We sidestep these challenges and introduce a simple and lightweight approach to adjust pretrained model predictions via optimal transport. Our technique requires only an estimate of the label distribution of a downstream task. Theoretically, we characterize the improvement produced by our procedure under certain mild conditions and provide bounds on the error caused by misspecification. Empirically, we validate our method in a wide array of zero-shot image and text classification tasks, improving accuracy by 4.8% and 15.9% on average, and beating baselines like prior matching -- often by significant margins -- in 17 out of 21 datasets.

Introduction

Zero-shot models like CLIP or BERT are trained on massive, unfiltered web-scale datasets. While powerful, these models inherit the biases of their training data. A major issue is label distribution mismatch: if a model was pretrained on data where "dogs" appeared ten times more often than "cats," it will naturally be biased toward predicting "dog" even when applied to a perfectly balanced downstream dataset.

Label distribution mismatch in zero-shot models (RN50, ViT-B/16) compared to ground truth.

Existing solutions to this "label shift" usually require labeled downstream data to fine-tune the model or knowledge of the pretraining distribution to perform prior matching. Both are often unavailable in zero-shot scenarios. OTTER (Optimal TransporT adaptER) seeks to adjust these biased predictions at inference time using only a rough estimate of the target task's label distribution.

Methods

OTTER treats classification not as a series of independent decisions, but as a resource allocation problem solved via Optimal Transport (OT). Instead of taking the highest probability for each individual image (the "naive" approach), OTTER looks at a batch of unlabeled test data. It uses the model's predicted negative log-probabilities as a "cost" for assigning a specific sample to a specific class. By enforcing a constraint that the final predictions must follow a specified label distribution, OTTER finds the global assignment that minimizes total cost using the Sinkhorn algorithm.

For online scenarios where samples arrive one by one, the authors introduce R-OTTER (Reweighting OTTER). This variant uses OTTER's batch predictions as pseudo-labels to learn a simple reweighting factor, allowing for real-time adaptation.

Key Insights and Results

A core insight of OTTER is that it performs global optimization. While standard classification only cares about the best fit for one image, OTTER ensures the entire batch makes sense collectively based on the known task balance. Mathematically, the authors prove that one can recover the Bayes-optimal classifier using only the target distribution and the model's internal scores, provided the model is well-calibrated.

OTTER performance and robustness to distribution shift and estimation noise.

Empirical validation across 21 datasets (17 image, 4 text) shows that OTTER improved zero-shot accuracy by an average of 4.8% for images and 15.5% for text. It outperformed standard baselines like "Prior Matching" in 17 out of 21 datasets. Furthermore, theoretical bounds and empirical tests demonstrate that OTTER is robust to noise; even with a slightly incorrect estimate of the target label distribution, it generally outperforms the biased naive model.

Conclusion

OTTER provides a lightweight, training-free method to mitigate label distribution artifacts in zero-shot models. By framing adaptation as an optimal transport problem, it achieves significant accuracy gains without requiring access to proprietary pretraining data. While it currently relies on a batch requirement and an accurate distribution specification, its efficiency and robustness make it a practical tool for real-world deployment of large-scale pretrained models.

Summary updated

BibTeX
@inproceedings{shin2024otter,
  author = {Changho Shin and Jitian Zhao and Sonia Cromp and Harit Vishwakarma and Frédéric Sala},
  title = {{OTTER: Effortless Label Distribution Adaptation of Zero-shot Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=RsawwSBCs7},
}
Figure