Title: Generalized Logit Adjustment: Calibrating Fine-tuned Models by Removing Label Bias in Foundation Models
Venue: NeurIPS 2023
Accepted: yes
Keywords: Foundation Model

Class Bias

Generalized Logit Adjustment
Abstract: Foundation models like CLIP allow zero-shot transfer on various tasks without additional training data. Yet, the zero-shot performance is less competitive than a fully supervised one. Thus, to enhance the performance, fine-tuning and ensembling are also commonly adopted to better fit the downstream tasks. However, we argue that such prior work has overlooked the inherent biases in foundation models. Due to the highly imbalanced Web-scale training set, these foundation models are inevitably skewed toward frequent semantics, and thus the subsequent fine-tuning or ensembling is still biased. In this study, we systematically examine the biases in foundation models and demonstrate the efficacy of our proposed Generalized Logit Adjustment (GLA) method. Note that bias estimation in foundation models is challenging, as most pre-train data cannot be explicitly assessed like in traditional long-tailed classification tasks.
To this end, GLA has an optimization-based bias estimation approach for debiasing foundation models. As our work resolves a fundamental flaw in the pre-training, the proposed GLA demonstrates significant improvements across a diverse range of tasks: it achieves 1.5 pp accuracy gains on ImageNet, an large average improvement (1.4-4.6 pp) on 11 few-shot datasets, 2.4 pp gains on long-tailed classification. Codes are in https://github.com/BeierZhu/GLA.

Generalized Logit Adjustment: Calibrating Fine-tuned Models by Removing Label Bias in Foundation Models

Abstract

Foundation models like CLIP allow zero-shot transfer on various tasks without additional training data. Yet, the zero-shot performance is less competitive than a fully supervised one. Thus, to enhance the performance, fine-tuning and ensembling are also commonly adopted to better fit the downstream tasks. However, we argue that such prior work has overlooked the inherent biases in foundation models. Due to the highly imbalanced Web-scale training set, these foundation models are inevitably skewed toward frequent semantics, and thus the subsequent fine-tuning or ensembling is still biased. In this study, we systematically examine the biases in foundation models and demonstrate the efficacy of our proposed Generalized Logit Adjustment (GLA) method. Note that bias estimation in foundation models is challenging, as most pre-train data cannot be explicitly accessed like in traditional long-tailed classification tasks. To this end, GLA has an optimization-based bias estimation approach for debiasing foundation models. As our work resolves a fundamental flaw in the pre-training, the proposed GLA demonstrates significant improvements across a diverse range of tasks: it achieves 1.5 pp accuracy gains on ImageNet, a large average improvement (1.4-4.6 pp) on 11 few-shot datasets, 2.4 pp gains on long-tailed classification. Codes are in https://github.com/ BeierZhu/GLA .

1 Introduction

Thanks to the Web-scale data and self-supervised strategies, foundation models like CLIP [40] empower zero-shot transfer to a wide variety of domains [7, 1, 52]. However, the zero-shot performance is still weak on several domain-specific tasks such as differentiating models of cars, species of flowers, and variants of aircraft [40, 7]. Therefore, it is a common practice to improve the downstream performance via supervised fine-tuning on labeled data, e.g. , linear probing, prompt tuning [54, 55], and end-to-end fine-tuning.

However, fine-tuned models are easily biased: they are adept in exploiting spurious correlations that only hold on the downstream distribution [40, 39, 48, 55]. To improve the robustness, several studies [48, 55, 56] propose to combine fine-tuned models with zero-shot models. For example, WiSE-FT [48] ensembles the fine-tuned and zero-shot models in weight space and ProGrad [55] uses zero-shot predictions to regularize the fine-tuning gradient. The underlying assumption lies in that the zero-shot models are robust to distribution shifts [40], and their predictions are complementary to those of fine-tuned models [48].

Despite these methods exhibiting performance gains on both in-distribution and out-of-distribution evaluations, they all overlook the inherent bias originating from the foundation models. Specifically, the Web-scale data for pre-training foundation models exhibit a highly skewed distribution due to Zipf's law of nature [42]. The resulting foundation models develop a biased decision boundary that leads to a poor zero-shot performance on rare classes. As evidenced in Figure 1(a) and (b), the purple

Model

Head

Medium

Tail

All

Zero-Shot

78.0

69.8

57.2

68.3

Fine-Tuned

83.6

83.0

77.3

81.3

WiSE-FT

85.3

(+1.7)

83.7 (+0.7)

76.4

(-0.9)

81.8 (+0.5)

GLA (ours)

85.2

(+1.6)

84.3

(+1.3)

78.8 (+1.5)

82.8

(+1.5)

Zoomed in results

Estimated label distribution

Head

Medium

Tail

(a) Per class accuracy of different models on ImageNet

(b) Beak-down performance of different models on ImageNet

line encounters a dramatic drop, and the zero-shot performance of tail classes is significantly lower than that of head classes ( 57 . 2% vs . 78 . 0% ). Existing ensemble methods like WiSE-FT [48] overlook the label bias, resulting in an improvement in top-1 ( +0 . 5% ) and head accuracy ( +1 . 7% ) while a noticeable degradation on the tail performances ( -0 . 9% ) in Figure 1(b). Another evidence is that the orange line (WiSE-FT) is below the blue line (fine-tuned models) for rare classes in Figure 1(a).

We propose Generalized Logit Adjustment (GLA), a simple post-hoc method consisting of two steps: 1) removing the label bias of zero-shot model via estimating the label distribution in the pre-training dataset; 2) ensembling the fine-tuned and debiased zero-shot models. As illustrated in Figure 1 (b), our GLA achieves consistent improvement across all three subgroups, particularly showing a significant gain on tail classes ( +1 . 5% ). Despite its simplicity, our GLA has a firm statistical grounding: it is the Bayes optimal classifier given the fine-tuned and zero-shot models, thus consistent for minimizing the error on a class-balanced target distribution (Section 4.2). It is worth noting that removing the bias of foundation models is challenging since the label distribution is often inaccessible due to privacy or copyright concerns. In this work, we only use the downstream labeled data and the zero-shot model to estimate the foundation label bias. Specifically, we formulate the problem by adjusting the margin of the zero-shot models such that the lowest error is achieved on the downstream dataset. This grounding translates into strong empirical performance on real-world datasets, covering few-shot, many-shot, and long-tail learning (Section 5).

The contributions and novelties of this work are summarized as follows:

We point out the overlooked label bias in foundation models, which originates from the skewness of pre-training distribution that affects the performance of downstream tasks.

We formalize the estimation of the label bias as a constrained optimization problem (Section 3.2) with theoretical justification (Section 4.3). The entire process does not require access to the pre-training dataset, making it practical for fine-tuning scenarios. We present Generalized Logit Adjustment (GLA) method, which ensembles the debiased zero-shot and fine-tuned models, and demonstrate its superiority over conventional fine-tuning and ensembling by proving it's a Bayes optimal classifier (Section 4.2).

We build a comprehensive benchmark for evaluation, which considers three real-world settings and three fine-tuning paradigms. The settings are: 1) many-shot learning with abundant data 2) few-shot learning; and 3) long-tail classification, representing a more challenging scenario that combines many-shot and few-shot data (Section 5). The three fine-tuning paradigms include: 1) end-to-end fine-tuning; 2) linear probing; and 3) prompt tuning (Section 3.1).

We demonstrate the efficacy of our proposed method GLA by conducting extensive experiments across various settings and fine-tuning paradigms. We observe 1 to 1.5 pp accuracy gains on ImageNet, large averaged improvement (1.4 to 4.6 pp) on 11 few-shot datasets and 2.4 pp averaged accuracy gains on long-tail datasets. (Section 5).

2 Related Work

Image-text foundation models. Foundation models pre-trained by contrastive objectives have set impressive milestones for image and text representation learning, with CLIP [40], ALIGN [23], CoCa [52] and Flamingo [1] being the exemplars. Such models exhibit impressive prompt-based zero-shot performance on various image recognition downstream tasks. Our method aims to reduce foundation model biases to boost performance in downstream tasks. While [2] also addresses word frequency bias, we differ in two key areas: Firstly, we debias zero-shot models using fixed prompts, whereas [2] refines the prompting process. Secondly, our GLA doesn't require access to a subset of the pre-training data.

Ensembles. Ensemble methods aim to boost performances by combining multiple networks, which can be either implemented by aggregating model outputs [12, 4, 28, 14, 27, 51], weight-space ensembling [48, 22], or ensemble distillation [19, 29]. For the adaptation of foundation models, several work propose to ensemble the fine-tuned and zero-shot models for better performance: Wortsman et al. [48] ensembles them in weight space; ProGrad and ProReg [55, 56] propose to fuse them via knowledge distillation. Our GLA is orthogonal to these approaches, as it concentrates on mitigating the biases in foundation models that are detrimental to ensemble models.

Logit adjustment. Logit adjustment [35, 45, 24, 49, 20] is a post-hoc technique to adjust the biased output of classification networks. Kang et al [24] proposes an element-wise scaling adjustment for the classifier weight. Tang et al [45] removes the projection of features on a global biased direction. Menon [35] derives the theoretically optimal adjustment from the training distribution. Unlike the those approaches which rely on a transparent training data or class distribution, our GLA can eliminate the class bias without accessing to the pre-training statistics.

3 Methods

3.1 Setup

Task. Consider a classification problem with instances x ∈ X and labels y ∈ Y = [ K ] = { 1 , ..., K } . We have a zero-shot model f zs (given below), a downstream dataset D s = { x i , y i } N s i =1 drawn from source distribution P s and a fine-tuned model f ft (given below) trained on the dataset D s . Give a model f : X → R K that outputs prediction score, we define the risk of f on the target distribution P t as the mis-classification rate: R t ( f ) = E x ,y ∼ P t [ y = argmax i f ( x ) i ] . Our goal is to learn a model f gla that best leverages f zs and f ft that minimizes the risk R t .

̸

Zero-shot models. We primarily explore CLIP [40] for zero-shot models. CLIP consists of a visual encoder Φ v ( x ) and a text encoder Φ t ( t ) , producing l 2 -normalized features from an image x and a text t respectively. Zero-shot model f zs for K classes is enabled by matching image features v = Φ v ( x ) with classification weights w k = Φ t ( t k ) , where t k is obtained by extending the class name { c k } to a pre-defined prompt, e.g. , 'a photo of a { c k }.'. Additional details are provided in Appendix B.2. The probability of x being classified as y is defined as:

Fine-tuned models. Standard fine-tuning initializes the model f ft with the pre-trained parameters and then solve f ft = argmin f R s ( f ) to minimize the risk on downstream dataset. We consider three common variants of fine-tuning: (1) end-to-end, where all parameters of Φ v and w k are updated; (2) linear probing, where only w k is modified while Φ v is fixed; (3) prompt tuning, where the text input t k is learned, while keeping Φ v and Φ t freezed. See Appendix B.3 for details on fine-tuning methods.

Notation. Let P p ( y ) , P s ( y ) and P t ( y ) be the marginal probability of class y ∈ [ K ] for pre-training, source (training) and target (test) distribution, respectively. Let π p and π s denote the log probabilities of class for pre-training and training distribution, i.e. , π p ( y ) = log P p ( y ) and π s ( y ) = log P s ( y ) .

3.2 Generalized Logit Adjustment Framework

Fine-tuned models often yield significant gains compared to zero-shot models, and ensembling them can further improve performance. This leads to a natural question: How should we best leverage

(b) Estimated label distribution

q

(a) Averaged outputs of zero-shot model

(c) Averaged outputs of debiased zero-shot model

the zero-shot and fine-tuned models for the prediction tasks? We attempt to answer by proposing generalized logit adjustment in Definition 1.

Definition 1. ( GLA ) The Generalized Logit Adjustment (GLA) model f gla is defined as follows:

In Section 4.2, we prove that given the zero-shot and fine-tuned models, our GLA model is the Bayes optimal classifier and no other combination of the two models can outperform it. Here remains one important question: how could we obtain π p as we have no access to the pre-training statistics? We provide the estimation process of π p in Eq (4) and postpone the justification in Section 4.3. The entire GLA algorithm consists of two steps which is given as follows:

Step 1: Estimation of π p . Let q be an arbitrary probability simplex over K classes. Given the validation data from P t or the balanced training data, we can estimate the ˆ π p = log q ∗ as the constrained optimization problem (proof in Section 4.3):

We constrain the sum of q to be 1 and ensure that each element is non-negative, guaranteeing that it forms a valid probability distribution. We solve the following Lagrangian problem to find optimal q ∗ :

Step 2: GLA ensembling. Given the estimated ˆ π p and the known downstream training π s , we ensemble the zero-shot model f zs and the fine-tuned model f ft to get our GLA model f gla via Eq. (2). We can regard f zs -ˆ π p and f ft -π s as the debiased zero-shot model (Figure 2(c)) and debiased fine-tuned models, respectively. Our GLA is actually ensembling two debiased models. Note that, different from [55, 48], we do not require a hyper-parameter to adjust the contribution of the two models, the optimal solution is to combine them equally (see Section 4.2 for justification).

4 Theoretical Analysis

In this section, we explain why our GLA model best ensembles the zero-shot and fine-tuned models (Section 4.2) and justify the estimation process of the pre-training label distribution π p (Section 4.3). We start with some preliminaries on Bayes optimal classifier.

4.1 Preliminaries

Suppose we have a pair ( X,Y ) ∼ P takes values in X × Y , where Y is the class label of input X

Definition 2. The 0-1 error (risk) of a classifier ˆ y : X → Y on distribution P

̸

. is given by:

̸

However, the 0-1 error is non-smooth, one typically minimizes a surrogate loss ℓ , e.g. , crossentropy: ℓ ( f ( x ) , y ) = log[ ∑ i ∈ [ K ] exp( f ( x ) i -f ( x ) y )] , where ˆ y ( x ) = argmax i f ( x ) i . It is known that the cross-entropy loss is Bayes consistent [53], i.e. , a nearly optimal minimizer of the crossentropy loss ( E x ,y ∼ P [ ℓ ( f ( x ) , y ) ] is also a nearly optimal optimizer of the mis-classification error ( E x ,y ∼ P [ y = ˆ y ( x )] ).

Definition 3. The Bayes optimal classifier y ∗ for P given input x is defined as:

It is called Bayes optimal classifier because on the average no other classifier using the same hypothesis and prior knowledge can outperform it.

Lemma 1. The Bayes optimal classifier y ∗ for P has lower risk than all classifiers ˆ y : X → Y .

4.2 Generalized Logit Adjustment Leads to Better Ensembling

Zero-shot and fine-tuned models are complementary. We revisit an empirical phenomena observed in [48] Section 5.1: After exploring a series of measures of diversity, covering predictions and features, they find that zero-shot and fine-tuned models have diverse predictions, despite sharing the same backbone. As the two data distribution P s and P p is known to be different, the resulting models leverage different cues to predict: fine-tuned models risk exploiting spurious correlations and indomain patterns which only hold for downstream dataset [46, 3]; On the other hand, zero-shot CLIP models capture stable correlations across diverse domains and exhibit much higher robustness [40]. For instance, zero-shot models rely on robust features for decisions that can achieve high performance on sketch and adversarial samples, while the fine-tuned models that trained on real images typically fail on these samples, as they rely on spurious correlations that only hold on real images. We formulate the phenomena in the following assumption.

Assumption 1. Zero-shot and fine-tuned models have diverse predictions:

We derive the conditional probability P t ( y | f ft ( x ) , f zs ( x )) w.r.t. the outputs of f zs ( x ) and f ft ( x ) :

Lemma 2. For a balanced target distribution 1 , where P t ( y ) = 1 /K for all y ∈ [ K ] , we have:

Intuitively, since the zero-shot and fine-tuned models provide diverse predictions, conditioned on the two predictions is equivalent to adding the logits in log space. Additionally, as the target distribution is class-balanced, we need to remove the class bias of two models by subtracting π s and π p . The formal proof is given in Appendix A.1. Note that the RHS of Eq. (9) is exactly the softmax output of our GLA model by Definition 1, which exhibits the following property:

Proposition 1. Let g : R K × R K → R K be an arbitrary function that ensemble the outputs of f zs and f ft . Our GLA classifier f gla has lower risk than any function f g ( x ) = g ( f zs ( x ) , f ft ( x )) , i.e.

Proof. From Lemma 2 and Definition 1, we have:

(11)

which means f gla is the Bayes optimal classifier (see Definition 3) given f ft ( x ) and f zs ( x ) . According to Lemma 1, any other classifier g ( f ft ( x ) , f zs ( x )) must have higher risk, i.e. , R t ( f gla ) ≤ R t ( f g ) .

Proposition 1 demonstrates that our f gla model is the best model, as it has the lowest risk on target distribution. Proposition 1 further explains the superiority of f gla over the fine-tuned model f ft and the naive ensemble f ens ( x ) = f ft ( x ) + f zs ( x ) :

Corollary 1. f gla performs better than fine-tuned model f ft and naive emsembling f ens :

Discussion: when do the GLA models degenerate? Note that there are two equality signs in Eq. (12), indicating that the performance of the GLA model can degenerate to be equivalent to that of the fine-tuned model and naive ensembling in the following two cases.

Case 1 : For the first equality, if zero-shot model f zs ( x ) provides no further information about y given f ft ( x ) , i.e. , ( y ⊥ f zs ( x )) | f ft ( x ) , then P t ( y | f ft ( x ) , f zs ( x )) degenerates to P t ( y | f ft ( x )) and the first equality applies. However, in practice, as downstream model and zero-shot model provides diverse predictions, we usually encounter strict inequality, i.e. , R t ( f gla ) < R ( f ft ) .

Case 2 : The second equality applies when pre-training and downstream training distribution are both class-balanced. In fact, the pre-training dataset for foundation models are known to be highly skewed. Therefore, in most cases, we have R t ( f gla ) < R t ( f ens ) .

In summary, the above two equalities are usually unattainable, which means that theoretically, our GLA model performs better than both the fine-tuned and the naive ensemble models.

4.3 Estimate the label bias of the pre-training dataset

However, π p is usually unknown as we have no access to pre-training dataset. In this work, we seek to estimate π p using the zero-shot models and the downstream data. Similar to Proposition 1, we have the following proposition says that f zs -π p has lower error on target distribution than any other classifiers that use f zs , see Appendix A.2 for the full proof.

Proposition 2. Let h : R K → R K be an arbitrary function that predicts labels using the outputs of the zero-shot model f zs ( x ) . Let the derived classifier be denoted as f h ( x ) = h ( f zs ( x )) . The classifier f zs -π p is better than any f h ( x ) : R t ( f zs -π p ) ≤ R t ( f h ( x )) .

Let q be an arbitrary probability simplex over K classes, then we have R t ( f zs ( x ) -π p ) ≤ R t ( f zs ( x ) -log q ) . Therefore, we choose to optimize a probability simplex q over K classes such that the model f zs -log q achieves the minimal empirical risk, as formulated in Eq. (3) (the Step 1 of GLA algorithm). Once we obtain the estimated class prior ˆ π p = log q , we can easily implement the GLA model by ensembling f gla ( x ) = f ft ( x ) + f zs ( x ) -π s -ˆ π p (the Step 2 of GLA algorithm).

Toy experiment. We conducted an experiment to show that the estimated label distribution closely approximates the true one. Specifically, we trained a model with a ResNet32 backbone on the imbalanced CIFAR-10-LT [10] dataset with an imbalanced ratio of 10. Subsequently, we used only the test set combined with our proposed method to estimate the label distribution. This procedure simulates scenarios where only downstream data is available and the pre-training data is inaccessible.

Figure 3 reveals a strong alignment between the estimated (orange line) and the actual distributions (blue line), which is further emphasized by a small KL-divergence value of 0.00062. The toy experiment validates the effectiveness of our debiasing method.

2

4

6

8

10

Class Index (sorted from head to tail)

0.00

0.05

0.10

0.15

0.20

0.25

0.30

0.35

0.40

Probability

True Label Distribution

Estimated Label Distribution

Discussion. The log q we estimated is not the marginal log-probability of the entire pre-training distribution but the label bias matches the downstream distribution. In the above toy experiment, although training and test sets show different label distributions, their conditional distribution P ( x | y ) remains invariant. In this case, our estimate will converge to the actual training label bias. For CLIP models, with diverse pre-training data, some might not align with the downstream domain, potentially compromising the accuracy of the estimation of the entire pre-training distribution.

However, we'd like to point out that removing the label bias of entire pre-training distribution may not optimal for downstream tasks. As a thought experiment, consider a pre-training dataset "sketch"

and "photo" styles for "dog" and "cat" samples. Suppose the sample size of "dog' and "cat' is equal but there are more "sketch dogs' than "sketch cats'. This means that even if the overall distribution is balanced, each style isn't, resulting in biased zero-shot predictions. if we aim to deploy models for the "sketch dogs and cats' domain, adjusting the overall label bias is insufficient. Instead, the optimal label bias should be estimated on the 'sketch' distribution. We also provide experiments using LAION-400M dataset in Appendix C.2, illustrating the situation when the downstream data diverges from the pre-training set.

5 Experiments

We evaluate our GLA on three real-world scenarios: many-shot (Section 5.1), few-shot (Section 5.2) and long-tail learning (Section 5.3). We show that our GLA boosts performance on all three settings.

5.1 Many-shot learning

Datasets. We use ImageNet [11] and CIFAR100 [26] for generic object classification, StanfordCars [25] for fine-grained classification, and SUN397 [50] for scene recognition. See Appendix B.1 for details.

Baselines. We compare GLA against four methods: (1) Zero-shot model, (2) Linear Probing (LP), (3) End-to-End fine-tuning (E2E), and (4) weight ensembling method WiSE-FT[48].

Implementation details. We consider two models: CLIP ViT-B/32 and ViT-B/16. For learning-based models, we fine-tune with AdamW using a cosine annealing learning rate scheduler. We fine-tune for 10 epochs on ImageNet and 20 epochs on other datasets. See Appendix B.3 for further details.

Main results. Table 1 compares our GLA with various baselines. We observe that our GLA can increase the performance of end-to-end fine-tuned models: it achieves 1 . 5% gains on ImageNet. Compared to WiSE-FT, GLA gains 1 . 1% top-1 accuracy boost on ImageNet dataset,. Beyond generic object recognition, our method also improves accuracy on the fine-grained dataset (Stanford Cars) and the scene recognition dataset (SUN397), by 0 . 4% and 0 . 5% , respectively.

Breakdown performance analysis. To analyze the impact of pre-training label bias on fine-tuned and ensemble models, we present the breakdown results on ImageNet using CLIP ViT-B/16, as shown in Table 2. Specifically, we sort the class index using the estimated π p , and assign the top third of the classes as the head classes, the last third as the tail classes, and the remaining classes as the medium classes. Due to the label bias, the zero-shot tail performance is significantly lower than the head one ( 57 . 2% vs . 78 . 0% ). The resulting E2E models are also affected by the bias, with the tail performance being 6 . 3% lower than the head. Existing ensemble WiSE-FT overlooks the bias, exhibiting noticeable degradation on the tail performances ( -0 . 9% ) compared to E2E model, while our GLA stands out for all three subgroups.

Estimated π p is transferable across different zero-shot models. The estimated π p should be transferable across different zero-shot models if they are trained on the same pre-training dataset. To verify this, we employed a CLIP ViT-B/32 based zero-shot model to estimate π p , which is subsequently used to debias zero-shot models based on CLIP ViT-B/16 and ViT-L/14. As shown in Table 3, our debiased models outperform the original zero-shot versions by a clear margin.

0 1 2

4

8

16

Shots per class

60.0

62.5

65.0

67.5

70.0

72.5

75.0

Accuracy (%)

Average over 11 datasets

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

58

60

62

64

66

Accuracy (%)

ImageNet

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

87

88

89

90

91

92

93

Accuracy (%)

Caltech101

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

82

83

84

85

86

87

88

89

90

Accuracy (%)

OxfordPets

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

55.0

57.5

60.0

62.5

65.0

67.5

70.0

72.5

75.0

Accuracy (%)

StanfordCars

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

65

70

75

80

85

90

95

Accuracy (%)

Flowers102

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

72

74

76

78

80

Accuracy (%)

Food101

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

10

15

20

25

30

Accuracy (%)

FGVCAircraft

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

60

62

64

66

68

70

72

Accuracy (%)

SUN397

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

45

50

55

60

65

Accuracy (%)

DTD

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

40

50

60

70

80

Accuracy (%)

EuroSAT

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

0 1 2

4

8

16

Shots per class

62

64

66

68

70

72

74

76

Accuracy (%)

UCF101

ZS CLIP

PLOT

CoOp

ProGrad

GLA (ours)

Ensembling with mixing coefficient. In Section 5.1, we prove the optimal solution is to combine the debiased zero-shot and fine-tuned models equally. We now examine the claim by introducing a mixture coefficient α ∈ [0 , 1] . The ensemble predictions are given by: f gla ( x , α ) = (1 -α ) · ( f zs ( x ) -π p ) + α · ( f ft ( x ) -π s ) . We compare the GLA and the naive ensembling with mixture α in Figure 4, where GLA meets its optimal performance at α = 0 . 5 , which is in line with our theoretical analysis. We also observe that the debiased zero-shot model increases accuracy by 2 . 3% and our GLA consistently outperforms naive ensembling with various α .

5.2 Few-shot learning

For few-shot scenarios, we primarily choose prompt tuning for fine-tuning, since it is empirically more effective than end-to-end fine-tuning and linear probing [54, 55, 8].

Datasets. We follow CoOp[54] to use 15 datasets: ImageNet [11], Caltech101 [13], OxfordPets [37], StanfordCars [25], Flowers102 [36], Food101 [6], FGVCAircraft [34], EuroSAT [16], UCF101 [44],

0.0

0.2

0.4

0.6

0.8

1.0

68

70

72

74

76

78

80

82

Accuracy (%)

ImageNet

GLA

ENS

E2E FT

ZS-

p

ZS

0.5

0.0

0.5

1.0

1.5

2.0

2.5

3.0

Absolute improvement (%) over the fine-tuned models

FGVCAircraft

UCF101

Caltech101

Flower102

SUN397

EuroSAT

ImageNet

StanfordCars

Food101

OxfordPets

DTD

Naive Ensemble

GLA (ours) Ensemble

DTD [9], SUN397 [50], ImageNet-{V2 [41], Sketch [47], A [18], R [17]}. We randomly select {1, 2, 4, 8, 16} shots for training and use the original test set for evaluation. See Appendix B.1 for details.

Baselines. We compare with three prompt tuning methods: (1) CoOp [54] optimizes prompts via empirical risk minimization; (2) ProGrad [55] prevents forgetting the general knowledge using zero-shot predictions; (3) PLOT [8] applies optimal transport to match the vision and text modalities.

Implementation details. We implement our proposed GLA method using CLIP-ResNet-50 as the foundation model and adopt class-specific prompt tuning from CoOp. Results are averaged over three seeds, with training configurations aligned with CoOp. See Appendix B.4 for further information.

Main results. Figure 5 summarizes the few-shot results on 11 datasets. The detailed accuracy and standard deviation are in Appendix C.1. Overall, our GLA clearly outperforms the baselines on average performance by a large margin, e.g. , our GLA gains 4 . 6% , 4 . 8% , 3 . 1% , 2 . 6% and 1 . 6% performance boost over CoOp at 1 , 2 , 4 , 8 , 16 shots. In particular, on ImageNet dataset, we observe a large improvement, e.g. , 3 . 9% , 2 . 9% , 1 . 9% , 2 . 0% and 2 . 2% over ProGrad at 1 , 2 , 4 , 8 , 16 shots. Furthermore, on OxfordPerts, Food101 and SUN397 datasets, our method's performance remains stable and consistently improves with increasing sample sizes, while the one of the baseline methods fluctuates significantly. In particular, on Food101, baseline models even underperform zero-shot models by a large margin, while our GLA shows clearly better performance than zero-shot models.

Robustness to distribution shifts. Following CoOp, we used the ImageNet at 16 training shots as the source domain and assess the robustness on ImageNet-{V2, Sketch, A, R} datasets. Table 4 summarizes the results, where the prompt tuning baselines perform worse on distribution shifted datasets compared to the zero-shot model, as fine-tuning on limited data misleads the model to learn in-distribution correlations. In comparison, our GLA approach makes the best of both fine-tuned and zero-shot models, thus consistently outperforms other methods on both source and target domains.

GLA improves accuracy over naive ensemble. Figure 6 compares the results between our GLA and naive ensembling. We rank the absolute improvements over fine-tuning baseline at 16 training shots. In summary, our GLA demonstrates superior accuracy gains. It is worth noting that the naive ensembling does not always lead to improvements, e.g. , on EuroSAT, SUN, Caltech, UCF and Aircraft, naive ensembling even underperforms fine-tuning baseline.

Debiased zero-shot models perform better. We estimate π p at 16 shots and compare the original zero-shot models with the debiased zero-shot models in Table 5. It is clear that the debiasing leads to improvement on all 11 datasets, showcasing an average accuracy gain of 1 . 6% .

5.3 Long-tail learning

Datasets and metrics. We evaluate our method on two standard benchmarks: Places365-LT and ImageNet-LT [31]. In addition to top-1 accuracy, we report the accuracy on three test subsets

(a) ImageNet-LT

(b) Places365-LT

according to the number of samples per class: many-shot ( > 100 samples), medium-shot ( 20 ∼ 100 samples), and few-shot ( < 20 samples). Detailed information is provided in Appendix B.1.

Fine-tuning and long-tail learning baselines. We compare our GLA with the combinations of fine-tuning protocols and long-tailed recognition methods. We consider three fine-tuning protocols: 1) Linear Probe (LP) 2) End-to-End (E2E) fine-tuning; 3) Prompt Tuning (PT). The three fine-tuning paradigms are introduced in Section 3.1 with details in Appendix B.3. We compare with 5 long-tail learning methods: 1) standard Empirical Risk Minimization (ERM); 2) Learnable Weight Scaling (LWS) [24]; 3) Logit Adjustment (LA) [35]; 4) Balanced Softmax (BS) [43], and 5) BALLAD [33], which is designed for VLMs. See Appendix B.6 for more details on long-tail baselines.

Implementation Details. For all combinations of the fine-tuning and long-tail learning baselines, visual backbones are initialized from CLIP-ResNet-50 and classifiers are initialized via zero-shot prompting. We use SGD for 50 epochs with batch size of 512. See Appendix B.6 for further details.

Results. Table 6 shows that our GLA method consistently surpasses baselines across all long-tailed datasets. Our approach outperforms PT-based models by 3 . 5% and 4 . 4% on ImageNet-LT and Places365-LT, respectively. Against E2E approaches, GLA exceeds not just the WiSE-FT but also the current SOTA method BALLAD, by a large margin, e.g. , 1pp gains on ImageNet-LT.

6 Conclusion and Limitation

In this paper, we identify the label bias in foundation models and underscore its adverse effects on downstream task performance. We propose the Generalized Logit Adjustment (GLA) framework for fine-tuning foundation models, which boosts the performance by effectively eliminating label bias and combining diverse predictions from zero-shot and fine-tuned models. We prove that when presented with zero-shot and fine-tuned models, our GLA is the Bayes optimal classifier for downstream task. Extensive experiments across a diverse range of tasks and fine-tuning framework demonstrate the effectiveness of our approach. We believe that the proposed GLA may partially improve the fairness and credibility of foundation models.

The first limitation is that we only focus on the label bias while other forms of model biases, e.g. , representation bias [5], cannot be addressed by our algorithm yet. The second limitation is that we primarily focus on enhancing the fine-tuning performance for discriminative models. However, applying our GLA framework to generative models presents challenges. For instance, language generation operates as a Markov process, meaning each output depends on previous ones. This implies it's not straightforward to estimate the biasedness of a sequence with our GLA, as we only compute the bias in a pre-defined and independent label space.

Acknowledgments

This research is supported by the National Research Foundation, Singapore under its AI Singapore Programme (AISG Award No: AISG2-PhD-2021-01-002 and AI Singapore AISG2-RP-2021-022).

References

Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. NeurIPS , 2022.

James Urquhart Allingham, Jie Ren, Michael W Dusenberry, Xiuye Gu, Yin Cui, Dustin Tran, Jeremiah Zhe Liu, and Balaji Lakshminarayanan. A simple zero-shot prompt weighting technique to improve prompt ensembling in text-image models. In ICML , 2023.

Martin Arjovsky. Out of distribution generalization in machine learning . PhD thesis, New York University, 2020.

Eric Bauer and Ron Kohavi. An empirical comparison of voting classification algorithms: Bagging, boosting, and variants. Machine learning , 1999.

Rishi Bommasani, Drew A Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, et al. On the opportunities and risks of foundation models. Technical Report , 2021.

Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101-mining discriminative components with random forests. In ECCV , 2014.

Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In NeurIPS , 2020.

Guangyi Chen, Weiran Yao, Xiangchen Song, Xinyue Li, Yongming Rao, and Kun Zhang. Prompt learning with optimal transport for vision-language models. ICLR , 2023.

Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In CVPR , 2014.

Yin Cui, Menglin Jia, Tsung-Yi Lin, Yang Song, and Serge Belongie. Class-balanced loss based on effective number of samples. In CVPR , 2019.

Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR , 2009.

Thomas G Dietterich. Ensemble methods in machine learning. In Multiple Classifier Systems: First International Workshop , 2000.

Li Fei-Fei, Rob Fergus, and Pietro Perona. Learning generative visual models from few training examples: An incremental bayesian approach tested on 101 object categories. In CVPRW , 2004.

Yoav Freund and Robert E Schapire. A decision-theoretic generalization of on-line learning and an application to boosting. Journal of computer and system sciences , 1997.

Jose Gallego-Posada and Juan Ramirez. Cooper: a toolkit for Lagrangian-based constrained optimization. https://github.com/cooper-org/cooper , 2022.

Patrick Helber, Benjamin Bischke, Andreas Dengel, and Damian Borth. Eurosat: A novel dataset and deep learning benchmark for land use and land cover classification. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing , 2019.

Dan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Zhu, Samyak Parajuli, Mike Guo, et al. The many faces of robustness: A critical analysis of out-of-distribution generalization. In CVPR , 2021.

Dan Hendrycks, Kevin Zhao, Steven Basart, Jacob Steinhardt, and Dawn Song. Natural adversarial examples. In CVPR , 2021.

Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. NeurIPS Workshop , 2014.

Youngkyu Hong, Seungju Han, Kwanghee Choi, Seokjun Seo, Beomsu Kim, and Buru Chang. Disentangling label distribution for long-tailed visual recognition. In CVPR , 2021.

Gabriel Ilharco, Mitchell Wortsman, Ross Wightman, Cade Gordon, Nicholas Carlini, Rohan Taori, Achal Dave, Vaishaal Shankar, Hongseok Namkoong, John Miller, Hannaneh Hajishirzi, Ali Farhadi, and Ludwig Schmidt. Openclip. Technical report, Zenodo, jul 2021.

Pavel Izmailov, Dmitrii Podoprikhin, Timur Garipov, Dmitry Vetrov, and Andrew Gordon Wilson. Averaging weights leads to wider optima and better generalization. UAI , 2018.

Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc Le, Yun-Hsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In ICML , 2021.

Bingyi Kang, Saining Xie, Marcus Rohrbach, Zhicheng Yan, Albert Gordo, Jiashi Feng, and Yannis Kalantidis. Decoupling representation and classifier for long-tailed recognition. In ICLR , 2020.

Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In CVPRW , 2013.

Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.

Ananya Kumar, Tengyu Ma, Percy Liang, and Aditi Raghunathan. Calibrated ensembles can mitigate accuracy tradeoffs under distribution shift. In UAI . PMLR, 2022.

Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and scalable predictive uncertainty estimation using deep ensembles. NeurIPS , 2017.

Tao Lin, Lingjing Kong, Sebastian U Stich, and Martin Jaggi. Ensemble distillation for robust model fusion in federated learning. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin, editors, NeurIPS , 2020.

Zachary Lipton, Yu-Xiang Wang, and Alexander Smola. Detecting and correcting for label shift with black box predictors. In ICML , 2018.

Ziwei Liu, Zhongqi Miao, Xiaohang Zhan, Jiayun Wang, Boqing Gong, and Stella X Yu. Large-scale long-tailed recognition in an open world. In CVPR , 2019.

Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In ICLR , 2019.

Teli Ma, Shijie Geng, Mengmeng Wang, Jing Shao, Jiasen Lu, Hongsheng Li, Peng Gao, and Yu Qiao. A simple long-tailed recognition baseline via vision-language model. arXiv preprint arXiv:2111.14745 , 2021.

Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Finegrained visual classification of aircraft. arXiv preprint arXiv:1306.5151 , 2013.

Aditya Krishna Menon, Sadeep Jayasumana, Ankit Singh Rawat, Himanshu Jain, Andreas Veit, and Sanjiv Kumar. Long-tail learning via logit adjustment. In ICLR , 2021.

Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In Indian Conference on Computer Vision, Graphics & Image Processing , 2008.

Omkar M Parkhi, Andrea Vedaldi, Andrew Zisserman, and CV Jawahar. Cats and dogs. In CVPR , 2012.

Xingchao Peng, Qinxun Bai, Xide Xia, Zijun Huang, Kate Saenko, and Bo Wang. Moment matching for multi-source domain adaptation. In ICCV , 2019.

Hieu Pham, Zihang Dai, Golnaz Ghiasi, Kenji Kawaguchi, Hanxiao Liu, Adams Wei Yu, Jiahui Yu, Yi-Ting Chen, Minh-Thang Luong, Yonghui Wu, et al. Combined scaling for zero-shot transfer learning. arXiv preprint arXiv:2111.10050 , 2021.

Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In ICML , 2021.

Benjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize to imagenet? In ICML , 2019.

William J Reed. The pareto, zipf and other power laws. Economics letters , 2001.

Jiawei Ren, Cunjun Yu, Xiao Ma, Haiyu Zhao, Shuai Yi, et al. Balanced meta-softmax for long-tailed visual recognition. NeurIPS , 2020.

Khurram Soomro, Amir Roshan Zamir, and Mubarak Shah. Ucf101: A dataset of 101 human actions classes from videos in the wild. arXiv preprint arXiv:1212.0402 , 2012.

Kaihua Tang, Jianqiang Huang, and Hanwang Zhang. Long-tailed classification by keeping the good and removing the bad momentum causal effect. NeurIPS , 2020.

Rohan Taori, Achal Dave, Vaishaal Shankar, Nicholas Carlini, Benjamin Recht, and Ludwig Schmidt. Measuring robustness to natural distribution shifts in image classification. NeurIPS , 2020.

Haohan Wang, Songwei Ge, Zachary Lipton, and Eric P Xing. Learning robust global representations by penalizing local predictive power. NeurIPS , 2019.

Mitchell Wortsman, Gabriel Ilharco, Jong Wook Kim, Mike Li, Simon Kornblith, Rebecca Roelofs, Raphael Gontijo Lopes, Hannaneh Hajishirzi, Ali Farhadi, Hongseok Namkoong, et al. Robust fine-tuning of zero-shot models. In CVPR , 2022. https://arxiv.org/abs/2109. 01903 .

Tong Wu, Ziwei Liu, Qingqiu Huang, Yu Wang, and Dahua Lin. Adversarial robustness under long-tailed distribution. CVPR , 2021.

Jianxiong Xiao, James Hays, Krista A Ehinger, Aude Oliva, and Antonio Torralba. Sun database: Large-scale scene recognition from abbey to zoo. In CVPR , 2010.

Xuanyu Yi, Jiajun Deng, Qianru Sun, Xian-Sheng Hua, Joo-Hwee Lim, and Hanwang Zhang. Invariant training 2d-3d joint hard samples for few-shot point cloud recognition. In ICCV , 2023.

Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. Coca: Contrastive captioners are image-text foundation models. TMLR , 2022.

Tong Zhang. Statistical behavior and consistency of classification methods based on convex risk minimization. The Annals of Statistics , 2004.

Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for vision-language models. IJCV , 2022.

Beier Zhu, Yulei Niu, Yucheng Han, Yue Wu, and Hanwang Zhang. Prompt-aligned gradient for prompt tuning. In ICCV , 2023.

Beier Zhu, Yulei Niu, Saeil Lee, Minhoe Hur, and Hanwang Zhang. Debiased fine-tuning for vision-language models by prompt regularization. AAAI , 2023.

A Proofs

A.1 Proof of Lemma 2

Restated Lemma (Lemma 2). Let π t denote the log probability of the target label distribution π t ( y ) = log P t ( y ) , we have:

In class-balanced target distribution, Eq. (13) simplifies to:

Proof. Denote the output e = f ft ( x ) and z = f zs ( x ) . We first use the Bayes Rule to decompose P t ( y | e , z ) into P t ( e , z | y ) , P t ( y ) and P t ( e , z ) in Eq. (15), then rewrite P t ( e , z | y ) in Eq. (16) according to Assumption 1. Focusing on label shift problem [35, 20, 30] where P ( x | y ) does not change, we derive Eq. (17)

(20)

Since e , z are fixed, we can replace the terms that not rely on y with a constant C 1 in Eq. (21). We replace P s ( y ) = exp(log P s ( y )) = exp( π s ( y )) , P p ( y ) = exp(log P p ( y )) = exp( π p ( y )) and P t ( y ) = exp(log P t ( y )) = exp( π t ( y )) . Suppose the underlying class-probabilities P s ( y | e ) ∝ exp( e y ) and P p ( y | z ) ∝ exp( z y ) for y ∈ [ K ] . Denote the constants C s and C p for normalizing exp( e y ) and exp( z y ) into probabilities, and merge all constants to C = C 1 C s C p , we get Eq. (23)

Because the summation of P t ( y | e , z ) is 1, C = 1 / ∑ i ∈ [ K ] exp( e + z -π s -π p + π t )( i ) . Therefore, we have:

In class-balanced target distribution case, π t = log 1 K is constant. Since the softmax function is invariant to constant offsets, Eq. (26) simplifies to:

A.2 Proof of Proposition 2

Restated Proposition (Proposition 2). Suppose that the target distribution P p is class-balanced. Let h : R K → R K be an arbitrary function that predicts labels using the outputs of the zero-shot model f zs ( x ) . Let the derived classifier be denoted as f h ( x ) = h ( f zs ( x )) . The classifier f zs -π p is better than any f h ( x ) : R t ( f zs -π p ) ≤ R t ( f h ( x )) .

Proof. Denote the output z = f zs ( x ) . Similar to Eq. (15)-Eq. (26), we have

Therefore, we have:

Again, using Lemma 1, any other classifier f h ( x ) has higher risk than f zs ( x ) -π p , i.e. , R t ( f zs -π p ) ≤ R t ( f h ( x )) .

B Experimental Details

B.1 Dataset details

Many-shot and few-shot datasets. For many-shot learning, we use ImageNet, CIFAR100, StanfordCars and SUN397 datasets. For few-shot learning, we evaluate models on 15 datasets. The details of each dataset are presented in Table 7.

Long-tail datasets. We use two standard long-tail benchmarks: Places365-LT and ImageNet-LT [31]. The skewness of a long-tailed training set is typically represented by imbalanced ratio, which is defined as N max /N min . N max ( N min ) denotes the largest (smallest) number of instances per class. A

larger imbalanced ratio means a more imbalanced training set. The test sets are divided into three splits: many-shot subset contains classes with > 100 images, medium-shot subset includes classes with ≥ 20 & ≤ 100 images, and few-shot subset covers classes with < 20 images. Details are listed in Table 8.

B.2 CLIP zero-shot

We use prompt ensembling of 80 prompts provided by CLIP [48] for ImageNet, CIFAR100, and Caltech101 to improve performance, i.e. , averaging the text embedding of many captions, e.g. ., 'a photo of a { c k }.' and 'an image of a { c k }.'. For OxfordPets, StanfordCars, Flowers102, Food101, FGVCAircraft, EuroSAT, UCF101, DTD and SUN397, we use the pre-defined prompt from CoOp [54].

B.3 Fine-tuned models

End-to-end and linear probe fine-tuning. We follow WiSE-FT [48] to implement fine-tuning. We initialize the classifier with the zero-shot classifier and the output of the image encoder Φ v is normalized during fine-tuning. We fine-tune for a total of 10 epochs using AdamW [32] optimizer with default hyper-parameters β 1 = 0 . 9 , β 2 = 0 . 999 , ϵ = 10 -8 and weight decay 0 . 1 . We choose a batch size of 512. We use the same data augmentation and cosine-annealing learning rate schedule as [48].

B.4 Prompt tuning.

Prompt tuning like CoOp [54] automates prompt engineering by learning the prompt given few samples from downstream tasks. CoOp provides two options of prompt design: unified prompt that is shared among all classes and class-specific prompt that is different for each class. In this paper, we adopt the class-specific prompt design as the fine-tuned model to implement GLA . In specific, given the word embedding t 0 k initialized by zero-shot prompts, we aim to learn a collection of class-specific word embedding R = { r k } K k =1 , such that the text input t k = t 0 k + r k minimizes the empirical risk: R ∗ = argmin R E x ,y [ y = argmax i f ( x ; R ) i ] .

̸

We adhere CoOp to use CLIP ResNet-50 as image encoder for few-shot classification. The word embedding R is initialized from zeros. For the m few-shot classification setting (where m ∈ { 1 , 2 , 4 , 8 , 16 } ), we randomly sample m training and m validation points from the respective full datasets. For all few-shot datasets except ImageNet, the training epoch is set to 200 for 16/8 shots, 100 for 4/2 shots, and 50 for 1 shot. For ImageNet, the epoch is set to 50 for all shots. We fine-tune the prompt with SGD optimizer decayed by the cosine annrealing rule. The base initial learning rate and batch size are set to 10 -4 and 32 . When given an m -shot sample setting, we increase the learning rate and batch size by m times simultaneously to accelerate the training speed.

B.5 Estimation of the class prior

To estimate the log-probability of the pre-training distribution ˆ π s = log q , we utilize the optimization toolkit Cooper [15] from https://github.com/cooper-org/cooper . q is initialized as a uniformed distribution, q ( y ) = 1 K for all y ∈ [ K ] . We use the standard SGD as the primal and dual optimizers for 2000 steps.

B.6 Long-tail learning baselines and training details

We compared with 5 long-tailed classification methods:

Standard ERM: We learn the model by standard empirical risk minimization on the long-tailed data.

Learnable Weight Scaling (LWS) [24]: We first learn the model by standard ERM, then fix the model and learn to re-scale the magnitude of the classifier using class-balanced sampling.

Logit Adjustment (LA) [35]: We first learn the model by standard ERM, then compensates the long-tailed distribution by subtracting a class-dependent offset to the model outputs.

Balanced Softmax (BS) [43] modifies the Softmax cross-entropy loss which explicitly accommodate the label distribution shift during optimization.

BALLAD [33] first fine-tunes the vision-language models via contrastive loss on long-tailed data, then freezes the backbone and finally employs an adapter to enhance the representations of tail classes with re-sampling strategies.

For all combinations of the fine-tuning baselines and long-tailed learning methods, visual backbones are initialized from CLIP-ResNet-50 and all classifiers are initialized by feeding prompt with class names to the text encoder. We use SGD for all experiments with a momentum of 0.9 for 50 epochs with batch size of 512. The initial learning rate is set to 1 . 6 × 10 -3 which is decayed by the cosine annealing rule. To mitigate explosive gradients, we use the warmup learning rate equals to 10 -5 during the first epoch. For the sake of fairness in comparison, all hyper-parameters of baselines are carefully searched using grid search on the validation set.

C Additional Experiments

C.1 Few-shot learning accuracy

Table 9: GLA Accuracy (%) with standard deviation of few-shot learning on 11 datasets.

C.2 Experiments on LAION-400M

To support our thought experiment in the discussion of Section 4.3, we use the Open-CLIP ViTB/16 [21], the first 20k image in LAION-400M datasets and the bias estimation method proposed by [2] to estimate the expected logits across 8 classes: 'dog', 'cat', 'squirrel', 'tiger', 'elephant', 'horse', 'pig' and 'bird'. The bias estimation proposed by [2] provides a good estimation of log P ( x ) over the labels under pre-training distribution. Our GLA estimates the label bias matches the downstream domain, we consider two downstream domain styles, i.e. , 'photo' and 'sketch' from DomainNet [38] dataset. For each domain, we randomly sampled 50 images for each class.

Table 10: Comparison among different bias estimation using Open-CLIP-ViT-B/16.

We present the expected logits estimated by [2], along with the one calculated from 'photo' and 'sketch' downstream domain data in Table 10. Since the softmax is invariant to constant offsets, i.e. ,

softmax( x + c ) = softmax( x ) , we align the three label bias to yield the same logits on 'dog' class by subtracting constant values. We observe that the label bias estimated by the "photo" domain align closely with [2] due to its close resemblance to the pre-trained domain. Conversely, the "sketch" image style, which significantly differs from the pre-training domain, results in a more pronounced deviation in the pre-trained label bias.

Additionally, we apply the three estimated label biases to debias the zero-shot model and evaluate the classification performance. The results are shown in Table 11, where the superiority of our method becomes evident on 'sketch' domain (93.00% vs 92.25%). Applying the label bias from [2] on the "sketch" domain degrades the model's performance (from 92.25% to 89.50%). This is attributed to the overall pre-training label bias does not adequately reflect the bias specific to the'sketch' domain.

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper addresses biases in foundation models, such as CLIP, which due to the imbalanced training datasets, are skewed towards frequent semantics. The authors propose a Generalized Logit Adjustment (GLA) method, an optimization-based approach for debiasing these models. Despite inherent challenges, the GLA method demonstrates significant improvements across multiple tasks and datasets, achieving 1.5 pp accuracy gains on ImageNet and large average improvement (1.4-4.6 pp) on 11 few-shot datasets. Notably, the GLA method does not require access to the pre-training dataset, making it practical for fine-tuning scenarios. The paper offers both theoretical justification and extensive empirical evidence for the proposed method.\n\nSTRENGTHS:\n1. **Solid Theoretical Analysis**: The paper provides robust theoretical justification for the Generalized Logit Adjustment (GLA) method. It formalizes the estimation of label bias as a constrained optimization problem, proving that GLA is a Bayes optimal classifier.\n\n2. **Practical Solution**: The proposed method doesn't require access to the pre-training dataset, which makes it practical for fine-tuning scenarios. This approach is useful given privacy and copyright concerns associated with accessing the label distribution of pre-training datasets.\n\n3. **Comprehensive Evaluation**: The paper uses a comprehensive benchmark for evaluation, considering three real-world settings and three fine-tuning paradigms. This diverse approach to evaluation adds credibility to the findings.\n\n4. **Significant Performance Improvement**: The paper reports notable improvements across various tasks, demonstrating the efficacy of the proposed GLA method. The substantial gains across multiple datasets reinforce the value of the method.\n\nWEAKNESSES:\n1. **Limited Validation**: The paper only presents results with a limited set of tasks and models. While they used the CLIP model for the zero-shot setup, the validity and effectiveness of the GLA framework with other models (like BERT, GPT, etc.) have not been validated.\n\n2. **Estimating Pre-training Bias**: The estimation of pre-training label bias is done with downstream data. However, this could be problematic if the downstream data distribution significantly differs from the pre-training data distribution, leading to incorrect bias estimation and sub-optimal performance.\n\nQUESTIONS:\nThe only two questions are listed in weakness.\n\nLIMITATIONS:\nWhile it's a promising beginning to uncover the biases in foundational models, it's crucial to recognize that the exploration should not be confined to computer vision alone. It is necessary to extend the studies to other fields as well.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-06-10"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper studies the label bias in Foundation Models, like CLIP. Specifically, authors model the estimation of the label bias as a constrained optimization problem, and propose a Generalized Logit Adjustment (GLA) method to debias foundation models. Experimental results demonstrate the effectiveness of proposed method.\n\nSTRENGTHS:\n-  Show that the skewness of pre-training distribution affects the performance of downstream tasks, i.e., label bias of foundation models.\n-  Propose a GLA method to ensemble the debiased zero-shot and fine-tuned models.\n-  Extensive experimental results demostrate the superiority of proposed method over conventional fine-tuning.\n\nWEAKNESSES:\n- Authors should discuss the difference with existing label bias estimation methods, e.g. [1,2].\n-  [3] also studied the label bias in CLIP. What's the difference? \n- There exist some strong assumption for proposed method.\n\n[1] Lipton Z, Wang Y X, Smola A. Detecting and correcting for label shift with black box predictors. In ICML, 2018: 3122-3130.\n[2] Garg S, Wu Y, Balakrishnan S, et al. A unified view of label shift estimation. In NeurIPS, 2020, 33: 3290-3300.\n[3] Wang X, Wu Z, Lian L, et al. Debiased learning from naturally imbalanced pseudo-labels. In CVPR, 2022: 14647-14657.\n\nQUESTIONS:\n- The Proposition 1 shows that $f_{gla}$ is the best model, or nearly optimal Bayesian classifer. Thus what leads to the error between the realistic results and the ideal performance of optimal Bayesian classifer.\n- What's the source of the validation data for a specific problem. In all experiments, the compared  fine-tuning methods whether or not to use the validation data.\n- Please illustrate that ''Intuitively, since the zero-shot and fine-tuned models provide diverse predictions, conditioned on the two predictions is equivalent to adding the logits in log space\".\n\nLIMITATIONS:\nThe proposed method can effectively deal with label bias in foundation models. However, it depends on some strong assumptions. E.g., the estimation relies on the validation data. How to guarantee that a good estimation can be obtained with poor validation data.", "TITLE": "Official Review", "RECOMMENDATION": 4, "REVIEWER_CONFIDENCE": 5, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-06-27"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper proposes a distribution estimation method that estimates the distribution of pre-training data for large VLMs like CLIP. Combined with downstream data distributions, a logit adjustment is applied to the outputs of both the zero-shot model and the fine-tuned model. By using a simple ensemble of the zero-shot and fine-tuned models, improved performance is achieved on the reported benchmarks.\n\nSTRENGTHS:\nThe proposed method introduced performance improvements over compared baselines on most of the reported benchmarks.\n\nWEAKNESSES:\nHere are some questions: \n1) The claim \"their predictions are complementary to those of fine-tuned models\" in line 30 cannot be supported by the cited references. Neither [3] nor [14] can support fine-tuned and zero-shot models are complementary. \n2) In addition, in Section 4.2, where the authors attempt to demonstrate the complementarity of fine-tuned models and zero-shot models, the reasoning provided is not persuasive. The authors argue that fine-tuned models are biased towards downstream distributions, while zero-shot models are robust to distribution shifts. However, it remains unclear why a distribution shift-robust model should be complementary to a model that has already been adapted to a shifted distribution. If the authors claim and can prove that zero-shot models can provide something that is missing in the fine-tuned model and cannot be provided by the shifted downstream dataset, it needs to be explicitly demonstrated and proven. Otherwise, this assumption lacks solidity, which consequently undermines the validity of all subsequent proofs.\n3) The rationale behind the method used to estimate the pre-training data distribution is not clearly explained. The paper does not provide sufficient information on why the method is designed in this particular way, nor does it address whether there are any means to verify the effectiveness of this method in accurately estimating the pre-training data distribution. Even though pre-training data is often proprietary, the authors could still perform toy experiments to demonstrate the efficacy of the proposed method. Given that this is a crucial component of the proposed method, it should not be overlooked.\n4) The biggest weakness of this paper is the improvements introduced by the proposed method is very limited (~1% on average across all reported benchmarks). \n\nEdit: most of my concerns are clarified. I will change my rating.\n\nQUESTIONS:\nSame as above.\n\nLIMITATIONS:\nThe biggest limitation is the limited performance improvements.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 2, "SOUNDNESS_CORRECTNESS": 2, "DATE": "2023-07-05"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nLogit adjustment method has been widely used in long-tailed recognition, in which the source dataset is available, thus the class margin can be set in advance. However, the large-scaled foundational data cannot be accessed. To reduce the recognition bias of foundational models on downstream tasks, this paper proposes a generalized logit adjustment (GLA) method. The main contribution of GLA is to estimate the class margins for zero-shot models, after that, the fine-tuned and debiased zero-shot models are assembled together to achieve consistent improvement. The authors demonstrate the effectiveness of the proposed method through extensive experiments, including three tasks and three finetuning approaches.\n\nSTRENGTHS:\n1) Estimate the class margins for foundational models is an important task, especially when the pretrained datasets are not available. This paper proposes an effective generalized logit adjustment method for the zero-shot models. \n\n2) To estimate the class margins, the authors consider it as a simple constrained optimization problem. They also provide theoretical analysis for their GLA method. The proofs seem to be ok.\n\n3) The authors verify their method with extensive experimental results, including many-shot learning, few shot learning and long-tailed recognition tasks. The presented results deem to be good.\n\nWEAKNESSES:\nThe main weaknesses include the following three aspects.\n\n1) The proposed method is simple, and the theoretical proofs look a little reluctant.\n\na. Section 4.1 sees to be redundant. The Definitions and Lemma are less important for the following analysis.\n\nb. The proof and conclusion of Proposition1 are not convincing. \n\nc. There are some false assumptions about the discussion of Corollary 1. In case 1, the authors claim that the zero-shot model can not provide further improvement when the fine-tuned model is given. Obversely, this is wrong. Because their combination can further improve recognition accuracy.\n\n2) The authors did not show the algorithm steps when estimating class margins (Eq. 3). They also did not provide the complexity and convergence of this optimization problem, and the choice of hyper-parameter \\lambda. \n\n3) Unfair comparisons make results look good. For example, in long-tail learning, the proposed GLA is an ensemble model with larger network parameters. Thus, it is not surprising that it outperforms other baselines. Please provide the model parameters and inference time to show the improvement.\n\nOther comments:\n\n1) Typo in line 109: w_k is not model parameter.\n\n2) In Eq.4, v should be bold.\n\nQUESTIONS:\n1) How to initialize q?\n\n2) Your assumption in Lemma 2 does not always hold, the target distribution may be unbalanced.\n\n3) Please provide more analysis for your proofs. The constant C_2 in Eq. 21 and the conclusion of Eq. 30 are not easy to understand.\n\nLIMITATIONS:\nThe authors discuss the limitations of their method.", "TITLE": "Official Review", "RECOMMENDATION": 4, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-10"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper proposes a method for combining the predictions of zero-shot and few-shot classifiers. The method removes the need for a weighting hyper-parameter to interpolate between the predictions. Furthermore, it also removes a source of bias (due to the frequency of words in the pre-training dataset).\n\nSTRENGTHS:\n## Simplicity \n\nThe proposed method is both simple to understand and implement. This means that it could have a significant impact. Simple methods can easily be deployed by both practitioners and by researchers (as a strong baseline for future work). \n\n## Presentation\n\nThe presentation of the method is clear, concise, and easy to understand. \n\n## Experimental Results\n\nThe experimental results show that the proposed method improves over a selection of sensible baselines in a range of settings, with some strong improvements in several cases.\n\nWEAKNESSES:\n## Correctness\n\nWhile the proposed method clearly results in improved performance in several settings, it is not clear to me that the reason for the improvement suggested by the authors is correct. That is, I am not convinced that the proposed method to estimate the label bias of the pre-training dataset is working as intended. Does $\\log \\mathbf{q}$, αs described in eq 3 and sec 4.3, provide a good estimate of $\\pi_p$? I do not believe that the paper provides theoretical or empirical evidence that this is the case and that the mechanism behind the success of the method is due to the suggested bias improvement, rather than something else. \n\n##############\n\n### Edit, after rebuttal and discussion. \n\nThe authors have now addressed my concerns above. They have demonstrated that their approximation is accurate when the downstream and pre-training datasets are similar. They have also shown that when the downstream and pre-training datasets are different, the approximation becomes worse. Nonetheless, the proposed method still works well, and the authors have given intuition for why this might be the case. Given the authors proposed updates to the paper, I believe that the story of the paper will now be accurate and clear. I've raised my score from 5 to 7.\n\nQUESTIONS:\nAdditional experimental and theoretical analysis showing that $\\log \\mathbf{q} \\approx \\pi_p$ would significantly strengthen the paper. Concretely, if this weakness were addressed, I would happily increase my score by 1-2 points. \n\nThe true value of $\\pi_p$ could, for example, be estimated by using the LAION-400m dataset, which is similar in scale and content to the true pre-training dataset of CLIP and results in similar zero-shot accuracies. This was the approach taken in the \"A Simple Zero-shot Prompt Weighting Technique to Improve Prompt Ensembling in Text-Image Models\" paper (https://arxiv.org/abs/2302.06235), which addresses similar biases in the context of prompt selection in zero-shot classifiers.  \n\nAdditionally, including the above-mentioned paper in the related work would be useful.\n\nLIMITATIONS:\nThe theoretical and experimental analysis does not support the main claim of the paper, as discussed above under \"weaknesses\".", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-26"}