[Paper Review] A Simple Zero-shot Prompt Weighting Technique to Improve Prompt Ensembling in Text-Image Models
The paper introduces Zero-shot Prompt Ensembling (ZPE): automatically score a large pool of prompts without labeled data, normalize scores to reduce pretraining/test biases, apply softmax weighting or prompt selection, and demonstrate improved zero-shot accuracy over hand-crafted prompts across ImageNet, its variants, and fine-grained datasets.
Contrastively trained text-image models have the remarkable ability to perform zero-shot classification, that is, classifying previously unseen images into categories that the model has never been explicitly trained to identify. However, these zero-shot classifiers need prompt engineering to achieve high accuracy. Prompt engineering typically requires hand-crafting a set of prompts for individual downstream tasks. In this work, we aim to automate this prompt engineering and improve zero-shot accuracy through prompt ensembling. In particular, we ask "Given a large pool of prompts, can we automatically score the prompts and ensemble those that are most suitable for a particular downstream dataset, without needing access to labeled validation data?". We demonstrate that this is possible. In doing so, we identify several pathologies in a naive prompt scoring method where the score can be easily overconfident due to biases in pre-training and test data, and we propose a novel prompt scoring method that corrects for the biases. Using our proposed scoring method to create a weighted average prompt ensemble, our method outperforms equal average ensemble, as well as hand-crafted prompts, on ImageNet, 4 of its variants, and 11 fine-grained classification benchmarks, all while being fully automatic, optimization-free, and not requiring access to labeled validation data.
Motivation & Objective
- Automate prompt engineering for zero-shot classifiers by scoring a large pool of prompts for a given downstream task without labeled validation data.
- Develop a bias-corrected prompt scoring method to avoid overconfident prompts driven by pretraining and test data frequencies.
- Demonstrate that a weighted or selected prompt ensemble using the scores improves zero-shot classification accuracy over equal-weight ensembles and hand-crafted prompts across diverse datasets.
Proposed method
- Use a large pool of prompts and compute a zero-shot score s_p for each prompt without access to labeled data.
- Identify pathologies in naive max-logit scoring due to word frequency biases and propose normalization using expected logits from pretraining and test distributions.
- Normalize logits via logits_normalized = logits - (E_pretrain + E_test)/2 to reduce biases.
- Compute prompt scores s_p by averaging max over classes of the normalized logits across images.
- Apply softmax weighting over prompt scores to form a weighted ensemble of logits (Equation 3/5) to mitigate long-tail effects.
- Optionally perform prompt selection by outlier detection (median and MAD) with a threshold tau to use only top prompts (Equation 4).
Experimental results
Research questions
- RQ1Can a zero-shot model select and weight prompts automatically from a large pool to maximize downstream zero-shot accuracy without labeled validation data?
- RQ2How can prompt scoring be corrected to mitigate pretraining word-frequency biases and test-data concept frequency biases?
- RQ3Does a weighted or selected prompt ensemble outperform equal-weight ensembles and hand-crafted prompts across diverse datasets?
- RQ4What is the impact of normalization and weighting schemes on the effectiveness of zero-shot prompt ensembling?
- RQ5How does prompt pool size and composition affect zero-shot performance on ImageNet and fine-grained datasets?
Key findings
- Weighted ZPE ensembles outperform equal-average ensembles and hand-crafted prompts on ImageNet, ImageNet variants, and several fine-grained benchmarks.
- Normalization using E_pretrain and E_test reduces word-frequency bias and spurious concept frequency bias, improving zero-shot accuracy across tasks.
- Softmax weighting of prompt scores generally yields better performance than raw-scores weighting or plain max-logit methods.
- Prompt selection (outlier-based tau threshold) can yield improvements, especially on fine-grained datasets where domain-specific prompts are more valuable.
- Across CLIP ViT-B/16 and LiT ViT-L/16, ZPE-based weighted averaging achieves higher average accuracies than hand-crafted prompts and naive methods, with notable gains on several datasets.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.