Paper: Enhancing Compositional Generalization via Compositional Feature Alignment (ICLR-2024)

Reviewer comment (Experiments):
While the features seem to be disentangled in the case of the simple Color-CIFAR dataset as shown in Figure 2, it is not clear if the same effect can be observed in the case of more complex datasets such as DomainNet.

Author response:
## 2. Feature Disengtanglement on Real-World Dataset

We believe the feature visualization for the DomainNet dataset, as mentioned above, also addresses the reviewer's concern: the CFA-finetuned CLIP model exhibits a feature structure with disentanglement similar to what is seen in the Color MNIST visualization in the paper.

Reviewer comment (Experiments):
Stability of the model during training is not discussed in detail. This is important because of the complex two-stage training process. The paper should include experiments where the number of training steps in the first and second stage are varied and analyze the effect on the performance of the final model.

Author response:
## 3. Training Complexity
To address your concerns regarding the training stability of CFA's two stages, we conducted experiments with different training lengths for each stage. The results are provided in item 3 of our **[General Response](https://openreview.net/forum?id=Aemqy6Hjdj&noteId=ddKHrBob2l)** above ([link](https://openreview.net/forum?id=Aemqy6Hjdj&noteId=ddKHrBob2l)). The table shows that Stage-1 training is quite stable, as it involves only optimization over linear models. Additionally, the training cost of Stage-1 (linear probing) is almost negligible compared to Stage-2 (backbone finetuning). Stage-1 requires only a single forward pass over training samples for feature gathering (features are stored in CPU memory), and then the linear probing can be optimized fastly on CPU. The training cost for Stage-2 is slightly less than standard full finetuning, as the last layer remains frozen during Stage-2 of CFA. Overall, we conclude that the implementation complexity and additional training costs of CFA are mild, making it a practical method for addressing compositional generalization problems in real-world applications.

Reviewer comment (Evaluation):
From the results in Table 1, the performance gain over the reweight strategy is minimal (<1%) for all datasets. The biggest performance gain comes from the use of WiSE-FT (Wortsman et al., 2022). Also, compared to the reweight strategy, the proposed approach uses 2-staged training. Therefore, it is not clear whether the increase in training complexity is justified by the small performance gain.

Author response:
## 4. Performance Gain
Regarding the performance gain of CFA over reweighting, a strong baseline method, we acknowledge that the improvement is not significant. However, our main contribution lies in designing a principled algorithm for compositional generalization, a novel challenge in OOD generalization. As our theoretical analysis and feature visualization in Figures 4 and 7 demonstrate (on Color MNIST and DomainNet, respectively), our method aligns features with a compositional structure suitable for compositional generalization. In OOD generalization research, it's typical for specialized algorithms to only modestly outperform baselines like ERM, as evidenced by extensive benchmarking in studies like DomainBed [1] and WILDS [2]. Thus, we consider CFA's performance gain to be meaningful and convincing. Additionally, the mild implementation complexity and training costs (discussed in the last item) make CFA a viable method for enhancing compositional generalization.


Moreover, we want to emphasize that real-world datasets used in our paper have lots of labeling issues (for both class and domain labels), which may prevent CFA from obtaining greater performance gain. Notably, CFA employs both class and domain labels for training, leading to an increased susceptibility to label noise, particularly from domain labels. Below, we illustrate two types of labeling noise encountered:

+ **(i) Mislabeling**: We observe that the DomainNet dataset contains many mislabeled images. Many images in the “Clipart” domain are actually real photos of a single object on a white background, which should be categorized into the “Product” domain. On the other hand, numerous class labels are also mislabeled: images in the “bush (plant)” class contain pictures of President George Bush of the USA; the “cooler” class includes electric fan images, which are incorrectly categorized; the “square (shape)” class contains table, which should be placed into the “table” class instead. Note: We only manually examined a very tiny subset of the DomainNet dataset, which comprises 0.6 million images, and have already found many mislabeled images. Therefore, overall, we believe the mislabeling ratio is not negligible.

+ **(ii) Ambiguous Labels**: We observe that certain domains contain a large number of images that are visually similar to those in another domain. For example, in both [Office-Home](https://www.hemanthdv.org/officeHomeDataset.html) and [DomainNet](https://ai.bu.edu/M3SDA), the images in the “Product” domain are real photos of objects, making them almost indistinguishable from their counterparts in the “Real” domain. The distinguishing feature of the “Product” domain is that its images all have a white background; however, some images in the “Real” domain also share this characteristic. Additionally, in DomainNet, the “Infograph” domain contains many images stylistically similar to those in “Clipart” or “Real”; some images in the “Painting” domain are sketches, despite the presence of a separate “Sketch” domain. This ambiguity issue extends to class labels as well. In DomainNet, the classes “cup,” “coffee cup,” and “mug” lack clear stylistic distinctions.

In addition to these issues, other aspects of these datasets may affect learning. For instance, the iWildCam dataset includes a class labeled “empty,” signifying the absence of animals, which comprises a significant portion of the dataset.

Reviewer comment (Experiments):
In Table 1, the reweight baseline with WiSE when using the DINOv2 model seems to be missing. Comparing reweighting and the proposed CFA method the gain in performance without WiSE seems to be <0.3%, especially in the case of OfficeHome and DomainNet.

Author response:
## 5. Reweighting Not Work with WiSE-FT for DINOv2 Backbone
We did not include the results of Reweighting+WiSE-FT for DINOv2 in Table 1, as we had observed its ineffectiveness before the submission of this paper. We re-run the experiments for Reweighting for DINOv2 on DomainNet over 3 random seeds and provide the mean accuracy results in the table below. 

It is evident that WiSE-FT significantly decreases the performance of Reweighting in terms of both ID and OOD accuracy. The primary reason is that, unlike CLIP that includes a text encoder capable of providing a zero-shot linear classifier on top of its image encoder, DINOv2 is solely an encoder without an initial classifier (the last linear layer). Therefore, when applying WiSE-FT to Fine-tuning and Reweighting methods on DINOv2, the initial parameters of the last linear layer are set to zeros and then interpolated with the final finetuned last linear layer. However, this interpolated image encoder may not align well with the interpolated last layer, leading to a decrease in both ID and OOD performance.

| Method       | ID Acc   | ID Acc (WiSE) | OOD Acc | OOD Acc (WiSE) |
|--------------|------|-----------|-----|------------|
| Reweight-E   | 81.8 | 40.7      | 5.1 | 3.6        |
| Reweight-YxE | 81.5 | 41.2      | 5.3 | 3.1        |

We will run Reweighting+WiSE-FT experiments for DINOv2 on more datasets, and provide results in the appendix of the next revision.

Reviewer comment (Experiments):
Can the proposed approach take advantage of unlabeled data? This is important because prior work such as CLIP or DINOv2 does not need explicit domain/class labels, unlike the proposed CFA approach.

Author response:
## 6. Use of Unlabeled Data

First, we wish to clarify the nature of label supervision for CLIP and DINOv2. Specifically, CLIP training involves using text captions for each image, which typically include the object class and often domain or contextual information (see examples at [this article](https://laion.ai/blog/laion-5b/)). Therefore, CLIP's training approach is essentially weak supervision rather than unsupervised learning. This textual supervision enables CLIP's direct application in zero-shot classification. In contrast, DINOv2 undergoes unsupervised training and thus requires supervised finetuning before it can be used for classification tasks.

Unlike CLIP and DINOv2, which are pretraining methods for large-scale image data (e.g., datasets with 400 million images or more), our CFA method is designed for finetuning pretrained image backbones. Our objective is not to replace CLIP or DINOv2. Instead, we aim to demonstrate how the typical applications of CLIP (for zero-shot classification) and DINOv2 (for supervised finetuning) encounter challenges within the compositional generalization problem setup. CFA is introduced to finetune these pretrained image models, enhancing their capabilities in compositional generalization contexts. 

In our compositional generalization benchmark (CG-Bench), we observed that the zero-shot prediction accuracy of CLIP was unsatisfactory, indicating the need for further finetuning with class labels. Similarly, the DINOv2 model, a bare image encoder, has to be supervised finetuned to obtain classification capabilities. Overall, class labels are necessary for achieving effective results in CG-Bench.
We recognize that the additional requirement of domain labels may not always be feasible in real-world applications. To address this, we propose two solutions to lessen the need for a fully domain-labeled dataset:

+ Use partially available domain labels, e.g., only 10% training samples have domain labels
+ Use zero-shot predicted domain labels by CLIP when no domain labels are provided.

The experimental results, detailed in the **[General Response](https://openreview.net/forum?id=Aemqy6Hjdj&noteId=ZWViPLA35z)** above, show that our CFA method maintains most of its OOD performance advantages even with limited domain label availability, such as with only 10% of labels. In situations where no domain labels are available, employing CFA with zero-shot predicted domain labels by CLIP still shows improvement compared to the standard finetuning method. Overall, these results indicate that CFA's dependency on domain labels is quite mild.

Reviewer comment (Experiments):
For models trained using CFA, do we observe the disentanglement similar to Color-CIFAR in Figure 2 in case of larger datasets such as DomainNet?

Author response:
## 2. Feature Disengtanglement on Real-World Dataset

We believe the feature visualization for the DomainNet dataset, as mentioned above, also addresses the reviewer's concern: the CFA-finetuned CLIP model exhibits a feature structure with disentanglement similar to what is seen in the Color MNIST visualization in the paper.

Reviewer comment (Evaluation):
Additional details of the reason for the small performance gain of the proposed CFA approach over the reweight baseline in Table 1 would be helpful.

Author response:
## 4. Performance Gain
Regarding the performance gain of CFA over reweighting, a strong baseline method, we acknowledge that the improvement is not significant. However, our main contribution lies in designing a principled algorithm for compositional generalization, a novel challenge in OOD generalization. As our theoretical analysis and feature visualization in Figures 4 and 7 demonstrate (on Color MNIST and DomainNet, respectively), our method aligns features with a compositional structure suitable for compositional generalization. In OOD generalization research, it's typical for specialized algorithms to only modestly outperform baselines like ERM, as evidenced by extensive benchmarking in studies like DomainBed [1] and WILDS [2]. Thus, we consider CFA's performance gain to be meaningful and convincing. Additionally, the mild implementation complexity and training costs (discussed in the last item) make CFA a viable method for enhancing compositional generalization.


Moreover, we want to emphasize that real-world datasets used in our paper have lots of labeling issues (for both class and domain labels), which may prevent CFA from obtaining greater performance gain. Notably, CFA employs both class and domain labels for training, leading to an increased susceptibility to label noise, particularly from domain labels. Below, we illustrate two types of labeling noise encountered:

+ **(i) Mislabeling**: We observe that the DomainNet dataset contains many mislabeled images. Many images in the “Clipart” domain are actually real photos of a single object on a white background, which should be categorized into the “Product” domain. On the other hand, numerous class labels are also mislabeled: images in the “bush (plant)” class contain pictures of President George Bush of the USA; the “cooler” class includes electric fan images, which are incorrectly categorized; the “square (shape)” class contains table, which should be placed into the “table” class instead. Note: We only manually examined a very tiny subset of the DomainNet dataset, which comprises 0.6 million images, and have already found many mislabeled images. Therefore, overall, we believe the mislabeling ratio is not negligible.

+ **(ii) Ambiguous Labels**: We observe that certain domains contain a large number of images that are visually similar to those in another domain. For example, in both [Office-Home](https://www.hemanthdv.org/officeHomeDataset.html) and [DomainNet](https://ai.bu.edu/M3SDA), the images in the “Product” domain are real photos of objects, making them almost indistinguishable from their counterparts in the “Real” domain. The distinguishing feature of the “Product” domain is that its images all have a white background; however, some images in the “Real” domain also share this characteristic. Additionally, in DomainNet, the “Infograph” domain contains many images stylistically similar to those in “Clipart” or “Real”; some images in the “Painting” domain are sketches, despite the presence of a separate “Sketch” domain. This ambiguity issue extends to class labels as well. In DomainNet, the classes “cup,” “coffee cup,” and “mug” lack clear stylistic distinctions.

In addition to these issues, other aspects of these datasets may affect learning. For instance, the iWildCam dataset includes a class labeled “empty,” signifying the absence of animals, which comprises a significant portion of the dataset.

Reviewer comment (Novelty):
The setting of compositional generalization (CG) means that the pre-trained model is tested on the unseen domain-class combinations and the setting of domain generalization means that the pre-trained model is tested on the unseen domain samples? If yes, what is the difference between CG and some papers in open-set tasks to solve domain generalization problems?

Author response:
## 1. Problem Setting

Compositional generalization (CG) explicitly assumes that all domains and classes are seen during training, with only certain combinations of them being unseen, which are used for OOD evaluation. As a comparison, in Open-Set Domain Generalization (OS-GD) [1,2], test samples are from a new domain, and unseen classes in the training phase can appear during the test phase. Notably, OS-DG typically requires models to assign the “unknown” class label to test samples from classes unseen in the training set, which essentially constitutes an auxiliary task of out-of-distribution (OOD) detection. 

Note: while OS-DG does not explicitly state requirements on test domains, it generally poses certain implicit assumptions about the test domains. For example, the OS-DG problem setup as described in [1] implicitly places distributional assumptions on domains, implying that the test domain is related to the training domains in a specific manner (so that data augmentation techniques, such as feature-level MixUp applied to training domains, can partially encompass test domains).

Below, we use two tables to illustrate the differences between CG and OS-DG, where "✓" marks a domain-class combination seen during training.
+ Compositional Generalization (CG)

    In the CG table, combinations marked with “✓” are present in the training set, while those labeled “Test” are not. The CG challenge is to determine if models trained on “✓” combinations can accurately generalize to “Test” combinations.

    |           | Class 1 | Class 2 | Class 3 |
    |-----------|---------|---------|---------|
    | **Domain 1** | ✓       | Test    | Test    |
    | **Domain 2** | Test    | ✓       | Test    |
    | **Domain 3** | ✓       | Test    | ✓       |

+ Open-Set Domain Generalization (OS-DG)

    In the OS-DG table, the symbols “✓” and “Test” have the same implications as in the CG table. Additionally, “X” denotes a domain-class combination that is unavailable during training and is also not evaluated. The class “Unknown” encompasses all classes not present during training, with models expected to predict the “Unknown” class for these.
    |                  | Train Class 1 | Train Class 2 | Train Class 3 | Class “Unknown” |
    |------------------|---------------|---------------|---------------|-----------------|
    | **Train Domain 1** | ✓             | X             | X             | X               |
    | **Train Domain 2** | X             | ✓             | X             | X               |
    | **Train Domain 3** | ✓             | X             | ✓             | X               |
    | **Test Domain**    | Test          | Test          | Test          | Test            |

In summary, while CG and OS-DG problems are similar, they aim for different outcomes in OOD generalization. CG seeks to generalize to unseen domain-class combinations composed of domains and classes seen during training. OS-DG can be viewed as domain generalization (DG) with an additional task of OOD detection.

Reviewer comment (Experiments):
To solve the CG problem, the authors propose a method to align the class information in different domain. I'm more curious about why the two-stage training method can achieve this goal? If possible, I would tend to see experiments on each stage of visualization.

Author response:
## 2. Explanation of Two Stages of CFA and Feature Visualization on Real-World Dataset
Stage-1 of CFA involves linear probing, which trains two orthogonal linear classifiers ($\mathbf{Y}$ and $\mathbf{E}$) for class and domain predictions on features $\mathbf{Z}$ of the pre-trained backbone. The backbone remains frozen in Stage-1, and the primary objective of this stage is to establish a compositional feature structure via the two trained orthogonal classifiers, $\mathbf{Z}$ and $\mathbf{E}$. 

In Stage 2, CFA freezes the trained classifiers $\mathbf{Y}$ & $\mathbf{E}$, and only fine-tunes the backbone (image encoder) – this process modifies the features $\mathbf{Z}$. Drawing from research on neural collapse [3,4,5], it is understood that supervised learning with cross-entropy loss causes the features of samples from class-$i$ to collapse towards the $i$-th column vector of $\mathbf{Y}$, denoted as $y_i$ (for a visual illustration of neural collapse, refer to Fig. 1 in this [ICLR 2022 paper](https://openreview.net/forum?id=w1UbdvWH_R3)). In our context of two orthogonal linear classifiers, our theoretical analysis indicates that for each training sample associated with class-$i$ and domain-$j$, its feature will collapse towards the composition $y_i + e_j$. Given the orthogonality constraint of classifiers $\mathbf{Y}$ and $\mathbf{E}$, the resulting collapsed features will adhere to the compositional feature structure defined in Definition 1.

As per your request, we visualized features using both the pretrained CLIP ViT model and the one fine-tuned with CFA on the DomainNet dataset. Due to limitations in 3D visualization, we selected 2 out of 6 domains and 3 out of 345 classes for representation. As figures cannot be inserted in OpenReview posts, the visualization is provided in Fig. 7 of Appendix D in the revised manuscript. Please refer to [this PDF](https://openreview.net/pdf?id=Aemqy6Hjdj) for review. This visualization clearly demonstrates that CFA can align features with the intended compositional feature structure. We are confident that this visualization effectively addresses your concern regarding the feature alignment of CFA with real data.

Reviewer comment (Experiments):
I am more concerned about different training stages and ablation experiments related to orthogonal loss.

Author response:
## 3. Ablation Study on Orthogonal Loss
We fixed other hyper-parameters as presented in the manuscript, only changing the orthogonal loss coefficient in Stage-1 of CFA. For each set of hyper-parameters, we repeated the experiment with three seeds. It is clear that with the coefficient set to 100, the out-of-distribution (OOD) performance peaks, leading to our choice of this value in our manuscript. From the table, we observe that a large orthogonal loss coefficient (e.g., >=100) is necessary to encourage orthogonality between heads. (The orthogonal loss coefficient of 100 was used in our paper.)

| **Orthogonal Loss Coef.** | **ID**        | **ID (WiSE)**  | **OOD**       | **OOD (WiSE)** |
|-----------------|---------------|----------------|---------------|----------------|
| 1               | 93.2          | 92.8           | 46.4          | 46.6           |
| 10              | **94.0**      | **93.6**       | 50.8          | 53.3           |
| 100 (Chosen)    | **94.0**      | 93.1           | **54.3**      | **56.9**       |
| 1000            | 93.8          | 92.8           | 53.9          | 55.2           |


In addition to studying the orthogonal loss coefficient, we also conducted experiments on the training steps of the two stages of CFA. These results, detailed in item-3 (_"Two-Stage Training Stability"_) of our [General Response](https://openreview.net/forum?id=Aemqy6Hjdj&noteId=ddKHrBob2l) above _([link](https://openreview.net/forum?id=Aemqy6Hjdj&noteId=ddKHrBob2l))_, demonstrate that the final performance is relatively stable to the training steps numbers in each stage of CFA.