Benchmarking Spurious Bias in Few-Shot Image Classifiers
Guangtao Zheng Wenqian Ye Aidong Zhang




 










G. Zheng et al.




^1University of Virginia, Charlottesville VA 22904, USA

{gz5hp,wenqian,aidong}@virginia.edu

Benchmarking Spurious Bias in Few-Shot Image Classifiers
    Guangtao Zheng10000-0002-1287-4931 Wenqian Ye10000-0002-6069-5153 Aidong Zhang10000-0001-9723-3246
    September 9, 2024
======================================================================================================



§ ABSTRACT 
Few-shot image classifiers are designed to recognize and classify new data with minimal supervision and limited data but often show reliance on spurious correlations between classes and spurious attributes, known as spurious bias.
Spurious correlations commonly hold in certain samples and few-shot classifiers can suffer from spurious bias induced from them. There is an absence of an automatic benchmarking system to assess the robustness of few-shot classifiers against spurious bias.  
In this paper, we propose a systematic and rigorous benchmark framework, termed FewSTAB, to fairly demonstrate and quantify varied degrees of robustness of few-shot classifiers to spurious bias. FewSTAB creates few-shot evaluation tasks with biased attributes so that using them for predictions can demonstrate poor performance. To construct these tasks, we propose attribute-based sample selection strategies based on a pre-trained vision-language model, eliminating the need for manual dataset curation. This allows FewSTAB to automatically benchmark spurious bias using any existing test data.  FewSTAB offers evaluation results in a new dimension along with a new design guideline for building robust classifiers. Moreover, it can benchmark spurious bias in varied degrees and enable designs for varied degrees of robustness. Its effectiveness is demonstrated through experiments on ten few-shot learning methods across three datasets. We hope our framework can inspire new designs of robust few-shot classifiers. Our code is available at <https://github.com/gtzheng/FewSTAB>.
  


    


§ INTRODUCTION









Few-shot classification <cit.> (FSC) has attracted great attention recently due to its promise for recognizing novel classes efficiently with limited data. 
Few-shot classifiers can transfer the knowledge learned from base classes to recognize novel classes with a few labeled samples. However, they face potential risks when deployed in the real world, such as data distribution shifts <cit.> and adversarial examples <cit.>. 
A subtle yet critical risk factor is the spurious correlations <cit.> between classes and spurious attributes — attributes of inputs non-essential to the classes. In the traditional learning setting <cit.>, deep learning models tend to rely on spurious correlations as their prediction shortcuts or exhibit
spurious bias, such as predicting
classes using the associated backgrounds <cit.> or image textures <cit.>, 
leading to significant performance drops when the associated backgrounds or textures change to different ones. 
In the low-data regime, spurious bias becomes more evident.
For example, in Fig. <ref>, the correlation between the class  and the attribute  in the support (training) image may form a shortcut path from  to 
predicting the image as  and hinder the learning of the desired one that uses class-related attributes, such as , , and . The shortcut will fail to generalize in the query (test) image where no  can be found. In general, few-shot image classifiers are susceptible to spurious bias.



However, there lacks a dedicated benchmarking framework that evaluates the robustness of few-shot classifiers to spurious bias. The standard benchmarking procedure in FSC trains a few-shot classifier on base classes from a training set with ample samples and evaluates the classifier on FSC test tasks constructed from a test set with novel classes. The problem with this procedure is the lack of explicit control over the spurious correlations in the constructed FSC tasks. Each FSC test task contains randomly sampled support and query samples. Thus, spurious correlations in the majority of the test set samples can be demonstrated in these tasks, providing unfair advantages for few-shot classifiers with high reliance on the spurious correlations. 



 In this paper, we propose a systematic and rigorous benchmark framework, termed Few-Shot Tasks with Attribute Biases (FewSTAB), to fairly compare the robustness of various few-shot classifiers to spurious bias. Our framework explicitly controls spurious correlations in the support and query samples when constructing an FSC test task to reveal the robustness pitfalls caused by spurious bias. 
 To achieve this, we propose attribute-based sample selection strategies that select support and query samples with biased attributes. These attributes together with their associated classes formulate spurious correlations such that if the support samples induce spurious bias in a few-shot classifier, i.e., the classifier learns the spurious correlations in the support samples as its prediction shortcuts, then the query samples can effectively degrade the classifier's performance, exposing its non-robustness to spurious bias.

Our framework exploits the spurious attributes in test data for formulating spurious correlations in FSC test tasks. Some existing datasets <cit.> provide spurious attribute annotations. However, they only have a few classes and cannot provide enough classes for training and testing. Many benchmark datasets for FSC do not have annotations on spurious attributes, and obtaining these annotations typically involves labor-intensive human-guided labeling <cit.>.  To address this, we further propose to use a pre-trained vision-language model (VLM) to automatically identify distinct attributes in images in the high-level text format. Our attribute-based sampling methods can use the identified attributes to simulate various spurious correlations.  Thus, we can reuse any existing FSC datasets for benchmarking few-shot classifiers' robustness to spurious bias, eliminating the need for the manual curation of new datasets.

The main contributions of our work are summarized as follows:

    
  * We propose a systematic and rigorous benchmark framework, termed Few-Shot Tasks with Attribute Biases (FewSTAB), that specifically targets spurious bias in few-shot classifiers, demonstrates their varied degrees of robustness to spurious bias, and benchmarks spurious bias in varied degrees. 
    
  * We propose novel attribute-based sample selection strategies using a pre-trained VLM for constructing few-shot evaluation tasks,  allowing us to reuse any existing few-shot benchmark datasets without manually curating new ones for the evaluation.
    
  * FewSTAB provides a new dimension of evaluation on the robustness to spurious bias along with a new design guideline for building robust few-shot classifiers. We demonstrate the effectiveness of FewSTAB by applying it to models trained on three benchmark datasets with ten FSC methods.









§ RELATED WORK


Few-shot classification. Few-shot classification <cit.> has received vast attention recently. Few-shot classifiers can be trained with meta-learning or transfer learning on base classes to learn the knowledge that can be transferred to recognize novel classes with a few labeled samples.  The transfer learning approaches <cit.> first learn a good embedding model and then fine-tune the model on samples from novel classes. The meta-learning approaches can be further divided into optimization-based and metric-based methods. The optimization-based methods <cit.> aim to learn a good initialized model such that the model can adapt to novel classes efficiently with a few gradient update steps on a few labeled samples. The metric-based methods <cit.> aim to learn a generalizable representation space with a well-defined metric, such as Euclidean distance <cit.>, to learn novel classes with a few labeled samples.  Recently, large vision-language models <cit.> are used for few-shot classification. However, they have completely different training and inference pipelines from the models that we consider in this paper.

Robustness in few-shot classification. There are several notions of robustness for few-shot classifiers. The common one requires a few-shot classifier to perform well on the in-distribution samples of novel classes in randomly sampled FSC test tasks. The robustness to adversarial perturbations further requires a few-shot classifier to perform well on samples with imperceptible perturbations <cit.>. Moreover, the cross-domain generalization <cit.> aims to test how robust a few-shot classifier is on samples from novel classes with domain shifts, which are typically reflected by the changes in both image styles and classes. In contrast, we focus on a new notion of robustness: the robustness to spurious bias.
There is a lack of rigorous evaluation methods on the topic. We provide
a new evaluation method that specifically targets spurious bias and can systematically demonstrate few-shot classifiers' varied degrees of vulnerability to spurious bias, which has not been addressed in the existing literature.

Benchmarks for spurious bias. There are some existing datasets <cit.> that are designed to benchmark spurious bias in image classifiers. However, these datasets are only applicable to the traditional learning setting <cit.> since the classes in them are not sufficient for the training and testing of few-shot classifiers. Existing benchmarks in few-shot classification are not tailored for benchmarking spurious bias in few-shot classifiers. A recent work <cit.> creates a large-scale few-shot classification benchmark dataset with spurious-correlation shifts. In contrast, we propose a benchmark framework that can reuse existing few-shot classification datasets and provide a new dimension of evaluation.


Discovering spurious attributes. A spurious attribute is non-essential to a class and only exists in some samples. Early works on discovering spurious attributes <cit.> require a predefined list of spurious attributes and expensive human-guided labeling of visual attributes. Recent works <cit.> greatly reduce the need for manual annotations by using the neurons of robust models to detect visual attributes. However, they still need humans to annotate the detected visual attributes.  We automate this process by using a pre-trained VLM to obtain distinct attributes as words. Instead of discovering spurious correlations, we simulate them via attribute-based sampling for benchmarking.















§ PRELIMINARY



Few-shot classification tasks. 
A typical FSC task 𝒯 has a support set 𝒮 for training and a query set 𝒬 for testing. In this task, there are C classes (c=1, …,C) with N_𝒮 (a small number) training samples and N_𝒬 test samples per class in 𝒮 and 𝒬, respectively. The task is called a C-way N_𝒮-shot task. 




































Few-shot classifiers.  A few-shot classifier f_θ with parameters θ aims to classify the samples in 𝒬 after learning from 𝒮 with a learning algorithm 𝒪 in a few-shot task 𝒯.
Here, 𝒪 could be any learning algorithms, such as the optimization method <cit.> or a prototype-based classifier learning method <cit.>. To acquire a good few-shot learning capability,  f_θ is typically meta-trained or pre-trained <cit.> on a base training set 𝒟_train={(x_n,y_n)|y_n∈𝒞_train,n=1,…,N_train} with N_train sample(x)-label(y) pairs, where 𝒞_train is a set of base classes.

Performance metrics. The performance of a few-shot classifier is typically measured by its average classification accuracy over N_𝒯 C-way N_𝒮-shot tasks randomly sampled from 𝒟_test={(x_n,y_n)|y_n∈𝒞_test,n=1,…,N_test} where N_test sample-label pairs from novel classes 𝒞_test do not appear in 𝒟_train, , 𝒞_train∩𝒞_test=∅.
We denote this metric as standard accuracy Acc(f_θ), ,

    Acc(f_θ)=1/N_𝒯∑_t=1^N_𝒯∑_c=1^CM_c(𝒯_t;f_θ, 𝒪),

where M_c(𝒯_t;f_θ, 𝒪) denotes the classification accuracy of f_θ on the query samples from the class c in 𝒯_t after f_θ is trained on 𝒮 with 𝒪. 
The metric Acc(f_θ) in Eq. (<ref>) only shows the average learning capability of f_θ over  C randomly selected novel classes.  To better characterize the robustness of f_θ  to spurious bias, we define the class-wise worst classification accuracy over tasks as 

    wAcc(f_θ)=1/N_𝒯∑_t=1^N_𝒯min_c=1,…,CM_c(𝒯_t;f_θ, 𝒪).

A larger wAcc(f_θ) indicates that  f_θ is  more robust to spurious bias.

Spurious correlations. A spurious correlation is the association between a class and an attribute of inputs that is non-essential to the class, and it only holds in some samples. We formally define it as follows.


   Let 𝒟_c denote a set of sample-label pairs having the label c, and let ψ:𝒳→ℬ_𝒜 be an attribute detector, where 𝒳 is the set of all possible inputs, ℬ_𝒜 denotes all possible subsets of 𝒜, and 𝒜 is the set of all possible attributes.  The class c and an attribute a∈𝒜 form a spurious correlation, denoted as ⟨ c,a⟩, if and only if the following conditions hold:
   
       
  * There exists (x, c) ∈𝒟_c that satisfies a ∈ψ(x), and
       
  * There exists (x', c) ∈𝒟_c that satisfies a ∉ψ(x').
   
  We define a as the spurious attribute in ⟨ c,a⟩.
   
 


<ref> specifies that all the spurious correlations are based on 𝒟_c.
In the remainder of the paper, we define 𝒟_c={(x,c)|∀(x,c)∈𝒟_test} with c∈𝒞_test as we focus on evaluating the robustness to spurious bias.

We list major symbols in the paper alongside their meanings in <ref>.













§ METHODOLOGY





 §.§ Attribute-Based Sample Selection

We first propose two attribute-based sample selection methods to reveal spurious bias in a few-shot classifier.
Consider a training set 𝒮 in a few-shot test task 𝒯, which has C classes with each class c∈𝒞_test associating with a unique spurious attribute a∈𝒜. We aim to discover samples that can exhibit a classifier's spurious bias on ⟨ c,a⟩ induced from 𝒮.

Motivated by existing findings <cit.> that classifiers with high reliance on ⟨ c,a⟩ tend to perform poorly on samples without it, we propose an attribute-based sample selection strategy
below.

Intra-class attribute-based sample selection. Given 𝒟_c and the training set 𝒮 having the spurious correlation ⟨ c,a⟩, we generate a set ℐ_⟨ c,a⟩ of sample-label pairs which have class c but do not contain attribute a, i.e.,

    ℐ_⟨ c,a⟩ = {(x, c)|∀ (x, c) ∈𝒟_c, a ∉ψ(x)}.


















The above proposed method demonstrates a few-shot classifier's robustness to individual spurious 
correlation ⟨ c,a⟩ and does not consider a multi-class classification setting where spurious attributes from some other class c' exist in samples of the class c. In this case, these attributes may mislead the classifier to predict those samples as the class c' and severely degrade the performance on the class c. For example, consider using the spurious correlations ⟨, ⟩ and ⟨, ⟩ for predicting  and , respectively. An image showing a vase in green is more effective in revealing the robustness to  ⟨, ⟩ as it is more likely to be misclassified as  than other images. 
Motivated by this, we propose the inter-class attribute-based sample selection below.

Inter-class attribute-based sample selection. Given  𝒟_c and the training set 𝒮 having the spurious correlations ⟨ c,a⟩ and ⟨ c',a'⟩,  where c'≠ c and a'≠ a, we generate a set  ℐ_⟨ c,a⟩^⟨ c',a'⟩ of sample-label pairs which have class c, do not contain attribute a, but contain attribute a' from another class c':

    ℐ_⟨ c,a⟩^⟨ c',a'⟩ = ℐ_⟨ c,a⟩∩{(x, c)|∀ (x, c) ∈𝒟_c, a'_⟨ c' ⟩∈ψ(x)},

 where a'_⟨ c' ⟩ denotes a' in ⟨ c',a'⟩, and ℐ_⟨ c,a⟩ is defined in <ref>.

Considering that there are C classes in the training set 𝒮 with each class associating with a unique spurious attribute a, to effectively demonstrate the reliance on the spurious correlation ⟨ c,a⟩ with the inter-class attribute-based sample selection, we consider all the spurious correlations in 𝒮.  Specifically, we apply the above selection strategy to all the C-1 spurious correlations in 𝒮 other than ⟨ c,a⟩ and obtain ℐ_⟨ c,a⟩^C as the union of the C-1 sets as follows:
 
    ℐ_⟨ c,a⟩^C = ⋃_⟨ c',a'⟩∈𝒞_\ cℐ_⟨ c,a⟩^⟨ c',a'⟩,

 where 𝒞_\ c denotes all the spurious correlations in 𝒮 other than ⟨ c,a⟩.

The inter-class attribute-based sample selection is built upon the intra-class attribute-based sample selection. In the remainder of the paper, we use the inter-class method as our default sample selection strategy, which is more effective empirically (<ref>). In certain cases, however, where there are not enough desired samples during task construction, we resort to the intra-class sample selection strategy (<ref>, Implementation details).

 

 In the following, we introduce FewSTAB, a benchmark framework that uses the proposed selection strategies to construct FSC tasks containing samples with biased attributes for benchmarking spurious bias in few-shot classifiers.
 
 





 §.§ FewSTAB (Part 1): Text-Based Attribute Detection

Our attribute-based sample selection methods require knowing the attributes in images, which typically involves labor-intensive human labeling. To make our method scalable and applicable to few-shot classifiers trained on different datasets, we adopt a pre-trained VLM to automatically identify distinct attributes in images in text format, which includes the following two steps.


Step 1: Generating text descriptions. We use a pre-trained VLM <cit.> ϕ to automatically generate text descriptions for images in 𝒟_test. The VLM is a model in the general domain and can produce text descriptions for various objects and patterns.  For example, for the current input image in the  class in  <ref>(a),  besides the class object , the VLM also detects the vase's color , and another object  with its material . 


Step 2: Extracting informative words. From the generated text descriptions, we extract nouns and adjectives as the detected attributes via  an automatic procedure Ω.  The two kinds of words are informative as a noun describes an object, and an adjective describes a property of an object. All the detected attributes form the candidate attribute set 𝒜. We realize the attribute detector ψ defined in <ref> as ψ(x)=Ω(ϕ(x)).

 Remark 1: A VLM in general can extract many distinct attributes from the images. On some images, the VLM may detect non-relevant attributes, such as detecting a duck from a bird image. A more capable VLM could warrant a better attribute detection accuracy and benefit individual measurements on few-shot classifiers. Although being a VLM-dependent benchmark framework, FewSTAB can produce consistent and robust relative measurements among all the compared FSC methods, regardless the choice of VLMs (<ref>).




Remark 2: The candidate set 𝒜 constructed with all the extracted words may contain attributes that represent the classes in 𝒟_test. However, during our attribute-based sample selection, these attributes will not be used since they always correlate with classes and therefore do not satisfy the definition of spurious attributes in <ref>.
 We provide details of ϕ and Ω in <ref>. 




 §.§ FewSTAB (Part 2): FSC Task Construction

Constructing a C-way N_𝒮-shot FSC task 𝒯 for benchmarking spurious bias in few-shot classifiers involves constructing a support (training) set 𝒮  and a query (test) 𝒬 with biased attributes.

 

Constructing the support set. The support set contains the spurious correlations that we aim to demonstrate to a few-shot classifier. As a fair and rigorous benchmark system, FewSTAB makes no assumptions on the few-shot classifiers being tested and randomly samples C classes from 𝒞_test. For each sampled class, it randomly selects a spurious correlation ⟨ c,a⟩ in 𝒟_test with a∈𝒜 . To effectively demonstrate the spurious correlation ⟨ c,a⟩ to a few-shot classifier, we select samples of the class c such that (1) they all have the spurious attribute a and (2) do not have spurious attributes from the other C-1 spurious correlations. 
We construct 𝒮_c with N_𝒮 samples for the class c that satisfy the above two conditions. Thus, the spurious attribute a becomes predictive of the class c in 𝒮_c.  We take the union of all C such sets to get  𝒮=∪_c=1^C𝒮_c.
<ref>(b) demonstrates the case when C=3. Note that we have no requirements for other non-selected attributes in 𝒜 to ensure that we have enough samples for 𝒮_c. 


Constructing the query set. To evaluate the robustness to the spurious correlations formulated in 𝒮, we first construct a candidate set ℐ_⟨ c,a⟩^C in Eq. (<ref>) for each spurious correlation ⟨ c,a⟩ in 𝒮. Since we have no requirements on the non-selected attributes that are not used to formulate spurious correlations in 𝒮, a few-shot classifier may predict query samples via some of these attributes, e.g., the yellow blocks in <ref>(b), bypassing the test on the formulated spurious correlations in 𝒮. To address this, we propose query sample selection below. 

Query sample selection:  We select query samples from ℐ_⟨ c,a⟩^C that are least likely to have non-selected spurious attributes, such as the ones enclosed with red boxes in <ref>(b). 
To achieve this, we first calculate the fraction of sample-label pairs in ℐ_⟨ c,a⟩^C that have the attribute a as

    p_a=|{x|a∈ψ(x),∀ (x,c)∈ℐ_⟨ c,a⟩^C}|/|ℐ_⟨ c,a⟩^C|,

where |·| denotes the size of a set, a∈𝒜̃, and 𝒜̃ contains all non-selected attributes. A larger p_a indicates that the attribute a occurs more frequently in data and is more likely to be used in formulating prediction shortcuts. We then calculate the likelihood score for each (x,c)∈ℐ_⟨ c,a⟩^C as s(x) = ∑_a∈ψ(x),a∈𝒜̃ p_a, i.e., the summation of all p_a of non-selected attributes in x. The likelihood score will be zero if there are no non-selected attributes in x. A large s(x) indicates that the image x can be predicted via many non-selected attributes. Therefore, we select N_𝒬 samples from ℐ_⟨ c,a⟩^C that have the lowest likelihood scores to construct 𝒬_c. Then, we have 𝒬=∪_c=1^C𝒬_c, which contains samples for evaluating the robustness of a few-shot classifier to the spurious correlations in 𝒮.

Complexity analysis. The text-based attribute detection only needs to use VLMs once to extract attributes for each test set of a
dataset. For the task construction, in a nutshell, we analyze the attributes of samples from each of the C classes and do the sampling. Thus, the computational complexity is O(N_𝒯CN_cN_𝒜), where N_c is the maximum number of samples per class in test data, N_𝒜 is the number of extracted attributes. We only need to run the process once and use the generated tasks to benchmark various models.






§ EXPERIMENTS



 §.§ Experimental Setup

Datasets. We used two general datasets of different scales, miniImageNet <cit.> and tieredImageNet <cit.>, and one fine-grained dataset, CUB-200 <cit.>. Each dataset consists of 𝒟_train, 𝒟_val, and 𝒟_test for training, validation, and test, respectively (see Appendix).
All images were resized to 84×84.


FSC methods. We trained FSC models with ten algorithms covering three major categories. For gradient-based meta-learning algorithms, we chose ANIL <cit.>, LEO <cit.>, and BOIL <cit.>. For metric-based meta-learning algorithms, we chose ProtoNet <cit.>, DN4 <cit.>, R2D2 <cit.>, CAN <cit.>, and RENet <cit.>. For transfer learning algorithms, we chose Baseline++ <cit.> and RFS <cit.>.
See Appendix for more details.
Any backbones can be used as the 
feature extractor. For fair comparisons between different methods, we used the ResNet-12 backbone adopted in <cit.>.



Text-based attribute detection. We used a pre-trained VLM named 
ViT-GPT2 <cit.> to generate text descriptions for images in 𝒟_test. 
After that, we used Spacy (<https://spacy.io/>) to extract nouns and adjectives from these descriptions automatically. 
We also used another pre-trained VLM, BLIP <cit.>, to test whether FewSTAB can produce consistent results. 
The statistics of the detected attributes are shown in Table <ref>.
























Implementation details. 
We trained FSC 
models with the implementation in <cit.>. 
Each model was trained on 𝒟_train of a dataset with one of the ten FSC methods. For each meta-learning based method, we trained two models using randomly sampled 5-way 1-shot and 5-way 5-shot tasks, respectively. All the tasks have 15 samples per class in the query set. We saved the model that achieves the best validation accuracy on 𝒟_val for evaluation. 
For FewSTAB, if we do not have enough desired samples to construct a support set, we redo the construction from the beginning. If there are not enough desired samples to construct a query set, we first try to use the intra-class attribute-based sample selection; if the desired samples are still not enough, we redo the construction from the beginning.
We created 3000 tasks for model evaluation. All experiments were conducted on the NVIDIA RTX 8000 GPUs.





























 §.§ Visualization of a Constructed Task

We show a 5-way 1-shot task constructed by FewSTAB in Fig. <ref>. Each class in the support set correlates with a unique spurious attribute. The query samples of a class do not have the spurious attribute correlated with the class and some of them have spurious attributes associated with other classes in the support set. For example, the query samples of the class  do not have the spurious attribute ,  and some of them have spurious attributes from other classes in the support set, such as  and . 

FewSTAB introduces biased attributes in the task so that query samples can be easily misclassified as other classes by a few-shot classifier that relies on the spurious correlations in the support set. 













































 §.§ Effectiveness of FewSTAB



FewSTAB can effectively reveal spurious bias in few-shot classifiers.  
We show in Table <ref> the wAcc (Eq. (<ref>)) on 5-way 1/5-shot test tasks  that 
are randomly
sampled (wAcc-R) and are constructed with FewSTAB (wAcc-A), respectively. FewSTAB generates FSC test tasks only based on the class-attribute correlations in data. In each test setting, the FSC methods in Table <ref> are evaluated with the same FSC tasks. 
  We observe that wAcc-A is consistently lower than wAcc-R on the three datasets and on two test-shot numbers, showing that FewSTAB 
is more effective than the standard evaluation procedure (random task construction) in exhibiting the spurious bias in various few-shot classifiers. We additionally show that FewSTAB also works on the most recent FSC methods and can reflect the improvement made to mitigate spurious bias (see Appendix).

R0.4
Spearman's rank correlations between wAcc-A and wAcc-R in Table <ref>.
0.8!

Dataset            1-shot     5-shot 
 miniImageNet       0.96       0.95   

tieredImageNet     0.96       0.90   

CUB-200            1.00       0.94   
 



















FewSTAB reveals new robustness patterns among FSC methods. In Table <ref>, we calculate the 
Spearman's rank correlation coefficients <cit.> between
the values of wAcc-R and wAcc-A from Table <ref>. The coefficients are bounded  from 0 to 1, with larger values indicating that the ranks of FSC methods based on wAcc-R are more similar to those based on wAcc-A. In the 1-shot setting, 
it is not effective to control the spurious correlations since we only have one sample per class in the support set. Hence, the coefficients are large, and the ranks based on wAcc-A are similar to those based on wAcc-R. In the 5-shot cases, we have more samples to  demonstrate the spurious correlations. The coefficients become smaller, , the ranks based on wAcc-A show different trends from those based on wAcc-R. In this case, FewSTAB reveals new information on FSC methods' varied degrees of robustness to spurious bias.

FewSTAB can benchmark spurious bias in varied degrees. As shown in Fig. <ref>, the accuracy gap, defined as wAcc-R minus wAcc-A, in general, becomes larger when we switch from 5-way 1-shot to 5-way 5-shot tasks. Compared with the random task construction, FewSTAB creates more challenging tasks in the 5-shot case for demonstrating spurious bias in few-shot classifiers. In other words, with a higher shot value in the constructed test tasks, FewSTAB aims to benchmark spurious bias in a higher degree.










































 §.§ A New Dimension of Evaluation and a New Design Guideline

r0.4
    
    < g r a p h i c s >

    Acc versus wAcc-A of the ten FSC methods tested on 5-way 5-shot tasks from miniImageNet. 
    

FewSTAB creates a new dimension of evaluation on the robustness to spurious bias. 
We demonstrate this
with a scatter plot (Fig. <ref>) of Acc  (Eq. (<ref>))
   and wAcc-A of the ten few-shot classifiers. FewSTAB offers new information regarding different few-shot classifiers' robustness to spurious bias as we observe that Acc does not well correlate with wAcc-A.
A high wAcc-A indicates that the classifier is robust to spurious bias, while a high Acc indicates that the classifier can correctly predict most of the samples. With the scatter plot, we can view tradeoffs between the two metrics on existing few-shot classifiers. A desirable few-shot classifier should appear in the top-right corner of the plot.







































R0.5
    
    < g r a p h i c s >

    Accuracy gaps of few-shot classifiers tested on 1-shot, 5-shot, and 10-shot tasks constructed from (a) miniImageNet, (b) tieredImageNet, and (c) CUB-200 datasets.
    




 §.§ FewSTAB Enables Designs for Varied Degrees of Robustness

As demonstrated in Section <ref>, FewSTAB can benchmark spurious bias in varied degrees, which in turn enables practitioners to design robust few-shot classifiers targeted for different degrees of robustness to spurious bias. The reason for differentiating designs for varied degrees of robustness is that the same design choice may not work under different robustness requirements. For example, increasing shot number in training tasks is a common strategy for improving the few-shot generalization of meta-learning based methods. We trained few-shot classifiers with 5-way 5-shot and 5-way 1-shot training tasks randomly sampled from 𝒟_train, respectively. We then calculated the accuracy gap defined as the wAcc-A of a model trained on 5-shot tasks minus the wAcc-A of the same model trained on 1-shot tasks. A positive and large accuracy gap indicates that this strategy is effective in improving the model's robustness to spurious bias. 
In Fig. <ref>, on each of the three datasets, we give results of the eight meta-learning based FSC methods on the 5-way 1-, 5-, and 10-shot FewSTAB tasks which are used to demonstrate the strategy's robustness to increased degrees of spurious bias. This strategy does not work consistently under different test shots. For example, in Fig. <ref>(a) this strategy with CAN only works the best on the 5-way 5-shot FewSTAB tasks.




 §.§ Ablation Studies

Techniques used in FewSTAB. We analyze how different sample selection methods affect the effectiveness of FewSTAB in Table <ref>. With only intra-class attribute-based sample selection, we randomly select query samples from Eq. (<ref>). For inter-class attribute-based sample selection and intra-class attribute-based sample selection (automatically included by Eq. (<ref>)), we randomly select query samples from Eq. (<ref>). FewSTAB uses all the techniques in Table <ref>.  We define accuracy drop as wAcc-R minus wAcc-A, and we use the drop averaged over the ten FSC methods tested on 5-way 5-shot tasks from the miniImageNet dataset as our metric.
A larger average drop indicates that the corresponding sample selection method is more effective in reflecting the spurious bias in few-shot classifiers. We observe that all proposed techniques are effective and the inter-class attribute-based sample selection is the most effective method. 




















Choice of VLMs.
Although our main results are based on the pre-trained ViT-GPT2 model <cit.>, we show in Table <ref> that when switching to a different VLM, , BLIP <cit.>, the relative ranks of different few-shot classifiers based on wAcc-A still hold with high correlations. In other words, FewSTAB is robust to different choices of VLMs.

Detection accuracy of VLMs. A VLM may miss some attributes due to its limited capacity, resulting in a small detection accuracy. However, the detection accuracy of a VLM has little impact on our framework.
To demonstrate this, we adopt a cross-validation strategy, , we use the outputs from one VLM as the ground truth to evaluate those from another VLM, since assessing the detection accuracy of a VLM typically requires labor-intensive human labeling. On the CUB-200 dataset, we observe that the detection accuracy of ViT-GPT2 based on the BLIP's outputs is 70.12%, while the detection accuracy of BLIP based on the ViT-GPT2's outputs is 59.28%. Although the two VLMs differ significantly in the detected attributes, our framework shows almost consistent rankings of the evaluated FSC methods (Table <ref>).



Additional results are presented in Appendix.






§ CONCLUSION

In this paper, we proposed a systematic and rigorous benchmark framework called FewSTAB for evaluating the robustness of few-shot classifiers to spurious bias. FewSTAB adopts attribute-based sample selection strategies to construct FSC test tasks with biased attributes so that the reliance on spurious correlations can be effectively revealed.  FewSTAB can automatically benchmark spurious bias in few-shot classifiers on any existing test data thanks to its use of a pre-trained VLM for automated attribute detection. With FewSTAB, we provided a new dimension of evaluation on the robustness of few-shot image classifiers to spurious bias and a new design guideline for building robust few-shot classifiers. FewSTAB can reveal and enable designs for varied degrees of robustness to spurious bias. We hope FewSTAB will inspire new developments on designing robust few-shot classifiers.








§ ACKNOWLEDGMENTS

This work is supported in part by the US National Science Foundation under grants 2313865, 2217071, 2213700, 2106913, 2008208, 1955151.

    splncs04
    












§ APPENDIX

The appendix is organized as follows:
we introduce the ten FSC algorithms adopted in the paper in <ref>. Then, we give the details of the evaluation metrics used in the main paper in <ref>. In <ref>, we show statistics of the datasets used in this paper along with detailed training settings. In <ref>, we analyze different methods for constructing the support and query sets in a FewSTAB task (<ref>), show the scatter plots of wAcc-A versus Acc from all the training settings (<ref>), present more results on the effectiveness of FewSTAB (<ref>), and demonstrate the robustness of FewSTAB with different VLMs (<ref>). Finally, we give more examples of the tasks constructed by FewSTAB in <ref>.



§ FEW-SHOT CLASSIFICATION ALGORITHMS


    ANIL (Almost No Inner Loop) <cit.>: ANIL is an optimization-based meta-learning method and follows a similar optimization procedure to MAML <cit.> whose few-shot adaptation algorithm 𝒪 is to update the whole model using gradient descent with a few learning samples.  ANIL does not update the whole model and instead only updates the classifier in the last layer.
    
    BOIL (Body Only update in Inner Loop) <cit.>: BOIL is another optimization-based meta-learning method. Its adaptation algorithm 𝒪 freezes the update of the classifier and only updates the embedding backbone.
    
    LEO (Latent Embedding Optimization) <cit.>:  LEO is similar to MAML. But instead of directly optimizing high-dimensional model parameters, its adaptation algorithm 𝒪  learns a generative distribution of model parameters and optimizes the model parameters in a low-dimensional latent space.
    
    ProtoNet (Prototypical Networks) <cit.>:   ProtoNet is a metric-based meta-learning method. Its adaptation algorithm 𝒪 first  calculates a prototype representation for each class as the mean vector of each support class, and then uses a nearest-neighbor classifier created with the class prototypes and the Euclidean distance function to predict a query image. 

    DN4 (Deep Nearest Neighbor Neural Network) <cit.>: DN4 is a metric-based meta-learning method, which does not use attributes after pooling for classification. Instead, DN4 uses the local attributes before pooling and employs a local descriptor based image-to-class measure for classification.

    R2D2 (Ridge Regression Differentiable Discriminator) <cit.>: R2D2 is a metric-based meta-learning method and adopts ridge regression as the few-shot adaptation algorithm 𝒪. The advantage of R2D2 is that ridge regression
    enjoys a closed-form solution and can learn efficiently with a few training samples. 

    CAN (Cross Attention Network) <cit.>: CAN is a metric-based meta-learning method and calculates the cross attention between each pair of class and query features so as to exploit and learn discriminative features for predictions.

    RENet (Relational Embedding Network) <cit.>: RENet is a  metric-based meta-learning method. It uses a self-correlational representation module and a  cross-correlational attention module to learn relational patterns within and between images, respectively.

    RFS (Rethinking Few-Shot) <cit.>: RFS is a transfer learning method. It first trains an embedding network using base classes. Then, instead of fine-tuning the last fully-connected classification layer, it learns a new logistic regression classifier with L2-normalized feature vectors from a few samples of novel classes.

    Baseline++ <cit.>: Baseline++ is a transfer learning method. It first pretrains an embedding network using samples from base classes. Then, it fine-tunes the last fully-connected layer with a few samples of novel classes but replaces the standard inner product  with a cosine distance between input features and the weight vectors of the layer.





§ EVALUATION METRICS

Standard accuracy (Acc): Acc measures on average how a few-shot classifier generalizes to different tasks with novel classes not seen before. We define Acc as follows,

    Acc=1/N_T∑_t=1^N_T∑_c=1^CM_c(𝒯_t;f_θ, 𝒪),

where N_T is the number of test tasks, C is the number of classes per task, 𝒯_t is the t-th C-way N_S-shot task with N_Q query samples per class, f_θ is a few-shot classifier, 𝒪 is the few-shot adaptation algorithm associated with f_θ, M_c denotes the classification accuracy on the query samples of the class c. This metric is used in <ref>.

Class-wise worst classification accuracy (wAcc): wAcc characterizes the performance limit of f_θ  in learning novel classes, and we calculate  wAcc as the average of the smallest per-class classification accuracy on query samples over N_T tasks, i.e.,

    wAcc=1/N_T∑_t=1^N_Tmin_c=1,…,CM_c(𝒯_t;f_θ, 𝒪).

Depending on what kinds of tasks are used for evaluation, we have the following two types of wAcc:

    
  * wAcc-R: If the test tasks are randomly sampled in Eq. (<ref>), then we get wAcc-R on N_T randomly sampled tasks. This metric is used in <ref> as a baseline for highlighting the effectiveness of our FewSTAB in revealing the spurious bias in few-shot classifiers.

    
  * wAcc-A: If the N_T test tasks in Eq. (<ref>) are constructed by our FewSTAB, then we get wAcc-A, which characterizes the robustness of a few-shot classifier to spurious bias. This metric is the main metric used in the experiments.




Accuracy gap between wAcc-R and wAcc-A: We obtain the wAcc-R and wAcc-A of a model by testing it with tasks randomly sampled and with tasks constructed by FewSTAB, respectively. The accuracy gap is calculated as the wAcc-R minus the wAcc-A. A large gap indicates the effectiveness of FewSTAB in revealing the robustness of a few-shot classifier to spurious bias. This metric is used in <ref> and <ref>.

 Accuracy gap between wAcc-A of models trained with different shots:
 We train a few-shot classifier with C-way (e.g. 5-way) 5-shot and 1-shot training tasks from 𝒟_train, respectively. Then, we test the obtained two classifiers with the same tasks created by FewSTAB and calculate the accuracy gap as the wAcc-A of the model trained with 5-shot tasks minus the wAcc-A of the model trained with 1-shot tasks. A large accuracy gap indicates that increasing training shots can improve a few-shot classifier's robustness to spurious bias. This metric is used in <ref>.


 













§ EXPERIMENTAL SETTINGS

We conducted experiments using three datasets: miniImageNet, tieredImageNet, and CUB-200. Each of these datasets  has training (𝒟_train), validation (𝒟_val), and test (𝒟_test) sets. Numbers of classes and samples in the three sets of the three datasets are shown in <ref>. 

We trained eight meta-learning based FSC methods with the ResNet-12 backbone using 5-way 1-shot or  5-way 5-shot tasks from each 𝒟_train of the three datasets, resulting in a total of 48 models. For the two transfer learning based methods, RFS and Baseline++, we trained them on each 𝒟_train of the three datasets using mini-batch stochastic gradient descent. As a result, we trained a total of 54 models. 

To facilitate reproducibility and further research, the training configurations and hyperparameters are provided in <ref> for training on the miniImageNet, tieredImageNet, and CUB-200 datasets, respectively. We closely followed the settings in <cit.> to train these models. In the “Mode” column of these tables, “T(5w1s)” denotes that we trained the corresponding model using 5-way 1-shot tasks, “T(5w5s)” denotes that we trained the corresponding model using 5-way 5-shot tasks, and “B (128)” denotes that we trained the corresponding model using mini-batch stochastic gradient descent with a batch size of 128. In the “LR scheduler” column, “CosineAnnealingLR” denotes a cosine annealing learning rate scheduler, “StepLR(20, 0.5)” denotes a learning rate scheduler which decreases the learning rate after every 20 epochs by multiplying it with 0.5, and “MultiStepLR([60, 80], 0.1)”  denotes a learning rate scheduler which decreases the learning rate after 60 epochs and 80 epochs by multiplying it with 0.1 each time. The “Training episodes” column in these tables denotes the number of tasks used in each epoch. The “Episode size” column of these tables denotes the number of tasks jointly used to do a model update.


















































§ ADDITIONAL EXPERIMENTAL RESULTS
 



 §.§ Ablation Studies


Support set construction methods:
To construct the support set in an FSC test task, FewSTAB randomly selects samples that have mutually exclusive spurious attributes across the randomly selected classes, which is illustrated in <ref>(a) and formally described in <ref> in the main paper. To further show the effectiveness of this construction method, we keep the techniques for constructing the query set in an FSC test task, and report in <ref> the results of two alternatives for constructing the support set: randomly selecting samples of the selected classes (SC1)  and randomly selecting samples with targeted attributes for selected classes with no further constraints on the selected samples (SC2). We also include the results of the proposed one: randomly selecting samples with mutually exclusive targeted attributes across the selected classes (SC3) in <ref>. 
A larger average drop in <ref> indicates that the corresponding support set construction method is more effective in revealing robustness of few-shot classifiers to spurious bias. We observe that the third technique SC3, which is used by FewSTAB, achieves the largest average accuracy drop among the techniques compared on the miniImageNet and tieredImageNet datasets and achieves a comparable drop to SC2 on the CUB-200 dataset due to the limited number of detected attributes in this dataset.  


Query set construction methods:
There are three techniques used by FewSTAB to construct the query set in a task: the intra-class attribute-based sample selection (QC1), the inter-class attribute-based sample selection (QC2), which is a special case of the intra-class attribute-based sample selection, and the query sample selection  (QC3). We have done an ablation study on the effectiveness of the three techniques in <ref> in the main paper using the miniImageNet dataset. Here, we include the results on all the three datasets in <ref>. 
We observe that all the three proposed techniques in FewSTAB are effective with positive accuracy drops for all the ten FSC methods on the three datasets. Moreover, using the inter-class attribute-based sample selection significantly improves the average drops of the intra-class attribute-based sample selection, with 8.17%, 13.26%, and 8.52% absolute gains on the miniImageNet, tieredImageNet, and CUB-200 datasets, respectively.





 §.§ Scatter Plots of wAcc-A versus Acc


We show the scatter plots of wAcc-A versus Acc (standard accuracy) of the ten FSC methods when they are tested with FewSTAB and randomly constructed FSC test tasks, respectively, on the three datasets in <ref> (exact values are shown in <ref>). We observe that an FSC method having a higher Acc does not necessarily have a higher wAcc-A. For example, in  <ref>(a), BOIL  has a higher Acc but a lower wAcc-A than ProtoNet, LEO, and Baseline++. Moreover, we observe that in <ref>(b) and (d), for methods that achieve high standard accuracies, e.g., for the top-5 methods in terms of Acc, their relative increments in wAcc-A are small (with differences smaller than 1%) compared with their relative increments in Acc. In other words, methods with higher standard accuracies do not necessarily learn more robust decision rules, since their wAcc-A values remain comparable to those with lower Acc values. 


The values of Acc and wAcc-A on the fine-grained dataset CUB-200 in <ref>(e) and (f) show a different pattern from those in <ref>(c) and (d). More specifically, methods that achieve high Acc values, e.g., R2D2, ProtoNet, DN4, RENet, and RFS, tend to have comparable relative increments in wAcc-A compared with their relative increments in Acc. This indicates that on a fine-grained dataset, which does not have many spurious attributes, an FSC method with a higher Acc also tends to have a higher wAcc-A or improved robustness to spurious bias. 

In summary, our framework, FewSTAB, reveals new robustness patterns of FSC methods in different evaluation settings.

 


















 §.§ Effectiveness of FewSTAB: More Results


Results on more recent methods.
Note that our method selection in <ref> aims to cover diverse methods and allow for rigorous comparison in the same setting. Importantly, our method is general and can continue to evaluate emerging methods. To demonstrate, we provide results on recent methods, namely UniSiam <cit.>, PsCo <cit.>, and BECLR <cit.>. FewSTAB uncovers that, even the state-of-the-art methods still suffer from spurious bias as we observe large gaps between wAcc-R and wAcc-A (Table <ref>),  when we explicitly construct the test tasks to have spurious correlations.  This also shows that FewSTAB is effective for various FSC methods.

Results on IFSL.  Interventional few-shot learning (IFSL) <cit.> is a method that specifically addresses spurious correlations in few-shot classification. We follow the settings in <cit.> and report the results of MAML <cit.>, MN <cit.>, SIB <cit.>, and MTL <cit.> in Table <ref>, where “Base” refers to one of the four methods, “+IFSL” denotes using IFSL on top of “Base”, and the better performance between the two is in bold. Overall, IFSL is effective in mitigating spurious bias in few-shot classifiers except for some methods, e.g. SIB. This shows that FewSTAB can reveal the improvement made to mitigate spurious bias.








 §.§ Robustness of FewSTAB with Different VLMs


We instantiated our FewSTAB with a pre-trained ViT-GPT2 and a pre-trained BLIP, respectively. We calculated the wAcc-A on FSC test tasks constructed by FewSTAB with the two VLMs on the miniImageNet, tieredImageNet, and CUB-200 datasets, respectively. 


Effects on individual and relative measurements. We observe from <ref> that FewSTAB with BLIP produces lower wAcc-A than with ViT-GPT2 on the miniImageNet and tieredImageNet datasets. This indicates that FewSTAB with BLIP is more effective in uncovering the robustness of few-shot classifiers to spurious bias. We reason that BLIP can identify more attributes than ViT-GPT2 (<ref>) and therefore more spurious correlations can be formulated by our FewSTAB. 
However, on the fine-grained CUB-200 dataset, which contains different bird classes, FewSTAB with BLIP is less effective than with ViT-GPT2. Although BLIP can identify more attributes than ViT-GPT2 in this fine-grained dataset, it may also detect more attributes related to classes.  To validate this, we first found a set of attributes 𝒰_BLIP unique to BLIP from all the attributes  𝒜_BLIP detected by BLIP, and a set of attributes 𝒰_ViT-GPT2 unique to ViT-GPT2 from all the attributes 𝒜_ViT-GPT2 detected by ViT-GPT2. Specifically, we have 𝒰_BLIP=𝒜_BLIP-𝒜_ViT-GPT2, and 𝒰_ViT-GPT2=𝒜_ViT-GPT2-𝒜_BLIP. Then, we found in 𝒰_BLIP and 𝒰_ViT-GPT2 how many attributes contain “bird”, “beak”, “wing”, “breast”, “tail”, or “mouth”, which are all related to the concept of a bird. We found that there are 11 attributes, or 8.5% of total attributes in 𝒰_BLIP that are related to a bird. While there is only 1 attribute (2.4% of total attributes) in 𝒰_ViT-GPT2 that is related to a bird. Due to the limited capability of BLIP, these class-related attributes cannot be detected in all the images. Hence, although these attributes are not spurious, they are treated as spurious attributes and used by FewSTAB to construct FSC test tasks. In this case, FewSTAB becomes ineffective in revealing the spurious bias in few-shot classifiers since the classifiers can exploit spurious correlations in the tasks to achieve high accuracies.
Nevertheless, from the perspective of comparing the robustness of different FSC methods to spurious bias, the test tasks constructed by FewSTAB using different VLMs can reveal consistent ranks in terms of wAcc-A for different FSC methods (<ref>).

Detection accuracies of VLMs. Using different VLMs may generate different sets of attributes. Some sets of attributes may not exactly reflect the data being described, resulting in low detection accuracies. For example, some attributes are not identified by a VLM or the identified attributes do not match with the ground truth attributes. To analyze how the detection accuracy of a VLM affects our framework, we show  in <ref> the detection accuracies of the two VLMs that we used in our paper along with the Spearman's rank correlation coefficients between the evaluation results on the ten FSC methods based on the two VLMs. To calculate the detection accuracy of a VLM without the labor-intensive human labeling, we use the outputs of another VLM as the ground truth. Specifically, for the i'th image, we have two detected sets of attributes, 𝒜_query^i and 𝒜_ref^i, representing the attributes from a VLM being evaluated and the ones from another VLM serving as the ground truth attributes. The detection accuracy  is calculated as follows:

    Acc(VLM_query,VLM_ref)=1/|𝒟_test|∑_i=1^N_test|𝒜_query^i∩𝒜_ref^i|/|𝒜_ref^i|,

where N_test=|𝒟_test|,  and |·| denotes the size of a set. For example, to calculate the detection accuracy of ViT-GPT2, we set VLM_query=ViT-GPT2 and VLM_ref=BLIP. From <ref>, we observe that the detection accuracies of the two VLMs are not high, indicating that the attributes identified by the two VLMs are very different. However, the two VLMs are well-established in practice and can identify many attributes from images (<ref>). The correlation coefficients in <ref> indicate that for well-established VLMs, the detection accuracies have little impact on the comparison of robustness to spurious bias between different FSC methods.






§ TASKS CONSTRUCTED BY FEWSTAB

FewSTAB does not construct tasks based on a specific model. Hence,  FewSTAB is a fair evaluation framework for different FSC methods, and the tasks constructed by FewSTAB can be used to reveal few-shot classifiers' varied degrees of robustness to spurious bias.


We show a 5-way 1-shot task constructed by FewSTAB using samples from the tieredImageNet and CUB-200 datasets in <ref> and <ref>, respectively. Query samples for each class are constructed such that they do not contain the spurious attribute from the support set sample of the same class but contain spurious attributes from support set samples of other classes. For example, in <ref>, the class  has a support set sample with a  background, but most of its query samples have a  which is the spurious attribute from the support set sample of the  class.
Moreover, in <ref>, the class  has a support set sample with a  background, but its query samples all have a  background similar to that in the support set sample of the  class. Note that the sample selection may not be ideal due to the limited capacity of VLMs. For example, in <ref>, some query images of the class  have the spurious attribute  which also appears in the support set image of the class, leading to a high accuracy on these query samples for a model that relies on this spurious attribute. However, this does not affect our evaluation of different FSC methods on their robustness to spurious bias since the same set of tasks is used to evaluate different FSC methods. Moreover, our metric, wAcc-A, measures the worst per-class classification accuracy over FSC tasks, making our evaluation robust to the sampling noise caused by a VLM.





