SlowGuess commited on
Commit
3a4dfbb
·
verified ·
1 Parent(s): de4ff16

Add Batch f0fe0e4d-80e3-4476-a182-00693100f615

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/2ad7003a-8690-410a-9883-91bd50ef7431_content_list.json +3 -0
  2. overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/2ad7003a-8690-410a-9883-91bd50ef7431_model.json +3 -0
  3. overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/2ad7003a-8690-410a-9883-91bd50ef7431_origin.pdf +3 -0
  4. overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/full.md +346 -0
  5. overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/images.zip +3 -0
  6. overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/layout.json +3 -0
  7. p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/545b26ce-6dd1-47a9-8f7a-cc0a3bbd491d_content_list.json +3 -0
  8. p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/545b26ce-6dd1-47a9-8f7a-cc0a3bbd491d_model.json +3 -0
  9. p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/545b26ce-6dd1-47a9-8f7a-cc0a3bbd491d_origin.pdf +3 -0
  10. p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/full.md +654 -0
  11. p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/images.zip +3 -0
  12. p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/layout.json +3 -0
  13. p2segpointlysupervisedsegmentationviamutualdistillation/301223cf-5861-4dd3-8b6c-02ceef166340_content_list.json +3 -0
  14. p2segpointlysupervisedsegmentationviamutualdistillation/301223cf-5861-4dd3-8b6c-02ceef166340_model.json +3 -0
  15. p2segpointlysupervisedsegmentationviamutualdistillation/301223cf-5861-4dd3-8b6c-02ceef166340_origin.pdf +3 -0
  16. p2segpointlysupervisedsegmentationviamutualdistillation/full.md +295 -0
  17. p2segpointlysupervisedsegmentationviamutualdistillation/images.zip +3 -0
  18. p2segpointlysupervisedsegmentationviamutualdistillation/layout.json +3 -0
  19. pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/b1e240a5-63a9-45b2-9edf-2f0f76e4b7e7_content_list.json +3 -0
  20. pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/b1e240a5-63a9-45b2-9edf-2f0f76e4b7e7_model.json +3 -0
  21. pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/b1e240a5-63a9-45b2-9edf-2f0f76e4b7e7_origin.pdf +3 -0
  22. pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/full.md +0 -0
  23. pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/images.zip +3 -0
  24. pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/layout.json +3 -0
  25. pacpredictionsetsunderlabelshift/80aefd3c-e03b-40b1-a6e1-2b267f349698_content_list.json +3 -0
  26. pacpredictionsetsunderlabelshift/80aefd3c-e03b-40b1-a6e1-2b267f349698_model.json +3 -0
  27. pacpredictionsetsunderlabelshift/80aefd3c-e03b-40b1-a6e1-2b267f349698_origin.pdf +3 -0
  28. pacpredictionsetsunderlabelshift/full.md +694 -0
  29. pacpredictionsetsunderlabelshift/images.zip +3 -0
  30. pacpredictionsetsunderlabelshift/layout.json +3 -0
  31. paereinforcementlearningfromexternalknowledgeforefficientexploration/246f10dd-6824-4248-ac26-a65e26c6cf25_content_list.json +3 -0
  32. paereinforcementlearningfromexternalknowledgeforefficientexploration/246f10dd-6824-4248-ac26-a65e26c6cf25_model.json +3 -0
  33. paereinforcementlearningfromexternalknowledgeforefficientexploration/246f10dd-6824-4248-ac26-a65e26c6cf25_origin.pdf +3 -0
  34. paereinforcementlearningfromexternalknowledgeforefficientexploration/full.md +595 -0
  35. paereinforcementlearningfromexternalknowledgeforefficientexploration/images.zip +3 -0
  36. paereinforcementlearningfromexternalknowledgeforefficientexploration/layout.json +3 -0
  37. pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/b39aaa9f-61cc-44c3-a665-5d8f55ab0c3f_content_list.json +3 -0
  38. pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/b39aaa9f-61cc-44c3-a665-5d8f55ab0c3f_model.json +3 -0
  39. pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/b39aaa9f-61cc-44c3-a665-5d8f55ab0c3f_origin.pdf +3 -0
  40. pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/full.md +362 -0
  41. pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/images.zip +3 -0
  42. pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/layout.json +3 -0
  43. panodiffusion360degreepanoramaoutpaintingviadiffusion/f283e772-e24b-4d76-8ec5-dab59382e974_content_list.json +3 -0
  44. panodiffusion360degreepanoramaoutpaintingviadiffusion/f283e772-e24b-4d76-8ec5-dab59382e974_model.json +3 -0
  45. panodiffusion360degreepanoramaoutpaintingviadiffusion/f283e772-e24b-4d76-8ec5-dab59382e974_origin.pdf +3 -0
  46. panodiffusion360degreepanoramaoutpaintingviadiffusion/full.md +556 -0
  47. panodiffusion360degreepanoramaoutpaintingviadiffusion/images.zip +3 -0
  48. panodiffusion360degreepanoramaoutpaintingviadiffusion/layout.json +3 -0
  49. parallelizingnonlinearsequentialmodelsoverthesequencelength/780516c7-792c-4bed-a463-a618813362e0_content_list.json +3 -0
  50. parallelizingnonlinearsequentialmodelsoverthesequencelength/780516c7-792c-4bed-a463-a618813362e0_model.json +3 -0
overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/2ad7003a-8690-410a-9883-91bd50ef7431_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54a5841040483a09adb57ab2df276f4c09998fd33554fa0e3012776d6eaa752c
3
+ size 103059
overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/2ad7003a-8690-410a-9883-91bd50ef7431_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e873c8cfa77c4cc99790af1ffc11ecb5442717184cf931fc789096e41f2a8441
3
+ size 122121
overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/2ad7003a-8690-410a-9883-91bd50ef7431_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d30085112c40768c93b60e283da46df194a2fb6b944c257ea41b66c8af027cac
3
+ size 5139992
overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/full.md ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OVERCOMING THE PITFALLS OF VISION-LANGUAGE
2
+ MODEL FINETUNING FOR OOD GENERALIZATION
3
+
4
+ Yuhang Zang\*1, Hanlin Goh?, Josh Susskind?, Chen Huang?
5
+
6
+ $^{1}$ Nanyang Technological University $^{2}$ Apple Inc.
7
+
8
+ zang0012@ntu.edu.sg {hanlin, jsusskind, chen-huang}@apple.com
9
+
10
+ # ABSTRACT
11
+
12
+ Existing vision-language models exhibit strong generalization on a variety of visual domains and tasks. However, such models mainly perform zero-shot recognition in a closed-set manner, and thus struggle to handle open-domain visual concepts by design. There are recent finetuning methods, such as prompt learning, that not only study the discrimination between in-distribution (ID) and out-of-distribution (OOD) samples, but also show some improvements in both ID and OOD accuracies. In this paper, we first demonstrate that vision-language models, after long enough finetuning but without proper regularization, tend to overfit the known classes in the given dataset, with degraded performance on unknown classes. Then we propose a novel approach OGEN to address this pitfall, with the main focus on improving the OOD GENeralization of finetuned models. Specifically, a class-conditional feature generator is introduced to synthesize OOD features using just the class name of any unknown class. Such synthesized features will provide useful knowledge about unknowns and help regularize the decision boundary between ID and OOD data when optimized jointly. Equally important is our adaptive self-distillation mechanism to regularize our feature generation model during joint optimization, i.e., adaptively transferring knowledge between model states to further prevent overfitting. Experiments validate that our method yields convincing gains in OOD generalization performance in different settings. Code: https://github.com/apple/ml-ogen.
13
+
14
+ # 1 INTRODUCTION
15
+
16
+ Large-scale pre-trained vision-language models like CLIP (Radford et al., 2021) demonstrate promising generalizability on various visual domains and tasks in the real world. However, their zero-shot in-distribution (ID) performance can be limited for some downstream datasets. Also due to their zero-shot evaluation in a closed-set manner (i.e., to match input image to a predefined set of classes), vision-language models often struggle to handle the out-of-distribution (OOD) samples from novel classes. Such shortcomings create major safety risks in the open domain that often require capabilities of OOD detection and/or accurate identification of both novel and seen classes.
17
+
18
+ Some recent works attempt to improve the zero-shot OOD detection performance of existing vision-language models, either by simple softmax scaling (Ming et al., 2022) or training an extra text generator (Esmaeilpour et al., 2022). Alternatively, Fort et al. (2021) first show the promise of CLIP models finetuned on an ID dataset. Encouragingly both ID and OOD accuracies are improved after finetuning. Parameter-efficient finetuning methods, such as prompt learning (Zhou et al., 2022a;b) or adaptor tuning (Zhang et al., 2022), illustrate similar benefits without heavy training.
19
+
20
+ Despite the success of prior finetuning methods, we found from our extensive benchmarking that finetuning on ID datasets is prone to overfitting (Fig. 1(b)). More specifically, we observed that models after long enough finetuning but without proper regularization, tend to overfit the known classes in the given dataset, with inferior generalization on unknown classes. Unfortunately, an explicit regularization mechanism has not been explored in literature to address this pitfall, and simple
21
+
22
+ ![](images/4261526b51252e4ec9e197efd68ca053942ff94c140d2dc00e663faa43d71158.jpg)
23
+ (a)
24
+
25
+ ![](images/e4fcc1f75d819513ad53eb75ec56c31bf0fc85d63a79c6ae72919d2f25f27d08.jpg)
26
+
27
+ ![](images/a542a5feb2c6585a0d89a67aeecd266f8239ca8b9f5865d6bd9022731be18fd9.jpg)
28
+
29
+ ![](images/0d940f13f792603ebc2fef45107f96e44eb74be5e7e0124f267ab5f6b08c564d.jpg)
30
+ (b)
31
+ Figure 1: (a) We study OOD generalization when finetuning the vision-language model CLIP on various downstream tasks. We consider both within-dataset generalization where one dataset has ID vs. OOD (or known vs. unknown) class splits for finetuning and evaluation respectively, and the more challenging cross-dataset generalization setting. More clarifications on the problem definition in Appendix A. (b) Examples of within-dataset generalization: we show learning curves of the prompt learning method CoOp (Zhou et al., 2022a) that finetunes CLIP for long enough (200 epochs) on three datasets (more in Appendix B). Apparently, CoOp overfits the known classes of each dataset with notable accuracy drop on the unknowns. Our proposed method OGEN largely reduces such overfitting through effective regularization.
32
+
33
+ ![](images/cc7a6b2de0a8aa3585abb8f2ac698b83dc77d2d88b9bc0da39fe75ef014fcb87.jpg)
34
+
35
+ ![](images/a34cf264bc241cc1792f345b203b04ae97962149f476106006af43e29aa233cd.jpg)
36
+
37
+ regularization strategies like early stopping seem insufficient. E.g. in Fig. 1(b), it is difficult to find an early model checkpoint with good trade-off between the known and unknown class performance.
38
+
39
+ One main challenge of effective model regularization is the missing knowledge about unknowns. Such knowledge could actually offer useful supervision signals to avoid overconfident predictions on OOD data. In this paper, we propose a novel method that features 1) image feature synthesis for unknown classes and 2) an unknown-aware finetuning algorithm with effective model regularization. The goal is to improve OOD generalization without hurting the ID performance of finetuned models. To synthesize unknown features, we introduce a class-conditional feature generator: i.e., generating image features just given the name of an unknown class. This is made possible by CLIP's well-aligned image-text feature spaces. Our feature generator is implemented by a lightweight attention module, with an "extrapolating bias" on the unknown classes. It generalizes well to "unknown unknowns" and hence can model the complex distributions of visual classes in the open domain. Then we use both the ID and synthesized OOD data for joint optimization, leading to a better regularized decision boundary. Another contribution is an adaptive self-distillation mechanism that regularizes our feature generator to further reduce overfitting during joint optimization. The idea is to find an adaptive teacher model of the feature generator from historical training epochs (with less overfitting) to guide optimization at the current epoch (student model, often with more overfitting).
40
+
41
+ Our overall approach OGEN is applicable to different finetuning methods e.g., (Zhou et al., 2022a;b; Jia et al., 2022) for CLIP-like models. OGEN is shown to consistently improve the OOD generalization performance (by up to absolute $18.77\%$ ) under two settings: within-dataset (base-to-new class) generalization and cross-dataset generalization. Summarizing, our main contributions are:
42
+
43
+ - Provide the first comprehensive study on OOD generalization that unveils the pitfalls of finetuning methods (based on prompt learning) for vision-language models.
44
+ - A class-conditional feature generator to synthesize OOD data for effective regularization.
45
+ - Adaptive self-distillation on our feature generator to further reduce overfitting.
46
+
47
+ # 2 RELATED WORK
48
+
49
+ Vision-Language Models. Recent large-scale vision-language models like ViLT (Kim et al., 2021) and PaLI (Chen et al., 2023) simply consume image-and-text features for multimodal downstream tasks with remarkable performance. Another popular paradigm used in CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021) contrastively aligns image and text encoders. These contrastive models are trained on massive web-scale image-text pairs, also showing strong adaptability to a range of
50
+
51
+ downstream tasks, such as semantic segmentation (Zang et al., 2022a; Ghiasi et al., 2021) and video classification (Qian et al., 2022). Numerous follow-up works (Li et al., 2022; Zhou et al., 2022a) aim to improve CLIP-like models in data efficiency or generalization. However, the zero-shot performance on some tasks can still be limited for existing vision-language models. Hu et al. (2023) found that they make different kinds of errors, e.g., PaLI is erroneous at tail visual concepts while CLIP may fail for common ones. This paper mainly studies and improves the generalization of finetuned CLIP models, but our approach is model-agnostic and thus applicable to other vision-language models as well.
52
+
53
+ Finetuning methods have been studied to improve the downstream performance of vision-language models over their zero-shot counterparts. Fort et al. (2021) showed that after finetuning the CLIP model on datasets of interest, both the ID and OOD generalization performance will be improved. More parameter-efficient finetuning methods are popularized in recent years. In particular, prompt learning focuses on learning visual (Jia et al., 2022), textual (Zhou et al., 2022a;b; Yao et al., 2023; Wang et al., 2023; Shu et al., 2023; Khattak et al., 2023b) or multi-modal Zang et al. (2022b); Khattak et al. (2023a) prompts, while adaptor tuning (Zhang et al., 2022) optimizes feature representations with the model backbone kept frozen. In this paper, we first unveil the overfitting issue of recent finetuning methods, and then propose a new regularization method to prevent overfitting. Our approach is orthogonal to the finetuning research, and shows consistent gains over various finetuning baselines.
54
+
55
+ Outlier synthesis proves effective for model regularization in the absence of OOD data. Previous methods rely on GANs (Lee et al., 2018) to synthesize outlier images. More recent methods like VOS (Du et al., 2022) directly synthesize virtual features which allows greater flexibility. Tao et al. (2023) propose non-parametric outlier synthesis, without the restrictive Gaussian assumption on feature distributions in VOS. Here we present a new feature synthesis method that has the same format as the CLIP framework and hence facilitates multimodal regularization. Specifically, given the name of an unknown class, we synthesize its example features in a generalizable way.
56
+
57
+ Model distillation techniques transfer knowledge from a teacher model to student models, e.g., from a large model to its efficient counterparts (Hinton et al., 2015) or from a weakly augmented model to the strongly augmented (Sohn et al., 2020). Here we aim to reduce overfitting for unseen classes and propose to distill knowledge from early to current epochs (i.e., self-distillation). Specifically, we extend Mean teacher (Tarvainen & Valpola, 2017) to an adaptive localized one with suitable teacher curriculum. In the vision-language domain, our approach differs from distillation into smaller models (Li et al., 2023) or towards various downstream tasks (Gu et al., 2022; Dai et al., 2022; Mal et al., 2022). Our approach is also orthogonal (and applicable) to recent distillation frameworks for improved multimodal pretraining (Dong et al., 2023; Li et al., 2021; Zhong et al., 2022).
58
+
59
+ # 3 METHODOLOGY
60
+
61
+ # 3.1 PRELIMINARIES
62
+
63
+ CLIP (Radford et al., 2021) is the vision-language model that we mainly study in this paper, although our study is applicable to other popular models. CLIP consists of an image encoder $\phi$ and a text encoder $\psi$ , which map the image and text inputs into a joint feature space. The CLIP training aims at aligning the image and text modalities by maximizing their feature similarity. Given an input image $\pmb{x}$ that belongs to one of the classes $\pmb{Y} = \{\pmb{y}_1, \pmb{y}_2, \dots, \pmb{y}_C\}$ , the image encoder $\phi$ first extracts image features $\pmb{z} = f_{\phi}(\pmb{x}) \in \mathbb{R}^d$ . To obtain the corresponding text features $\pmb{w}_{c \in \{1, \dots, C\}}$ , all the given class names can be fed into a fixed prompt template $\{\text{a photo of a [CLASS]}\}$ , leading to text descriptions $\pmb{A}$ which are further encoded by $\psi$ into the text embeddings $\pmb{W} = f_{\psi}(\pmb{A}) \in \mathbb{R}^{d \times C}$ (hence $\pmb{w}_{c} = \pmb{W}_{:,c}$ ). The image-text alignment is optimized based on the cosine feature similarity:
64
+
65
+ $$
66
+ p (y = c \mid \boldsymbol {x}) = \frac {\exp (\cos (\boldsymbol {w} _ {c} , \boldsymbol {z}) / \tau)}{\sum_ {i = 1} ^ {C} \exp (\cos (\boldsymbol {w} _ {i} , \boldsymbol {z}) / \tau)}, \tag {1}
67
+ $$
68
+
69
+ where $\tau$ is the temperature. A larger cosine score often indicates stronger image-text alignment in their underlying semantics.
70
+
71
+ Prompt Learning. For efficient model finetuning on downstream tasks, recent prompt learning approaches like CoOp (Zhou et al., 2022a) replace the aforementioned fixed prompts with learnable
72
+
73
+ ![](images/be53187c7ba75ba5ce273aff88829b7a2a16b747f84f4f8325d355f58a358058.jpg)
74
+ (a)
75
+
76
+ ![](images/f7b424088887b57a5a9d5affaa7cf8dd44590e28e539682f6867d22554cf226b.jpg)
77
+ (b)
78
+
79
+ ![](images/f6dfea4fcf736d499e969aa0de43d5458d39de5675f0542b8953e51117d82e2a.jpg)
80
+ (c)
81
+ Figure 2: (a) To improve OOD generalization, we propose to gain knowledge of unknown classes by directly synthesizing their image features. This helps to learn a more reliable decision boundary between known and unknown classes in the feature space. (b) Prompt learning based on discriminating both the known and synthesized unknown features (from our class-conditional feature generator $\theta$ , see details in text). (c) Implementation of $\theta$ using a lightweight attention module.
82
+
83
+ ones $\pmb{V} = [\pmb{v}_1, \pmb{v}_2, \dots, \pmb{v}_L] \in \mathbb{R}^{d \times L}$ where $L$ is the prompt length. Then the text encoder $\psi$ of CLIP will be able to convert the learned prompts $\pmb{V}$ (together with $\pmb{Y}$ ) into adapted text embeddings $\hat{\pmb{W}} = f_{\psi}([\pmb{V}, \pmb{Y}]) \in \mathbb{R}^{d \times C}$ . Note $\pmb{V}$ is learned on each downstream task using the task-specific loss. The image encoder $\phi$ and text encoder $\psi$ of CLIP are kept frozen during prompt learning.
84
+
85
+ # 3.2 CLASS-CONDITIONAL FEATURE GENERATOR
86
+
87
+ As shown in Fig. 1(b), the "prompt-tuned" CLIP model tends to overfit the known classes (aka base classes $\mathbf{Y}^b = \{\pmb{y}_1, \pmb{y}_2, \dots, \pmb{y}_{C_b}\}$ from the downstream task, while OOD generalization on unknown classes (aka new classes $\mathbf{Y}^n$ with $|\mathbf{Y}^n| = C_n$ ) will deteriorate. To reduce overfitting, one might choose model regularization strategies, which will inevitably suffer from the missing knowledge about unknowns. Moreover, the potential number of unknown classes $C_n$ is huge and $C_n \gg C_b$ . Hence it is very challenging to model their complex distributions for effective regularization.
88
+
89
+ Here we make one step towards gaining knowledge of unknowns in a class-conditional manner, in order to provide supervision signals for the vast space of unknown data. Given a textual description or simply the class name of any unknown class, we aim to synthesize the class example features without seeing labeled instances (Fig. 2(a)), leveraging the well-aligned image-text feature spaces of CLIP. Such synthesized image features will then facilitate learning a regularized decision boundary between known and unknown classes, leading to improved OOD generalization capabilities.
90
+
91
+ In early experiments, we found that directly generating OOD image features out of class names is hard due to the highly non-linear and high-dimensional nature of the former. This is similarly observed in those strong cases of OOD generalization in (Abbe et al., 2023), where the manifold embeddings are typically nonlinear and, more critically, part of the distribution domain is entirely unseen at training. It is proved that successful learning under such extreme distribution shift leads to extrapolating solutions since memorization is voided on the unseen domain. Following the "extrapolating bias" on the unknown, we reframe our feature synthesis problem as an easier one — extrapolating from the most similar classes of the seen data, e.g., to generate features of the unknown class raccoon by extrapolating features of the similar training classes like cat and bear.
92
+
93
+ More specifically, for prompt learning, given the learned prompts and one unknown [CLASS] from the open set $\mathbf{Y}^n$ , we first obtain the corresponding text features $\hat{\boldsymbol{w}}^n \in \mathbb{R}^d$ through the text encoder $\psi$ of CLIP. Then we find for $\hat{\boldsymbol{w}}^n$ its kNN classes from the entire set of text features of known classes $\hat{\boldsymbol{W}}^b \in \mathbb{R}^{d \times C_b}$ , resulting in $\hat{\boldsymbol{W}}_R^b \in \mathbb{R}^{d \times K}$ where $R$ is the neighbor set with $|R| = K$ . From each of the kNN classes, we randomly sample only one class example and obtain its text-aligned image features from the image encoder $\phi$ , leading to the same number of $K$ image feature vectors $Z_R^b \in \mathbb{R}^{d \times K}$ . Our goal is to train a class-conditional feature generator $f_{\theta}(\hat{\boldsymbol{w}}^n, \hat{\boldsymbol{W}}_R^b, Z_R^b)$ that can synthesize unknown image features conditioned on the text features $\hat{\boldsymbol{w}}^n$ of an unknown class and auxiliary text/image features $(\hat{\boldsymbol{W}}_R^b, Z_R^b)$ of kNN known classes, see Fig. 2 (b).
94
+
95
+ Remarks. To retrieve semantically similar kNN classes $\hat{W}_R^b$ from $\hat{W}^b$ , we choose to use the cosine similarity score between the text features (not image features) of class pairs. Then the kNN retrieval
96
+
97
+ process can be formally defined as:
98
+
99
+ $$
100
+ \underset {R \subset \{1, \dots , C _ {b} \}: | R | = K} {\arg \max } \sum_ {i \in R} \cos \left(\hat {\boldsymbol {w}} ^ {n}, \hat {\boldsymbol {w}} _ {i} ^ {b}\right), \text {w h e r e} \hat {\boldsymbol {w}} _ {i} ^ {b} = \hat {\boldsymbol {W}} _ {:, i} ^ {b}. \tag {2}
101
+ $$
102
+
103
+ On another note, our empirical study shows that the one random example sampled from each kNN class is enough for assisting new feature generation. Such randomness encourages the diversity of the synthesized features for new classes.
104
+
105
+ Extrapolating per class. Recall the tuple $(\hat{W}_R^b, Z_R^b)$ consists of $K$ text and image feature vectors respectively (one for each similar known class). One straightforward feature synthesis method for an unknown class (with text features $\hat{w}^n$ ) is to extrapolate each image feature vector in $Z_R^b$ based on some notion of similarity with $\hat{w}^n$ , leading to a total of $K$ extrapolated image features from $K$ known classes (e.g., $cat \rightarrow raccoon$ , $bear \rightarrow raccoon, \ldots$ ). The similarity notion can be well learned by Multi-Head Cross-Attention (MHCA) that operates on the triplets of queries, keys and values $(\hat{w}^n, \hat{W}_R^b, Z_R^b)$ . This way, we can effectively take into account the similarity between the unknown class and each known class in $R$ as well as all other between-class similarities. Summarizing, the matrix form of our "extrapolating-per-class" scheme is given as:
106
+
107
+ $$
108
+ \boldsymbol {Z} ^ {n} = \operatorname {L N} \left(\boldsymbol {Z} _ {R} ^ {b} + \hat {\boldsymbol {Z}} ^ {n}\right) \in \mathbb {R} ^ {d \times K}, \quad \hat {\boldsymbol {Z}} ^ {n} = \mathrm {M H C A} \left(\hat {\boldsymbol {w}} ^ {n} \cdot \mathbf {1} _ {K} ^ {\top}, \hat {\boldsymbol {W}} _ {R} ^ {b}, \boldsymbol {Z} _ {R} ^ {b}\right) \in \mathbb {R} ^ {d \times K}, \tag {3}
109
+ $$
110
+
111
+ where $\hat{Z}^n$ are the learned feature residuals when extrapolating each of the $K$ known classes. LN denotes layer normalization. Obviously, our feature generator $\theta$ is lightweight with only one MHCA layer and one LN layer. The simplicity benefits from the "extrapolating bias" in our generator design.
112
+
113
+ Finally, we use the synthesized features $Z^n$ to regularize prompt learning and perform joint discrimination of $C_b$ known and $C_n$ unknown class features. The objective of maximizing the image-text alignment in Eq. (1) now becomes:
114
+
115
+ $$
116
+ p (y = c \mid \boldsymbol {Z} ^ {n}) = \frac {1}{K} \sum_ {k = 1} ^ {K} \frac {\exp \left(\cos \left(\hat {\boldsymbol {w}} _ {c} , \boldsymbol {z} _ {k} ^ {n}\right) / \tau\right)}{\sum_ {i = 1} ^ {C _ {b} + C _ {n}} \exp \left(\cos \left(\hat {\boldsymbol {w}} _ {i} , \boldsymbol {z} _ {k} ^ {n}\right) / \tau\right)}, \forall c \in \{1, \dots , C _ {b} + C _ {n} \}, \tag {4}
117
+ $$
118
+
119
+ where $\hat{\boldsymbol{w}}_c = [\hat{\boldsymbol{W}}^b, \hat{\boldsymbol{W}}^n]_{:,c}$ and $\boldsymbol{z}_k^n = \boldsymbol{Z}_{:,k}^n$ . Note under the "extrapolating-per-class" scheme, we have synthesized $K$ image features for the same unknown class. We simply aggregate them at the score level when computing the cosine feature similarity score in Eq. (4).
120
+
121
+ Extrapolating jointly is a more collaborative approach for new feature synthesis. As the name hints, we extrapolate a single image feature vector $\mathbf{z}^n$ from all the kNN known class features $(\hat{\mathbf{W}}_R^b, \mathbf{Z}_R^b)$ , based on the cross attention against $\hat{\mathbf{w}}^n$ :
122
+
123
+ $$
124
+ \boldsymbol {z} ^ {n} = \operatorname {L N} \left(\operatorname {F F N} \left(\hat {\boldsymbol {w}} ^ {n}\right) + \hat {\boldsymbol {z}} ^ {n}\right) \in \mathbb {R} ^ {d}, \quad \hat {\boldsymbol {z}} ^ {n} = \operatorname {M H C A} \left(\hat {\boldsymbol {w}} ^ {n}, \hat {\boldsymbol {W}} _ {R} ^ {b}, \boldsymbol {Z} _ {R} ^ {b}\right) \in \mathbb {R} ^ {d}, \tag {5}
125
+ $$
126
+
127
+ where $\hat{z}^n$ is the residual image feature vector, while text features $\hat{\boldsymbol{w}}^n$ are projected into the image feature space via a two-layer fully connected feed-forward network FFN. Note $\mathrm{FFN}(\hat{\boldsymbol{w}}^n)$ could be replaced by some anchor point directly searched in the image feature space, e.g., a weighted average of kNN image features from $Z_R^b$ . However, searching is a hard problem itself and learning an explicit text-to-image feature mapping works consistently better in our experiments. Fig. 2 (c) summarizes the overall network architecture, and the objective function in Eq. (4) could be updated as:
128
+
129
+ $$
130
+ p (y = c \mid z ^ {n}) = \frac {\exp \left(\cos \left(\hat {\boldsymbol {w}} _ {c} , \boldsymbol {z} ^ {n}\right) / \tau\right)}{\sum_ {i = 1} ^ {C _ {b} + C _ {n}} \exp \left(\cos \left(\hat {\boldsymbol {w}} _ {i} , \boldsymbol {z} ^ {n}\right) / \tau\right)}, \forall c \in \{1, \dots , C _ {b} + C _ {n} \}. \tag {6}
131
+ $$
132
+
133
+ Remarks. Our ablation study (Table 4) shows that "extrapolating jointly" (our default approach) is better than "extrapolating per class" at synthesizing useful unknown features for joint optimization. We train our class-conditional feature generator using the "known" and "unknown" class splits from the training set of downstream tasks. Fig. 3 demonstrates the ability of our feature generator to generalize to "unknown unknowns" during testing, with faithful image feature synthesis.
134
+
135
+ # 3.3 ADAPTIVE SELF-DISTILLATION
136
+
137
+ Optimizing both known and synthesized unknown features generally improves OOD generalization and oftentimes the ID performance too. However, that does not take into account the optimization
138
+
139
+ ![](images/745bd28f666d083eaaaecabd6318300005917e5ea25f63b70e7b9399bb48f241.jpg)
140
+ Figure 3: Visualizing image feature synthesis based on the joint extrapolation scheme (Eq. (5)) on Flowers102 dataset. Note our feature generator is not trained on the unknown classes, but can still synthesize faithful image features (red triangle) lying close to the real ones (gray cross). This is achieved by extrapolating an unseen instance from the kNN class examples (only a random one per kNN class is used), effectively combining their related patterns like the shape and texture of flowers.
141
+
142
+ ![](images/965e00df570cae1f2dc53f84008402388ea6992a976d1678e3eb4ac20d5dcbd3.jpg)
143
+
144
+ dynamics that could also impact the ID-OOD performance tradeoff, especially with long finetuning runs. Take Fig. 1(b) for example. Without proper regularization, the CoOp baseline achieves either suboptimal ID performance at early epochs, or saturated ID performance but decreasing OOD performance (i.e., overfitting) later on. To address this issue, we introduce an adaptive self-distillation method that regularizes optimization dynamics to further reduce overfitting.
145
+
146
+ More specifically, we use the model checkpoints from earlier epochs (i.e., teacher model often with less overfitting) to guide optimization at the current epoch (i.e., student model often with more overfitting). Since the CLIP model is frozen during prompt learning, the "model" we consider here is our feature generator $\theta$ whose synthesized OOD features will impact the joint ID-OOD optimization. Hence we enforce the consistency between the final prediction probabilities (Eq. (4) or (6)) induced by the teacher model $p^T$ and student model $p^S$ using the mean squared error $\mathrm{MSE}(p^T,p^S)$ . Ideally, this will help us to avoid OOD performance drop while preserving the ID performance.
147
+
148
+ The key to our self-distillation method is the choice of teacher model $\theta^T$ . Obviously, selecting $\theta^T$ as one single model checkpoint at a historical epoch time is unlikely to strike a good trade-off between the ID and OOD performance. Mean Teacher (MT) (Tarvainen & Valpola, 2017) is a better alternative, which calculates an Exponential Moving Average (EMA) over the past checkpoints up until the current time $t$ (Eq. (7)). Here we propose Adaptive Local Mean Teacher (ALMT) that extends MT in two ways: 1) calculating EMA only within a local time window $[t - m_t, t]$ using the last $m_t$ checkpoints. This avoids the negative impact on the teacher's ID performance from those underfit early checkpoints. 2) the window size $m_t$ is time-adaptive such that $m_t$ is small in the early stage of finetuning (for the same purpose of ruling out underfit checkpoints), and then $m_t$ gradually increases in order to cover older checkpoints with improved ID performance but less overfitting. Such curriculum is summarized in Eq. (8) as below:
149
+
150
+ $$
151
+ \mathbf {M T} _ {[ 1, t ]}: \theta_ {i} ^ {T} = \alpha \theta_ {i - 1} ^ {T} + (1 - \alpha) \theta_ {i}, \quad f o r \quad i = \{1, \dots , t \}, \tag {7}
152
+ $$
153
+
154
+ $$
155
+ \mathbf {A L M T} _ {t}: \mathbf {M T} _ {[ t - m _ {t}, t ]}, \quad m _ {t} = \left\lfloor \left(1 + \cos \left(\frac {t _ {\max } + t}{t _ {\max }} \pi\right)\right) \cdot \frac {1}{2} \left(m _ {\max } - m _ {\min }\right) + m _ {\min } \right\rfloor , \tag {8}
156
+ $$
157
+
158
+ where $m_{\mathrm{max}} = 9$ , $m_{\mathrm{min}} = 2$ , $t_{\mathrm{max}}$ is the maximum number of finetuning epochs, and the window size $m_t$ is increased following a cosine schedule. Note our ALMT method requires maintaining a queue of past $m_t$ checkpoints and re-calculating EMA for each time $t$ , both of which are cheap thanks to our compact model size of $\theta_i$ and the small window size $m_t \in \{2, \dots, 9\}$ .
159
+
160
+ # 4 EXPERIMENTS
161
+
162
+ We evaluate OOD generalization under the two settings introduced in (Zhou et al., 2022b) (more details in Appendix A): 1) generalization from ID (base) to OOD (new) classes within one dataset. The base and new class splits are used for finetuning and evaluation respectively. 2) cross-dataset generalization with one ID dataset for finetuning and other datasets for OOD evaluation. The cross
163
+
164
+ Table 1: Base-to-new class generalization. Our OGEN approach consistently improves the new class generalization for all prompt learning baselines on average (across 11 datasets). OGEN also maintains or improves the average performance on base classes. H: Harmonic mean of base and new accuracies $(\%)$
165
+
166
+ <table><tr><td rowspan="2"></td><td rowspan="2">+OGEN</td><td colspan="2">CoOp</td><td colspan="2">CoCoOp</td><td colspan="2">VPT</td><td colspan="2">SHIP</td><td colspan="2">KgCoOp</td><td colspan="2">MaPLe</td><td colspan="2">PromptSRC</td></tr><tr><td>X</td><td>✓</td><td>X</td><td>✓</td><td>X</td><td>✓</td><td>X</td><td>✓</td><td>X</td><td>✓</td><td>X</td><td>✓</td><td>X</td><td>✓</td></tr><tr><td rowspan="4">Avg across 11 datasets</td><td>Base</td><td>82.69</td><td>83.47</td><td>80.47</td><td>79.86</td><td>82.51</td><td>82.52</td><td>80.03</td><td>80.79</td><td>80.73</td><td>81.34</td><td>82.28</td><td>82.40</td><td>84.26</td><td>84.17</td></tr><tr><td>New</td><td>63.22</td><td>69.54</td><td>71.69</td><td>73.35</td><td>69.01</td><td>70.61</td><td>73.69</td><td>76.14</td><td>73.60</td><td>75.68</td><td>75.14</td><td>76.37</td><td>76.10</td><td>76.86</td></tr><tr><td>Δ</td><td colspan="2">+6.32</td><td colspan="2">+1.66</td><td colspan="2">+1.60</td><td colspan="2">+2.45</td><td colspan="2">+2.08</td><td colspan="2">+1.23</td><td colspan="2">+0.76</td></tr><tr><td>H</td><td>71.66</td><td>75.87</td><td>75.83</td><td>76.47</td><td>75.16</td><td>76.10</td><td>76.73</td><td>78.40</td><td>77.00</td><td>78.40</td><td>78.55</td><td>79.27</td><td>79.97</td><td>80.34</td></tr><tr><td rowspan="3">ImageNet</td><td>Base</td><td>76.47</td><td>76.40</td><td>75.98</td><td>76.50</td><td>75.96</td><td>75.09</td><td>75.87</td><td>76.14</td><td>75.83</td><td>75.88</td><td>76.66</td><td>77.02</td><td>77.60</td><td>77.50</td></tr><tr><td>New</td><td>67.88</td><td>68.80</td><td>70.43</td><td>70.23</td><td>67.32</td><td>67.66</td><td>69.95</td><td>71.18</td><td>69.96</td><td>70.93</td><td>70.54</td><td>70.73</td><td>70.73</td><td>70.97</td></tr><tr><td>H</td><td>71.92</td><td>72.40</td><td>73.10</td><td>73.23</td><td>71.38</td><td>71.18</td><td>72.79</td><td>73.58</td><td>72.78</td><td>73.32</td><td>73.47</td><td>73.74</td><td>74.01</td><td>74.09</td></tr><tr><td rowspan="3">Caltech101</td><td>Base</td><td>98.00</td><td>96.67</td><td>97.96</td><td>96.67</td><td>97.50</td><td>96.33</td><td>97.55</td><td>98.09</td><td>97.72</td><td>98.52</td><td>97.74</td><td>98.37</td><td>98.10</td><td>98.32</td></tr><tr><td>New</td><td>89.81</td><td>92.61</td><td>93.81</td><td>94.79</td><td>94.10</td><td>92.36</td><td>95.20</td><td>95.26</td><td>94.39</td><td>94.12</td><td>94.36</td><td>94.54</td><td>94.03</td><td>94.76</td></tr><tr><td>H</td><td>93.73</td><td>94.59</td><td>95.84</td><td>95.72</td><td>95.77</td><td>94.30</td><td>96.36</td><td>96.65</td><td>96.03</td><td>96.27</td><td>96.02</td><td>96.42</td><td>96.02</td><td>96.50</td></tr><tr><td rowspan="3">OxfordPets</td><td>Base</td><td>93.67</td><td>95.18</td><td>95.20</td><td>96.49</td><td>96.05</td><td>96.05</td><td>95.37</td><td>96.95</td><td>94.65</td><td>95.91</td><td>95.43</td><td>95.11</td><td>95.33</td><td>95.96</td></tr><tr><td>New</td><td>95.29</td><td>96.45</td><td>97.69</td><td>97.86</td><td>95.84</td><td>96.84</td><td>97.87</td><td>97.33</td><td>97.76</td><td>97.65</td><td>97.76</td><td>97.89</td><td>97.30</td><td>97.48</td></tr><tr><td>H</td><td>94.47</td><td>95.81</td><td>96.43</td><td>97.17</td><td>95.94</td><td>96.45</td><td>96.61</td><td>97.14</td><td>96.18</td><td>96.77</td><td>96.58</td><td>96.47</td><td>96.30</td><td>96.71</td></tr><tr><td rowspan="3">Stanford Cars</td><td>Base</td><td>78.12</td><td>78.65</td><td>70.49</td><td>68.96</td><td>75.00</td><td>74.23</td><td>68.57</td><td>68.63</td><td>71.76</td><td>71.86</td><td>72.94</td><td>73.63</td><td>78.27</td><td>77.59</td></tr><tr><td>New</td><td>60.40</td><td>65.28</td><td>73.59</td><td>74.23</td><td>63.45</td><td>67.97</td><td>73.90</td><td>75.45</td><td>75.04</td><td>75.95</td><td>74.00</td><td>74.30</td><td>74.97</td><td>75.17</td></tr><tr><td>H</td><td>68.13</td><td>71.35</td><td>72.01</td><td>71.50</td><td>68.74</td><td>70.96</td><td>71.14</td><td>71.88</td><td>73.36</td><td>73.84</td><td>73.47</td><td>73.96</td><td>76.58</td><td>76.38</td></tr><tr><td rowspan="3">Flowers102</td><td>Base</td><td>97.60</td><td>97.38</td><td>94.87</td><td>93.95</td><td>96.89</td><td>98.03</td><td>94.02</td><td>94.67</td><td>95.00</td><td>95.83</td><td>95.92</td><td>96.52</td><td>98.07</td><td>97.34</td></tr><tr><td>New</td><td>59.67</td><td>67.70</td><td>71.75</td><td>72.08</td><td>70.02</td><td>69.15</td><td>74.40</td><td>76.49</td><td>74.73</td><td>74.75</td><td>72.46</td><td>74.46</td><td>76.50</td><td>77.67</td></tr><tr><td>H</td><td>74.06</td><td>79.87</td><td>81.71</td><td>81.57</td><td>81.29</td><td>81.09</td><td>83.06</td><td>84.61</td><td>83.65</td><td>83.98</td><td>82.56</td><td>84.06</td><td>85.95</td><td>86.39</td></tr><tr><td rowspan="3">Food101</td><td>Base</td><td>88.33</td><td>89.21</td><td>90.70</td><td>91.17</td><td>88.88</td><td>91.50</td><td>90.54</td><td>91.07</td><td>90.50</td><td>90.80</td><td>90.71</td><td>91.02</td><td>90.67</td><td>90.69</td></tr><tr><td>New</td><td>82.26</td><td>87.22</td><td>91.29</td><td>91.67</td><td>88.95</td><td>88.53</td><td>91.03</td><td>92.79</td><td>91.70</td><td>92.01</td><td>92.05</td><td>92.02</td><td>91.53</td><td>91.68</td></tr><tr><td>H</td><td>85.19</td><td>88.21</td><td>90.99</td><td>91.42</td><td>88.91</td><td>89.99</td><td>90.78</td><td>91.92</td><td>91.09</td><td>91.40</td><td>91.38</td><td>91.52</td><td>91.10</td><td>91.19</td></tr><tr><td rowspan="3">FGVC Aircraft</td><td>Base</td><td>40.44</td><td>41.67</td><td>33.41</td><td>35.33</td><td>38.33</td><td>39.33</td><td>34.27</td><td>35.47</td><td>36.21</td><td>37.08</td><td>37.44</td><td>37.07</td><td>42.73</td><td>41.26</td></tr><tr><td>New</td><td>22.30</td><td>29.14</td><td>23.71</td><td>34.41</td><td>25.27</td><td>26.55</td><td>32.33</td><td>34.32</td><td>33.55</td><td>37.19</td><td>35.61</td><td>37.41</td><td>37.87</td><td>40.26</td></tr><tr><td>H</td><td>28.75</td><td>34.29</td><td>27.74</td><td>34.86</td><td>30.46</td><td>31.70</td><td>33.28</td><td>34.89</td><td>34.83</td><td>37.14</td><td>36.50</td><td>37.24</td><td>40.15</td><td>40.75</td></tr><tr><td rowspan="3">SUN397</td><td>Base</td><td>80.60</td><td>80.86</td><td>79.74</td><td>80.27</td><td>80.27</td><td>79.06</td><td>79.54</td><td>81.14</td><td>80.29</td><td>81.91</td><td>80.82</td><td>81.06</td><td>82.67</td><td>82.57</td></tr><tr><td>New</td><td>65.89</td><td>67.49</td><td>76.86</td><td>75.69</td><td>74.36</td><td>74.49</td><td>75.27</td><td>75.94</td><td>76.53</td><td>78.83</td><td>78.70</td><td>81.07</td><td>78.47</td><td>78.83</td></tr><tr><td>H</td><td>72.51</td><td>73.57</td><td>78.27</td><td>77.91</td><td>77.20</td><td>76.71</td><td>77.35</td><td>78.45</td><td>78.36</td><td>80.34</td><td>79.75</td><td>81.06</td><td>80.52</td><td>80.65</td></tr><tr><td rowspan="3">DTD</td><td>Base</td><td>79.44</td><td>79.16</td><td>77.01</td><td>75.00</td><td>77.08</td><td>77.43</td><td>74.88</td><td>76.02</td><td>77.55</td><td>78.01</td><td>80.36</td><td>79.73</td><td>83.37</td><td>83.75</td></tr><tr><td>New</td><td>41.18</td><td>50.96</td><td>56.00</td><td>56.44</td><td>53.62</td><td>55.79</td><td>56.88</td><td>64.62</td><td>54.99</td><td>62.56</td><td>59.18</td><td>62.68</td><td>62.97</td><td>62.54</td></tr><tr><td>H</td><td>54.24</td><td>62.01</td><td>64.85</td><td>64.41</td><td>63.24</td><td>64.85</td><td>64.65</td><td>69.86</td><td>64.35</td><td>69.43</td><td>68.16</td><td>70.18</td><td>71.75</td><td>71.60</td></tr><tr><td rowspan="3">EuroSAT</td><td>Base</td><td>92.19</td><td>91.67</td><td>87.49</td><td>78.33</td><td>91.67</td><td>90.00</td><td>88.62</td><td>89.17</td><td>85.64</td><td>86.05</td><td>94.07</td><td>93.83</td><td>92.90</td><td>93.40</td></tr><tr><td>New</td><td>54.74</td><td>73.51</td><td>60.04</td><td>64.69</td><td>58.31</td><td>66.75</td><td>66.87</td><td>74.28</td><td>64.34</td><td>70.18</td><td>73.23</td><td>74.30</td><td>73.90</td><td>76.74</td></tr><tr><td>H</td><td>68.69</td><td>81.59</td><td>71.21</td><td>70.86</td><td>71.28</td><td>76.65</td><td>76.22</td><td>81.05</td><td>73.48</td><td>77.30</td><td>82.35</td><td>82.93</td><td>82.32</td><td>84.25</td></tr><tr><td rowspan="3">UCF101</td><td>Base</td><td>84.69</td><td>91.33</td><td>82.33</td><td>85.78</td><td>80.07</td><td>90.68</td><td>81.08</td><td>81.33</td><td>82.89</td><td>82.84</td><td>83.00</td><td>82.99</td><td>87.10</td><td>87.44</td></tr><tr><td>New</td><td>56.05</td><td>65.81</td><td>73.45</td><td>74.78</td><td>74.50</td><td>70.54</td><td>76.85</td><td>79.83</td><td>76.67</td><td>78.28</td><td>78.66</td><td>80.68</td><td>78.80</td><td>79.28</td></tr><tr><td>H</td><td>67.46</td><td>76.50</td><td>77.64</td><td>79.90</td><td>77.18</td><td>79.35</td><td>78.91</td><td>80.57</td><td>79.65</td><td>80.49</td><td>80.77</td><td>81.82</td><td>82.74</td><td>83.16</td></tr></table>
167
+
168
+ dataset setting is more challenging since there will be both domain- and class-incremental distribution shift, e.g., from generic object classification on ImageNet (Deng et al., 2009) to satellite imagery recognition on EuroSAT (Helber et al., 2019).
169
+
170
+ Datasets. For both settings we use 11 datasets: ImageNet (Deng et al., 2009), Caltech101 (Fei-Fei et al., 2004), OxfordPnts (Parkhi et al., 2012), StanfordCars (Krause et al., 2013), Flowers102 (Nilsback & Zisserman, 2008), Food101 (Bossard et al., 2014), FGVC-Aircraft (Maji et al., 2013), SUN397 (Xiao et al., 2010), UCF101 (Soomro et al., 2012), DTD (Cimpoi et al., 2014) and EuroSAT (Helber et al., 2019).
171
+
172
+ Baselines. For finetuning, we consider prompt learning approaches CoOp (Zhou et al., 2022a), CoCoOp (Zhou et al., 2022b), VPT (Jia et al., 2022), and the state-of-the-art methods SHIP (Wang et al., 2023), KgCoOp (Yao et al., 2023), MaPLe (Khattak et al., 2023a) and PromptSRC (Khattak et al., 2023b). For each baseline, we apply our method (dubbed OGEN) to obtain an OOD GENeralization improved version. For fairness, we use the same implementation details of each baseline, including the prompt length, vision backbone in CLIP (Radford et al., 2021) (i.e., ViT-B/16) and train/test data splitting. The reported results are an average over three random seeds.
173
+
174
+ # 4.1 GENERALIZATION FROM BASE TO NEW CLASSES
175
+
176
+ The base-to-new generalization setting creates a strictly class-incremental distribution shift since the base and new class splits in one dataset are disjoint. All prompt learners are trained on the base classes, and tested on the base and new classes separately to evaluate the trade-off between ID and OOD performance. Here we follow (Xian et al., 2017) to report the harmonic mean of base and new class accuracies to quantify such trade-off.
177
+
178
+ Table 2: Cross-dataset generalization: CLIP finetuning (prompt learning) on the source dataset ImageNet, followed by testing on 10 target datasets. Our method OGEN improves the generalization performance of both CoOp and CoCoOp on all the target datasets.
179
+
180
+ <table><tr><td rowspan="2"></td><td>Source</td><td colspan="11">Target</td></tr><tr><td>ImageNet</td><td>Caltech101</td><td>OxfordPets</td><td>StanfordCars</td><td>Flowers102</td><td>Food101</td><td>FGVCAir</td><td>SUN397</td><td>DTD</td><td>EuroSAT</td><td>UCF101</td><td>Average</td></tr><tr><td>CoOp</td><td>71.51</td><td>93.70</td><td>89.14</td><td>64.51</td><td>68.71</td><td>85.30</td><td>18.47</td><td>64.15</td><td>41.92</td><td>46.39</td><td>66.55</td><td>63.88</td></tr><tr><td>OGEN-CoOp</td><td>71.52</td><td>94.60</td><td>90.73</td><td>65.07</td><td>70.55</td><td>87.26</td><td>19.84</td><td>65.77</td><td>44.90</td><td>49.53</td><td>69.36</td><td>65.76</td></tr><tr><td>CoCoOp</td><td>71.02</td><td>94.43</td><td>90.14</td><td>65.32</td><td>71.88</td><td>86.06</td><td>22.94</td><td>67.36</td><td>45.73</td><td>45.37</td><td>68.21</td><td>65.74</td></tr><tr><td>OGEN-CoCoOp</td><td>71.28</td><td>95.12</td><td>91.37</td><td>66.04</td><td>72.90</td><td>86.54</td><td>22.95</td><td>68.42</td><td>46.38</td><td>45.82</td><td>69.74</td><td>66.53</td></tr></table>
181
+
182
+ Table 1 summarizes the results on 11 datasets. On average, our OGEN method consistently improves the new class accuracy for all the prompt learning baselines. CoOp is particularly interesting since its default learning schedule (200 epochs) is much longer than that of CoCoOp and VPT (10 epochs). Without proper regularization, CoOp inevitably shows more serious overfitting to the base classes (82.69% on average) with low performance on new classes (63.22%) after long training runs. Our OGEN is especially useful in this case, significantly improving the average new class accuracy of CoOp from 63.22% to 69.54%. As also visualized in Appendix C - Fig. 6(a), the new class generalization sees notable gains on 3 datasets — DTD for texture classification, EuroSAT for satellite image recognition and UCF101 for action recognition, which all demonstrate large inter-class variations. This validates the superior generalizability of OGEN, thanks to its capability of OOD feature synthesis and regularization. OGEN also improves the average base class accuracy of CoOp from 82.69% to 83.47%. Specifically, OGEN improves on 6 datasets with negligible performance drop on other 5, see Fig. 6(b). The gains on base classes can be attributed to 1) the joint discrimination of known and unknown classes and 2) our adaptive self-distillation method that strikes a good ID-OOD performance tradeoff.
183
+
184
+ For CoCoOp and VPT with a significantly shorter training schedule, they suffer from much less overfitting with higher new but lower base accuracies than CoOp. This makes our OGEN unable to unleash its full potential to address overfitting. That said, we find both OGEN-CoCoOp and OGEN-VPT can still improve the average new class accuracy while achieving a similar base class accuracy. We are likely to further improve the base accuracy when given a longer optimization schedule that allows more ID-OOD performance balancing.
185
+
186
+ Among the state-of-the-art methods, SHIP (+CoOp) and PromptSRC are related to our OGEN approach in the use of similar techniques of feature synthesis and self-regularization respectively. Table 1 shows that OGEN can improve the new class generalization of both SHIP and PromptSRC by exploring the synergy between regularization and OOD feature synthesis. OGEN also consistently improves the average base and new class accuracies for KgCoOp and MaPLe. Fig. 5 uses KgCoOp to exemplify how these methods still suffer from overfitting (although reduced to some extent by various techniques), and how our OGEN improves the learning curves of both base and new classes. It is worth noting that different methods are trained for different numbers of epochs, thus again, they have different levels of overfitting. OGEN improves generalization more over SHIP (200 epochs) and KgCoOp (100 epochs) with long learning schedules (more serious overfitting). Our gains are smaller over MaPLe (5 epochs) and PromptSRC (20 epochs) with short training runs, but larger gains are expected when trained for longer runs.
187
+
188
+ # 4.2 CROSS-DATASET GENERALIZATION
189
+
190
+ Table 2 shows the generalization performance from ImageNet to 10 target datasets. We consider the representative CoOp and CoCoOp baselines with long and short training runs respectively. As shown in the table, our OGEN uniformly improves the generalization performance (across baselines and target datasets) with competitive source dataset performance. The improvements are especially large on those low performing datasets DTD, EuroSAT, UCF101 with large distribution shift from ImageNet. This highlights the benefits of our OOD feature generation module. OGEN also obtains reasonable gains on the high performing datasets like OxfordPets that contains similar classes (e.g., different dog breeds) with ImageNet, demonstrating the universality of our approach.
191
+
192
+ Table 3: Ablating our class-conditional feature generator $\theta$ (Eq. (5)) and self-distillation method ALMT (Eq. (8)). H: Harmonic mean of the base and new class accuracies averaged on 11 datasets.
193
+
194
+ <table><tr><td>θ</td><td>ALMT</td><td>Base</td><td>New</td><td>H</td></tr><tr><td>X</td><td>X</td><td>82.69±1.08</td><td>63.22±0.51</td><td>71.66±0.54</td></tr><tr><td>✓</td><td>X</td><td>82.49±0.95</td><td>69.02±0.64</td><td>75.15±1.12</td></tr><tr><td>✓</td><td>✓</td><td>83.47±0.30</td><td>69.54±0.34</td><td>75.88±0.11</td></tr></table>
195
+
196
+ Table 5: Class-conditional feature generator: kNN retrieval vs. Random sampling of known classes with varying $K$ .
197
+
198
+ <table><tr><td></td><td>K</td><td>Base</td><td>New</td><td>H</td></tr><tr><td rowspan="4">kNN</td><td>1</td><td>82.76±0.49</td><td>67.01±1.35</td><td>74.06±0.63</td></tr><tr><td>2</td><td>82.35±0.76</td><td>67.79±2.37</td><td>74.36±1.19</td></tr><tr><td>3</td><td>82.49±0.95</td><td>69.02±1.25</td><td>75.15±1.12</td></tr><tr><td>4</td><td>82.37±0.46</td><td>68.85±0.52</td><td>75.00±0.13</td></tr><tr><td>Rand</td><td>3</td><td>81.69±0.35</td><td>68.30±0.38</td><td>74.40±0.36</td></tr></table>
199
+
200
+ Table 4: Class-conditional feature generator: different design choices of no extrapolation from kNN classes, extrapolating per class (Eq. (3)) and extrapolating jointly (Eq. (5)).
201
+
202
+ <table><tr><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>No Extrap</td><td>83.34±0.26</td><td>64.08±0.95</td><td>72.46±0.68</td></tr><tr><td>Extrap per class</td><td>82.90±0.35</td><td>66.04±0.89</td><td>73.52±0.63</td></tr><tr><td>Extrap jointly</td><td>82.49±0.95</td><td>69.02±1.25</td><td>75.15±1.12</td></tr></table>
203
+
204
+ Table 6: Self-distillation: Mean Teacher (MT) vs. Adaptive Local Mean Teacher (ALMT) with fixed window size $m$ or adaptive ${m}_{t}$ (default).
205
+
206
+ <table><tr><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>No distillation</td><td>82.49±0.65</td><td>69.02±0.64</td><td>75.15±1.12</td></tr><tr><td>MT</td><td>83.34±0.15</td><td>68.30±0.77</td><td>75.08±0.47</td></tr><tr><td>ALMT (m=2)</td><td>81.70±0.59</td><td>68.47±0.59</td><td>74.50±0.55</td></tr><tr><td>ALMT (m=9)</td><td>82.21±0.80</td><td>68.57±0.85</td><td>74.77±0.29</td></tr><tr><td>ALMT (mt)</td><td>83.47±0.30</td><td>69.54±0.34</td><td>75.88±0.11</td></tr></table>
207
+
208
+ # 4.3 ABLATION STUDIES
209
+
210
+ Our ablation studies are conducted using OGEN-CoOp with a meaningfully long learning schedule. We start with ablating the two main components of OGEN: class-conditional feature generator $\theta$ and adaptive self-distillation method ALMT. Table 3 confirms both components are useful (more visuals in Appendix B). We see the feature generator improves the new class accuracy by a large margin without hurting the base class accuracy. This suggests the high quality of its generated OOD features and the need of joint ID-OOD feature optimization. ALMT is shown to further improve on both base and new classes, leading to a higher Harmonic mean and a much lower performance variance. This highlights the need of regularizing joint optimization for a good performance tradeoff.
211
+
212
+ Table 4 compares different design choices of our class-conditional feature generator. Recall that we adopt an extrapolation scheme that extrapolates new image features from the kNN base class features. What if we use no extrapolation at all, and directly learn a mapping from the new class name to new image features? As shown in the table, this only slightly helps the new class generalization probably because the generated features are not faithful enough from an unconstrained text-to-image mapping. Then between the "Extrapolating per class" and "Extrapolating jointly" schemes, the latter improves on new classes much more significantly, showing the benefits of collaborative class relation modeling for extrapolation. Table 5 further ablates on the number of kNN base classes needed for extrapolation, arriving at the best $K = 3$ . By comparison, randomly selecting 3 base classes does not perform as well. Finally, Appendix D illustrates the advantage of our feature synthesis approach over replay-based methods using real data.
213
+
214
+ Table 6 compares various self-distillation baselines applied on top of our feature generator. Notably, the simple Mean Teacher (MT) is not helping, which inspires us to use a local version to completely rule out the early-stage underfit model checkpoints. We further propose Adaptive Local Mean Teacher (ALMT) that calculates EMA within a local time window of increasing size $m_{t}$ (from $m_{\min} = 2$ to $m_{\max} = 9$ ). As shown in the table, ALMT achieves the best performance due to the adaptiveness of $m_{t}$ , which effectively avoids both the underfitting (from early epochs) and overfitting (from recent epochs) effects in the teacher model. Apparently, this is not possible with a fixed window size ( $m = m_{\min}$ or $m_{\max}$ ) which hurts performance.
215
+
216
+ # 5 CONCLUSIONS AND FUTURE WORK
217
+
218
+ In this paper, we study the OOD generalization of recent CLIP finetuners and propose an effective approach to reduce their overfitting to seen classes. For that, a class-conditional feature generator is used to synthesize OOD features for joint optimization, and the optimization dynamics are further regularized by an adaptive distillation scheme. The superior generalization capability of our approach is demonstrated under different OOD settings. In the future, we plan to go beyond prompt learning and evaluate how much our benefits hold for other finetuning methods like adaptor tuning. Moreover, it would be interesting to figure out how well our "unknown-aware" approach can model uncertainties on unseen data, which can be evaluated on existing OOD detection benchmarks.
219
+
220
+ # REFERENCES
221
+
222
+ Emmanuel Abbe, Samy Bengio, Aryo Lotfi, and Kevin Rizk. Generalization on the unseen, logic reasoning and degree curriculum. In ICML, 2023.
223
+ Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101-mining discriminative components with random forests. In ECCV, 2014.
224
+ Xi Chen, Xiao Wang, Soravit Changpinyo, AJ Piergiovanni, Piotr Padlewski, Daniel Salz, Sebastian Alexander Goodman, Adam Grycner, Basil Mustafa, Lucas Beyer, Alexander Kolesnikov, Joan Puigcerver, Nan Ding, Keran Rong, Hassan Akbari, Gaurav Mishra, Linting Xue, Ashish Thapliyal, James Bradbury, Weicheng Kuo, Mojtaba Seyedhosseini, Chao Jia, Burcu Karagol Ayan, Carlos Riquelme, Andreas Steiner, Anelia Angelova, Xiaohua Zhai, Neil Houlsby, and Radu Soricut. PaLI: A jointly-scaled multilingual language-image model. In ICLR, 2023.
225
+ Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In CVPR, 2014.
226
+ Wenliang Dai, Lu Hou, Lifeng Shang, Xin Jiang, Qun Liu, and Pascale Fung. Enabling multimodal generation on CLIP via vision-language knowledge distillation. In ACL, 2022.
227
+ 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.
228
+ Xiaoyi Dong, Jianmin Bao, Yinglin Zheng, Ting Zhang, Dongdong Chen, Hao Yang, Ming Zeng, Weiming Zhang, Lu Yuan, Dong Chen, Fang Wen, and Nenghai Yu. MaskCLIP: Masked self-distillation advances contrastive language-image pretraining. In CVPR, 2023.
229
+ Xuefeng Du, Zhaoning Wang, Mu Cai, and Yixuan Li. Vos: Learning what you don't know by virtual outlier synthesis. In ICLR, 2022.
230
+ Sepideh Esmaeilpour, Bing Liu, Eric Robertson, and Lei Shu. Zero-shot out-of-distribution detection based on the pretrained model clip. In AAAI, 2022.
231
+ 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 CVPR workshop, 2004.
232
+ Stanislav Fort, Jie Jessie Ren, and Balaji Lakshminarayanan. Exploring the limits of out-of-distribution detection. In NeurIPS, 2021.
233
+ Golnaz Ghiasi, Xiuye Gu, Yin Cui, and Tsung-Yi Lin. Open-vocabulary image segmentation. arXiv preprint arXiv:2112.12143, 2021.
234
+ Xiuye Gu, Tsung-Yi Lin, Weicheng Kuo, and Yin Cui. Open-vocabulary object detection via vision and language knowledge distillation. In ICLR, 2022.
235
+ 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 J. Sel. Top. Appl. Earth Obs. Remote Sens., 2019.
236
+ Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
237
+ Hexiang Hu, Yi Luan, Yang Chen, Urvashi Khandelwal, Mandar Joshi, Kenton Lee, Kristina Toutanova, and Ming-Wei Chang. Open-domain visual entity recognition: Towards recognizing millions of wikipedia entities. arXiv preprint arXiv:2302.11154, 2023.
238
+ 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.
239
+ Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and Ser-Nam Lim. Visual prompt tuning. In ECCV, 2022.
240
+
241
+ Muhammad Uzair Khattak, Hanoona Rasheed, Muhammad Maaz, Salman Khan, and Fahad Shahbaz Khan. MaPLe: Multi-modal prompt learning. In CVPR, 2023a.
242
+ Muhammad Uzair Khattak, Syed Talal Wasim, Muzammal Naseer, Salman Khan, Ming-Hsuan Yang, and Fahad Shahbaz Khan. Self-regulating prompts: Foundational model adaptation without forgetting. In ICCV, 2023b.
243
+ Wonjae Kim, Bokyung Son, and Ildoo Kim. Vilt: Vision-and-language transformer without convolution or region supervision. In ICML, 2021.
244
+ Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In ICCV workshops, 2013.
245
+ Kimin Lee, Honglak Lee, Kibok Lee, and Jinwoo Shin. Training confidence-calibrated classifiers for detecting out-of-distribution samples. In ICLR, 2018.
246
+ Junnan Li, Ramprasaath R. Selvaraju, Akhilesh Deepak Gotmare, Shafiq Joty, Caiming Xiong, and Steven Hoi. Align before fuse: Vision and language representation learning with momentum distillation. In NeurIPS, 2021.
247
+ Xuanlin Li, Yunhao Fang, Minghua Liu, Zhan Ling, Zhuowen Tu, and Hao Su. Distilling large vision-language model with out-of-distribution generalizability. In ICCV, 2023.
248
+ Yangguang Li, Feng Liang, Lichen Zhao, Yufeng Cui, Wanli Ouyang, Jing Shao, Fengwei Yu, and Junjie Yan. Supervision exists everywhere: A data efficient contrastive language-image pretraining paradigm. In ICLR, 2022.
249
+ Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. arXiv preprint arXiv:1306.5151, 2013.
250
+ Z. Mal, G. Luo, J. Gao, L. Li, Y. Chen, S. Wang, C. Zhang, and W. Hu. Open-vocabulary one-stage detection with hierarchical visual-language knowledge distillation. In CVPR, 2022.
251
+ Yifei Ming, Ziyang Cai, Jiuxiang Gu, Yiyou Sun, Wei Li, and Yixuan Li. Delving into out-of-distribution detection with vision-language representations. In NeurIPS, 2022.
252
+ Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In ICVGIP, 2008.
253
+ Omkar M Parkhi, Andrea Vedaldi, Andrew Zisserman, and CV Jawahar. Cats and dogs. In CVPR, 2012.
254
+ Rui Qian, Yeqing Li, Zheng Xu, Ming-Hsuan Yang, Serge Belongie, and Yin Cui. Multimodal open-vocabulary video classification via pre-trained vision and language models. arXiv preprint arXiv:2207.07646, 2022.
255
+ 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.
256
+ Christoph Schuhmann, Richard Vencu, Romain Beaumont, Robert Kaczmarczyk, Clayton Mullis, Aarush Katta, Theo Coombes, Jenia Jitsev, and Aran Komatsuzaki. LAION-400M: open dataset of clip-filtered 400 million image-text pairs. arXiv preprint arXiv:2111.02114, 2021.
257
+ Yang Shu, Xingzhuo Guo, Jialong Wu, Ximei Wang, Jianmin Wang, and Mingsheng Long. CLIPood: Generalizing clip to out-of-distributions. In ICML, 2023.
258
+ Kihyuk Sohn, David Berthelot, Nicholas Carlini, Zizhao Zhang, Han Zhang, Colin A Raffel, Ekin Dogus Cubuk, Alexey Kurakin, and Chun-Liang Li. Fixmatch: Simplifying semi-supervised learning with consistency and confidence. In NeurIPS, 2020.
259
+ 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.
260
+
261
+ Leitian Tao, Xuefeng Du, Jerry Zhu, and Yixuan Li. Non-parametric outlier synthesis. In ICLR, 2023.
262
+ Antti Tarvainen and Harri Valpola. Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning results. In NeurIPS, 2017.
263
+ Zhengbo Wang, Jian Liang, Ran He, Nan Xu, Zilei Wang, and Tieniu Tan. Improving zero-shot generalization for clip with synthesized prompts. In ICCV, 2023.
264
+ Yongqin Xian, Bernt Schiele, and Zeynep Akata. Zero-shot learning-the good, the bad and the ugly. In CVPR, 2017.
265
+ 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.
266
+ Hantao Yao, Rui Zhang, and Changsheng Xu. Visual-language prompt tuning with knowledge-guided context optimization. In CVPR, 2023.
267
+ Yuhang Zang, Wei Li, Kaiyang Zhou, Chen Huang, and Chen Change Loy. Open-vocabulary detr with conditional matching. In ECCV, 2022a.
268
+ Yuhang Zang, Wei Li, Kaiyang Zhou, Chen Huang, and Chen Change Loy. Unified vision and language prompt learning. arXiv preprint arXiv:2210.07225, 2022b.
269
+ Renrui Zhang, Zhang Wei, Rongyao Fang, Peng Gao, Kunchang Li, Jifeng Dai, Yu Jiao Qiao, and Hongsheng Li. Tip-adapter: Training-free adaption of clip for few-shot classification. In ECCV, 2022.
270
+ Yiwu Zhong, Jianwei Yang, Pengchuan Zhang, Chunyuan Li, Noel Codella, Liunian Harold Li, Luowei Zhou, Xiyang Dai, Lu Yuan, Yin Li, et al. Regionclip: Region-based language-image pretraining. In CVPR, 2022.
271
+ Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for vision-language models. IJCV, 2022a.
272
+ Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Conditional prompt learning for vision-language models. In CVPR, 2022b.
273
+
274
+ ![](images/a0def82db0c0e2fca2c369bf5e8df1c9e94e328e265e028cc915ae19a7193a77.jpg)
275
+
276
+ ![](images/7e3ffde80a1b72a3ba5f15b60f27cc9a9b8081372d35f878bc206cd1063b9928.jpg)
277
+
278
+ ![](images/0a454385cb90292f101d52eeb056d6af5457568586d04552738e4a4ede72ed8c.jpg)
279
+
280
+ ![](images/0d8ce211174bbe345b35e93348faf568f5285222f514108c7ca9df3198780a12.jpg)
281
+ Figure 4: More example learning curves of the long finetuning runs (200 epochs) with CoOp (Zhou et al., 2022a) method. Under the within-dataset generalization setting, CoOp typically overfits the known classes and achieves decreasing accuracy for the unknown classes. The class-conditional feature generator plays a key role in our full method OGEN, which reduces overfitting by generating OOD features for the unknown-aware optimization. Our adaptive self-distillation method further reduces overfitting via regularizing the optimization dynamics.
282
+
283
+ ![](images/810e75f391188cd726942c419d1b943cc15a1e0ca26b531a29e9a16191597955.jpg)
284
+
285
+ ![](images/1023bae40e09fa41e8401f1a9fd5a076548ce13f28d7184b695b5470d5b78242.jpg)
286
+
287
+ ![](images/204d9c85405c38bbf368c42a154cfe8c7ebb9d4b0fd3dc2825f80b10d36ce071.jpg)
288
+ Figure 5: Learning curves of the long finetuning runs (100 epochs) with KgCoOp (Yao et al., 2023) vs. OGEN-KgCoOp methods (within-dataset generalization setting). Despite the overfitting reducing technique used in KgCoOp, it still suffers from some extent of overfitting. See how OGEN often improves the learning curves of both base and new classes.
289
+
290
+ ![](images/0debabc6150959c2761be1e3ab77f451a52df77a0c35ca398585fbefbd0d7207.jpg)
291
+
292
+ ![](images/8f1b3c8664a476d40a0b40d3d0ad7940ea3fe1407fb5593c3be049f49edc3d97.jpg)
293
+
294
+ # A REMARKS ON PROBLEM DEFINITION
295
+
296
+ The focus of this paper is to understand the behaviors of and improve OOD generalization of CLIP finetuning. As shown in Fig. 1(a) of the main paper, the CLIP model can be finetuned on various downstream tasks before evaluating OOD generalization. Two settings are considered: 1) within-dataset generalization where one dataset has ID (base) vs. OOD (new) class splits for finetuning and evaluation respectively; 2) cross-dataset generalization with one ID dataset for finetuning and other OOD datasets for evaluation.
297
+
298
+ Note CLIP is pretrained on enormous volumes of data, which inevitably could have class overlap with some "OOD" data for evaluation. Also, there could be potential class overlap between the curated ID and OOD data themselves, e.g., under the cross-dataset generalization setting where the dataset pair may include similar categories in their class taxonomies. Therefore, we consider more of a generalized OOD generalization test for the large-scale pretrained CLIP model. That is, whenever the class overlap happens, the domain-incremental distribution shift is considered in our evaluation, otherwise we evaluate under the strictly class-incremental distribution shift.
299
+
300
+ ![](images/b9e178a6d5495261aee5f0606ec5dafc209d1b8e613baf0cddbbb56bfd6a5fa2.jpg)
301
+ Figure 6: Base-to-new class generalization when our OGEN approach is applied to the CoOp baseline that suffers from overfitting due to a long learning schedule (200 epochs). OGEN largely overcomes overfitting and (a) improves OOD generalization on new classes for all 11 datasets, sometimes by a large margin. (b) At the same time, OGEN is able to improve the base class accuracies on most datasets, with only minor accuracy drop on a few others.
302
+
303
+ ![](images/a1b595bc5697d3805705f55bdfb3e2a4de07fad62406aa13045a3ab9c0ca5f37.jpg)
304
+
305
+ # B OVERFITTING WITH CLIP FINETUNING: MORE EXAMPLES
306
+
307
+ Fig. 4 shows more learning curves of the prompt learning method CoOp (Zhou et al., 2022a) that finetunes CLIP on a long schedule. Clearly, CoOp overfits on all the considered datasets with decreasing generalization performance on the unknown classes. While both components of our proposed OGEN method - class-conditional feature generator and adaptive self-distillation - are found useful to address overfitting. Our feature generator is observed to play a key role by generating OOD features for the following unknown-aware optimization and regularization.
308
+
309
+ Fig. 5 shows example learning curves of one of the state-of-the-art methods KgCoOp (Yao et al., 2023). This method has relatively long finetuning runs by default (100 epochs). We can see that KgCoOp still suffers from some extent of overfitting, although there is an overfitting reducing component in it. Our OGEN can further alleviate overfitting with KgCoOp, improving its learning curves of both base and new classes.
310
+
311
+ # C VISUALIZING PER-Dataset RESULTS
312
+
313
+ Fig. 6 breaks down the performance gap between CoOp and our OGEN-CoOp on both the base and new classes for 11 datasets. The base-to-new class generalization setting is considered on each dataset.
314
+
315
+ # D FEATURE SYNTHESIS VS. REPLAY-BASED METHOD
316
+
317
+ Recall the goal of our class-conditional feature generator is to model the vast space and complex distribution of unknown class data in OOD domains. Here we investigate how well our synthesized OOD features can represent the real world of unknown data. Specifically, we explore the use of replay methods by sampling real OOD data from the large-scale LAION-400M dataset (Schuhmann et al., 2021) and using the sampled data for replay. We compare our synthesized OOD features against those real OOD data in terms of their contribution to training regularization on downstream tasks.
318
+
319
+ Experimental details. We experiment under the base-to-new class generalization setting where CoOp (Zhou et al., 2022a) is the CLIP finetuning baseline on each of the 11 downstream datasets. For fair comparison between the OGEN- and replay-boosted CoOp variants, we always use ALMT with the only difference in the OOD data source (synthesis vs. replay).
320
+
321
+ # Sampling of replay data.
322
+
323
+ - Class filtering: to ensure the replay data serve as a good proxy of OOD data for each downstream task, we need to perform class filtering when sampling image-text-pairs from LAION-400M, i.e., we filter image-text-pairs that are semantically close to those "known" classes on the considered dataset. We do so by using CLIP to calculate the cosine similarity
324
+
325
+ ![](images/d6e7b34081648ecf31aa4bc59c78a1cc4a28052a0817fe481db19fe19ab5a45f.jpg)
326
+
327
+ ![](images/e2e930ffe8f7f5928eb141614b284c02b05e84933a3e2cd0a3f2f709a1668eb3.jpg)
328
+
329
+ ![](images/74de857ccb849d30b691347b1c372a5c3edfa4af01de8618d9ed203b9f953da9.jpg)
330
+
331
+ ![](images/c1d5d74d11a3a92bf28b34957d166d61aa8c485f7c8d08b3e0ea348bcf546295.jpg)
332
+ Figure 7: OOD feature synthesis is much more data efficient than replaying real OOD data. Real OOD data are sampled from LAION-400M dataset with varying data scale, i.e., multiple times more than the synthesized data. Here we use the CoOp baseline for base-to-new class generalization, and measure the Harmonic mean of base and new accuracies. (a) We can see that OGEN with OOD feature synthesis creates about $3.5\mathrm{x}$ and $7.5\mathrm{x}$ gain in data efficiency on average across 11 datasets, when compared to the replay method with hard sample mining and random sampling strategy respectively (see text for details). (b-c) The replayed OOD samples, despite being data inefficient, are more helpful when they have a closer semantic or data distribution with the downstream dataset (e.g., Caltech101) so to act as semi-hard negatives. They are far less useful for distributionally different DTD, the texture database. On the other hand, OGEN benefits from dataset-specific OOD feature synthesis, which often offers hard negatives to boost data efficiency for training.
333
+
334
+ between the text features of the query text and known class names, and then dropping query texts with the maximum similarity score higher than 0.82. Note our synthesized features are guaranteed to be OOD since they are generated in a class-conditional manner with the query classes disjoint from known classes.
335
+
336
+ - Sampling strategy: with class filtering in place, we consider both random data sampling and hard sample mining to retrieve replay data from LAION-400M. For hard sample mining, we first rank the query texts from a sufficiently large pool (randomly sampled) in terms of the maximum similarity score mentioned above. Then we simply select the top similar query texts and use the corresponding images as hard replay data (similar to hard negatives from hard negative sampling).
337
+ - Sampling data size: given the large amount of image-text-pairs in LAION-400M, we increase the data size of the replay data (either random or hard) by 1-to-12x more than the size of our synthesized OOD data on each downstream dataset. Note our feature generator synthesizes the same amount of OOD features as the "unknown" class splits of the training set of considered dataset.
338
+
339
+ # Observations from Fig. 7.
340
+
341
+ - Better performance is generally obtained with the use of more real OOD data for replay, and performance grows faster with hard mined replay data. When sufficient replay data are used, the performance can surpass that of our synthesized OOD features. This demonstrates the benefits of sampling big and diverse OOD data for training regularization purposes.
342
+ - However, our feature synthesis approach is much more data efficient than replay-based methods. The key reason behind such advantage is that our feature generator is more likely to generate hard OOD samples to better regularize decision boundaries, in comparison to real-world samples. In our case, 1) the feature generator itself is trained on the downstream dataset, thus can synthesize dataset-specific OOD features that adapt better to the task at hand. 2) Recall that we extrapolate OOD features from kNN known class features. This suggests there is inevitable shared information between the known class and synthesized features, further increasing the hardness of the latter. On the other hand, both of the aforementioned factors are missing for the real OOD data sampled from a separate domain, which contributes to their data inefficiency in training regularization. Real OOD data are most useful when they are distributionally similar to the downstream dataset (e.g., Caltech101) and hence can act as semi-hard negatives. Otherwise, data efficiency will see a significant drop when replaying OOD data on distributionally distant dataset like DTD. On
343
+
344
+ average (across 11 datasets), our feature synthesis method is about $3.5\mathrm{x}$ and $7.5\mathrm{x}$ more data efficient than the replay method with hard mining and random sampling respectively.
345
+
346
+ Summary. Replay-based methods perform well with large data size, but suffer from low data efficiency as well as large memory cost (to maintain replay data). Our class-conditional feature generator avoids these issues by synthesizing hard OOD features on the fly. Note our feature generator is lightweight and only incurs small computational cost. Its runtime on GPU is 0.019 seconds, which is significantly smaller than that of the feature extraction step of CLIP (text encoder: 0.046 seconds, image encoder: 1.016 seconds). One promising future direction is the combination of our feature synthesis method and replay methods, aiming to take advantage of their respective benefits of data efficiency and diversity.
overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:574e73db8c2cf027a85f7f602ba4a553a584d3c59f8e45a3695a954749a6f8f6
3
+ size 905135
overcomingthepitfallsofvisionlanguagemodelfinetuningforoodgeneralization/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:298ec82d391c0cf0a7bb6d54eeacec1758e969a7b564152375e3bf95b520b344
3
+ size 473805
p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/545b26ce-6dd1-47a9-8f7a-cc0a3bbd491d_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d77b920ab837471a22eef976243169ad2a96f903aee5a76198c52126a36fa8b
3
+ size 151270
p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/545b26ce-6dd1-47a9-8f7a-cc0a3bbd491d_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8508b8788f4454cfb7baf5e0be0c1ad5475d8d30467c53a0492c7628d9f891a
3
+ size 176993
p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/545b26ce-6dd1-47a9-8f7a-cc0a3bbd491d_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41f103cb0b09840ec4e45cdf49ec93bd04de53f1cc77f333ac7eb3e7a4d95d6a
3
+ size 1641190
p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/full.md ADDED
@@ -0,0 +1,654 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # $\mathbf{P}^2\mathrm{OT}$ : PROGRESSIVE PARTIAL OPTIMAL TRANSPORT FOR DEEP IMBALANCED CLUSTERING
2
+
3
+ Chuyu Zhang $^{1,2,*}$ Hui Ren $^{1,*}$ Xuming He $^{1,3}$
4
+
5
+ $^{1}$ ShanghaiTech University, Shanghai, China $^{2}$ Lingang Laboratory, Shanghai, China
6
+ $^{3}$ Shanghai Engineering Research Center of Intelligent Vision and Imaging, Shanghai, China
7
+
8
+ {zhangchy2, renhui, hexm}@shanghaiitech.edu.cn
9
+
10
+ # ABSTRACT
11
+
12
+ Deep clustering, which learns representation and semantic clustering without labels information, poses a great challenge for deep learning-based approaches. Despite significant progress in recent years, most existing methods focus on uniformly distributed datasets, significantly limiting the practical applicability of their methods. In this paper, we first introduce a more practical problem setting named deep imbalanced clustering, where the underlying classes exhibit an imbalance distribution. To tackle this problem, we propose a novel pseudo-labeling-based learning framework. Our framework formulates pseudo-label generation as a progressive partial optimal transport problem, which progressively transports each sample to imbalanced clusters under prior distribution constraints, thus generating imbalance-aware pseudo-labels and learning from high-confident samples. In addition, we transform the initial formulation into an unbalanced optimal transport problem with augmented constraints, which can be solved efficiently by a fast matrix scaling algorithm. Experiments on various datasets, including a human-curated long-tailed CIFAR100, challenging ImageNet-R, and large-scale subsets of fine-grained iNaturalist2018 datasets, demonstrate the superiority of our method.
13
+
14
+ # 1 INTRODUCTION
15
+
16
+ Human beings possess the innate ability to categorize similar concepts, even when encountering them for the first time. In contrast, artificial models struggle to group similar concepts without labels, although they excel primarily in scenarios where extensive semantic labeling is available. Deep clustering, which aims to learn representation and semantic clustering, is proposed to enable models to achieve that. Currently, many works (Ji et al., 2019; Van Gansbeke et al., 2020; Ronen et al., 2022) are advancing the field of deep clustering. However, they focus on developing methods on balanced datasets, limiting their application in reality, where the data distributions are imbalanced.
17
+
18
+ In this paper, we propose a practical deep imbalanced clustering problem, bridging the gap between the existing deep clustering and real-world application. Existing methods are broadly categorized into relation matching-based (Dang et al., 2021), mutual information maximization-based (Ji et al., 2019), and pseudo-labeling (PL)-based (Van Gansbeke et al., 2020). They face significant challenges when dealing with imbalanced clustering. Relation matching and mutual information maximization act as surrogate losses for clustering and show inferior results compared to the PL method (Van Gansbeke et al., 2020; Niu et al., 2022). PL, on the other hand, tends to learn degenerate solutions (Caron et al., 2018) and heavily relies on the quality of the pseudo-labels. This reliance often requires an additional training stage for representation initialization and sensitive hyperparameter tuning to mitigate confirmation bias (Arazo et al., 2020; Wei et al., 2021), especially in challenging imbalanced clustering scenarios, where imbalanced learning will seriously affect the quality of pseudo labels.
19
+
20
+ To mitigate the above weakness, we propose a novel PL-based progressive learning framework for deep imbalanced clustering. Our framework introduces a novel Progressive Partial Optimal Transport $(\mathrm{P}^2\mathrm{OT})$ algorithm, which integrates imbalance class distribution modeling and confident sample selection within a single optimization problem, enabling us to generate imbalanced pseudo labels and learn from high-confident samples in a progressive manner. Computationally, we reformulate our $\mathrm{P}^2\mathrm{OT}$ as a typical unbalanced OT problem with a theoretical guarantee and employ the light-speed scaling algorithm (Cuturi, 2013; Chizat et al., 2018) to solve it.
21
+
22
+ Specifically, in our progressive PL-based learning framework, we leverage cluster estimation to generate soft pseudo-labels while imposing a set of prior constraints, including an inequality constraint governing sample weight, a Kullback-Leibler ( $KL$ ) divergence constraint on cluster size uniform distribution, and a total mass constraint. Notably, the $KL$ divergence-based uniform distribution constraint empowers our method to avoid degenerate solutions. And our approach with $KL$ , which represents a relaxed constraint compared to an equality constraint, facilitates the generation of imbalanced pseudo-labels. The total mass constraint allows us to selectively learn from high-confident samples by adjusting their weights through optimization, alleviating the noisy pseudo-label learning, and eliminating the sensitive and hand-crafted confidence threshold tuning. As training progresses, we incrementally raise the total mass value, facilitating a gradual transition from learning easy samples to tackling more difficult ones. To solve our $\mathrm{P}^2\mathrm{OT}$ problem efficiently, we introduce a virtual cluster and replace the naive $KL$ with the weighted $KL$ constraint, thus reformulating our $\mathrm{P}^2\mathrm{OT}$ into an unbalanced optimal transport problem under transformed constraints. Then, we solve the unbalanced OT with a scaling algorithm that relies on light-speed matrix-vector multiplications.
23
+
24
+ To validate our method, we propose a new challenging benchmark, which encompasses a diverse range of datasets, including the human-curated CIFAR100 dataset (Krizhevsky et al., 2009), challenging 'out-of-distribution' ImageNet-R dataset (Hendrycks et al., 2021), and large-scale subsets of fine-grained iNaturalist18 dataset (Van Horn et al., 2018). Experiments on those challenging datasets demonstrate the superiority of our method. In summary, our contribution is as follows:
25
+
26
+ - We generalize the deep clustering problem to more realistic and challenging imbalance scenarios, and establish a new benchmark.
27
+ - We propose a novel progressive PL-based learning framework for deep imbalance clustering, which formulates the pseudo label generation as a novel $\mathrm{P}^2\mathrm{OT}$ problem, enabling us to consider class imbalance distribution and progressive learning concurrently.
28
+ - We reformulate the $\mathrm{P}^2\mathrm{OT}$ problem as an unbalanced OT problem with a theoretical guarantee, and solve it with the efficient scaling algorithm.
29
+ - Our method achieves the SOTA performance on most datasets compared with existing methods on our newly proposed challenging and large-scale benchmark.
30
+
31
+ # 2 RELATED WORK
32
+
33
+ Deep clustering. The goal of deep clustering (Zhou et al., 2022a; Huang et al., 2022) is to learn representation and cluster data into semantic classes simultaneously. Based on clustering methods, current works can be grouped into three categories: relation matching, mutual information maximization, and pseudo labeling. Specifically, relation matching (Chang et al., 2017; Van Gansbeke et al., 2020; Tao et al., 2020) involves the minimization of the distance between instances considered 'similar' by representation distance, thus achieving clustering in a bottom-up way. Mutual information maximization (Ji et al., 2019; Li et al., 2021; Shen et al., 2021) either in the prediction or representation space, aims at learning invariant representations, thereby achieving clustering implicitly (Ben-Shaul et al., 2023). Pseudo labeling (PL) (Lee et al., 2013), which is widely used in semi-supervised learning (SSL) (Sohn et al., 2020; Zhang et al., 2021a), assigns each instance to semantic clusters and has demonstrated exceptional performance in the domain of deep clustering (Caron et al., 2018; Van Gansbeke et al., 2020; Asano et al., 2020; Niu et al., 2022). In contrast to the relatively clean pseudo-labels produced by SSL, deep clustering often generates noisier pseudo-labels, particularly in scenarios characterized by data imbalance, imposing a great challenge on pseudo-label generation. In this paper, our primary focus is on PL, and we introduce a novel $\mathrm{P^2OT}$ algorithm. This algorithm progressively generates high-quality pseudo labels by simultaneously considering class imbalance distribution and sample confidence through a single convex optimization problem.
34
+
35
+ Optimal transport and its application. Optimal Transport (OT) (Villani et al., 2009; Peyre et al., 2017; Chizat et al., 2018; Khamis et al., 2023) aims to find the most efficient transportation plan while adhering to marginal distribution constraints. It has been used in a broad spectrum of machine learning tasks, including but not limited to generative model (Frogner et al., 2015; Gulrajani et al., 2017), semi-supervised learning (Tai et al., 2021; Taherkhani et al., 2020), clustering (Asano et al., 2020; Caron et al., 2020), and domain adaptation (Flamary et al., 2016; Chang et al., 2022; Liu et al., 2023; Chang et al., 2023). Of particular relevance to our work is its utilization in pseudo labeling (Asano et al., 2020; Tai et al., 2021; Zhang et al., 2023). Asano et al. (2020) initially
36
+
37
+ introduces an equality constraint on cluster size, formulating pseudo-label generation as an optimal transport problem. Subsequently, Tai et al. (2021) enhances the flexibility of optimal transport by incorporating relaxation on the constraint, which results in its failure in deep imbalanced clustering, and introduces label annealing strategies through an additional total mass constraint. Recently, Zhang et al. (2023) relaxes the equality constraint to a $KL$ divergence constraint on cluster size, thereby addressing imbalanced data scenarios. In contrast to these approaches, which either ignore class imbalance distribution or the confidence of samples, our novel $\mathrm{P}^2\mathrm{OT}$ algorithm takes both into account simultaneously, allowing us to generate pseudo-labels progressively and with an awareness of class imbalance. In terms of computational efficiency, we transform our $\mathrm{P}^2\mathrm{OT}$ into an unbalanced optimal transport (OT) problem under specific constraints and utilize a light-speed scaling algorithm.
38
+
39
+ # 3 PRELIMINARY
40
+
41
+ Optimal Transport (OT) is the general problem of moving one distribution of mass to another with minimal cost. Mathematically, given two probability vectors $\pmb{\mu} \in \mathbb{R}^{m \times 1}$ , $\pmb{\nu} \in \mathbb{R}^{n \times 1}$ , as well as a cost matrix $\mathbf{C} \in \mathbb{R}^{m \times n}$ defined on joint space, the objective function which OT minimizes is as follows:
42
+
43
+ $$
44
+ \min _ {\mathbf {Q} \in \mathbb {R} ^ {m \times n}} \left\langle \mathbf {Q}, \mathbf {C} \right\rangle_ {F} + F _ {1} \left(\mathbf {Q} \mathbf {1} _ {n}, \boldsymbol {\mu}\right) + F _ {2} \left(\mathbf {Q} ^ {\top} \mathbf {1} _ {m}, \boldsymbol {\nu}\right) \tag {1}
45
+ $$
46
+
47
+ where $\mathbf{Q} \in \mathbb{R}^{m \times n}$ is the transportation plan, $\langle, \rangle_F$ denotes the Frobenius product, $F_1, F_2$ are constraints on the marginal distribution of $\mathbf{Q}$ and $\mathbf{1}_n \in \mathbb{R}^{n \times 1}$ , $\mathbf{1}_m \in \mathbb{R}^{m \times 1}$ are all ones vector. For example, if $F_1, F_2$ are equality constraints, i.e. $\mathbf{Q}\mathbf{1}_n = \boldsymbol{\mu}, \mathbf{Q}^\top\mathbf{1}_m = \boldsymbol{\nu}$ , the above OT becomes a widely-known Kantorovich's form (Kantorovich, 1942). And if $F_1, F_2$ are $KL$ divergence or inequality constraints, Equ.(1) turns into the unbalanced OT problem (Liero et al., 2018).
48
+
49
+ In practice, to efficiently solve Kantorovich's form OT problem, Cuturi (2013) introduces an entropy term $-\epsilon \mathcal{H}(\mathbf{Q})$ to Equ.(1) and solve the entropic regularized OT with the efficient scaling algorithm (Knight, 2008). Subsequently, Chizat et al. (2018) generalizes the scaling algorithm to solve the unbalanced OT problem. Additionally, one can introduce the total mass constraint to Equ.(1), and it can be solved by the efficient scaling algorithm by adding a dummy or virtual point to absorb the total mass constraint into marginal. We detail the scaling algorithm in Appendix A and refer readers to (Cuturi, 2013; Chizat et al., 2018) for more details.
50
+
51
+ # 4 METHOD
52
+
53
+ # 4.1 PROBLEM SETUP AND METHOD OVERVIEW
54
+
55
+ In deep imbalanced clustering, the training dataset is denoted as $\mathcal{D} = \{(x_i)\}_{i=1}^N$ , where the cluster labels and distribution are unknown. The number of clusters $K$ is given as a prior. The goal is to learn representation and semantic clusters. To achieve that, we learn representation and pseudo-label alternately, improving the data representation and the quality of cluster assignments. Specifically, given the cluster prediction, we utilize our novel Progressive Partial Optimal Transport $(\mathrm{P}^2\mathrm{OT})$ algorithm to generate high-quality pseudo labels. Our $\mathrm{P}^2\mathrm{OT}$ algorithm has two advantages: 1) generating pseudo labels in an imbalanced manner; 2) reweighting confident samples through optimization. Then, given the pseudo label, we update the representation. We alternate the above two steps until convergence. In the following section, we mainly detail our $\mathrm{P}^2\mathrm{OT}$ algorithm.
56
+
57
+ # 4.2 PROGRESSIVE PARTIAL OPTIMAL TRANSPORT $(\mathrm{P}^2\mathrm{OT})$
58
+
59
+ In this section, we derive the formulation of our novel $\mathrm{P}^2\mathrm{OT}$ algorithm and illustrate how to infer pseudo label $\mathbf{Q}$ by the $\mathrm{P}^2\mathrm{OT}$ algorithm. Given the model's prediction and its pseudo-label, the loss function is denoted as follows:
60
+
61
+ $$
62
+ \mathcal {L} = - \sum_ {i = 1} ^ {N} \mathbf {Q} _ {i} \log \mathbf {P} _ {i} = \langle \mathbf {Q}, - \log \mathbf {P} \rangle_ {F}, \tag {2}
63
+ $$
64
+
65
+ where $\mathbf{Q},\mathbf{P}\in \mathbb{R}_{+}^{N\times K}$ , $\mathbf{Q}_i,\mathbf{P}_i$ is the pseudo label and prediction of sample $x_{i}$ . Note that we have absorbed the normalize term $\frac{1}{N}$ into $\mathbf{Q}$ for simplicity, thus $\mathbf{Q}\mathbf{1}_K = \frac{1}{N}\mathbf{1}_N$ .
66
+
67
+ In deep clustering, it is typical to impose some constraint on the cluster size distribution to avoid a degenerate solution, where all the samples are assigned to a single cluster. As the cluster distribution is
68
+
69
+ long-tailed and unknown, we adopt a $KL$ divergence constraint and only assume the prior distribution is uniform. Therefore, with two marginal distribution constraints, we can formulate the pseudo-label generation problem as an unbalanced OT problem:
70
+
71
+ $$
72
+ \min _ {\mathbf {Q} \in \Pi} \left\langle \mathbf {Q}, - \log \mathbf {P} \right\rangle_ {F} + \lambda K L \left(\mathbf {Q} ^ {\top} \mathbf {1} _ {N}, \frac {1}{K} \mathbf {1} _ {K}\right) \tag {3}
73
+ $$
74
+
75
+ $$
76
+ \text {s . t .} \quad \Pi = \left\{\mathbf {Q} \in \mathbb {R} _ {+} ^ {N \times K} \mid \mathbf {Q} \mathbf {1} _ {K} = \frac {1}{N} \mathbf {1} _ {N} \right\} \tag {4}
77
+ $$
78
+
79
+ where $\langle ,\rangle_F$ is the Frobenius product, and $\lambda$ is a scalar factor. In Equ.(3), the first term is exactly $\mathcal{L}$ , the $KL$ term is a constraint on cluster size, and the equality term ensures each sample is equally important. However, the unbalanced OT algorithm treats each sample equally, which may generate noisy pseudo labels, due to the initial representation being poor, resulting in confirmation bias. Inspired by curriculum learning, which first learns from easy samples and gradually learns hard samples, we select only a fraction of high-confident samples to learn initially and increase the fraction gradually. However, instead of manually selecting confident samples through thresholding, we formulate the selection process as a total mass constraint in Equ.(5). This approach allows us to reweight each sample through joint optimization with the pseudo-label generation, eliminating the need for sensitive hyperparameter tuning. Therefore, the formulation of our novel $\mathrm{P}^2\mathrm{OT}$ is as follows:
80
+
81
+ $$
82
+ \min _ {\mathbf {Q} \in \Pi} \left\langle \mathbf {Q}, - \log \mathbf {P} \right\rangle_ {F} + \lambda K L \left(\mathbf {Q} ^ {\top} \mathbf {1} _ {N}, \frac {\rho}{K} \mathbf {1} _ {K}\right) \tag {5}
83
+ $$
84
+
85
+ $$
86
+ \text {s . t .} \quad \Pi = \left\{\mathbf {Q} \in \mathbb {R} _ {+} ^ {N \times K} \mid \mathbf {Q} \mathbf {1} _ {K} \leq \frac {1}{N} \mathbf {1} _ {N}, \mathbf {1} _ {N} ^ {\top} \mathbf {Q} \mathbf {1} _ {K} = \rho \right\} \tag {6}
87
+ $$
88
+
89
+ where $\rho$ is the fraction of selected mass and will increase gradually, and $KL$ is the unnormalized divergence measure, enabling us to handle imbalance distribution. The resulted $\mathbf{Q1}_K$ is the weight for samples. Intuitively, the $\mathrm{P}^2\mathrm{OT}$ subsumes a set of prior distribution constraints, achieving imbalanced pseudo-label generation and confident sample "selection" in a single optimization problem.
90
+
91
+ Increasing strategy of $\rho$ . In our formulation, the ramp-up strategy for the parameter $\rho$ plays an important role in model performance. Instead of starting with 0 and incrementally increasing to 1, we introduce an initial value $\rho_0$ to mitigate potential issues associated with the model learning from very limited samples in the initial stages. And we utilize the sigmoid ramp-up function, a technique commonly employed in semi-supervised learning (Samuli Laine, 2017; Tarvainen & Valpola, 2017). Therefore, the increasing strategy of $\rho$ is expressed as follows:
92
+
93
+ $$
94
+ \rho = \rho_ {0} + (1 - \rho_ {0}) \cdot e ^ {- 5 (1 - t / T) ^ {2}}, \tag {7}
95
+ $$
96
+
97
+ where $T$ represents the total number of iterations, and $t$ represents the current iteration. We analyze and compare alternate design choices (e.g. linear ramp-up function) in our ablation study. Furthermore, we believe that a more sensible approach to setting $\rho$ involves adaptively increasing it based on the model's learning progress rather than relying on a fixed parameterization tied to the number of iterations. We leave the advanced design of $\rho$ for future work.
98
+
99
+ # 4.3 EFFICIENT SOLVER FOR $\mathbf{P}^2\mathrm{OT}$
100
+
101
+ In this section, we reformulate our $\mathrm{P}^2\mathrm{OT}$ into an unbalanced OT problem and solve it with an efficient scaling algorithm. Our approach involves introducing a virtual cluster onto the marginal (Caffarelli & McCann, 2010; Chapel et al., 2020). This virtual cluster serves the purpose of absorbing the $1 - \rho$ unselected mass, enabling us to transform the total mass constraint into the marginal constraint. Additionally, we replace the $KL$ constraint with a weighted $KL$ constraint to ensure strict adherence to the total mass constraint. As a result, we can reformulate Equ.(5) into a form akin to Equ.(1) and prove their solutions can be interconverted. Subsequently, we resolve this reformulated problem using an efficient scaling algorithm. As shown in Sec.5.3, compared to the generalized scaling solver proposed by (Chizat et al., 2018), our solver is two times faster.
102
+
103
+ Specifically, we denote the assignment of samples on the virtual cluster as $\xi$ . Then, we extend $\xi$ to $\mathbf{Q}$ , and denote the extended $\mathbf{Q}$ as $\hat{\mathbf{Q}}$ which satisfies the following constraints:
104
+
105
+ $$
106
+ \hat {\mathbf {Q}} = \left[ \mathbf {Q}, \boldsymbol {\xi} \right] \in \mathbb {R} ^ {N \times (K + 1)}, \quad \boldsymbol {\xi} \in \mathbb {R} ^ {N \times 1}, \quad \hat {\mathbf {Q}} \mathbf {1} _ {K + 1} = \mathbf {1} _ {N}. \tag {8}
107
+ $$
108
+
109
+ Due to $\mathbf{1}_N^\top \mathbf{Q}\mathbf{1}_K = \rho$ , we know that,
110
+
111
+ $$
112
+ \mathbf {1} _ {N} ^ {\top} \hat {\mathbf {Q}} \mathbf {1} _ {K + 1} = \mathbf {1} _ {N} ^ {\top} \mathbf {Q} \mathbf {1} _ {K} + \mathbf {1} _ {N} ^ {\top} \boldsymbol {\xi} = 1 \Rightarrow \mathbf {1} _ {N} ^ {\top} \boldsymbol {\xi} = 1 - \rho . \tag {9}
113
+ $$
114
+
115
+ Therefore,
116
+
117
+ $$
118
+ \hat {\mathbf {Q}} ^ {\top} \mathbf {1} _ {N} = \left[ \begin{array}{l} \mathbf {Q} ^ {\top} \mathbf {1} _ {N} \\ \boldsymbol {\xi} ^ {\top} \mathbf {1} _ {N} \end{array} \right] = \left[ \begin{array}{c} \mathbf {Q} ^ {\top} \mathbf {1} _ {N} \\ 1 - \rho \end{array} \right]. \tag {10}
119
+ $$
120
+
121
+ The equation is due to $1_N^\top \pmb {\xi} = \pmb{\xi}^T\mathbf{1}_N = 1 - \rho$ . We denote $\mathbf{C} = [-\log \mathbf{P},\mathbf{0}_N]$ and replace $\mathbf{Q}$ with $\hat{\mathbf{Q}}$ thus the Equ.(5) can be rewritten as follows:
122
+
123
+ $$
124
+ \min _ {\hat {\mathbf {Q}} \in \Phi} \langle \hat {\mathbf {Q}}, \mathbf {C} \rangle_ {F} + \lambda K L (\hat {\mathbf {Q}} ^ {\top} \mathbf {1} _ {N}, \beta), \tag {11}
125
+ $$
126
+
127
+ $$
128
+ \text {s . t .} \quad \Phi = \left\{\hat {\mathbf {Q}} \in \mathbb {R} _ {+} ^ {N \times (K + 1)} \mid \hat {\mathbf {Q}} \mathbf {1} _ {K + 1} = \frac {1}{N} \mathbf {1} _ {N} \right\}, \quad \beta = \left[ \begin{array}{c} \frac {\rho}{K} \mathbf {1} _ {K} \\ 1 - \rho \end{array} \right]. \tag {12}
129
+ $$
130
+
131
+ However, the Equ.(11) is not equivalent to Equ.(5), due to the $KL$ constraint can not guarantee Equ.(10) is strictly satisfied, i.e. $\pmb{\xi}^{\top}\mathbf{1}_N = 1 - \rho$ . To solve this problem, we replace the $KL$ constraint with weighted $KL$ , which enables us to control the constraint strength for each class. The formula of weighted $KL$ is denoted as follows:
132
+
133
+ $$
134
+ \hat {K L} \left(\hat {\mathbf {Q}} ^ {\top} \mathbf {1} _ {N}, \boldsymbol {\beta}, \boldsymbol {\lambda}\right) = \sum_ {i = 1} ^ {K + 1} \boldsymbol {\lambda} _ {i} \left[ \hat {\mathbf {Q}} ^ {\top} \mathbf {1} _ {N} \right] _ {i} \log \frac {\left[ \hat {\mathbf {Q}} ^ {\top} \mathbf {1} _ {N} \right] _ {i}}{\boldsymbol {\beta} _ {i}}. \tag {13}
135
+ $$
136
+
137
+ Therefore, the Equ.(5) can be rewritten as follows:
138
+
139
+ $$
140
+ \min _ {\hat {\mathbf {Q}} \in \Phi} \langle \hat {\mathbf {Q}}, \mathbf {C} \rangle_ {F} + K \hat {L} \left(\hat {\mathbf {Q}} ^ {\top} \mathbf {1} _ {N}, \boldsymbol {\beta}, \boldsymbol {\lambda}\right) \tag {14}
141
+ $$
142
+
143
+ $$
144
+ \text {s . t .} \quad \Phi = \left\{\hat {\mathbf {Q}} \in \mathbb {R} _ {+} ^ {N \times (K + 1)} \mid \hat {\mathbf {Q}} \mathbf {1} _ {K + 1} = \frac {1}{N} \mathbf {1} _ {N} \right\}, \quad \beta = \left[\begin{array}{l}\frac {\rho}{K} \mathbf {1} _ {K}\\1 - \rho\end{array}\right], \quad \boldsymbol {\lambda} _ {K + 1} \rightarrow + \infty . \tag {15}
145
+ $$
146
+
147
+ Intuitively, to assure Equ.(10) is strictly satisfied, we set $\lambda_{K + 1}\to +\infty$ . This places a substantial penalty on the virtual cluster, compelling the algorithm to assign a size of $1 - \rho$ to the virtual cluster.
148
+
149
+ Proposition 1 If $\mathbf{C} = [-\log \mathbf{P}, \mathbf{0}_N]$ , and $\lambda_{:K} = \lambda, \lambda_{K+1} \to +\infty$ , the optimal transport plan $\hat{\mathbf{Q}}^{\star}$ of Equ.(14) can be expressed as:
150
+
151
+ $$
152
+ \hat {\mathbf {Q}} ^ {\star} = \left[ \mathbf {Q} ^ {\star}, \boldsymbol {\xi} ^ {\star} \right], \tag {16}
153
+ $$
154
+
155
+ where $\mathbf{Q}^{\star}$ is optimal transport plan of Equ.(5), and $\pmb{\xi}^{\star}$ is the last column of $\hat{\mathbf{Q}}^{\star}$ .
156
+
157
+ The proof is in Appendix B. Consequently, we focus on solving Equ.(14) to obtain the optimal $\hat{\mathbf{Q}}^*$ .
158
+
159
+ Proposition 2 Adding a entropy regularization $-\epsilon \mathcal{H}(\hat{\mathbf{Q}})$ to Equ.(14), we can solve it by efficient scaling algorithm. We denote $\mathbf{M} = \exp (-\mathbf{C} / \epsilon),\pmb {f} = \frac{\lambda}{\lambda + \epsilon},\pmb {\alpha} = \frac{1}{N}\mathbf{1}_N$ . The optimal $\hat{\mathbf{Q}}^{\star}$ is denoted as follows:
160
+
161
+ $$
162
+ \mathbf {Q} ^ {\star} = \operatorname {d i a g} (\mathbf {a}) \mathbf {M} \operatorname {d i a g} (\mathbf {b}), \tag {17}
163
+ $$
164
+
165
+ where $\mathbf{a},\mathbf{b}$ are two scaling coefficient vectors and can be derived by the following recursion formula:
166
+
167
+ $$
168
+ \mathbf {a} \leftarrow \frac {\alpha}{\mathbf {M b}}, \quad \mathbf {b} \leftarrow \left(\frac {\beta}{\mathbf {M} ^ {\top} \mathbf {a}}\right) ^ {\circ f}, \tag {18}
169
+ $$
170
+
171
+ where $\circ$ denotes Hadamard power, i.e., element-wise power. The recursion will stop until $\mathbf{b}$ converges.
172
+
173
+ The proof is in Appendix C, and the pseudo-code is shown in Alg.1. The efficiency analysis is in the Sec.5.3. In practice, rather than solving the $\mathrm{P}^2\mathrm{OT}$ for the entire dataset, we implement a mini-batch approach and store historical predictions as a memory buffer to stabilize optimization.
174
+
175
+ # 5 EXPERIMENTS
176
+
177
+ # 5.1 EXPERIMENTAL SETUP
178
+
179
+ Datasets. To evaluate our method, we have established a realistic and challenging benchmark, including CIFAR100 (Krizhevsky et al., 2009), ImageNet-R (abbreviated as ImgNet-R) (Hendrycks et al., 2021) and iNaturalist2018 (Van Horn et al., 2018) datasets. To quantify the level of class imbalance, we introduce the imbalance ratio denoted as $R$ , calculated as the ratio of $N_{max}$ to $N_{min}$ ,
180
+
181
+ Algorithm 1: Scaling Algorithm for $\mathrm{P^2OT}$
182
+ Input: Cost matrix $-\log \mathbf{P},\epsilon ,\lambda ,\rho ,N,K$ a large value $\iota$ $\mathbf{C}\gets [-\log \mathbf{P},\mathbf{0}_N],\quad \boldsymbol {\lambda}\gets [\lambda ,\dots,\lambda ,\iota ]^\top$ $\beta \leftarrow [\frac{\rho}{K}\mathbf{1}_K^\top ,1 - \rho ]^\top$ , $\alpha \leftarrow \frac{1}{N}\mathbf{1}_N$
183
+ b $\leftarrow 1_{K + 1}$ ,M $\leftarrow \exp (-\mathbf{C} / \epsilon)$ ,f $\leftarrow \frac{\lambda}{\lambda + \epsilon}$
184
+ while b not converge do
185
+ a $\leftarrow \frac{\alpha}{\mathrm{Mb}}$
186
+ b $\leftarrow (\frac{\beta}{\mathrm{M}^{\top}\mathrm{a}})^{\circ f}$
187
+ end
188
+ Q $\leftarrow$ diag(a)Mdiag(b)
189
+ return Q[::K]
190
+
191
+ where $N_{max}$ represents the largest number of images in a class, and $N_{min}$ represents the smallest. For CIFAR100, as in (Cao et al., 2019), we artificially construct a long-tailed CIFAR100 dataset with an imbalance ratio of 100. For ImgNet-R, which has renditions of 200 classes resulting in 30k images and is inherently imbalanced, we split 20 images per class as the test set, leaving the remaining data as the training set ( $R = 13$ ). Note that the data distribution of ImgNet-R is different from the ImageNet, which is commonly used for training unsupervised pre-trained models, posing a great challenge to its clustering. Consequently, ImgNet-R serves as a valuable resource for assessing the robustness of various methods. Furthermore, we incorporate the iNaturalist2018 dataset, a natural long-tailed dataset frequently used in supervised long-tailed learning (Cao et al., 2019; Zhang et al., 2021b). This dataset encompasses 8,142 classes, posing significant challenges for clustering. To mitigate this complexity, we extract subsets of 100, 500, and 1000 classes, creating the iNature100 ( $R = 67$ ), iNature500 ( $R = 111$ ), and iNature1000 ( $R = 111$ ) datasets, respectively. iNature100 is the subset of iNature500, and iNature500 is the subset of iNature1000. The distribution of datasets is in Appendix E. We perform evaluations on both the imbalanced training set and the corresponding balanced test set. Note that we do not conduct experiments on ImageNet datasets because the unsupervised pretrained models have trained on the whole balanced ImageNet.
192
+
193
+ Evaluation Metric. We evaluate our method using the clustering accuracy (ACC) metric averaged over classes, normalized mutual information (NMI), and F1-score. We also provide the adjusted Rand index (ARI) metrics, which is not a suitable metric for imbalanced datasets, in Appendix H. To provide a more detailed analysis, we rank the classes by size in descending order and divide the dataset into Head, Medium, and Tail categories, maintaining a ratio of 3:4:3 across all datasets. Then, we evaluate performance on the Head, Medium, and Tail, respectively.
194
+
195
+ Implementation Details. Building upon the advancements in transformer (Dosovitskiy et al., 2020) and unsupervised pre-trained models (He et al., 2022), we conduct experiments on the ViT-B16, which is pre-trained with DINO (Caron et al., 2021). To provide a comprehensive evaluation, we re-implement most methods from the existing literature, including the typical IIC (Ji et al., 2019), PICA (Huang et al., 2020), CC (Li et al., 2021), SCAN (Van Gansbeke et al., 2020), strong two-stage based SCAN* (Van Gansbeke et al., 2020) and SPICE (Niu et al., 2022), and the recently proposed DivClust (Metaxas et al., 2023). In addition, we also implement BCL (Zhou et al., 2022b), which is specifically designed for representation learning with long-tailed data. It is important to note that all of these methods are trained using the same backbone, data augmentation, and training configurations to ensure a fair comparison. Specifically, we train 50 epochs and adopt the Adam optimizer with the learning rate decay from 5e-4 to 5e-6 for all datasets. The batch size is 512. Further details can be found in Appendix F. For hyperparameters, we set $\lambda$ as 1, $\epsilon$ as 0.1, and initial $\rho$ as 0.1. The stop criterion of Alg.1 is when the change of $\mathbf{b}$ is less than 1e-6, or the iteration reaches 1000. We utilize the loss on training sets for clustering head and model selection. For evaluation, we conduct experiments with each method three times and report the mean results.
196
+
197
+ # 5.2 MAIN RESULTS
198
+
199
+ In Tab.1, we provide a comprehensive comparison of our method with existing approaches on various imbalanced training sets. The results for iNature1000 and balanced test sets can be found in Appendix H. On the relatively small-scale CIFAR100 dataset, our method outperforms the previous state-of-the-art by achieving an increase of 0.9 in ACC, 0.3 in NMI, and 0.6 in F1 score. On the ImgNet-R datasets, our method demonstrates its effectiveness with significant improvements of 2.4
200
+
201
+ Table 1: Comparison with SOTA methods on different imbalanced training sets. The best results are shown in boldface, and the next best results are indicated with an underscore.
202
+
203
+ <table><tr><td rowspan="2">Method</td><td colspan="3">CIFAR100</td><td colspan="3">ImgNet-R</td><td colspan="3">iNature100</td><td colspan="3">iNature500</td></tr><tr><td>ACC</td><td>NMI</td><td>F1</td><td>ACC</td><td>NMI</td><td>F1</td><td>ACC</td><td>NMI</td><td>F1</td><td>ACC</td><td>NMI</td><td>F1</td></tr><tr><td>DINO</td><td>36.6</td><td>68.9</td><td>31.0</td><td>20.5</td><td>39.6</td><td>22.2</td><td>40.1</td><td>67.8</td><td>34.2</td><td>29.8</td><td>67.0</td><td>24.0</td></tr><tr><td>BCL</td><td>35.7</td><td>66.0</td><td>29.9</td><td>20.7</td><td>40.0</td><td>22.4</td><td>41.9</td><td>67.2</td><td>35.4</td><td>28.1</td><td>64.7</td><td>22.4</td></tr><tr><td>IIC</td><td>27.3±3.1</td><td>65.0±1.8</td><td>23.0±2.6</td><td>18.7±1.5</td><td>39.6±1.1</td><td>15.9±1.5</td><td>28.5±1.6</td><td>63.9±1.0</td><td>22.2±1.2</td><td>13.1±0.3</td><td>58.4±0.3</td><td>7.1±0.2</td></tr><tr><td>PICA</td><td>29.8±0.6</td><td>59.9±0.2</td><td>24.0±0.2</td><td>12.6±0.3</td><td>34.0±0.0</td><td>12.1±0.2</td><td>34.8±2.4</td><td>54.8±0.6</td><td>23.8±1.2</td><td>16.3±0.3</td><td>55.9±0.1</td><td>11.3±0.1</td></tr><tr><td>SCAN</td><td>37.2±0.9</td><td>69.4±0.4</td><td>31.4±0.7</td><td>21.8±0.7</td><td>42.6±0.3</td><td>21.7±0.8</td><td>38.7±0.6</td><td>66.3±0.5</td><td>28.4±0.6</td><td>29.0±0.3</td><td>66.7±0.2</td><td>21.6±0.2</td></tr><tr><td>SCAN*</td><td>30.2±0.9</td><td>68.5±2.3</td><td>25.4±1.1</td><td>23.6±0.2</td><td>44.1±0.2</td><td>22.8±0.1</td><td>39.5±0.4</td><td>68.5±0.2</td><td>30.7±0.1</td><td>19.0±0.7</td><td>65.9±0.5</td><td>12.5±0.5</td></tr><tr><td>CC</td><td>29.0±0.6</td><td>60.7±0.6</td><td>24.6±0.5</td><td>12.1±0.6</td><td>30.5±0.1</td><td>11.2±0.9</td><td>28.2±2.4</td><td>56.1±1.2</td><td>20.6±2.1</td><td>16.5±0.7</td><td>55.5±0.0</td><td>12.3±0.4</td></tr><tr><td>DivClust</td><td>31.8±0.3</td><td>64.0±0.4</td><td>26.1±0.8</td><td>14.8±0.2</td><td>33.9±0.4</td><td>13.8±0.2</td><td>33.7±0.2</td><td>59.3±0.5</td><td>23.3±0.7</td><td>17.2±0.5</td><td>56.4±0.3</td><td>12.5±0.4</td></tr><tr><td>P2OT</td><td>38.2±0.8</td><td>69.6±0.3</td><td>32.0±0.9</td><td>25.9±0.9</td><td>45.7±0.5</td><td>27.3±1.4</td><td>44.2±1.2</td><td>67.0±0.6</td><td>36.9±2.0</td><td>32.2±2.0</td><td>67.2±0.3</td><td>25.2±1.7</td></tr></table>
204
+
205
+ ![](images/ee9a4e666e30d29e1a52523f6ff4566e69d6e058db435fc0fe1c0226671a85d4.jpg)
206
+ Figure 1: Head, Medium, and Tail comparison on several datasets.
207
+
208
+ ![](images/5ffb6e3baeed9934f634785566d2ed3b685b3e59f23ba8ea2a64d6bca8be2a1a.jpg)
209
+ PICA
210
+
211
+ ![](images/5b2ef638fa33c4b61c2fd606d2b1182f076103bce7e99fc18050c053cf93fd73.jpg)
212
+ SCAN
213
+ Figure 2: The T-SNE analysis on iNature100 training set.
214
+
215
+ ![](images/dfb20a6304e993581885da2aca2b89374c8bab0d01edc05141b8edc1dbebbf49.jpg)
216
+ DivClust
217
+
218
+ ![](images/2dc8809e3b6c18c93d123929fc534996a5e7ec655f39af59c6e2a8467565c69b.jpg)
219
+ P2OT
220
+
221
+ in ACC, 1.6 in NMI, and 4.5 in F1 score, highlighting its robustness in out-of-distribution scenarios. When applied to the fine-grained iNature datasets, our approach consistently delivers substantial performance gains across each subset in terms of ACC and F1 scores. Specifically, on ACC, we achieve improvements of 5.9 on iNature100 and 3.4 on iNature500. On the F1 score, we obtain improvements of 1.5 and 1.2 on the two datasets, respectively. In terms of NMI, we observe a 0.6 improvement on iNature500 but a 1.5 decrease on iNature100. It's worth noting that our method is an efficient one-stage approach, unlike SCAN*, which is a two-stage pseudo-labeling-based method. Additionally, another pseudo-labeling-based method, SPICE, exhibits a degenerate solution in the imbalance scenario (see Appendix F). Those results indicate the naive pseudo-labeling methods encounter a great challenge and demonstrate our superiority in handling imbalance scenarios.
222
+
223
+ In addition, we provide a detailed analysis of the results for the Head, Medium, and Tail classes, offering a more comprehensive understanding of our method's performance across different class sizes. As depicted in Fig. 1, our improvements are predominantly driven by the Medium and Tail classes, especially in challenging scenarios like ImgNet-R and iNature500, although our results show some reductions in performance for the Head classes. These results highlight the effectiveness of our $\mathrm{P}^2\mathrm{OT}$ algorithm in generating imbalance-aware pseudo-labels, making it particularly advantageous for the Medium and Tail classes. Furthermore, in Fig.2, we present a T-SNE (Van der Maaten & Hinton, 2008) comparison of features before the clustering head. The T-SNE results illustrate our method learns more distinct clusters, particularly benefiting Medium and Tail classes.
224
+
225
+ # 5.3 ABLATION STUDY
226
+
227
+ Component Analysis. To assess the $KL$ constraint and the progressive $\rho$ , we conduct ablation experiments to analyze their individual contributions. As shown in Tab.2, we compare our full $\mathrm{P}^2\mathrm{OT}$ method with three ablated versions: OT, POT and UOT. OT (Asano et al., 2020) imposes equality constraint on cluster size and without the progressive $\rho$ component. POT signifies the replacement of
228
+
229
+ Table 2: Analysis of different formulations. SLA is proposed by (Tai et al., 2021) in semi-supervised learning. OT (Asano et al., 2020), POT and UOT are variants of our $\mathrm{P}^2\mathrm{OT}$ . POT substitutes the $KL$ constraint with the equality constraint. UOT removes the progressive $\rho$ .
230
+
231
+ <table><tr><td rowspan="2">Formulation</td><td colspan="4">CIFAR100</td><td colspan="4">ImgNet-R</td><td colspan="4">iNature500</td></tr><tr><td>Head</td><td>Medium</td><td>Tail</td><td>ACC</td><td>Head</td><td>Medium</td><td>Tail</td><td>ACC</td><td>Head</td><td>Medium</td><td>Tail</td><td>ACC</td></tr><tr><td>SLA</td><td>-</td><td>-</td><td>-</td><td>3.26</td><td>-</td><td>-</td><td>-</td><td>1.00</td><td>-</td><td>-</td><td>-</td><td>6.33</td></tr><tr><td>OT</td><td>35.0</td><td>30.2</td><td>18.7</td><td>28.2</td><td>24.4</td><td>19.3</td><td>10.7</td><td>18.2</td><td>27.1</td><td>27.5</td><td>16.4</td><td>24.1</td></tr><tr><td>POT</td><td>39.6</td><td>42.9</td><td>14.5</td><td>33.4</td><td>25.5</td><td>23.3</td><td>17.6</td><td>22.2</td><td>31.7</td><td>32.7</td><td>19.7</td><td>28.5</td></tr><tr><td>UOT</td><td>43.4</td><td>42.5</td><td>19.6</td><td>35.9</td><td>27.7</td><td>23.9</td><td>14.6</td><td>22.2</td><td>32.2</td><td>29.0</td><td>18.3</td><td>26.7</td></tr><tr><td>P²OT</td><td>45.1</td><td>45.5</td><td>21.6</td><td>38.2</td><td>31.5</td><td>29.3</td><td>16.1</td><td>25.9</td><td>36.3</td><td>37.0</td><td>21.6</td><td>32.2</td></tr></table>
232
+
233
+ ![](images/d76845fd6afccff84d04b6ecb0b16bc43312c5236c148d7c561acd19542d6407.jpg)
234
+ Figure 3: Confusion matrix on the balanced CIFAR100 test set. The two red rectangles represent the Medium and Tail classes.
235
+
236
+ ![](images/55f55518ad01aa3d1e1bb0e5847eebc5d15406506e8c551cfe654259f1f181c9.jpg)
237
+
238
+ ![](images/39267dcc9be397b22da3bd702edcdd18ffe7f39ed4da129b3c27edebbf4b40a2.jpg)
239
+
240
+ ![](images/aa5969475c41978878cb9b12e512e68441927a62892ca39c1e3939a863e68fc6.jpg)
241
+ Figure 4: Precision, Recall analysis on train dataset with different training epoch. The weighted precision and recall are derived by reweighting each sample by our $\mathrm{P^2OT}$ algorithm.
242
+
243
+ ![](images/1eb5fdd1af171ad5f1763b6e020fe8f040d96c209be4e545760bf4e724fba786.jpg)
244
+
245
+ ![](images/956c149a66e29f4b11481ba134b229e2fb13ea094aeec091df70b86bb0f49f3e.jpg)
246
+
247
+ the $KL$ term in the original $\mathrm{P}^2\mathrm{OT}$ formulation with a typical uniform constraint. UOT denotes the removal of the progressive $\rho$ component from the original $\mathrm{P}^2\mathrm{OT}$ formulation. Furthermore, we also compare with SLA (Tai et al., 2021), which relaxes the equality constraint of POT by utilizing an upper bound. However, due to this relaxation, samples are erroneously assigned to a single cluster in the early stages, rendering its failure for clustering imbalanced data. We detail their formulation and further analysis in Appendix J. The results show POT and UOT both significantly surpass the OT, indicating that both of our components yield satisfactory effects. Compared to POT, we achieve improvements of 5.8, 3.8, and 3.6 on CIFAR100, ImgNet-R, and iNature500, respectively. Our improvement is mainly from Head and Tail classes, demonstrating that our P2OT with $KL$ constraint can generate imbalanced pseudo labels. Compared to UOT, we realize gains of 2.3, 3.8, and 5.4 on CIFAR100, ImgNet-R, and iNature500, respectively. Furthermore, as depicted in Fig.3, the confusion matrix for the CIFAR100 test set also validates our improvement on Medium and Tail classes. These remarkable results underscore the effectiveness of each component in our $\mathrm{P}^2\mathrm{OT}$ .
248
+
249
+ Pseudo Label Quality Analysis. To provide a deeper understanding, we conduct an analysis of the pseudo-label quality generated by our $\mathrm{P}^2\mathrm{OT}$ . We evaluate precision and recall metrics to assess the pseudo-label quality for the entire training set. Notably, our $\mathrm{P}^2\mathrm{OT}$ algorithm conducts selection through reweighting, rather than hard selection. Consequently, we reweight each sample and present the weighted precision and recall results. As depicted in Fig.4, our weighted precision and recall consistently outperform precision and recall across different epochs. In the early stages, weighted precision and recall exhibit more rapid improvements compared to precision and recall. However,
250
+
251
+ Table 3: Analysis of $\rho_0$ and different ramp up function. Fixed denotes $\rho$ as a constant value.
252
+
253
+ <table><tr><td rowspan="2">ρ0</td><td colspan="5">Sigmoid</td><td colspan="3">Linear</td><td colspan="2">Fixed</td></tr><tr><td>0.00</td><td>0.05</td><td>0.1</td><td>0.15</td><td>0.2</td><td>0</td><td>0.1</td><td>0.2</td><td>0.1</td><td>0.2</td></tr><tr><td>CIFAR100</td><td>32.9</td><td>37.9</td><td>38.2</td><td>36.3</td><td>37.6</td><td>35.0</td><td>36.6</td><td>36.8</td><td>37.4</td><td>37.1</td></tr><tr><td>ImgNet-R</td><td>26.5</td><td>27.2</td><td>25.9</td><td>26.0</td><td>26.6</td><td>25.8</td><td>28.5</td><td>23.0</td><td>25.5</td><td>24.7</td></tr><tr><td>iNature500</td><td>32.6</td><td>31.7</td><td>32.2</td><td>32.8</td><td>32.9</td><td>31.9</td><td>32.0</td><td>30.5</td><td>29.9</td><td>30.3</td></tr></table>
254
+
255
+ ![](images/cc79706909a743237ec715823d0b5d4d08fa44ca9a3b18e0cdc60954d7ed6353.jpg)
256
+ Figure 5: Time cost comparison of our solver with Generalized Scaling Algorithm (GSA).
257
+
258
+ ![](images/09ac8851a48383b9423422dd9395e5f4bccb5673674e707521e8c7354d71cc3b.jpg)
259
+
260
+ they eventually plateau around 10 epochs ( $\rho \approx 0.15$ ), converging gradually with precision and recall. The decline observed in weighted precision and recall over time suggests that our current ramp-up function may not be optimal, and raising to 1 for $\rho$ may not be necessary. We believe that the ramp-up strategy for $\rho$ should be adaptive to the model's learning progress. In this paper, we have adopted a typical sigmoid ramp-up strategy, and leave more advanced designs for future work.
261
+
262
+ Analysis of $\rho$ . In our $\mathrm{P}^2\mathrm{OT}$ algorithm, the choice of initial $\rho_0$ and the specific ramp-up strategy are important hyperparameters. In this section, we systematically investigate the impact of varying $\rho_0$ values and alternative ramp-up strategy. The term "Linear" signifies that $\rho$ is increased to 1 from $\rho_0$ using a linear function, while "Fixed" indicates that $\rho$ remains constant as $\rho_0$ . The results in Tab.3 provide several important insights: 1) Our method exhibits consistent performance across various $\rho_0$ values when using the sigmoid ramp-up function, highlighting its robustness on datasets like ImgNet-R and iNature500; 2) The linear ramp-up strategy, although slightly less effective than sigmoid, still demonstrates the importance of gradually increasing $\rho$ during the early training stage; 3) The fixed $\rho$ approach results in suboptimal performance, underscoring the necessity of having a dynamically increasing $\rho$ . These findings suggest that a good starting value for $\rho_0$ is around 0.1, and it should be progressively increased during training.
263
+
264
+ Efficiency Analysis. To demonstrate the efficiency of our solver, we perform a comparison between our solver and the Generalized Scaling Algorithm (GSA) proposed by (Chizat et al., 2018). The pseudo-code of GSA is in Appendix K. This comparison is conducted on iNaure1000 using identical conditions (NVIDIA TITAN RTX, $\epsilon = 0.1$ , $\lambda = 1$ ), without employing any acceleration strategies for both. To ensure the comprehensiveness of our time cost analysis, we conduct experiments by varying both the number of data points and the $\rho$ value. Subsequently, we average the time costs for different numbers of data points across different $\rho$ values and vice versa. The results presented in Fig.5 reveal several insights: 1) the time cost of both methods increases near linearly with the number of points; 2) as $\rho$ approaches 1, the time cost of GSA increases rapidly due to the tightening inequality constraint, whereas our time cost decreases; 3) as shown in the left figure, our solver is $2\times$ faster than GSA. Those results demonstrate the efficiency of our solver.
265
+
266
+ # 6 CONCLUSION
267
+
268
+ In this paper, we introduce a more practical problem called "deep imbalanced clustering," which aims to learn representations and semantic clusters from imbalanced data. To address this challenging problem, we propose a novel progressive PL-based learning framework, which formulates the pseudolabel generation as a progressive partial optimal transport $(\mathrm{P}^2\mathrm{OT})$ algorithm. The $\mathrm{P}^2\mathrm{OT}$ enables us to generate high-quality pseudo-labels in an imbalance-aware and progressive manner, thereby significantly improving model learning and clustering performance. To efficiently solve the $\mathrm{P}^2\mathrm{OT}$ algorithm, we introduce a virtual cluster and a weighted $KL$ constraint. Subsequently, by imposing certain constraints, we transform our problem into an unbalanced optimal transport problem, which can be efficiently solved using a scaling algorithm. Finally, extensive results on the human-curated long-tailed CIFAR100 dataset, challenging ImageNet-R datasets, and several large-scale fine-grained iNature datasets validate the superiority of our method.
269
+
270
+ # ACKNOWLEDGMENTS
271
+
272
+ This work was supported by National Science Foundation of China under grant 62350610269, Shanghai Frontiers Science Center of Human-centered Artificial Intelligence, and MoE Key Lab of Intelligent Perception and Human-Machine Collaboration (ShanghaiTech University). We thank Wanxing Chang for her valuable and inspiring comments.
273
+
274
+ # REFERENCES
275
+
276
+ Eric Arazo, Diego Ortego, Paul Albert, Noel E O'Connor, and Kevin McGuinness. Pseudo-labeling and confirmation bias in deep semi-supervised learning. In 2020 International Joint Conference on Neural Networks (IJCNN), pp. 1-8. IEEE, 2020.
277
+ Yuki M. Asano, Christian Rupprecht, and Andrea Vedaldi. Self-labelling via simultaneous clustering and representation learning. In International Conference on Learning Representations (ICLR), 2020.
278
+ Ido Ben-Shaul, Ravid Shwartz-Ziv, Tomer Galanti, Shai Dekel, and Yann LeCun. Reverse engineering self-supervised learning. arXiv preprint arXiv:2305.15614, 2023.
279
+ Luis A Caffarelli and Robert J McCann. Free boundaries in optimal transport and monge-ampere obstacle problems. Annals of mathematics, pp. 673-730, 2010.
280
+ Kaidi Cao, Colin Wei, Adrien Gaidon, Nikos Arechiga, and Tengyu Ma. Learning imbalanced datasets with label-distribution-aware margin loss. Advances in neural information processing systems, 32, 2019.
281
+ Mathilde Caron, Piotr Bojanowski, Armand Joulin, and Matthijs Douze. Deep clustering for unsupervised learning of visual features. In Proceedings of the European conference on computer vision (ECCV), pp. 132-149, 2018.
282
+ Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. Advances in Neural Information Processing Systems, 33:9912-9924, 2020.
283
+ Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 9650-9660, 2021.
284
+ Jianlong Chang, Lingfeng Wang, Gaofeng Meng, Shiming Xiang, and Chunhong Pan. Deep adaptive image clustering. In Proceedings of the IEEE international conference on computer vision, pp. 5879-5887, 2017.
285
+ Wanxing Chang, Ye Shi, Hoang Tuan, and Jingya Wang. Unified optimal transport framework for universal domain adaptation. Advances in Neural Information Processing Systems, 35:29512-29524, 2022.
286
+ Wanxing Chang, Ye Shi, and Jingya Wang. Csot: Curriculum and structure-aware optimal transport for learning with noisy labels. In Thirty-seventh Conference on Neural Information Processing Systems, 2023.
287
+ Laetitia Chapel, Mokhtar Z Alaya, and Gilles Gasso. Partial optimal transport with applications on positive-unlabeled learning. Advances in Neural Information Processing Systems, 33:2903-2913, 2020.
288
+ Lenaic Chizat, Gabriel Peyre, Bernhard Schmitzer, and François-Xavier Vialard. Scaling algorithms for unbalanced optimal transport problems. Mathematics of Computation, 87(314):2563-2609, 2018.
289
+ Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. Advances in neural information processing systems, 26, 2013.
290
+
291
+ Zhiyuan Dang, Cheng Deng, Xu Yang, Kun Wei, and Heng Huang. Nearest neighbor matching for deep clustering. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 13693-13702, June 2021.
292
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2020.
293
+ R Flamary, N Courty, D Tuia, and A Rakotomamonjy. Optimal transport for domain adaptation. IEEE Trans. Pattern Anal. Mach. Intell, 1:1-40, 2016.
294
+ Charlie Frogner, Chiyuan Zhang, Hossein Mobahi, Mauricio Araya, and Tomaso A Poggio. Learning with a wasserstein loss. Advances in neural information processing systems, 28, 2015.
295
+ Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron C Courville. Improved training of wasserstein gans. Advances in neural information processing systems, 30, 2017.
296
+ Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dólár, and Ross Girshick. Masked autoencoders are scalable vision learners. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 16000-16009, 2022.
297
+ Dan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Zhu, Samyak Parajuli, Mike Guo, Dawn Song, Jacob Steinhardt, and Justin Gilmer. The many faces of robustness: A critical analysis of out-of-distribution generalization. ICCV, 2021.
298
+ Jiabo Huang, Shaogang Gong, and Xiatian Zhu. Deep semantic clustering by partition confidence maximisation. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
299
+ Zhizhong Huang, Jie Chen, Junping Zhang, and Hongming Shan. Learning representation for clustering via prototype scattering and positive sampling. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
300
+ Xu Ji, Joao F Henriques, and Andrea Vedaldi. Invariant information clustering for unsupervised image classification and segmentation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 9865-9874, 2019.
301
+ Ziyu Jiang, Tianlong Chen, Bobak J Mortazavi, and Zhangyang Wang. Self-damaging contrastive learning. In International Conference on Machine Learning, pp. 4927-4939. PMLR, 2021.
302
+ L. Kantorovich. On the transfer of masses (in russian). Doklady Akademii Nauk, 37:227-229, 1942.
303
+ Abdelwahed Khamis, Russell Tsuchida, Mohamed Tarek, Vivien Rolland, and Lars Petersson. Earth movers in the big data era: A review of optimal transport in machine learning. arXiv preprint arXiv:2305.05080, 2023.
304
+ Philip A Knight. The sinkhorn-knopp algorithm: convergence and applications. SIAM Journal on Matrix Analysis and Applications, 30(1):261-275, 2008.
305
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
306
+ Dong-Hyun Lee et al. Pseudo-label: The simple and efficient semi-supervised learning method for deep neural networks. In Workshop on challenges in representation learning, ICML, volume 3, pp. 896. Atlanta, 2013.
307
+ Yunfan Li, Peng Hu, Zitao Liu, Dezhong Peng, Joey Tianyi Zhou, and Xi Peng. Contrastive clustering. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 8547-8555, 2021.
308
+ Matthias Liero, Alexander Mielke, and Giuseppe Savare. Optimal entropy-transport problems and a new hellinger-kantorovich distance between positive measures. Inventiones mathematicae, 211(3): 969-1117, 2018.
309
+
310
+ Hong Liu, Jeff Z HaoChen, Adrien Gaidon, and Tengyu Ma. Self-supervised learning is more robust to dataset imbalance. 2022.
311
+ Yang Liu, Zhipeng Zhou, and Baigui Sun. Cot: Unsupervised domain adaptation with clustering and optimal transport. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 19998-20007, June 2023.
312
+ Ioannis Maniadis Metaxas, Georgios Tzimiropoulos, and Ioannis Patras. Divclust: Controlling diversity in deep clustering. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3418-3428, 2023.
313
+ Chuang Niu, Hongming Shan, and Ge Wang. Spice: Semantic pseudo-labeling for image clustering. IEEE Transactions on Image Processing, 31:7264-7278, 2022.
314
+ Gabriel Peyre, Marco Cuturi, et al. Computational optimal transport. Center for Research in Economics and Statistics Working Papers, (2017-86), 2017.
315
+ Meitar Ronen, Shahaf E. Finder, and Oren Freifeld. Deepdpm: Deep clustering with an unknown number of clusters. In Conference on Computer Vision and Pattern Recognition, 2022.
316
+ Timo Aila Samuli Laine. Temporal ensembling for semi-supervised learning. International Conference on Learning Representations (ICLR), 30, 2017.
317
+ Yuming Shen, Ziyi Shen, Menghan Wang, Jie Qin, Philip Torr, and Ling Shao. You never cluster alone. Advances in Neural Information Processing Systems, 34:27734-27746, 2021.
318
+ Kihyuk Sohn, David Berthelot, Nicholas Carlini, Zizhao Zhang, Han Zhang, Colin A Raffel, Ekin Dogus Cubuk, Alexey Kurakin, and Chun-Liang Li. Fixmatch: Simplifying semi-supervised learning with consistency and confidence. Advances in Neural Information Processing Systems, 33:596-608, 2020.
319
+ Fariborz Taherkhani, Ali Dabouei, Sobhan Soleymani, Jeremy Dawson, and Nasser M Nasrabadi. Transporting labels via hierarchical optimal transport for semi-supervised learning. In Computer Vision-ECCV 2020: 16th European Conference, Glasgow, UK, August 23-28, 2020, Proceedings, Part IV 16, pp. 509-526. Springer, 2020.
320
+ Kai Sheng Tai, Peter D Bailis, and Gregory Valiant. Sinkhorn label allocation: Semi-supervised classification via annealed self-training. In International Conference on Machine Learning, pp. 10065-10075. PMLR, 2021.
321
+ Yaling Tao, Kentaro Takagi, and Kouta Nakata. Clustering-friendly representation learning via instance discrimination and feature decorrelation. In International Conference on Learning Representations, 2020.
322
+ Antti Tarvainen and Harri Valpola. Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning results. Advances in neural information processing systems, 30, 2017.
323
+ Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008.
324
+ Wouter Van Gansbeke, Simon Vandenhende, Stamatios Georgoulis, Marc Proesmans, and Luc Van Gool. Scan: Learning to classify images without labels. In Proceedings of the European Conference on Computer Vision, 2020.
325
+ Grant Van Horn, Oisin Mac Aodha, Yang Song, Yin Cui, Chen Sun, Alex Shepard, Hartwig Adam, Pietro Perona, and Serge Belongie. The inaturalist species classification and detection dataset. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 8769-8778, 2018.
326
+ Cédric Villani et al. Optimal transport: old and new, volume 338. Springer, 2009.
327
+ Chen Wei, Kihyuk Sohn, Clayton Mellina, Alan Yuille, and Fan Yang. Crest: A class-rebalancing self-training framework for imbalanced semi-supervised learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 10857-10866, June 2021.
328
+
329
+ Bowen Zhang, Yidong Wang, Wenxin Hou, Hao Wu, Jindong Wang, Manabu Okumura, and Takahiro Shinozaki. Flexmatch: Boosting semi-supervised learning with curriculum pseudo labeling. Advances in Neural Information Processing Systems, 34:18408-18419, 2021a.
330
+ Chuyu Zhang, Ruijie Xu, and Xuming He. Novel class discovery for long-tailed recognition. Transactions on Machine Learning Research, 2023.
331
+ Songyang Zhang, Zeming Li, Shipeng Yan, Xuming He, and Jian Sun. Distribution alignment: A unified framework for long-tail visual recognition. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 2361-2370, 2021b.
332
+ Sheng Zhou, Hongjia Xu, Zhuonan Zheng, Jiawei Chen, Jiajun Bu, Jia Wu, Xin Wang, Wenwu Zhu, Martin Ester, et al. A comprehensive survey on deep clustering: Taxonomy, challenges, and future directions. arXiv preprint arXiv:2206.07579, 2022a.
333
+ Zhihan Zhou, Jiangchao Yao, Yan-Feng Wang, Bo Han, and Ya Zhang. Contrastive learning with boosted memorization. In International Conference on Machine Learning, pp. 27367-27377. PMLR, 2022b.
334
+
335
+ # A EFFICIENT SCALING ALGORITHM FOR SOLVING OPTIMAL TRANSPORT
336
+
337
+ In this section, we detail how to solve the optimal transport by an efficient scaling algorithm. Let's recall the definition of optimal transport, given two probability vectors $\mu \in \mathbb{R}^{m\times 1},\nu \in \mathbb{R}^{n\times 1}$ , as well as a cost matrix $\mathbf{C}\in \mathbb{R}_+^{m\times n}$ defined on joint space, the objective function which OT minimizes is as follows:
338
+
339
+ $$
340
+ \min _ {\mathbf {Q} \in \mathbb {R} _ {+} ^ {m \times n}} \left\langle \mathbf {Q}, \mathbf {C} \right\rangle_ {F} + F _ {1} \left(\mathbf {Q} \mathbf {1} _ {n}, \boldsymbol {\mu}\right) + F _ {2} \left(\mathbf {Q} ^ {\top} \mathbf {1} _ {m}, \boldsymbol {\nu}\right) \tag {S19}
341
+ $$
342
+
343
+ where $\mathbf{Q} \in \mathbb{R}_+^{m \times n}$ is the transportation plan, $\langle, \rangle_F$ denotes the Frobenius product, $F_1, F_2$ are constraints on the marginal distribution of $\mathbf{Q}$ , which are convex, lower semicontinuous and lower bounded functions, and $\mathbf{1}_n \in \mathbb{R}^{n \times 1}$ , $\mathbf{1}_m \in \mathbb{R}^{m \times 1}$ are all ones vector. To solve it efficiently, motivated by Cuturi (2013), we first introduce an entropy constraint, $-\epsilon \mathcal{H}(\mathbf{Q})$ . Therefore, the first term of Equ.(S19) is as follows:
344
+
345
+ $$
346
+ \begin{array}{l} < \mathbf {Q}, \mathbf {C} > _ {F} - \epsilon \mathcal {H} (\mathbf {Q}) = \epsilon < \mathbf {Q}, \mathbf {C} / \epsilon + \log \mathbf {Q} > _ {F} (S20) \\ = \epsilon < \mathbf {Q}, \log \frac {\mathbf {Q}}{\exp (- \mathbf {C} / \epsilon)} > _ {F} (S21) \\ = \epsilon K L (\mathbf {Q}, \exp (- \mathbf {C} / \epsilon)), (S22) \\ \end{array}
347
+ $$
348
+
349
+ The entropic optimal transport can be reformulated as follows:
350
+
351
+ $$
352
+ \min _ {\mathbf {Q} \in \mathbb {R} _ {+} ^ {m \times n}} \epsilon K L (\mathbf {Q}, \exp (- \mathbf {C} / \epsilon)) + F _ {1} (\mathbf {Q} \mathbf {1} _ {n}, \boldsymbol {\mu}) + F _ {2} (\mathbf {Q} ^ {\top} \mathbf {1} _ {m}, \boldsymbol {\nu}) \tag {S23}
353
+ $$
354
+
355
+ Then, this problem can be approximately solved by an efficient scaling Alg.2, where the proximal operator is as follows:
356
+
357
+ $$
358
+ \operatorname {p r o x} _ {F / \epsilon} ^ {K L} (\mathbf {z}, \boldsymbol {\mu}) = \operatorname {a r g m i n} _ {\mathbf {x} \in \mathbb {R} _ {+} ^ {n}} F (\mathbf {x}, \boldsymbol {\mu}) + \epsilon K L (\mathbf {x}, \mathbf {z}) \tag {S24}
359
+ $$
360
+
361
+ Intuitively, it is the iterative projection on affine subspaces for the KL divergence. We refer readers to (Chizat et al., 2018) for more derivation. Consequently, for OT problems with any proper constraint, if we can transform it into the form of Equ.(S19) and derive the corresponding proximal operator, we can solve it with Alg.2 efficiently.
362
+
363
+ # Algorithm 2: Scaling Algorithm for Optimal Transport
364
+
365
+ ```txt
366
+ Input: Cost matrix $\mathbf{C},\epsilon ,m,n,\pmb {\mu},\pmb{\nu}$ $\mathbf{M} = \exp (-\mathbf{C} / \epsilon)$
367
+ b $\leftarrow$ 1n
368
+ while b not converge do a $\leftarrow$ proxKL(F1/ε(Mb,μ)/(Mb) b $\leftarrow$ proxKL(F2/ε(Ma,ν)/(Ma)
369
+ end
370
+ return diag(a)Mdiag(b);
371
+ ```
372
+
373
+ # B PROOF OF PROPOSITION 1
374
+
375
+ In this section, we prove the Proposition 1. Assume the optimal transportation plan of Equ.(14) is $\hat{\mathbf{Q}}^{\star}$ , which can be decomposed as $[\hat{\mathbf{Q}}^{\star},\pmb {\xi}^{\star}]$ , and the optimal transportation plan of Equ.(5) is $\mathbf{Q}^{\star}$ .
376
+
377
+ Step 1. We first prove $\pmb{\xi}^{\star \top}\mathbf{1}_N = 1 - \rho$ . To prove that, we expand the second $K\hat{L}$ term and rewrite it as follows:
378
+
379
+ $$
380
+ \begin{array}{l} \hat {K L} \left(\hat {\mathbf {Q}} ^ {\star \top} \mathbf {1} _ {N}, \boldsymbol {\beta}, \boldsymbol {\lambda}\right) = \sum_ {i = 1} ^ {K} \boldsymbol {\lambda} _ {i} \left[ \tilde {\mathbf {Q}} ^ {\star \top} \mathbf {1} _ {N} \right] _ {i} \log \frac {\left[ \tilde {\mathbf {Q}} ^ {\star \top} \mathbf {1} _ {N} \right] _ {i}}{\boldsymbol {\beta} _ {i}} + \boldsymbol {\lambda} _ {K + 1} \boldsymbol {\xi} ^ {\star \top} \mathbf {1} _ {N} \log \frac {\boldsymbol {\xi} ^ {\star \top} \mathbf {1} _ {N}}{1 - \rho} (S25) \\ = \lambda K L \left(\tilde {\mathbf {Q}} ^ {\star \top} \mathbf {1} _ {N}, \frac {\rho}{K} \mathbf {1} _ {K}\right) + \lambda_ {K + 1} \boldsymbol {\xi} ^ {\star \top} \mathbf {1} _ {N} \log \frac {\boldsymbol {\xi} ^ {\star \top} \mathbf {1} _ {N}}{1 - \rho} (S26) \\ \end{array}
381
+ $$
382
+
383
+ Due to $\pmb{\lambda}_{K + 1}\rightarrow +\infty$ , if $\pmb{\xi}^{\star \top}\mathbf{1}_N$ is not equal to $1 - \rho$ , the cost of Equ.(14) will be $+\infty$ . In such case, we can find a more optimal $\hat{\mathbf{Q}}^\dagger$ , which satisfies $\pmb{\xi}^{\dagger \top}\mathbf{1}_N = 1 - \rho$ , and its cost is finite, contradicting to our assumption. Therefore, $\pmb{\xi}^{\star \top}\mathbf{1}_N = 1 - \rho$ , and $K\hat{L} (\hat{\mathbf{Q}}^{\star \top}\mathbf{1}_N,\beta ,\lambda) = \lambda KL(\tilde{\mathbf{Q}}^{\star \top}\mathbf{1}_N,\frac{\rho}{K}\mathbf{1}_K)$
384
+
385
+ Step 2. We then prove $\tilde{\mathbf{Q}}^{\star},\mathbf{Q}^{\star}$ are in the same constraint set. Due to
386
+
387
+ $$
388
+ \hat {\mathbf {Q}} ^ {\star} \mathbf {1} _ {K + 1} = \left[ \tilde {\mathbf {Q}} ^ {\star}, \boldsymbol {\xi} ^ {\star} \right] \mathbf {1} _ {K + 1} = \tilde {\mathbf {Q}} ^ {\star} \mathbf {1} _ {K} + \boldsymbol {\xi} ^ {\star} = \mathbf {1} _ {N}, \tag {S27}
389
+ $$
390
+
391
+ and $\pmb{\xi}^{\star}\geq 0$ , we know $\tilde{\mathbf{Q}}^{\star}\mathbf{1}_{K} = \mathbf{1}_{N} - \pmb{\xi}^{\star}\leq \mathbf{1}_{N}$ . Furthermore,
392
+
393
+ $$
394
+ \mathbf {1} _ {N} ^ {\top} \hat {\mathbf {Q}} ^ {\star} \mathbf {1} _ {K + 1} = \mathbf {1} _ {N} ^ {\top} \left(\tilde {\mathbf {Q}} ^ {\star} \mathbf {1} _ {K} + \boldsymbol {\xi} ^ {\star}\right) = \mathbf {1} _ {N} ^ {\top} \tilde {\mathbf {Q}} ^ {\star} \mathbf {1} _ {K} + \mathbf {1} _ {N} ^ {\top} \boldsymbol {\xi} ^ {\star} = 1, \tag {S28}
395
+ $$
396
+
397
+ and $\pmb{\xi}^{\star \top}\mathbf{1}_N = \mathbf{1}_N^\top \pmb{\xi}^{\star} = 1 - \rho$ , we derive that
398
+
399
+ $$
400
+ \mathbf {1} _ {N} ^ {\top} \tilde {\mathbf {Q}} ^ {\star} \mathbf {1} _ {K} = 1 - \mathbf {1} _ {N} ^ {\top} \boldsymbol {\xi} ^ {\star} = 1 - (1 - \rho) = \rho . \tag {S29}
401
+ $$
402
+
403
+ In summary, $\tilde{\mathbf{Q}}^{\star} \in \{\tilde{\mathbf{Q}}^{\star} \in \mathbb{R}^{N \times K} | \tilde{\mathbf{Q}}^{\star} \mathbf{1}_{K} \leq \frac{1}{N} \mathbf{1}_{N}, \mathbf{1}_{N}^{\top} \tilde{\mathbf{Q}}^{\star} \mathbf{1}_{K} = \rho\}$ , which is the same $\Pi$ in Equ.(5).
404
+
405
+ Step 3. Finally, we prove $\tilde{\mathbf{Q}}^{\star} = \mathbf{Q}^{\star}$ . According to Proposition 1, $\mathbf{C} = [-\log \mathbf{P}, \mathbf{0}_N]$ . We plug it into Equ.(14), and the cost of $\hat{\mathbf{Q}}^{\star}$ is as follows:
406
+
407
+ $$
408
+ \begin{array}{l} \langle \hat {\mathbf {Q}} ^ {\star}, \mathbf {C} \rangle_ {F} + K \hat {L} \left(\hat {\mathbf {Q}} ^ {\star \top} \mathbf {1} _ {N}, \boldsymbol {\beta}, \boldsymbol {\lambda}\right) = \left\langle \left[ \tilde {\mathbf {Q}} ^ {\star}, \boldsymbol {\xi} ^ {\star} \right], \left[ - \log \mathbf {P}, \mathbf {0} _ {N} \right] \right\rangle_ {F} + \lambda K L \left(\tilde {\mathbf {Q}} ^ {\star \top} \mathbf {1} _ {N}, \frac {\rho}{K} \mathbf {1} _ {K}\right) (S30) \\ = \left\langle \tilde {\mathbf {Q}} ^ {\star}, - \log \mathbf {P} \right\rangle_ {F} + \lambda K L \left(\tilde {\mathbf {Q}} ^ {\star^ {\top}} \mathbf {1} _ {N}, \frac {\rho}{K} \mathbf {1} _ {K}\right) (S31) \\ = C _ {1} (S32) \\ \end{array}
409
+ $$
410
+
411
+ And in Equ.(5), the cost for $\mathbf{Q}^{\star}$ is as follows:
412
+
413
+ $$
414
+ \langle \mathbf {Q} ^ {\star}, - \log \mathbf {P} \rangle_ {F} + \lambda K L \left(\mathbf {Q} ^ {\star^ {\top}} \mathbf {1} _ {N}, \frac {\rho}{K} \mathbf {1} _ {K}\right) = C _ {2} \tag {S33}
415
+ $$
416
+
417
+ From step 2, we know that $\tilde{\mathbf{Q}}^{\star},\mathbf{Q}^{\star}$ are in the same set. Consequently, the form of Equ.(S30) is the same as Equ.(S33), and in set $\Pi$ , $\langle \mathbf{Q}, - \log \mathbf{P}\rangle_F + \lambda KL\big(\mathbf{Q}^\top \mathbf{1}_N,\frac{\rho}{K}\mathbf{1}_K\big)$ is a convex function.
418
+
419
+ If $C_1 = C_2$ , due to it is a convex function, $\tilde{\mathbf{Q}}^{\star} = \mathbf{Q}^{\star}$ .
420
+
421
+ If $C_1 > C_2$ , we can construct a transportation plan $\hat{\mathbf{Q}}^{\dagger} = [\mathbf{Q}^{\star}, \boldsymbol{\xi}^{\star}]$ for Equ.(14), which cost is $C_2$ , achieving smaller cost than $\hat{\mathbf{Q}}^{\star}$ . The results contradict the initial assumption that $\hat{\mathbf{Q}}^{\star}$ is the optimal transport plan. Therefore, $C_1$ can not be larger than $C_2$ .
422
+
423
+ If $C_1 < C_2$ , we can construct a transportation plan $\tilde{\mathbf{Q}}^*$ for Equ.(5), which cost is $C_1$ , achieving smaller cost than $\mathbf{Q}^*$ . The results contradict the initial assumption that $\mathbf{Q}^*$ is the optimal transport plan. Therefore, $C_1$ can not be smaller than $C_2$ .
424
+
425
+ In conclusion, $C_1 = C_2$ and $\tilde{\mathbf{Q}}^{\star} = \mathbf{Q}^{\star}$ , i.e. $\hat{\mathbf{Q}}^{\star} = [\mathbf{Q}^{\star},\pmb {\xi}^{\star}]$ . We can derive $\mathbf{Q}^{\star}$ by omitting the last column of $\hat{\mathbf{Q}}^{\star}$ . Therefore, Proposition 1 is proved.
426
+
427
+ # C PROOF OF PROPOSITION 2
428
+
429
+ From the Appendix A, we know the key to proving Proposition 2 is to derive the proximal operator for $F_{1}, F_{2}$ . Without losing generality, we rewrite the entropic version of Equ.(14) in a more simple and general form, which is detailed as follows:
430
+
431
+ $$
432
+ \min _ {\hat {\mathbf {Q}} \in \Phi} \epsilon K L (\mathbf {Q}, \exp (- \mathbf {C} / \epsilon)) + K \hat {L} (\mathbf {Q} ^ {\top} \mathbf {1} _ {N}, \boldsymbol {\beta}, \boldsymbol {\lambda}) \tag {S34}
433
+ $$
434
+
435
+ $$
436
+ \text {s . t .} \quad \Phi = \left\{\mathbf {Q} \in \mathbb {R} _ {+} ^ {N \times K} \mid \mathbf {Q} \mathbf {1} _ {K} = \boldsymbol {\alpha} \right\}, \tag {S35}
437
+ $$
438
+
439
+ In Equ.(S34), the equality constraint means that $F_{1}$ is an indicator function, formulated as:
440
+
441
+ $$
442
+ F _ {1} (\mathbf {x}, \boldsymbol {\alpha}) = \left\{ \begin{array}{l l} 0, & \mathbf {x} = \boldsymbol {\alpha} \\ + \infty , & \text {o t h e r w i s e} \end{array} \right. \tag {S36}
443
+ $$
444
+
445
+ Therefore, we can plug in the above $F_{1}$ to Equ.(S24), and derive the proximal operator for $F_{1}$ is $\alpha$ . For the weighted $KL$ constraint, the proximal operator is as follows:
446
+
447
+ $$
448
+ \begin{array}{l} \operatorname {p r o x} _ {F _ {2} / \epsilon} ^ {K L} (\mathbf {z}, \boldsymbol {\beta}) = \operatorname {a r g m i n} _ {\mathbf {x} \in \mathbb {R} _ {+} ^ {K}} \hat {K L} (\mathbf {x}, \boldsymbol {\beta}, \boldsymbol {\lambda}) + \epsilon K L (\mathbf {x}, \mathbf {z}) (S37) \\ = \operatorname {a r g m i n} _ {\mathbf {x} \in \mathbb {R} _ {+} ^ {K}} \sum_ {i} \boldsymbol {\lambda} _ {i} \mathbf {x} _ {i} \log \frac {\mathbf {x} _ {i}}{\beta_ {i}} - \boldsymbol {\lambda} _ {i} \mathbf {x} _ {i} + \boldsymbol {\beta} _ {i} + \epsilon \mathbf {x} _ {i} \log \frac {\mathbf {x} _ {i}}{\mathbf {z} _ {i}} - \epsilon \mathbf {x} _ {i} + \mathbf {z} _ {i} (S38) \\ = \operatorname {a r g m i n} _ {\mathbf {x} \in \mathbb {R} _ {+} ^ {K}} \sum_ {i} \boldsymbol {\lambda} _ {i} \mathbf {x} _ {i} \log \frac {\mathbf {x} _ {i}}{\boldsymbol {\beta} _ {i}} - \boldsymbol {\lambda} _ {i} \mathbf {x} _ {i} + \epsilon \mathbf {x} _ {i} \log \frac {\mathbf {x} _ {i}}{\mathbf {z} _ {i}} - \epsilon \mathbf {x} _ {i} (S39) \\ = \operatorname {a r g m i n} _ {\mathbf {x} \in \mathbb {R} _ {+} ^ {K}} \sum_ {i} \left(\boldsymbol {\lambda} _ {i} + \epsilon\right) \mathbf {x} _ {i} \log \mathbf {x} _ {i} - \left(\boldsymbol {\lambda} _ {i} \log \boldsymbol {\beta} _ {i} + \boldsymbol {\lambda} _ {i} + \epsilon \log \mathbf {z} _ {i} + \epsilon\right) \mathbf {x} _ {i} \quad (\mathrm {S 4 0}) \\ \end{array}
449
+ $$
450
+
451
+ The first line to the second is that we expand the unnormalized $KL$ . The second line to the third is that we omit the variable unrelated to $\mathbf{x}$ . The third line to the fourth line is that we reorganize the equation. Now, we consider a function as follows:
452
+
453
+ $$
454
+ g (x) = a x \log x - b x \tag {S41}
455
+ $$
456
+
457
+ Its first derivative is denoted as:
458
+
459
+ $$
460
+ g ^ {\prime} (x) = a + a \log x - b \tag {S42}
461
+ $$
462
+
463
+ Therefore, $\operatorname{argmin}_x g(x) = \exp \left(\frac{b - a}{a}\right)$ . According to this conclusion, we know that:
464
+
465
+ $$
466
+ \mathbf {x} _ {i} = \exp \left(\frac {\boldsymbol {\lambda} _ {i} \log \boldsymbol {\beta} _ {i} + \epsilon \log \mathbf {z} _ {i}}{\boldsymbol {\lambda} _ {i} + \epsilon}\right) = \boldsymbol {\beta} _ {i} ^ {\frac {\boldsymbol {\lambda} _ {i}}{\boldsymbol {\lambda} _ {i} + \epsilon}} \mathbf {z} _ {i} ^ {\frac {\epsilon}{\boldsymbol {\lambda} _ {i} + \epsilon}} \tag {S43}
467
+ $$
468
+
469
+ And the vectorized version is as follows::
470
+
471
+ $$
472
+ \mathbf {x} = \boldsymbol {\beta} ^ {\circ f} \mathbf {z} ^ {\circ (1 - f)}, \quad \mathbf {f} = \frac {\boldsymbol {\lambda}}{\boldsymbol {\lambda} + \epsilon}. \tag {S44}
473
+ $$
474
+
475
+ Finally, we plug in the two proximal operators into Alg.2. The iteration of $\mathbf{a}$ , $\mathbf{b}$ is as follows:
476
+
477
+ $$
478
+ \mathbf {a} \leftarrow \operatorname {p r o x} _ {F _ {1} / \epsilon} ^ {K L} (\mathbf {M b}, \alpha) / (\mathbf {M b}) = \frac {\boldsymbol {\alpha}}{\mathbf {M} \cdot \mathbf {b}} \tag {S45}
479
+ $$
480
+
481
+ $$
482
+ \mathbf {b} \leftarrow \operatorname {p r o x} _ {F _ {2} / \epsilon} ^ {K L} (\mathbf {M} ^ {\top} \mathbf {a}, \boldsymbol {\beta}) / (\mathbf {M} ^ {\top} \mathbf {a}) = \beta^ {\circ f} (\mathbf {M} ^ {\top} \mathbf {a}) ^ {\circ (1 - f)} / (\mathbf {M} ^ {\top} \mathbf {a}) = \left(\frac {\boldsymbol {\beta}}{\mathbf {M} ^ {\top} \mathbf {a}}\right) ^ {\circ f} \tag {S46}
483
+ $$
484
+
485
+ Consequently, Proposition 2 is proved.
486
+
487
+ # D MORE DISCUSSION ON UNIFORM CONSTRAINT
488
+
489
+ In deep clustering, the uniform constraint is widely used to avoid degenerate solutions. Among them, KL constraint is a common feature in many clustering baselines, such as SCAN (Van Gansbeke et al., 2020), PICA(Huang et al., 2020), CC(Li et al., 2021), and DivClust(Metaxas et al., 2023). These methods employ an additional entropy regularization loss term on cluster size to prevent degenerate solutions, which is equivalent to the KL constraint. Different from above, Huang et al. (2022) achieves uniform constraints by maximizing the inter-clusters distance between prototypical representations. By contrast, our method incorporates KL constraint in pseudo-label generation, constituting a novel OT problem. As demonstrated in 1, our approach significantly outperforms these baselines.
490
+
491
+ # E DATASETS DETAILS
492
+
493
+ Fig.S6 displays the class distribution of ImgNet-R and several training datasets from iNaturalist18. As evident from the figure, the class distribution in several iNature datasets is highly imbalanced. While ImgNet-R exhibits a lower degree of imbalance, its data distribution still presents a significant challenge for clustering tasks.
494
+
495
+ # F MORE IMPLEMENTATION DETAILS
496
+
497
+ In this section, we illustrate the implementation details of other methods.
498
+
499
+ ![](images/445cd0bc915306bfa64108625f20af71a24ec7275f3a13d61c21ce65d7d20538.jpg)
500
+
501
+ ![](images/3d9d9dc4754fcd2d05c32d6272fb8c487a9cdb900da6c197a36e5f98780a8e6c.jpg)
502
+
503
+ ![](images/bc448ae4e309984a37fe88cfecabbbb4d297865a6d4285d67b801155ecde8d32.jpg)
504
+ Figure S6: The class distribution of different datasets.
505
+
506
+ ![](images/8641df1b62add940bf9e669d89461a5018c948c3f84fd5ebaa19858f5c24352e.jpg)
507
+
508
+ # F.1 DEEP CLUSTERING
509
+
510
+ In our study, we employed various methods, all utilizing the same datasets and finetuning the last block of ViT-B16. All methods are trained for 50 epochs due to convergence observation.
511
+
512
+ For our $\mathrm{P}^2\mathrm{OT}$ method, we use a batch size of 512. To stabilize the mini-batch $\mathrm{P}^2\mathrm{OT}$ , We incorporate a memory buffer queue of size 5120 for history prediction after the first epoch to stabilize optimization. During training, we apply two transformations to the same sample and cross-utilize the two pseudolabels as supervision, thereby encouraging the model to maintain equivariance. We employ 2 clustering heads on the CIFAR100 dataset and 1 clustering head on others. The clustering heads are designed with the sample cluster number as ground truth. Since the sum of sample weights in the pseudo label $\mathbf{Q}$ is $\rho$ , we adjust the loss on training sets for the clustering head and model selection as $\mathcal{L} / \rho$ .
513
+
514
+ For IIC, we adopt their method (loss function) from GitHub. They aim at maximizing the mutual information of class assignments between different transformations of the same sample. In all experiments, we use a batch size of 512. We follow their over-clustering strategy, i.e., using two heads, one matching the ground-truth cluster number and the other set at 200 for CIFAR100 and iNature100, 400 for ImgNet-R, and 700 for iNature500. We do not use over-clustering for iNature1000 due to resource and efficiency considerations. Models from the last epoch are selected.
515
+
516
+ For PICA, we adopt their method (loss function) from GitHub. Their basic idea is to minimize cluster-wise Assignment Statistics Vector(ASV) cosine similarity. In our implementation, the batch size, over-clustering strategy, and model selection are the same as IIC above.
517
+
518
+ For SCAN, we adopt their code from GitHub. For clustering, their basic idea is to make use of the information of nearest neighbors from pretrained model embeddings. We use a batch size of 512. Following their implementation, we use 10 heads for CIFAR100, iNature100, iNature500, and ImgNet-R. We use 1 head for iNature1000 due to resource and efficiency considerations. While the authors select models based on loss on test sets, we argue that this strategy may not be suitable as test sets are unavailable during training. For the fine-tuning stage of SCAN, they use high-confident samples to obtain pseudo labels. Following their implementation, we use the confidence threshold
519
+
520
+ of 0.99 on CIFAR. On other datasets, we use the confidence threshold of 0.7 because the model is unable to select confident samples if we use 0.99.
521
+
522
+ For CC, we adopt their code from GitHub. They perform both instance- and cluster-level contrastive learning. Following their implementation, we use a batch size of 128, and the models of the last epochs are selected.
523
+
524
+ For DivClust, we adopt their code from GitHub. Their basic idea is to enlarge the diversity of multiple clusterings. Following their implementation, we use a batch size of 256, with 20 clusterings for CIFAR100, ImgNet-R, iNature100, and iNature500. We use 2 clusterings for iNature1000 due to resource and efficiency considerations. The models of the last epoch along with the best heads are selected.
525
+
526
+ Table S4: SPICE accuracy on different datasets.
527
+
528
+ <table><tr><td>Dataset Imbalance ratio</td><td>CIFAR100 100</td><td>ImgNet-R 13</td><td>iNature100 67</td><td>iNature500 111</td><td>iNature1000 111</td></tr><tr><td>SPICE</td><td>6.74</td><td>2.58</td><td>10.29</td><td>2.15</td><td>0.74</td></tr></table>
529
+
530
+ We also tried to implement SPICE from GitHub on imbalanced datasets. Given a pre-trained backbone, they employ a two-stage training process: initially training the clustering head while keeping the backbone fixed, and subsequently training both the backbone and clustering head jointly. For the first stage, they select an equal number of confident samples for each cluster and generate pseudo-labels to train the clustering head. However, on imbalanced datasets, this strategy can easily lead to degraded results as presented in Tab.S4. For example, for the medium and tail classes, the selected confident samples will easily include many samples from head classes, causing clustering head degradation. For the second stage, they utilize neighbor information to generate reliable pseudo-labels for further training. However, the degradation of the clustering head, which occurs as a result of the first stage's limitations, poses a hurdle in the selection of reliable samples for the second stage, thus preventing the training of the second stage. For comparison with SPICE on the balanced training set, please refer to Sec.I.
531
+
532
+ # F.2 REPRESENTATION LEARNING WITH LONG-TAILED DATA
533
+
534
+ In the literature, (Zhou et al., 2022b; Liu et al., 2022; Jiang et al., 2021) aims to learn unbiased representation with long-tailed data. For a fair comparison, we adopt the pre-trained ViT-B16, finetune the last block of the ViT-B16 with their methods by 500 epochs, and perform K-means on representation space to evaluate the clustering ability. However, we exclude reporting results from (Liu et al., 2022; Jiang et al., 2021) for the following reasons: 1) (Jiang et al., 2021) prunes the ResNet, making it challenging to transfer to ViT; 2) (Liu et al., 2022) has not yet open-sourced the code for kernel density estimation, which is crucial for its success.
535
+
536
+ # G ARIMETRIC
537
+
538
+ Additionally, we report the results on the Adjusted Rand Index (ARI) metric. Interestingly, on the imbalanced training set (Fig.S5), methods like IIC and SCAN* tend to exhibit a bias toward head classes (Fig.S7) and achieve very high ARI scores, even though they perform inferiorly compared to our method in terms of ACC and NMI. However, as shown in Fig.S6, on the balanced test set, the performance of IIC and SCAN* is relatively poor compared to our method. This inconsistency in performance across different class distributions highlights that ARI can be sensitive to the distribution of data and may not be a suitable metric in imbalance scenarios.
539
+
540
+ # H MORE COMPARISON
541
+
542
+ iNature1000 dataset. As shown in Tab.S7, in the large-scale iNature1000 dataset, our method achieves comparable results with Strong SCAN. Specifically, we achieve improvements of 0.5 in ACC and 0.3 in F1 score, while there is a slight decrease of 0.6 in the NMI metric. It's important to note that pseudo-labeling-based methods face significant challenges in large-scale scenarios, as
543
+
544
+ ![](images/7f569b6951d89bc52f1933c5d2174bc9d28070074f1a7165905f4413566f2d2d.jpg)
545
+
546
+ ![](images/4e12972ce65c6ef84e73ea82d08eedb06d2117cf5c1704035c86c22615e8f94c.jpg)
547
+
548
+ ![](images/b94f9fef8b5f87d80e44b134b814a6f44968c50c7a83162d1755adeb4b13e8dc.jpg)
549
+ Figure S7: Prediction distribution comparison of IIC, SCAN* and $\mathrm{P}^2\mathrm{OT}$ on CIFAR100.
550
+
551
+ ![](images/3deafcec8072f6c4a0bb9f5a9576e295fd37a367f721fba668ad48e8cb046d65.jpg)
552
+
553
+ Table S5: ARI Comparison with SOTA methods on imbalanced training datasets.
554
+
555
+ <table><tr><td>Dataset Imbalance ratio</td><td>CIFAR100 100</td><td>ImgNet-R 13</td><td>iNature100 67</td><td>iNature500 111</td><td>iNature1000 111</td></tr><tr><td>IIC</td><td>43.3±3.9</td><td>13.2±0.8</td><td>33.6±6.2</td><td>19.2±0.6</td><td>20.2±1.5</td></tr><tr><td>PICA</td><td>24.6±0.2</td><td>5.2±0.1</td><td>12.6±0.5</td><td>7.1±0.1</td><td>5.4±0.2</td></tr><tr><td>SCAN</td><td>34.7±0.5</td><td>13.5±0.4</td><td>18.2±0.2</td><td>13.6±0.1</td><td>14.3±0.2</td></tr><tr><td>SCAN*</td><td>50.0±2.4</td><td>15.8±0.2</td><td>21.0±0.4</td><td>27.6±1.3</td><td>28.0±1.6</td></tr><tr><td>CC</td><td>29.8±0.4</td><td>6.0±0.3</td><td>13.9±0.8</td><td>13.6±1.3</td><td>11.9±0.6</td></tr><tr><td>DivClust</td><td>29.0±1.1</td><td>7.1±0.2</td><td>14.2±0.5</td><td>11.0±0.5</td><td>10.8±0.9</td></tr><tr><td>P²OT</td><td>36.9±1.3</td><td>16.0±0.7</td><td>23.1±0.5</td><td>14.3±0.3</td><td>12.6±0.2</td></tr></table>
556
+
557
+ Table S6: ARI Comparison with SOTA methods on balanced test datasets.
558
+
559
+ <table><tr><td>Dataset Imbalance ratio</td><td>CIFAR100 100</td><td>ImgNet-R 13</td><td>iNature100 67</td><td>iNature500 111</td><td>iNature1000 111</td></tr><tr><td>IIC</td><td>21.5±1.6</td><td>11.6±0.9</td><td>16.9±1.7</td><td>7.7±0.4</td><td>4.4±0.1</td></tr><tr><td>PICA</td><td>19.9±0.5</td><td>5.2±0.0</td><td>17.6±3.4</td><td>6.4±0.3</td><td>3.6±0.2</td></tr><tr><td>SCAN</td><td>28.2±0.2</td><td>12.0±0.5</td><td>25.0±1.7</td><td>17.0±0.3</td><td>14.0±0.3</td></tr><tr><td>SCAN*</td><td>21.7±1.8</td><td>13.9±0.1</td><td>27.7±0.6</td><td>11.1±0.6</td><td>5.8±0.2</td></tr><tr><td>CC</td><td>19.1±0.7</td><td>4.3±0.3</td><td>15.1±0.4</td><td>6.8±0.5</td><td>4.3±0.1</td></tr><tr><td>DivClust</td><td>21.3±0.6</td><td>5.5±0.5</td><td>19.2±1.1</td><td>8.0±0.6</td><td>4.5±0.3</td></tr><tr><td>P2OT</td><td>28.8±0.8</td><td>13.4±0.8</td><td>29.7±1.7</td><td>18.9±0.4</td><td>14.2±0.7</td></tr></table>
560
+
561
+ generating high-quality pseudo-labels becomes increasingly difficult. Despite this challenge, our method demonstrates competitive performance in such a challenging setting.
562
+
563
+ Results on the balanced test sets. As presented in Tab.S8, we conduct a comprehensive comparison of our method with existing approaches on balanced test sets, validating their ability in an inductive setting. On the relatively small-scale CIFAR100 dataset, our method outperforms the previous state-of-the-art (SCAN) by margins of 1.4, respectively. On the ImgNet-R datasets, our method demonstrates its effectiveness with a notable improvement of 2.2, highlighting its robustness in out-of-distribution scenarios. On the fine-grained iNature datasets, our performance gains are substantial across each subset. Particularly, we observe improvements of 5.2 on iNature100, 3.2 on iNature500, and 1.2 on iNature1000. Note that SPCIE degrades in the imbalance scenario (see Appendix F), and SCAN* performs worse than SCAN in some cases, indicating the ineffectiveness of naive
564
+
565
+ Table S7: Comparison with SOTA methods on iNature1000 training set.
566
+
567
+ <table><tr><td rowspan="2">Method</td><td colspan="3">iNature1000</td></tr><tr><td>ACC</td><td>NMI</td><td>F1</td></tr><tr><td>IIC</td><td>7.8±0.5</td><td>56.9±0.4</td><td>4.2±0.2</td></tr><tr><td>PICA</td><td>12.4±0.2</td><td>55.0±0.1</td><td>8.5±0.1</td></tr><tr><td>SCAN</td><td>26.2±0.2</td><td>68.0±0.0</td><td>19.6±0.1</td></tr><tr><td>SCAN*</td><td>10.5±0.2</td><td>63.9±0.5</td><td>6.4±0.2</td></tr><tr><td>CC</td><td>12.1±0.4</td><td>55.2±0.4</td><td>9.1±0.4</td></tr><tr><td>DivClust</td><td>13.0±0.2</td><td>56.0±0.3</td><td>9.5±0.2</td></tr><tr><td>P2OT</td><td>26.7±0.5</td><td>67.4±0.4</td><td>19.9±0.4</td></tr></table>
568
+
569
+ Table S8: ACC Comparison with SOTA methods on balanced test sets. SCAN* (Van Gansbeke et al., 2020) denotes performing another self-labeling training stage based on SCAN.
570
+
571
+ <table><tr><td>Dataset Imbalance ratio</td><td>CIFAR100 100</td><td>ImgNet-R 13</td><td>iNature100 67</td><td>iNature500 111</td><td>iNature1000 111</td></tr><tr><td>IIC</td><td>29.4±3.0</td><td>21.4±1.7</td><td>35.1±2.7</td><td>19.8±0.7</td><td>13.3±1.0</td></tr><tr><td>PICA</td><td>30.3±0.4</td><td>16.6±0.1</td><td>43.5±3.3</td><td>31.4±0.3</td><td>28.3±0.2</td></tr><tr><td>SCAN</td><td>37.5±0.3</td><td>23.8±0.8</td><td>44.0±0.9</td><td>39.0±0.1</td><td>36.5±0.3</td></tr><tr><td>SCAN*</td><td>30.5±0.6</td><td>25.2±0.1</td><td>44.8±0.7</td><td>24.3±0.6</td><td>14.5±0.2</td></tr><tr><td>CC</td><td>29.1±1.3</td><td>14.7±0.2</td><td>38.2±1.4</td><td>29.7±1.1</td><td>26.6±0.5</td></tr><tr><td>DivClust</td><td>31.8±0.6</td><td>16.8±0.3</td><td>42.4±1.2</td><td>31.6±0.5</td><td>26.9±0.1</td></tr><tr><td>P2OT</td><td>38.9±1.1</td><td>27.5±1.2</td><td>50.0±2.1</td><td>42.2±1.1</td><td>37.7±0.2</td></tr></table>
572
+
573
+ Table S9: NMI Comparison with SOTA methods on balanced test sets.
574
+
575
+ <table><tr><td>Dataset Imbalance ratio</td><td>CIFAR100 100</td><td>ImgNet-R 13</td><td>iNature100 67</td><td>iNature500 111</td><td>iNature1000 111</td></tr><tr><td>IIC</td><td>56.0±1.6</td><td>53.9±1.0</td><td>75.4±1.4</td><td>73.9±0.4</td><td>71.2±0.6</td></tr><tr><td>PICA</td><td>54.5±0.5</td><td>51.9±0.1</td><td>78.2±1.5</td><td>79.7±0.2</td><td>80.0±0.2</td></tr><tr><td>SCAN</td><td>63.0±0.1</td><td>57.0±0.5</td><td>80.8±0.5</td><td>83.4±0.1</td><td>84.2±0.1</td></tr><tr><td>SCAN*</td><td>57.6±2.0</td><td>57.1±0.3</td><td>81.9±0.6</td><td>77.0±0.6</td><td>72.8±0.3</td></tr><tr><td>CC</td><td>54.2±0.6</td><td>48.5±0.3</td><td>76.3±0.3</td><td>78.3±0.7</td><td>78.7±0.2</td></tr><tr><td>DivClust</td><td>58.1±0.3</td><td>50.4±0.3</td><td>78.7±0.6</td><td>79.2±0.5</td><td>78.8±0.2</td></tr><tr><td>P2OT</td><td>63.1±0.8</td><td>58.0±0.7</td><td>83.0±0.9</td><td>84.3±0.1</td><td>84.4±0.2</td></tr></table>
576
+
577
+ Table S10: F1 Comparison with SOTA methods on balanced test sets.
578
+
579
+ <table><tr><td>Dataset Imbalance ratio</td><td>CIFAR100 100</td><td>ImgNet-R 13</td><td>iNature100 67</td><td>iNature500 111</td><td>iNature1000 111</td></tr><tr><td>IIC</td><td>21.0±3.6</td><td>17.7±1.9</td><td>25.7±2.8</td><td>10.6±0.4</td><td>5.0±0.7</td></tr><tr><td>PICA</td><td>28.2±0.6</td><td>16.6±0.2</td><td>38.7±3.5</td><td>28.3±0.2</td><td>26.0±0.1</td></tr><tr><td>SCAN</td><td>34.9±0.4</td><td>23.8±0.9</td><td>36.5±1.1</td><td>33.3±0.3</td><td>31.8±0.4</td></tr><tr><td>SCAN*</td><td>19.8±0.8</td><td>23.5±0.2</td><td>36.8±1.3</td><td>14.4±0.4</td><td>5.8±0.2</td></tr><tr><td>CC</td><td>25.6±1.3</td><td>14.2±0.4</td><td>32.4±0.6</td><td>26.5±1.4</td><td>23.9±0.8</td></tr><tr><td>DivClust</td><td>28.9±0.6</td><td>16.4±0.3</td><td>36.1±1.4</td><td>27.8±0.6</td><td>24.3±0.2</td></tr><tr><td>P²OT</td><td>35.9±0.8</td><td>28.1±1.3</td><td>44.2±2.1</td><td>37.2±1.4</td><td>33.0±0.2</td></tr></table>
580
+
581
+ self-labeling training. These strong results demonstrate the superiority of our method in fine-grained and large-scale scenarios.
582
+
583
+ The NMI and F1 result comparisons of our method with existing approaches are presented in Tab.S9 and Tab.S10. For NMI, our method achieves comparable results with previous state-of-the-art (SCAN) on the CIFAR100 and iNature1000 datasets. On ImgNet-R, iNature100, and iNature500, our method outperforms state-of-the-art by $\sim 1\%$ . For F1, our method surpasses the previous method by a large margin, demonstrating the effectiveness of our method in handling imbalance learning.
584
+
585
+ Table S11: Comparison with SPICE on balanced training set
586
+
587
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Backbone</td><td rowspan="2">Fine Tune</td><td rowspan="2">Confidence Ratio</td><td rowspan="2">Time Cost(h)</td><td colspan="3">CIFAR100</td></tr><tr><td>ACC</td><td>NMI</td><td>ARI</td></tr><tr><td>SPICEs</td><td>ViT-B16</td><td>False</td><td>-</td><td>3.6</td><td>31.9</td><td>57.7</td><td>22.5</td></tr><tr><td>SPICEs</td><td>ViT-B16</td><td>True</td><td>-</td><td>6.7</td><td>60.9</td><td>69.2</td><td>46.3</td></tr><tr><td>SPICE</td><td>ViT-B16</td><td>False</td><td>&gt;0</td><td>3.6</td><td>Fail</td><td>Fail</td><td>Fail</td></tr><tr><td>SPICE</td><td>ViT-B16</td><td>True</td><td>&gt;0.6</td><td>6.7</td><td>Fail</td><td>Fail</td><td>Fail</td></tr><tr><td>SPICE</td><td>ViT-B16</td><td>True</td><td>0.5</td><td>21.6</td><td>68.0</td><td>77.7</td><td>54.8</td></tr><tr><td>Ours</td><td>ViT-B16</td><td>False</td><td>-</td><td>2.9</td><td>61.9</td><td>72.1</td><td>48.8</td></tr></table>
588
+
589
+ # I COMPARISON AND ANALYSIS ON BALANCED TRAINING DATASET
590
+
591
+ To compare and analyze our method with baselines on balanced datasets, we conduct experiments using the balanced CIFAR100 dataset as demonstrated in Tab.S11. Overall, we have achieved superior performance on imbalanced datasets, and on balanced datasets, we have achieved satisfactory results. However, in balanced settings, we believe that it is a bit unfair to compare our proposed method to methods developed in balanced scenarios, which usually take advantage of the uniform prior.
592
+
593
+ Note that, as imagenet-r and iNaturelist2018 subsets are inherently imbalanced, we do not conduct experiments on them.
594
+
595
+ For all methods, we employ the ImageNet-1K pre-trained ViT-B16 backbone. Fine tune refers to the first training stage of SPICE, which trains the model on the target dataset using self-supervised learning, like MoCo. $\mathsf{SPICE}_s$ corresponds to the second stage of training, which fixes the backbone and learns the clustering head by selecting top-K samples for each class, heavily relying on the uniform distribution assumption. SPICE refers to the final joint training stage, which selects an equal number of reliable samples for each class based on confidence ratio and applies FixMatch-like training. In SPICE, the confidence ratio varies across different datasets. Time cost denotes the accumulated time cost in hours on A100 GPUs.
596
+
597
+ The observed results in the table reveal several key findings: 1) Without self-supervised training on the target dataset, $\mathrm{SPICE}_s$ yields inferior results; 2) SPICE tends to struggle without self-supervised training and demonstrates sensitivity to hyperparameters; 3) SPICE incurs a prolonged training time; 4) Our method achieves comparable results with $\mathrm{SPICE}_s$ and inferior results than SPICE.
598
+
599
+ On imbalanced datasets, as demonstrated in Tab.S4, SPICE encounters difficulties in clustering tail classes due to the noisy top-K selection, resulting in a lack of reliable samples for these classes. In contrast, our method attains outstanding performance on imbalanced datasets without the need for further hyperparameter tuning.
600
+
601
+ In summary, the strength of SPICE lies in its ability to leverage the balanced prior and achieve superior results in balanced scenarios. However, SPICE exhibits weaknesses: 1) It necessitates multi-stage training, taking 21.6 hours and 7.45 times our training cost; 2) It requires meticulous tuning of multiple hyperparameters for different scenarios and may fail without suitable hyperparameters, while our method circumvents the need for tedious hyperparameter tuning; 3) It achieves unsatisfactory results on imbalanced datasets due to its strong balanced assumption.
602
+
603
+ In contrast, the advantage of our method lies in its robustness to dataset distribution, delivering satisfactory results on balanced datasets and superior performance on imbalanced datasets.
604
+
605
+ # J FURTHER ANALYSIS OF POT, UOT AND SLA
606
+
607
+ In this section, we provide a comprehensive explanation of the formulations of POT, UOT, and SLA (Tai et al., 2021), followed by an analysis of their limitations in the context of deep imbalanced scenarios. POT replaces the $KL$ constraint with an equality constraint, and its formulation is as
608
+
609
+ Algorithm 3: Generalized Scaling Algorithm for $\mathrm{P^2OT}$
610
+ Input: Cost matrix - log P, $\epsilon ,\lambda ,\rho ,N,K$
611
+ C<-logP
612
+ $\beta \leftarrow \frac{\rho}{K}\mathbf{1}_K^{\top},\quad \alpha \leftarrow \frac{1}{N}\mathbf{1}_N,$
613
+ b $\leftarrow 1_{K},\quad s\gets 1,\quad \mathbf{M}\leftarrow \exp (-\mathbf{C} / \epsilon),\quad f\leftarrow \frac{\lambda}{\lambda + \epsilon}$
614
+ while b not converge do a $\leftarrow$ min( $\frac{\alpha}{s\mathrm{Mb}},1)$ b $\leftarrow (\frac{\beta}{s\mathbf{M}^{\top}\mathbf{a}})^{f}$ $s\gets \frac{\rho}{\mathbf{a}^{\top}\mathbf{M}\mathbf{b}}$
615
+ end
616
+ return diag(a)Mdiag(b);
617
+
618
+ follows:
619
+
620
+ $$
621
+ \min _ {\mathbf {Q} \in \Pi} \left\langle \mathbf {Q}, - \log \mathbf {P} \right\rangle_ {F} \tag {S47}
622
+ $$
623
+
624
+ $$
625
+ \text {s . t .} \quad \Pi = \left\{\mathbf {Q} \in \mathbb {R} _ {+} ^ {N \times K} \mid \mathbf {Q} \mathbf {1} _ {K} \leq \frac {1}{N} \mathbf {1} _ {N}, \mathbf {Q} ^ {\top} \mathbf {1} _ {N} = \frac {\rho}{K} \mathbf {1} _ {K}, \mathbf {1} _ {N} ^ {\top} \mathbf {Q} \mathbf {1} _ {K} = \rho \right\} \tag {S48}
626
+ $$
627
+
628
+ This formulation overlooks the class imbalance distribution, thus making it hard to generate accurate pseudo-labels in imbalance scenarios.
629
+
630
+ On the other hand, UOT eliminates the progressive $\rho$ , and its corresponding formulation is denoted as follows:
631
+
632
+ $$
633
+ \min _ {\mathbf {Q} \in \Pi} \left\langle \mathbf {Q}, - \log \mathbf {P} \right\rangle_ {F} + \lambda K L \left(\mathbf {Q} ^ {\top} \mathbf {1} _ {N}, \frac {1}{K} \mathbf {1} _ {K}\right) \tag {S49}
634
+ $$
635
+
636
+ $$
637
+ \text {s . t .} \quad \Pi = \left\{\mathbf {Q} \in \mathbb {R} _ {+} ^ {N \times K} \mid \mathbf {Q} \mathbf {1} _ {K} = \frac {1}{N} \mathbf {1} _ {N} \right\} \tag {S50}
638
+ $$
639
+
640
+ UOT has the capability to generate imbalanced pseudo-labels, but it lacks the ability to effectively reduce the impact of noisy samples, which can adversely affect the model's learning process.
641
+
642
+ SLA (Tai et al., 2021), represented by Equ.(S51), relaxes the equality constraint using an upper bound $b$ . However, during the early training stages when $\rho$ is smaller than the value in $b\mathbf{1}_K$ , SLA tends to assign all the mass to a single cluster, leading to a degenerate representation.
643
+
644
+ $$
645
+ \min _ {\mathbf {Q} \in \Pi} \left\langle \mathbf {Q}, - \log \mathbf {P} \right\rangle_ {F} \tag {S51}
646
+ $$
647
+
648
+ $$
649
+ \text {s . t .} \quad \Pi = \left\{\mathbf {Q} \in \mathbb {R} _ {+} ^ {N \times K} \mid \mathbf {Q} \mathbf {1} _ {K} \leq \frac {1}{N} \mathbf {1} _ {N}, \mathbf {Q} ^ {\top} \mathbf {1} _ {N} \leq b \mathbf {1} _ {K}, \mathbf {1} _ {N} ^ {\top} \mathbf {Q} \mathbf {1} _ {K} = \rho \right\} \tag {S52}
650
+ $$
651
+
652
+ # K GENERALIZED SCALING ALGORITHM FOR $\mathbf{P}^2\mathrm{OT}$
653
+
654
+ We provide the pseudo-code for the Generalized Scaling Algorithm (GSA) proposed by (Chizat et al., 2018) in Alg.3.
p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10741dfda7256ccf7cee03c5e696491969f7e6b423ca9bfe34571a0232291204
3
+ size 1108534
p2otprogressivepartialoptimaltransportfordeepimbalancedclustering/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3a5f1b75b020418e13cdd40f2c780e7c4937c1ae7e5074b1fc0438179d2c8b5
3
+ size 789671
p2segpointlysupervisedsegmentationviamutualdistillation/301223cf-5861-4dd3-8b6c-02ceef166340_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c9a4affcf79002ad1838821c6936001a04d359811d9610570643211bbb37e7e
3
+ size 77437
p2segpointlysupervisedsegmentationviamutualdistillation/301223cf-5861-4dd3-8b6c-02ceef166340_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a592371cb3d49d94e27780e277b922015f1d845babcc972138723015b9138be8
3
+ size 98670
p2segpointlysupervisedsegmentationviamutualdistillation/301223cf-5861-4dd3-8b6c-02ceef166340_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:04aed188f3c503140197d3165ca8b4ea695af2a827916ae2bd0e362a76d30171
3
+ size 2947445
p2segpointlysupervisedsegmentationviamutualdistillation/full.md ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # P2SEG: POINTLY-SUPERVISED SEGMENTATION VIA MUTUAL DISTILLATION
2
+
3
+ Zipeng Wang $^{1*}$ , Xuehui Yu $^{1*}$ , Xumeng Han $^{1}$ , Wenwen Yu $^{1}$ , Zhixun Huang $^{2}$ , Jianbin Jiao $^{1}$ , Zhenjun Han $^{1\dagger}$
4
+
5
+ <sup>1</sup>University of Chinese Academy of Sciences <sup>2</sup>Xiaomi AI Lab, Beijing, China
6
+
7
+ wangzipeng22@mails.ucas.ac.cn
8
+
9
+ # ABSTRACT
10
+
11
+ Point-level Supervised Instance Segmentation (PSIS) aims to enhance the applicability and scalability of instance segmentation by utilizing low-cost yet instance-informative annotations. Existing PSIS methods usually rely on positional information to distinguish objects, but predicting precise boundaries remains challenging due to the lack of contour annotations. Nevertheless, weakly supervised semantic segmentation methods are proficient in utilizing intra-class feature consistency to capture the boundary contours of the same semantic regions. In this paper, we design a Mutual Distillation Module (MDM) to leverage the complementary strengths of both instance position and semantic information and achieve accurate instance-level object perception. The MDM consists of Semantic to Instance (S2I) and Instance to Semantic (I2S). S2I is guided by the precise boundaries of semantic regions to learn the association between annotated points and instance contours. I2S leverages discriminative relationships between instances to facilitate the differentiation of various objects within the semantic map. Extensive experiments substantiate the efficacy of MDM in fostering the synergy between instance and semantic information, consequently improving the quality of instance-level object representations. Our method achieves $55.7\mathrm{mAP}_{50}$ and $17.6\mathrm{mAP}$ on the PASCAL VOC and MS COCO datasets, significantly outperforming recent PSIS methods and several box-supervised instance segmentation competitors. Our code is available on https://github.com/ucas-vg/P2Seg-Public.
12
+
13
+ # 1 INTRODUCTION
14
+
15
+ Instance segmentation is a critical task in computer vision, where semantic segmentation estimation and instance discrimination are equally important. In recent years, instance segmentation has gained extensive interest due to its significance in various application scenarios and research domains (Dai et al., 2016a; 2015; 2016b; He et al., 2017b; Kirillov et al., 2017; Liu et al., 2016; Novotny et al., 2018) and it aims not only to locate objects accurately but also to estimate their boundaries to differentiate instances of the same category. The advanced instance segmentation methods use point annotations that only approximate object positions, making it difficult to capture detailed features and accurate boundaries. Hence, relying solely on point annotations has limitations that would not allow instance segmentation methods to provide precise object contours. On the other hand, semantic segmentation in computer vision involves image classification, object recognition, and semantic region boundary delineation, and its goal is to divide the image into distinct regions and assign category labels. Although advanced semantic segmentation excels at precise semantic region boundaries, it often struggles with instance-level discrimination within the same category.
16
+
17
+ Semantic information struggles to define precise boundaries when multiple same-class objects are close or overlapping. For example, if an image contains multiple bottles, semantic information methods lumps them into one "bottle" region, unable to distinguish between different bottles. Therefore, considering the limitations both instance information and semantic information have, it can be concluded that instance information is vital for accurate discrimination among instances but is limited
18
+
19
+ ![](images/4a2e0388f6a2d8319831e900943b350a8242dfc3f461ed3862950342b2fce5b3.jpg)
20
+ Figure 1: Two limitations of PSIS methods: Left: severe local responses caused by points separated with image features. Right: ambiguous boundaries caused by missing instance information.
21
+
22
+ ![](images/04556b8bc02c0b2f88cb22fec88f9b35b92b1779559545a38b1e5a0c652b2fe5.jpg)
23
+ Figure 2: The illustration of S2I and I2S Complementary Advantage. Semantic and instance information is mutually distilled, resulting in high-quality instance segmentation maps.
24
+
25
+ to only instance point annotations; semantic information excels in scene understanding and object recognition but struggles with instance-level information. Both have their own merits. In summary, as shown in Fig. 1 the two problems faced by Point-level Supervised Instance Segmentation (PSIS) methods are:
26
+
27
+ - The local response caused by the separation of points from image features. Image features and point supervision are decoupled and heavily rely on off-the-shelf proposals for instance segmentation, resulting in localized outcomes.
28
+ - The semantic segmentation estimation and instance differentiation are separated. Point supervision is underutilized in the interaction of semantic segmentation and instance information, resulting in inaccurate instance estimation and challenges in distinguishing similar object boundaries.
29
+
30
+ In this paper, we aim to solve the above two problems through the Mutual Distillation Module (MDM) of the P2seg method, which leverages the advantages of instance and semantic segmentation. We achieve this by employing the Semantic to Instance (S2I) and Instance to Semantic (I2S) modules within MDM for knowledge distillation. Specifically, our contributions are as follows:
31
+
32
+ - We design an MDM module that mutually distills instance and semantic information to facilitate improved PSIS without relying on pre-trained proposals.
33
+ - We develop the S2I method to transfer semantic information to instances, guiding the network toward producing improved final instance segmentation labels. These enhanced labels lead to superior performance in the subsequent segmentor training.
34
+ - We propose the I2S module that merges instance details with class map (semantic score predicted by HRNet (Sun et al., 2019)) via affinity matrix. This integration embeds instance information into semantic context to facilitate mutual distillation and improve instance estimation accuracy.
35
+
36
+ # 2 RELATED WORK
37
+
38
+ Weakly-Supervised Semantic Segmentation(WSSS). Most WSSS methods extract object location using CAM from CNNs with image-level labels. However, CAM lacks precise boundaries and is insufficient for training semantic networks. ReCAM (Chen et al., 2022) refines CAM with SCE loss. CLIMS (Xie et al., 2022) uses a text-driven approach for better object activation. AFA (Ru et al., 2022) adds an attention affinity module in the transformer to refine CAM. MCTformer (Xu et al., 2022) improves CAM using patch-level pairwise affinity and transformer. L2G (Jiang et al., 2022) learns comprehensive attention knowledge from multiple maps. (Kweon et al., 2023) improves the quality of CAM by reducing the inferability between segments. WSSS focuses on pixel-level classification and cannot distinguish instances within the same category.
39
+
40
+ ![](images/7bddebe39012745f9447bef99cd0b155d54cf02b12fe75b20aeb99153a969e1d.jpg)
41
+ Figure 3: The architecture of MDM. In S2I branch, instance segmentation map is generated from the results of semantic segmentation using the offset map. In I2S branch, semantic segmentation results are influenced by instance segmentation map using affinity matrix. Finally, instance segmentation map generated by the trained S2I branch of MDM is used as supervision for training the segmentor.
42
+
43
+ Weakly-Supervised Instance Segmentation(WSIS). Weakly-supervised instance segmentation (WSIS) struggles with obtaining instance-level information from image-level labels. IRNet (Ahn et al., 2019) learns class-agnostic instance maps and pixel pair similarities, deriving pseudo instance segmentation labels without predefined proposals or extra supervision. In contrast, Label-PEnet (Ahn et al., 2019; Ge et al., 2019) transforms image-level labels into pixel-wise labels through a cascaded pipeline where the modules in this pipeline share a backbone network and use curriculum learning to enhance accuracy gradually. PDSL (Shen et al., 2021) unifies object detection and segmentation by integrating bottom-up cues into a top-down pipeline. The detection-segmentation separation allows both to perform better in their respective tasks.
44
+
45
+ Pointly-Supervised Instance Segmentation(PSIS). The aim of PSIS is to leverage point annotations for improved segmentation, and PSIS methods, such as WISE-Net (Laradji et al., 2020), use point-level labels. To generate high quality mask proposals, WISE-Net trains L-Net with point annotations to locate objects and then uses E-Net to group pixels, generating high quality mask proposals. BESTIE (Kim et al., 2022) refines mask proposals using point supervision and instance-level cues for robust instance segmentation. It addresses semantic drift by using self-refinement and instance-aware guidance and enhances segmentation accuracy by effectively integrating semantic and instance information, thus surpassing methods relying solely on image-level labels. SAM (Kirillov et al., 2023b) is an interactive image segmentation framework that can segment specified objects in an image using coarse hints, such as points, bounding boxes, and textual descriptions. Point2Mask (Li et al., 2023) is employed in panoramic segmentation tasks. It uses ground truth points as supervisory information to generate pseudo-label masks, thereby reducing annotation costs.
46
+
47
+ Mutual Distillation. Knowledge distillation (Bucilua et al., 2006; Hinton et al., 2015) distills knowledge from a complex teacher model into a simpler, compressed student model to achieve satisfactory performance. Mutual learning strategy (Zhang et al., 2018) involves collaboration among students, allowing them to learn from each other. (Wu et al., 2019) applies mutual learning to each block of a salient object detection backbone. (Zhang et al., 2019) suggests self-distillation within network. (Crowley et al., 2018) transforms a teacher network into a student network. (Hou et al., 2019) uses self-attention distillation for lane detection. (Yun et al., 2020) distills prediction distribution among same-labeled samples. (Wei et al., 2020) employs mutual learning for image classification with noisy labels, aiming to reduce network diversity during training. (Pang et al., 2020) introduces an aggregate interaction module to handle feature fusion challenges. (Yuan et al., 2020) proposes teacher-free knowledge distillation with improved label smoothing regularization. (Yang et al., 2021) introduces mutual learning by considering network width and resolution simultaneously. Inspired by these methods, we propose mutual distillation learning for PSIS. It achieves effective fusion and information promotion from instances and semantics, thereby improving the quality of segmentation results.
48
+
49
+ # 3 METHOD
50
+
51
+ Overview. As shown in Fig. 3, our proposed MDM consists of distillation from semantic to instance information and instance to semantic information. In our framework, HRNet serves as the backbone network for feature extraction, which following BESTIE, predicts offset maps, class maps, and instance affinity matrices separately. MDM is a recurrent learning module.
52
+
53
+ Initially, S2I branch obtains initial offset maps from the generated semantic segmentation map, serving as the initial instance segmentation labels. The offset maps predicted by HRNet connect with the semantic segmentation maps to produce new instance segmentation maps.
54
+
55
+ Then, the I2S branch uses the newly generated instance segmentation maps to compute the instance affinity matrix. A new semantic segmentation map is generated by multiplying the affinity matrix with the semantic scores (i.e., class map) predicted from HRNet. The instance segmentation map generated at the final stage of MDM is used as pseudo labels to supervise the learning of the segmentor.
56
+
57
+ ![](images/ece753a978d97fdbb0e76c859eb2af944ca1675f333df9ae867085fdfcd08d96.jpg)
58
+ Figure 4: The abstract concept of semantic and instance information interaction. Corresponding to Fig. 3, the S2I branch is colored in green, while the I2S branch is colored in blue.
59
+
60
+ # 3.1 SEMANTIC TOINSTANCE
61
+
62
+ As shown in Fig. 5 regarding the information distilled from semantic to instance, we introduce the S2I branch that combines point annotations and weakly supervised semantic segmentation results to create initial instance segmentation labels. It also calculates instance-level offset maps by measuring inter-pixel distances within the initial results. Initially, it identifies preliminary instance regions using connected component labeling based on the semantic segmentation. Then, these regions are matched with the set of point annotations $E = \{e_1, e_2, \dots, e_K\}$ , where $K$ denotes the number of point annotations. In cases of conflicts (e.g., multiple annotations in one region), a distance separation strategy is used. The distance is defined as:
63
+
64
+ $$
65
+ k ^ {*} = \arg \min _ {k} \| e _ {k} - p \|, \tag {1}
66
+ $$
67
+
68
+ where $p$ denotes the points in semantic segmentation map, $e_k$ denotes the $k$ -th annotation point, $k^*$ represents the point $p$ assigned to the $k^*$ -th annotation point $e_{k^*}$ . After obtaining the initial
69
+
70
+ ![](images/d5d1b2278b0df1d66d58a8c5bd16edc1c40c351547675242a788bdc97c4d321e.jpg)
71
+ Figure 5: The architecture of the S2I branch. Left: The semantic segmentation map generates the offset map and class maps as supervised. Right: The process of generating the new instance segmentation map.
72
+
73
+ instance segmentation labels from the distance separation strategy, it generates the corresponding offset maps from the initial labels. Similar to BESTIE, we calculate the offset map for all instance points belonging to the annotation points by calculating the offset between the annotation and other points. The formula is as follows:
74
+
75
+ $$
76
+ \mathcal {O} = \bigcup_ {e _ {k} \in E} \| e _ {k} - m \|, \tag {2}
77
+ $$
78
+
79
+ where $m$ denotes the points within the instance region to which the $k$ -th annotated point $e_k$ belongs. $\mathcal{O}$ denotes the offset maps.
80
+
81
+ The offset maps generated by HRNet prediction is not only used for generating class-agnostic instance segmentation maps based on points but also contributes to the calculation of the loss function with initial offset map to facilitate further network learning through gradient back-propagation. The class-agnostic instance segmentation map is multiplied with the semantic segmentation map generated through I2S branch, leading to new instance segmentation results. It is important to note that instance adaptive grouping is based on point annotations for mask grouping. Our network creates final instance segmentation labels based on a combination of predicted semantic segmentation results, instance similarity matrices, and point annotations. In case of discrepancies between semantic and point-based segmentation, point annotations take precedence. For points without clear instance predictions, a default pseudo-box of size $16 \times 16$ is assigned as their segmentation prediction.
82
+
83
+ In the first stage, semantic map for S2I consists of pseudo-labels generated from the off-the-shelf segmentation map (e.g. SAM). Since the second stage, the semantic map input to MDM is generated from the previous stage. The instance segmentation map generated in the final stage will serve as pseudo-labels for the instance segmentor and perform the ultimate fine-tuning of the model.
84
+
85
+ # 3.2INSTANCE TO SEMANTIC
86
+
87
+ As shown in the blue region in Fig. 3, through the I2S branch, semantic information is distilled into instances. First, the branch obtains an affinity matrix from the instance segmentation map generated by S2I, representing the instance affinity between pairs of pixels. Specifically, in the instance similarity matrix, if two pixels belong to the same instance, their value is set to 1, otherwise, it is set to 0. Subsequently, this branch uses the affinity matrix $\mathcal{A} \in \mathbb{R}^{hw \times hw}$ predicted by HRNet as weights to adjust the class map $\mathcal{C} \in \mathbb{R}^{hw \times (c + 1)}$ generated by HRNet. This adjustment enables the class map to incorporate instance information and generate the updated semantic segmentation map $S = \mathcal{A}^{\circ \beta} * \mathcal{C}$ , where $\mathcal{A}^{\circ \beta}$ denotes the $\beta$ times Hadamard power of $\mathcal{A}$ , which smoothes the distribution to attain the optimal semantic segmentation map. Then affinity matrix generated from the instance segmentation map is used to compute the $\mathcal{L}_{I2S}$ (see Sec. 3.3) with the predicted affinity from HRNet to facilitate gradient backpropagation and promote self-learning of the network. The semantic segmentation map obtained through I2S serves as the semantic information input for the next stage. Through the constraints of instances, I2S enriches the semantic segmentation results with instance information. I2S can be widely applied to various weakly supervised segmentation tasks to allow the segmentation prediction with instance-wise information.
88
+
89
+ # 3.3 Loss
90
+
91
+ As shown in Fig. 3, our framework consists of two branches corresponding to the respective two loss functions, namely the S2I loss $\mathcal{L}_{S2I}$ , the I2S loss $\mathcal{L}_{I2S}$ .
92
+
93
+ S2I Loss. S2I loss consists of the offset loss and the segmentation loss, i.e., $\mathcal{L}_{S2I} = \mathcal{L}_{off} + \mathcal{L}_{seg}$ , which is primarily used to constrain the network to capture instance information. Based on the annotations, we generate the offset map of the pixel value of the corresponding instance object according to the point annotations, which is represented by vector $(x,y)$ . Offset map collects sets of pixels for labeled instance regions from pseudo labels, and set is denoted as $\mathcal{P}_{\mathrm{pseudo}}$ . The offset loss is expressed as follows:
94
+
95
+ $$
96
+ \mathcal {L} _ {o f f} = \frac {1}{| \mathcal {P} _ {\text {p s e u d o}} |} \sum_ {(i, j) \in \mathcal {P} _ {\text {p s e u d o}}} \mathcal {W} (i, j) \cdot \text {s m o o t h} _ {L 1} | \hat {\mathcal {O}} (i, j) - \mathcal {O} (i, j) |, \tag {3}
97
+ $$
98
+
99
+ where predicted pseudos in the former stage are $\hat{\mathcal{O}}$ , $\mathcal{O}$ , respectively. $\mathcal{W}$ means the weight of the pseudo loss. Offset loss represents the instance object's scale range that can well constrain the network regression. For semantic segmentation branch, the objective function is defined as:
100
+
101
+ $$
102
+ \mathcal {L} _ {s e g} = \frac {1}{| \mathcal {P} _ {s e g} |} \sum_ {(i, j) \in \mathcal {P} _ {s e g}} \operatorname {C E} \left(p _ {\hat {\mathcal {C}} (i, j)}, \mathcal {C} (i, j)\right), \tag {4}
103
+ $$
104
+
105
+ where $\hat{\mathcal{C}},\mathcal{C}$ respectively represent the class map predicted by the network and the class map obtained at the S2I stage while acquiring the offset map, $p_{\hat{\mathcal{C}} (i,j)}$ represents the probabilities predicted by the network for each category in the class map, and $\mathcal{P}_{seg}$ is the set of all pixels in $\hat{\mathcal{C}}$
106
+
107
+ I2S Loss. I2S loss uses the instance ownership relation between pixels to model the affinity matrix. The expression of I2S loss is as follows:
108
+
109
+ ![](images/38a7afeb2f246709a5873f987c426361b64bd981f360619ab2fd8abf20449c8b.jpg)
110
+ Figure 6: Comparison of distillation from S2I. The yellow area represents BESTIE method, and the green zone indicates the S2I branch.
111
+
112
+ $$
113
+ \mathcal {L} _ {I 2 S} = \frac {1}{N ^ {+}} \sum_ {(i, j) \in R ^ {+}} \left(2 - \sigma \left(\mathcal {A} ^ {i j}\right) - \sigma \left(\hat {\mathcal {A}} ^ {i j}\right)\right) + \frac {1}{N ^ {-}} \sum_ {(k, l) \in R ^ {-}} \left(\sigma \left(\mathcal {A} ^ {k l}\right) + \sigma \left(\hat {\mathcal {A}} ^ {k l}\right)\right), \tag {5}
114
+ $$
115
+
116
+ where $\sigma$ represents the sigmoid activation function. $R^{+}$ and $R^{-}$ denote the set of affinity and non-affinity pixel-pair samples. $(i,j)$ , $(k,l)$ denote the pixel pairs, respectively. $N^{+}$ and $N^{-}$ count the number of $R^{+}$ and $R^{-}$ , $\mathcal{A}$ and $\hat{\mathcal{A}}$ means the the affinity matrix generated from the instance map produced by the S2I process and predicted instance affinity matrix by the network HRNet. Eq. 5 reinforces the network to learn highly confident instance affinity relations from iterative training. On the other hand, since the instance affinity prediction is used by semantic segmentation branch, it also benefits the learning of global instance features and further helps to discover the integral object regions. The overall loss is finally formulated as $\mathcal{L} = \lambda_{I2S}\mathcal{L}_{I2S} + \lambda_{\mathrm{S2I}}\mathcal{L}_{S2I}$ .
117
+
118
+ # 4 EXPERIMENT
119
+
120
+ # 4.1 IMPLEMENTATION DETAILS
121
+
122
+ Datasets. Our experiments are conducted on PASCAL VOC 2012 (Everingham et al., 2010) and MS COCO 2017 (Lin et al., 2014) datasets. VOC dataset contains 20 instance classes, which is usually augmented with the SBD (Hariharan et al., 2011) dataset. It includes 10,582, 1,449, and 1,464 images for training, validation, and testing, respectively. COco dataset contains 80 classes and includes $118k$ images for training and $5k$ images for validation. The images we used for training are annotated with point-level labels only.
123
+
124
+ Evaluation Metrics. We assess the performance of instance segmentation using two measures. We measure the performance using the standard protocol mean Average Precision(mAP). First, we measure the performance using the standard protocol mean Average Precision(mAP) with intersection-over-union(IoU) thresholds of 0.5, 0.7, and 0.75 for VOC. Second, the averaged AP over IoU thresholds from 0.5 to 0.95 is used on COCO dataset.
125
+
126
+ Training details. We use an AdamW (Loshchilov & Hutter, 2017) optimizer to train our network. The initial learning rate is set as $5 \times 10^{-5}$ and the batch size is set as 8. For the experiments on the VOC dataset, we train the network for 50,000 iterations. To ensure the initial pseudo labels are favorable, we warm-up the network for 2,000 iterations. For experiments on the COCO dataset, the total iterations number is 100,000 and the number of warm-up iterations is 5,000. The weights of semantic segmentation loss, offset map loss and instance affinity matrix loss are set as 1.0, 0.01, 1.0, respectively. The data augmentation strategies used here include random resizing between 0.7 and 1.3, random cropping, random flipping, and photometric distortion. In the fine-tuning phase of the network's instance segmentor, we primarily employ the Mask R-CNN (He et al., 2017a) to retrain the instance segmentation map obtained from the last stage of MDM. We use SGD optimizer with a learning rate of 0.02 and the batch size is 16 with 12 epochs for both VOC and COCO dataset.
127
+
128
+ # 4.2 COMPARISON WITH STATE-OF-THE-ART METHODS.
129
+
130
+ Results on Pascal VOC 2012. We report the performance of the proposed method on the commonly used VOC validation dataset( $\dagger$ represents the method reproduced in this paper). As shown in Table 1, the methods are grouped as image-supervised, box-supervised, and pointly-supervised methods from top to bottom. Our method achieves the best performance among all competing methods and even outperforms the most competitive BESTIE on both $\mathrm{mAP}_{50}$ and $\mathrm{mAP}_{75}$ .
131
+
132
+ Table 1: Quantitative comparison of the state-of-the-art WSIS methods on VOC 2012 val-set. We denote the supervision sources as: $\mathcal{F}$ (full mask), $\mathcal{B}$ (box-level label), $\mathcal{I}$ (image-level label), $\mathcal{P}$ (point-level label), and $\mathcal{C}$ (object count). The off-the-shelf proposal techniques are denoted as follows: $\mathcal{M}$ (segment proposal (Pont-Tuset et al., 2016)), $\mathcal{R}$ (region proposal (Uijlings et al., 2013)), and $\mathcal{S}_{\mathcal{I}}$ (salient instance segmentor (Fan et al., 2019)).
133
+
134
+ <table><tr><td>Method</td><td>Sup.</td><td>Backbone</td><td>Extra</td><td>\(mAP_{25}\)</td><td>\(mAP_{50}\)</td><td>\(mAP_{70}\)</td><td>\(mAP_{75}\)</td></tr><tr><td>Mask R-CNN (He et al., 2017a)</td><td>\(\mathcal{F}\)</td><td>ResNet-50</td><td>-</td><td>76.7</td><td>67.9</td><td>-</td><td>44.9</td></tr><tr><td colspan="8">End-to-End weakly-supervised models.</td></tr><tr><td>PRM (Zhou et al., 2018)</td><td>\(\mathcal{I}\)</td><td>ResNet-50</td><td>\(\mathcal{M}\)</td><td>44.3</td><td>26.8</td><td>-</td><td>9.0</td></tr><tr><td>IAM (Zhu et al., 2019)</td><td>\(\mathcal{I}\)</td><td>ResNet-50</td><td>\(\mathcal{M}\)</td><td>45.9</td><td>28.3</td><td>-</td><td>11.9</td></tr><tr><td>Label-PEnet (Ge et al., 2019)</td><td>\(\mathcal{I}\)</td><td>VGG-16</td><td>\(\mathcal{R}\)</td><td>49.2</td><td>30.2</td><td>-</td><td>12.9</td></tr><tr><td>CL (Hwang et al., 2021)</td><td>\(\mathcal{I}\)</td><td>ResNet-50</td><td>\(\mathcal{M},\mathcal{R}\)</td><td>56.6</td><td>38.1</td><td>-</td><td>12.3</td></tr><tr><td>BBTP (Hsu et al., 2019)</td><td>\(\mathcal{B}\)</td><td>ResNet-101</td><td>-</td><td>23.1</td><td>54.1</td><td>-</td><td>17.1</td></tr><tr><td>BBTP w/CRF</td><td>\(\mathcal{B}\)</td><td>ResNet-101</td><td>-</td><td>27.5</td><td>59.1</td><td>-</td><td>21.9</td></tr><tr><td>BoxInst (Tian et al., 2021)</td><td>\(\mathcal{B}\)</td><td>ResNet-101</td><td>-</td><td>-</td><td>60.1</td><td>-</td><td>34.6</td></tr><tr><td>OCIS (Cholakkal et al., 2019)</td><td>\(\mathcal{C}\)</td><td>ResNet-50</td><td>\(\mathcal{M}\)</td><td>48.5</td><td>30.2</td><td>-</td><td>14.4</td></tr><tr><td>Point2Mask Li et al. (2023)</td><td>\(\mathcal{P}\)</td><td>ResNet-101</td><td>-</td><td>-</td><td>48.4</td><td>-</td><td>22.8</td></tr><tr><td colspan="8">Multi-Stage weakly-supervised models.</td></tr><tr><td>WISE (Laradji et al., 2019)</td><td>\(\mathcal{I}\)</td><td>ResNet-50</td><td>\(\mathcal{M}\)</td><td>49.2</td><td>41.7</td><td>-</td><td>23.7</td></tr><tr><td>IRN (Ahn et al., 2019)</td><td>\(\mathcal{I}\)</td><td>ResNet-50</td><td>-</td><td>-</td><td>46.7</td><td>23.5</td><td>-</td></tr><tr><td>LIID (Liu et al., 2020)</td><td>\(\mathcal{I}\)</td><td>ResNet-50</td><td>\(\mathcal{M},\mathcal{S}_{\mathcal{I}}\)</td><td>-</td><td>48.4</td><td>-</td><td>24.9</td></tr><tr><td>Arun et al. (Arun et al., 2020)</td><td>\(\mathcal{I}\)</td><td>ResNet-101</td><td>\(\mathcal{M}\)</td><td>59.7</td><td>50.9</td><td>30.2</td><td>28.5</td></tr><tr><td>WISE-Net (Laradji et al., 2020)</td><td>\(\mathcal{P}\)</td><td>ResNet-50</td><td>\(\mathcal{M}\)</td><td>53.5</td><td>43.0</td><td>-</td><td>25.9</td></tr><tr><td>BESTIE† (Kim et al., 2022)</td><td>\(\mathcal{P}\)</td><td>HRNet-48</td><td>-</td><td>62.8</td><td>52.8</td><td>-</td><td>31.2</td></tr><tr><td>SAM (Kirillov et al., 2023a)</td><td>\(\mathcal{P}+\mathcal{S}\)</td><td>ViT-S/22.1M</td><td>-</td><td>59.4</td><td>39.9</td><td>-</td><td>19.0</td></tr><tr><td>Ours</td><td>\(\mathcal{P}\)</td><td>ResNet-101</td><td>-</td><td>64.1</td><td>53.9</td><td>37.7</td><td>32.0</td></tr><tr><td>Ours</td><td>\(\mathcal{P}\)</td><td>HRNet-48</td><td>-</td><td>65.8</td><td>55.6</td><td>40.2</td><td>34.4</td></tr></table>
135
+
136
+ Table 2: Quantitative comparison of the state-of-the-art WSIS methods on MS COCO 2017 val-set. We denote the supervision sources as: $\mathcal{F}$ (full mask), $\mathcal{B}$ (box-level label), $\mathcal{I}$ (image-level label), and $\mathcal{P}$ (point-level label). The off-the-shelf proposal techniques are denoted as follows: $\mathcal{M}$ (segment proposal (Pont-Tuset et al., 2016)).
137
+
138
+ <table><tr><td>Method</td><td>Sup.</td><td>Backbone</td><td>Extra</td><td>AP</td><td>\( AP_{50} \)</td><td>\( AP_{75} \)</td></tr><tr><td>Mask R-CNN (He et al., 2017a)</td><td>\(\mathcal{F}\)</td><td>ResNet-50</td><td>-</td><td>34.6</td><td>56.5</td><td>36.6</td></tr><tr><td colspan="7">End-to-End weakly-supervised models.</td></tr><tr><td>BBTP (Hsu et al., 2019)</td><td>\(\mathcal{B}\)</td><td>ResNet-101</td><td>-</td><td>21.1</td><td>45.5</td><td>17.2</td></tr><tr><td>BoxInst (Tian et al., 2021)</td><td>\(\mathcal{B}\)</td><td>ResNet-101</td><td>-</td><td>31.6</td><td>54.0</td><td>31.9</td></tr><tr><td>Point2Mask (Li et al., 2023)</td><td>\(\mathcal{P}\)</td><td>ResNet-101</td><td>-</td><td>12.8</td><td>26.3</td><td>11.2</td></tr><tr><td colspan="7">Multi-Stage weakly-supervised models.</td></tr><tr><td>IRN (Ahn et al., 2019)</td><td>\(\mathcal{I}\)</td><td>ResNet-50</td><td>-</td><td>6.1</td><td>11.7</td><td>5.5</td></tr><tr><td>WISE-Net (Laradji et al., 2020)</td><td>\(\mathcal{P}\)</td><td>ResNet-50</td><td>\(\mathcal{M}\)</td><td>7.8</td><td>18.2</td><td>8.8</td></tr><tr><td>\(BESTIE^{\dagger}\)(Kim et al., 2022)</td><td>\(\mathcal{P}\)</td><td>HRNet-48</td><td>-</td><td>14.2</td><td>28.4</td><td>22.5</td></tr><tr><td>Ours</td><td>\(\mathcal{P}\)</td><td>HRNet-48</td><td>-</td><td>17.6</td><td>33.6</td><td>28.1</td></tr></table>
139
+
140
+ Results on MS COCO 2017. The proposed P2Seg is compared with the state-of-the-art on more challenging COCO dataset( $\dagger$ represents the method reproduced in this paper). In Table 2, our method achieves the best performance among all competing methods and even outperforms the most competitive BESTIE on both $\mathrm{AP}_{50}$ and $\mathrm{AP}_{75}$ . We find that P2Seg significantly outperforms weakly supervised methods and is on par with top-performing box-supervised methods.
141
+
142
+ Overall Analysis. In summary of all the above experimental results, P2Seg significantly enhances AP75, leading to overall segmentation performance improvement. The experiments illustrate that the mutual distillation method, leveraging instance and semantic information, can effectively estimate target scale and shape without requiring subsequent network fine-tuning. This optimization enhances handling of fine-grained segmentation details and resolves challenges with adjacent objects of the same class, ultimately improving segmentation performance.
143
+
144
+ # 4.3 ABLATION STUDY AND ANALYSIS
145
+
146
+ In order to further investigate the effectiveness of the instance-based and semantic-based mutual distillation algorithm, this section will conduct corresponding ablation experiments on the mutual
147
+
148
+ Table 3: Ablation study for Table 4: Ablation study for differ-our S2I and I2S, compared with ent Segmentor Backbones. BESTIE.
149
+
150
+ <table><tr><td>S→I</td><td>I→S</td><td>mAP50</td></tr><tr><td>BESTIE</td><td></td><td>52.8</td></tr><tr><td>S2I</td><td></td><td>53.2</td></tr><tr><td>S2I</td><td>I2S</td><td>55.7</td></tr></table>
151
+
152
+ Table 5: Ablation experiment to analyze the impact of hard pixel ratio.
153
+
154
+ <table><tr><td>Method</td><td>Segmentor</td><td>\( \mathrm{mAP}_{50} \)</td></tr><tr><td>BESTIE Ours</td><td>Mask-RCNN</td><td>52.8 55.6</td></tr><tr><td>BESTIE Ours</td><td>SOLOv2</td><td>51.9 54.1</td></tr></table>
155
+
156
+ <table><tr><td>Hard pixel ratio</td><td>mAP50</td></tr><tr><td>0.1</td><td>52.0</td></tr><tr><td>0.2</td><td>50.8</td></tr><tr><td>0.4</td><td>51.5</td></tr><tr><td>0.8</td><td>50.9</td></tr></table>
157
+
158
+ Table 6: The comparison of BESTIE and our P2Seg for IoU with the ground truth.
159
+
160
+ <table><tr><td>Method</td><td>IoU&gt;50</td><td>IoU&gt;70</td><td>IoU&gt;90</td><td>overall IoU</td></tr><tr><td>Semantic Results First</td><td>5782</td><td>4939</td><td>2440</td><td>58.49</td></tr><tr><td>Points First</td><td>9544</td><td>7417</td><td>2558</td><td>66.57</td></tr></table>
161
+
162
+ distillation method. Unless otherwise specified, the datasets used in this section are from the PAS-CAL VOC 2012 dataset.
163
+
164
+ Effect of S2I. The motivation of S2I is to distill the semantic segmentation information into instance segmentation information. Based on the point annotation, S2I also shows its powerful ability to merge semantic segmentation results with point annotations. As shown in Fig. 6, the yellow part illustrates the Semantic Knowledge Transfer method proposed in BESTIE, which has a similar role to the S2I proposed in this paper. However, BESTIE does not fully utilize existing point annotations, whose design only considers scenarios where point annotations and foreground regions have no conflicts, leading to the loss of adjacent objects. In contrast, S2I assigns a unique instance region to represent each point's instance, ensuring better distinction and allocation of instances. As shown in Table.3, S2I obtains $1.4\mathrm{mAP}_{50}$ performance improvement on PSIS tasks compared with the previous methods, showing the effectiveness of S2I statistically.
165
+
166
+ Effect of I2S. I2S module improves instance discrimination in the same class by using the instance affinity matrix. As shown in Table 3, I2S raises $\mathrm{mAP}_{50}$ from 53.2 to 55.7. The Hadamard power of the affinity matrix provides additional information.
167
+
168
+ Other Segmentors for Instance Segmentation. As shown in the Table 4, we further evaluate instance segmentation networks trained with our pseudo labels, comparing them to SOLOv2 (Wang et al., 2020) and Mask R-CNN (He et al., 2017a), which are effective networks for single-stage and two-stage methods, respectively. The table displays results of Mask R-CNN and SOLOv2 trained with our pseudo labels, showing significant improvement over the previous state-of-the-art BESTIE. Our method outperforms BESTIE by $2.8\mathrm{mAP}_{50}$ on Mask R-CNN and $2.2\mathrm{mAP}_{50}$ on SOLOv2, highlighting the superiority of mutual distillation over one-way distillation.
169
+
170
+ Hard pixel ratio. As shown in Table 5, the term "hard pixel ratio" refers to the proportion of challenging samples used in loss computation. A lower proportion of hard pixels during training yields higher $\mathrm{mAP}_{50}$ , which is the validated result without a segmentor. However, reducing this proportion can lead to overfitting on easier examples and limit the model's ability to handle diverse scenarios, resulting in decreased generalization performance. We set the hard pixel ratio to 0.2.
171
+
172
+ Prediction Mask Quality Comparison. Considering that the post-processing in this approach involves fine-tuning the Mask RCNN network, this study further evaluates the quality of the predicted masks obtained before inputting them into the Mask RCNN network. Table 6 displays data from the PASCAL VOC 2012 dataset, showing the number of predicted masks with IoU thresholds of 0.5, 0.7, and 0.9 compared to ground truth masks in the first three columns. The "average IoU" column presents the mean IoU between predicted instance masks and ground truth masks.
173
+
174
+ Backbone. We make the ablation experiments about our method on the backbone layer of the network. As shown in Table 1, our method has consistent effects in different feature extracting methods from the backbone network.
175
+
176
+ # 4.4 VISUALIZATION
177
+
178
+ As shown in Fig. 7, the results demonstrate image segments using our method and the baseline. P2Seg effectively distinguishes boundaries between neighboring objects in the same class to enhance
179
+
180
+ ![](images/1ecc916b6827c3a405b7211e5d1aecc2e201b8601438df5d352914396125107f.jpg)
181
+ Figure 7: Visualization result on COCO. First row: Original image. Second row: Segmentation results of BESTIE before fine-tuning. Third row: Segmentation results of the point-supervised instance segmentation network constructed in this paper before fine-tuning. Fourth row: GT.
182
+
183
+ ![](images/1d2d1f49fe7bd2909328fe843c9765e70034ee4072957d69e06c4f40baa5bbf0.jpg)
184
+ Image
185
+
186
+ ![](images/2c875d4548709a398faa9959f2834e623c65ce675022ab264a2f59e78e888fe0.jpg)
187
+ initial
188
+
189
+ ![](images/b0999249dc2de8912579b9705a77bbc3963aa6c96141524c9de8752086536246.jpg)
190
+ $5000^{\mathrm{th}}$ iter
191
+
192
+ ![](images/7ef9da25ed096df4bad3e2b04466c5490ce623e66c5ba8e008bdc03a08d6688a.jpg)
193
+ w/o Mutual Distillation
194
+ 10000thiter
195
+
196
+ ![](images/54fcb286d97d8cc7abc04fb17d7d768778d4fa8da13d452cf47acbe86f1407a6.jpg)
197
+ 15000thiter
198
+
199
+ ![](images/51edddfcb9f0d0c495cc9ef0e7d78390320c0c56fd02e2876aa33df88349da7b.jpg)
200
+ 20000thiter
201
+
202
+ ![](images/5a1a610d9dcb1344cd8b7ef2de7d4e1dad18de2615dce7b2893e08b2172d4746.jpg)
203
+ 50000thiter
204
+
205
+ ![](images/55754c1f4fb5b27a6f6324e838377d8ed670a692303fada12df7cf5b1deafd2c.jpg)
206
+ Label
207
+ Figure 8: Comparison of class-agnostic instance segmentation learning. Left: Original image and class-agnostic instance segmentation annotations. Right: Learning progression from initialization to 50,000 iterations. The top without mutual distillation, and the bottom with it.
208
+
209
+ ![](images/f46c110d8918e44ad237b54621457ce4d3c4e66d527dc35b2fd8ed3c264c8864.jpg)
210
+ initial
211
+
212
+ ![](images/879e45581a91d9fd88b3739eaef0c57bbb7e5cdea82599eb2bd4b4a56425667d.jpg)
213
+ $5000^{\mathrm{th}}$ iter
214
+
215
+ ![](images/b3879cef64e0c9c036d7636902a290ffff323f794422f5cbc1a9b648166f44ff.jpg)
216
+ w/ Mutual Distillation
217
+ $10000^{\mathrm{th}}$ iter
218
+
219
+ ![](images/12ccdada6b33839002cbc4fbacef5101755b18e2eda3ae4be94bfe03bc0566c8.jpg)
220
+ 15000thiter
221
+
222
+ ![](images/04017bb6407ecca1998ce25ab24d298437cfd5e20b083ba4b2031db67dc4ca58.jpg)
223
+ 2000thiter
224
+
225
+ ![](images/85822dc8c3ed6ad123777d7e59419f97ac09e4dbbc6f9be3f1304be69fdfd431.jpg)
226
+ $50000^{\mathrm{th}}$ iter
227
+
228
+ completeness and boundary clarity. The study validates the impact of mutual distillation on instance features through visualizations of class-agnostic instance segmentation maps. As shown in Fig. 8, we compare the segmentation results with and without mutual distillation reveals that the network gains more instance information over time with MDM, allowing it to segment more objects. MDM method significantly enhances the point-supervised instance segmentation network.
229
+
230
+ # 5 CONCLUSION
231
+
232
+ We propose MDM, a mutual distillation network using point-level data. It effectively combines point annotations with features and facilitates mutual distillation of information between instance-level and semantic-level information, and distinguishes object boundaries within the same class. MDM employs S2I and I2S processes, enhancing simple class and localization attentions for fully supervised instance segmentation training. Trained on Pascal VOC 2012, MDM shows outstanding performance in both instance and semantic segmentation tasks, showing the power of mutual distillation.
233
+
234
+ # 6 ACKNOWLEDGMENTS
235
+
236
+ This work was supported in part by the Youth Innovation Promotion Association CAS, the National Natural Science Foundation of China (NSFC) under Grant No. 61836012 and 61771447, the Strategic Priority Research Program of the Chinese Academy of Sciences under Grant No.XDA27000000.
237
+
238
+ # REFERENCES
239
+
240
+ Jiwoon Ahn, Sunghyun Cho, and Suha Kwak. Weakly supervised learning of instance segmentation with inter-pixel relations. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2204-2213, 2019.
241
+ Aditya Arun, CV Jawahar, and M Pawan Kumar. Weakly supervised instance segmentation by learning annotation consistent instances. In European Conference on Computer Vision, pp. 254-270. Springer, 2020.
242
+ Cristian Bucilua, Rich Caruana, and Alexandru Niculescu-Mizil. Model compression. In Proceedings of the 12th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 535-541, 2006.
243
+ Zhaozheng Chen, Tan Wang, Xiongwei Wu, Xian-Sheng Hua, Hanwang Zhang, and Qianru Sun. Class reactivation maps for weakly-supervised semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 969-978, 2022.
244
+ Hisham Cholakkal, Guolei Sun, Fahad Shahbaz Khan, and Ling Shao. Object counting and instance segmentation with image-level supervision. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12397-12405, 2019.
245
+ Elliot J Crowley, Gavin Gray, and Amos J Storkey. Moonshine: Distilling with cheap convolutions. Advances in Neural Information Processing Systems, 31, 2018.
246
+ J. Dai, K. He, and J. Sun. Convolutional feature masking for joint object and stuff segmentation. In Computer Vision and Pattern Recognition, 2015.
247
+ J. Dai, K. He, Y. Li, S. Ren, and J. Sun. Instance-sensitive fully convolutional networks. arXiv e-prints, 2016a.
248
+ Jifeng Dai, Kaiming He, and Jian Sun. Instance-aware semantic segmentation via multi-task network cascades. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 3150-3158, 2016b.
249
+ Mark Everingham, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman. The pascal visual object classes (voc) challenge. International journal of computer vision, 88:303-338, 2010.
250
+ Ruochen Fan, Qibin Hou, Ming-Ming Cheng, Gang Yu, Ralph R Martin, and Shi-Min Hu. Associating interimage salient instances for weakly supervised semantic segmentation. In Proceedings of the European conference on computer vision (ECCV), pp. 367-383, 2018.
251
+ Ruochen Fan, Ming-Ming Cheng, Qibin Hou, Tai-Jiang Mu, Jingdong Wang, and Shi-Min Hu. S4net: Single stage salient-instance segmentation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 6103-6112, 2019.
252
+ Weifeng Ge, Sheng Guo, Weilin Huang, and Matthew R Scott. Label-penet: Sequential label propagation and enhancement networks for weakly supervised instance segmentation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 3345-3354, 2019.
253
+ Bharath Hariharan, Pablo Arbeláez, Lubomir Bourdev, Subhransu Maji, and Jitendra Malik. Semantic contours from inverse detectors. In 2011 international conference on computer vision, pp. 991-998. IEEE, 2011.
254
+ Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In Proceedings of the IEEE international conference on computer vision, pp. 2961-2969, 2017a.
255
+ Kaiming He, Georgia Gkioxari, Piotr Dlár, and Ross Girshick. Mask r-cnn. In ICCV, 2017b.
256
+ Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
257
+ Yuenan Hou, Zheng Ma, Chunxiao Liu, and Chen Change Loy. Learning to steer by mimicking features from heterogeneous auxiliary networks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 8433-8440, 2019.
258
+
259
+ Cheng-Chun Hsu, Kuang-Jui Hsu, Chung-Chi Tsai, Yen-Yu Lin, and Yung-Yu Chuang. Weakly supervised instance segmentation using the bounding box tightness prior. Advances in Neural Information Processing Systems, 32, 2019.
260
+ Jaedong Hwang, Seohyun Kim, Jeany Son, and Bohyung Han. Weakly supervised instance segmentation by deep community learning. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pp. 1020-1029, 2021.
261
+ Peng-Tao Jiang, Yuqi Yang, Qibin Hou, and Yunchao Wei. L2g: A simple local-to-global knowledge transfer framework for weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16886-16896, 2022.
262
+ Beomyoung Kim, Young Joon Yoo, Chae-Eun Rhee, and Junmo Kim. Beyond semantic to instance segmentation: Weakly-supervised instance segmentation via semantic knowledge transfer and self-refinement. 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 4268-4277, 2022.
263
+ A. Kirillov, E. Levinkov, B. Andres, B. Savchynskyy, and C. Rother. Instanccut: From edges to instances with multicut. In IEEE Conference on Computer Vision and Pattern Recognition, 2017.
264
+ Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alexander C Berg, Wan-Yen Lo, et al. Segment anything. arXiv preprint arXiv:2304.02643, 2023a.
265
+ Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alexander C Berg, Wan-Yen Lo, et al. Segment anything. arXiv preprint arXiv:2304.02643, 2023b.
266
+ Hyeokjun Kweon, Sung-Hoon Yoon, and Kuk-Jin Yoon. Weakly supervised semantic segmentation via adversarial learning of classifier and reconstructor. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11329-11339, 2023.
267
+ Issam H Laradji, David Vazquez, and Mark Schmidt. Where are the masks: Instance segmentation with image-level supervision. arXiv preprint arXiv:1907.01430, 2019.
268
+ Issam H Laradji, Negar Rostamzadeh, Pedro O Pinheiro, David Vazquez, and Mark Schmidt. Proposal-based instance segmentation with point supervision. In 2020 IEEE International Conference on Image Processing (ICIP), pp. 2126-2130. IEEE, 2020.
269
+ Wentong Li, Yuqian Yuan, Song Wang, Jianke Zhu, Jianshu Li, Jian Liu, and Lei Zhang. Point2mask: Point-supervised panoptic segmentation via optimal transport. arXiv preprint arXiv:2308.01779, 2023.
270
+ Yi Li, Zhanghui Kuang, Liyang Liu, Yimin Chen, and Wayne Zhang. Pseudo-mask matters in weakly-supervised semantic segmentation. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 6964-6973, 2021.
271
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dolar, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In Computer Vision-ECCV 2014: 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part V 13, pp. 740-755. Springer, 2014.
272
+ S. Liu, X. Qi, J. Shi, H. Zhang, and J. Jia. Multi-scale patch aggregation (mpa) for simultaneous detection and segmentation. In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
273
+ Yun Liu, Yu-Huan Wu, Pei-Song Wen, Yu-Jun Shi, Yu Qiu, and Ming-Ming Cheng. Leveraging instance-, image-and dataset-level information for weakly supervised instance segmentation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2020.
274
+ Ilya Loshchilov and Frank Hutter. Fixing weight decay regularization in adam. CoRR, abs/1711.05101, 2017.
275
+ David Novotny, Samuel Albanie, Diane Larlus, and Andrea Vedaldi. Semi-convolutional operators for instance segmentation. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 86-102, 2018.
276
+ Youwei Pang, Xiaoqi Zhao, Lihe Zhang, and Huchuan Lu. Multi-scale interactive network for salient object detection. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 9413-9422, 2020.
277
+ Jordi Pont-Tuset, Pablo Arbelaez, Jonathan T Barron, Ferran Marques, and Jitendra Malik. Multiscale combinatorial grouping for image segmentation and object proposal generation. IEEE transactions on pattern analysis and machine intelligence, 39(1):128-140, 2016.
278
+
279
+ Lixiang Ru, Yibing Zhan, Baosheng Yu, and Bo Du. Learning affinity from attention: End-to-end weakly-supervised semantic segmentation with transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16846-16855, 2022.
280
+ Yunhang Shen, Liujuan Cao, Zhiwei Chen, Baochang Zhang, Chi Su, Yongjian Wu, Feiyue Huang, and Rongrong Ji. Parallel detection-and-segmentation learning for weakly supervised instance segmentation. 2021 IEEE/CVF International Conference on Computer Vision (ICCV), pp. 8178-8188, 2021.
281
+ Ke Sun, Bin Xiao, Dong Liu, and Jingdong Wang. Deep high-resolution representation learning for human pose estimation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 5693-5703, 2019.
282
+ Zhi Tian, Chunhua Shen, Xinlong Wang, and Hao Chen. Boxinst: High-performance instance segmentation with box annotations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5443-5452, 2021.
283
+ Jasper RR Uijlings, Koen EA Van De Sande, Theo Gevers, and Arnold WM Smeulders. Selective search for object recognition. International journal of computer vision, 104:154-171, 2013.
284
+ Xinlong Wang, Rufeng Zhang, Tao Kong, Lei Li, and Chunhua Shen. Solov2: Dynamic and fast instance segmentation. Advances in Neural information processing systems, 33:17721-17732, 2020.
285
+ Hongxin Wei, Lei Feng, Xiangyu Chen, and Bo An. Combating noisy labels by agreement: A joint training method with co-regularization. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 13726-13735, 2020.
286
+ Runmin Wu, Mengyang Feng, Wenlong Guan, Dong Wang, Hutchuan Lu, and Errui Ding. A mutual learning method for salient object detection with intertwined multi-supervision. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 8150-8159, 2019.
287
+ Jinheng Xie, Xianxu Hou, Kai Ye, and Linlin Shen. Cross language image matching for weakly supervised semantic segmentation. arXiv preprint arXiv:2203.02668, 2022.
288
+ Lian Xu, Wanli Ouyang, Mohammed Bennamoun, Farid Boussaid, and Dan Xu. Multi-class token transformer for weakly supervised semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4310-4319, 2022.
289
+ Taojiannan Yang, Sijie Zhu, Matias Mendieta, Pu Wang, Ravikumar Balakrishnan, Minwoo Lee, Tao Han, Mubarak Shah, and Chen Chen. Mutualnet: Adaptive convnet via mutual learning from different model configurations. IEEE Transactions on Pattern Analysis and Machine Intelligence, 45(1):811-827, 2021.
290
+ Li Yuan, Francis EH Tay, Guilin Li, Tao Wang, and Jiashi Feng. Revisiting knowledge distillation via label smoothing regularization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3903-3911, 2020.
291
+ Sukmin Yun, Jongjin Park, Kimin Lee, and Jinwoo Shin. Regularizing class-wise predictions via self-knowledge distillation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 13876-13885, 2020.
292
+ Linfeng Zhang, Jiebo Song, Anni Gao, Jingwei Chen, Chenglong Bao, and Kaisheng Ma. Be your own teacher: Improve the performance of convolutional neural networks via self distillation. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 3713-3722, 2019.
293
+ Ying Zhang, Tao Xiang, Timothy M Hospedales, and Huchuan Lu. Deep mutual learning. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4320-4328, 2018.
294
+ Yanzhao Zhou, Yi Zhu, Qixiang Ye, Qiang Qiu, and Jianbin Jiao. Weakly supervised instance segmentation using class peak response. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 3791-3800, 2018.
295
+ Yi Zhu, Yanzhao Zhou, Huijuan Xu, Qixiang Ye, David Doermann, and Jianbin Jiao. Learning instance activation maps for weakly supervised instance segmentation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 3116-3125, 2019.
p2segpointlysupervisedsegmentationviamutualdistillation/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:23dc149111bbfae028a9ecd48750adaf567a8236b6b4efd051139bc8762dd1fd
3
+ size 580105
p2segpointlysupervisedsegmentationviamutualdistillation/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8f79ba8b8e58018a34358d4deb2a6ba96c1007ee03fd22a3b5fdc82450c26a9
3
+ size 405944
pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/b1e240a5-63a9-45b2-9edf-2f0f76e4b7e7_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6855235e44d7e9ef152f6fab1d4ed9f13cb3dff04b733d73f97c56f5bc299ce3
3
+ size 156334
pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/b1e240a5-63a9-45b2-9edf-2f0f76e4b7e7_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:adb57ac7398fa1b570a52a196f0c57ab0f9954584ccd580514a40c9a32647e76
3
+ size 176485
pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/b1e240a5-63a9-45b2-9edf-2f0f76e4b7e7_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c48e83677c93b8eebbb59cd3dd2b6b79192c88686eeffb82275816568a707b31
3
+ size 841840
pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/full.md ADDED
The diff for this file is too large to render. See raw diff
 
pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37d09641d2565a9632efee3290bc9fb0ea559a69f72a433cd7980f56c9c41a5c
3
+ size 1507436
pacfnoparallelstructuredallcomponentfourierneuraloperatorsforrecognizinglowqualityimages/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6ced7ed6432434f06b1fedc4e604532d9fc773c28b69252bc2f6ef9d037e7e6
3
+ size 625089
pacpredictionsetsunderlabelshift/80aefd3c-e03b-40b1-a6e1-2b267f349698_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:91166a9978650245b147ba797cf34a7fb2fdba33327e237e08d4a23d4d408031
3
+ size 141202
pacpredictionsetsunderlabelshift/80aefd3c-e03b-40b1-a6e1-2b267f349698_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a01ef317d6ea245157e45c3ad04232b3b93ad33b595ae89b4832bed75eac728
3
+ size 169211
pacpredictionsetsunderlabelshift/80aefd3c-e03b-40b1-a6e1-2b267f349698_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e493dcd83c4f7c1c216a0df33aba4e5d4c8f4db1cce7bbd503e4f85bd9f4d881
3
+ size 1592252
pacpredictionsetsunderlabelshift/full.md ADDED
@@ -0,0 +1,694 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PAC PREDICTION SETS UNDER LABEL SHIFT
2
+
3
+ Wenwen Si $^{1}$ , Sangdon Park $^{2}$ , Insup Lee $^{1}$ , Edgar Dobriban $^{3}$ , Osbert Bastani $^{1}$
4
+
5
+ $^{1}$ Department of Computer & Information Science, University of Pennsylvania
6
+ 2Graduate School of AI and Computer Science & Engineering, POSTECH
7
+ $^{3}$ Department of Statistics and Data Science, University of Pennsylvania
8
+
9
+ {wenwens,lee,obastani}@seas.upenn.edu,sangdon@postech.ac.kr
10
+
11
+ dobriban@wharton.upenn.edu
12
+
13
+ # ABSTRACT
14
+
15
+ Prediction sets capture uncertainty by predicting sets of labels rather than individual labels, enabling downstream decisions to conservatively account for all plausible outcomes. Conformal inference algorithms construct prediction sets guaranteed to contain the true label with high probability. These guarantees fail to hold in the face of distribution shift, which is precisely when reliable uncertainty quantification can be most useful. We propose a novel algorithm for constructing prediction sets with PAC guarantees in the label shift setting, where the probabilities of labels can differ between the source and target distributions. Our algorithm relies on constructing confidence intervals for importance weights by propagating uncertainty through a Gaussian elimination algorithm. We evaluate our approach on four datasets: the CIFAR-10 and ChestX-Ray image datasets, the tabular CDC Heart Dataset, and the AGNews text dataset. Our algorithm satisfies the PAC guarantee while producing smaller prediction set sizes compared to several baselines.
16
+
17
+ # 1 INTRODUCTION
18
+
19
+ Uncertainty quantification can be a critical tool for building reliable systems from machine learning components. For example, a medical decision support system can convey uncertainty to a doctor, or a robot can act conservatively with respect to uncertainty. These approaches are particularly important when the data distribution shifts as the predictive system is deployed, since they enable the decision-maker to react to degraded performance.
20
+
21
+ Conformal prediction (Vovk et al., 2005; Angelopoulos & Bates, 2021) is a promising approach to uncertainty quantification, aiming to outputs sets of labels instead of a single label. Under standard assumptions (i.i.d. or exchangeable data), it guarantees that the prediction set contains the true label with high probability. We consider probably approximately correct (PAC) (or calibration-set-conditional) guarantees (Vovk, 2012; Park et al., 2019), which ensure high probability coverage over calibration datasets used to construct the prediction sets.
22
+
23
+ In this paper, we propose a novel prediction set algorithm that provides PAC guarantees under the label shift setting, where the distribution of the labels may shift, but the distribution of covariates conditioned on the labels remains fixed. For instance, during a pandemic, a disease may spread to a much larger fraction of the population, but the manifestations of the disease may remain the same. As another example, real-world data may have imbalanced classes, unlike the balanced classes typical of curated training datasets. We consider the unsupervised domain adaptation setting (Ben-David et al., 2006), where we are given labeled examples from a source domain, but only unlabeled examples from the target domain, and care about performance in the target domain.
24
+
25
+ A standard way to adapt conformal inference to handle distribution shift is by using importance weighting to "convert" data from the source distribution into data from the target distribution (Tibshirani et al., 2019). In the label shift setting, one possible way to express the importance weights is $w^{*} = \mathbf{C}_{P}^{-1}q^{*}$ , where $\mathbf{C}_P$ is the confusion matrix and $q^{*}$ is the distribution of predicted labels (Lipton et al., 2018); see details below. However, the estimation error for the unknown $\mathbf{C}_P$ and $q^{*}$ breaks the PAC guarantee.
26
+
27
+ ![](images/bbb721aa87344bae3bb2dbdb87b3523f1316a3b9499177a778e6a529453251d3.jpg)
28
+ Figure 1: An example of our approach on the ChestX-ray dataset. In the unshifted setting, standard PAC prediction sets guarantee high-probability coverage, but this guarantee fails under label shift. Our approach addresses this challenge and continues to work in the shifted environment.
29
+
30
+ Instead, we construct confidence intervals around $\mathbf{C}_P$ and $q^*$ , and then devise a novel algorithm to propagate these intervals through the Gaussian elimination algorithm used to compute $w^*$ . Finally, we leverage an existing strategy for constructing PAC prediction sets when given confidence intervals for the importance weights (Park et al., 2021).
31
+
32
+ We empirically evaluate our approach on four datasets across three application domains: CIFAR-10 (Krizhevsky et al., 2009) in the computer vision domain, the CDC Heart Dataset (Centers for Disease Control and Prevention (CDC), 1984) and ChestX-ray (National Institutes of Health and others, 2022) in the medical domain, and AGNews (Zhang et al., 2015) in the language domain.
33
+
34
+ Contributions. We propose a novel algorithm for constructing PAC prediction sets in the presence of label shift, which computes provably valid intervals around the true importance weights. Our algorithm is based on a technique for propagating confidence intervals through the updates of Gaussian elimination, which to our knowledge is a novel approach to uncertainty propagation in a prediction set construction setting. Finally, we empirically demonstrate that our approach satisfies the PAC guarantee while constructing smaller prediction sets than several baselines.
35
+
36
+ Example. Figure 1 illustrates a use case of our technique on the ChestX-ray dataset. In medical settings, prediction sets (denoted PS) provide a rigorous way to quantify uncertainty for making downstream decisions. In particular, they can guarantee that the prediction set contains the true label (in this case, a diagnosis) with high probability. However, label shift happens commonly in medical settings, for instance, many illnesses have varying rates of incidence over time even when the patient population remains the same. Unfortunately, label shift breaks the PAC coverage guarantee. Our approach (denoted PSW) corrects for the label shift via importance weighting; it does so in a provably correct way. The resulting prediction sets satisfy the PAC guarantee.
37
+
38
+ Related work. There has been recent interest in conformal inference under distribution shift, much of it focusing on covariate shift (Tibshirani et al., 2019; Lei & Candès, 2021; Qiu et al., 2022). (Podkopaev & Ramdas, 2021) develop methods for marginal coverage under label shift, whereas we are interested in training-set conditional—or PAC—guarantees. Furthermore, they formally assume that the true importance weights are known exactly, which is rarely the case. In the label shift setting, the importance weights can be estimated (Lipton et al., 2018), but as we show in our experiments, uncertainty in these estimates must be handled for the PAC guarantee to hold.
39
+
40
+ We leverage the method of (Park et al., 2021) to handle estimation error in the importance weights. That work studies covariate shift, and uses a heuristic to obtain intervals around the importance weights. For the label shift setting, we can in fact obtain stronger guarantees: we modify Gaussian
41
+
42
+ elimination to propagate uncertainty through the computation of the weights $w^{*} = \mathbf{C}_{P}^{-1}q^{*}$ . We give a more comprehensive discussion of related work in Appendix A.
43
+
44
+ # 2 PROBLEM FORMULATION
45
+
46
+ # 2.1 BACKGROUND ON LABEL SHIFT
47
+
48
+ Consider the goal of training a classifier $g: \mathcal{X} \to \mathcal{Y}$ , where $\mathcal{X} \subseteq \mathbb{R}^d$ is the covariate space, and $\mathcal{Y} = [K] = \{1, \dots, K\}$ is the set of labels. We consider the setting where we train on one distribution $P$ over $\mathcal{X} \times \mathcal{Y}$ —called the source—with a probability density function (PDF) $p: (x, y) \mapsto p(x, y)$ and evaluate on a potentially different test distribution $Q$ —called the target—with PDF $q: (x, y) \mapsto q(x, y)$ . We focus on the unsupervised domain adaptation setting (Ben-David et al., 2007), where we are given an i.i.d. sample $S_m \sim P^m$ of $m$ labeled datapoints, and an i.i.d. sample of $n$ unlabeled datapoints $T_X^n \sim Q_X^n$ . The label shift setting (Lipton et al., 2018) assumes that only the label distribution $Q_Y$ may be change from $P_Y$ , and the conditional covariate distributions remain the same:
49
+
50
+ Assumption 2.1. (Label shift) We have $p(x \mid y) = q(x \mid y)$ for all $x \in \mathcal{X}, y \in \mathcal{Y}$ .
51
+
52
+ We denote $p(y) = P_{Y}(Y = y)$ for all $y \in \mathcal{V}$ and analogously for $Q$ . (Lipton et al., 2018) consider two additional mild assumptions:
53
+
54
+ Assumption 2.2. For all $y \in \mathcal{V}$ such that $q(y) > 0$ , we have $p(y) > 0$ .
55
+
56
+ Next, given the trained classifier $g: \mathcal{X} \to \mathcal{Y}$ let $\mathbf{C}_P \in \mathbb{R}^{K \times K}$ denote its expected confusion matrix—i.e., $c_{ij} := (\mathbf{C}_P)_{ij} = \mathbb{P}_{(X,Y) \sim P}(g(X) = i, Y = j)$ .
57
+
58
+ Assumption 2.3. The confusion matrix $\mathbf{C}_P$ is invertible.
59
+
60
+ This last assumption requires that the per-class expected predictor outputs be linearly independent; for instance, it is satisfied when $g$ is reasonably accurate across all labels. In addition, one may test whether this assumption holds (Lipton et al., 2018).
61
+
62
+ Denoting the importance weights $w^{*} \coloneqq (q(y) / p(y))_{y \in \mathcal{Y}} \in \mathbb{R}^{K}$ , and $\hat{y} \coloneqq g(x)$ , we will write $p(\hat{y} | y) = \mathbb{P}_{(X,Y) \sim P}[g(X) = \hat{y} | Y = y]$ , and define $p(\hat{y}, y)$ , $p_{\hat{y}}$ as well as the corresponding expressions for $q$ analogously. Since $\hat{y}$ depends only on $x$ , we have $q(\hat{y} | y) = p(\hat{y} | y)$ . Thus, see e.g., Lipton et al. (2018),
63
+
64
+ $$
65
+ q _ {\hat {y}} = \sum_ {y \in \mathcal {Y}} q (\hat {y} \mid y) q (y) = \sum_ {y \in \mathcal {Y}} p (\hat {y} \mid y) q (y) = \sum_ {y \in \mathcal {Y}} p (\hat {y}, y) \frac {q (y)}{p (y)},
66
+ $$
67
+
68
+ or in a matrix form, $q^{*} = \mathbf{C}_{P}w^{*}$ , where $q^{*} \coloneqq (q_{\hat{y}})_{\hat{y} \in \mathcal{Y}} \in \mathbb{R}^{K}$ . As we assume $\mathbf{C}_P$ is invertible,
69
+
70
+ $$
71
+ w ^ {*} = \mathbf {C} _ {P} ^ {- 1} q ^ {*}. \tag {1}
72
+ $$
73
+
74
+ Our algorithm uses this equation to approximate $w^{*}$ , and then use its approximation to construct PAC prediction sets that remain valid under label shift.
75
+
76
+ # 2.2 PAC PREDICTION SETS UNDER LABEL SHIFT
77
+
78
+ We are interested in constructing a prediction set $C: \mathcal{X} \to 2^{\mathcal{V}}$ , which outputs a set of labels $C(x) \subseteq \mathcal{V}$ for each given input $x \in \mathcal{X}$ rather than a single label. The benefit of outputting a set of labels is that we can obtain correctness guarantees such as:
79
+
80
+ $$
81
+ \mathbb {P} _ {(X, Y) \sim P} [ Y \in C (X) ] \geq 1 - \varepsilon , \tag {2}
82
+ $$
83
+
84
+ where $\varepsilon \in (0,1)$ is a user-provided confidence level. Then, downstream decisions can be made in a way that accounts for all labels $y \in C(x)$ rather than for a single label. Thus, prediction sets quantify uncertainty. Intuitively, equation 2 can be achieved if we output $C(x) = \mathcal{Y}$ for all $x \in \mathcal{X}$ , but this is not informative. Instead, the typical goal is to output prediction sets that are as small as possible.
85
+
86
+ The typical strategy for constructing prediction sets is to leverage an fixed existing model. In particular, we assume given a scoring function $f: \mathcal{X} \times \mathcal{Y} \to \mathbb{R}$ ; most deep learning algorithms provide such scores in the form of predicted probabilities, with the corresponding classifier being $g(x) =$
87
+
88
+ arg $\max_{y\in \mathcal{Y}}f(x,y)$ . The scores do not need to be reliable in any way; if they are unreliable, the PAC prediction set algorithm will output larger sets. Then, we consider prediction sets parameterized by a real-valued threshold $\tau \in \mathbb{R}$ :
89
+
90
+ $$
91
+ C _ {\tau} (x) = \{y \in \mathcal {Y} \mid f (x, y) \geq \tau \}.
92
+ $$
93
+
94
+ In other words, we include all labels with score at least $\tau$ . First, we focus on correctness for $P$ , in which case we only need $S_{m}$ , usually referred to as the calibration set. Then, a prediction set algorithm constructs a threshold $\hat{\tau}(S_m) \in \mathbb{R}$ and returns $C_{\hat{\tau}(S_m)}$ .
95
+
96
+ Finally, we want $\hat{\tau}$ to satisfy (2); one caveat is that it may fail to do so due to randomness in $S_{m}$ . Thus, we allow an additional probability $\delta \in \mathbb{R}$ of failure, resulting in the following desired guarantee:
97
+
98
+ $$
99
+ \mathbb {P} _ {S _ {m} \sim P ^ {m}} \left[ \mathbb {P} _ {(X, Y) \sim P} [ Y \in C _ {\hat {\tau} (S _ {m})} (X) ] \geq 1 - \varepsilon \right] \geq 1 - \delta . \tag {3}
100
+ $$
101
+
102
+ Vovk (2012); Park et al. (2019) propose an algorithm $\hat{\tau}$ that satisfies (3), see Appendix B.
103
+
104
+ Finally, we are interested in constructing PAC prediction sets in the label shift setting, using both the labeled calibration dataset $S_{m} \sim P^{m}$ from the source domain, and the unlabeled calibration dataset $T_{n}^{X} \sim Q^{n}$ from the target distribution. Our goal is to construct $\hat{\tau}(S_{m}, T_{n}^{X})$ based on both $S_{m}$ and $T_{n}^{X}$ , which satisfies the coverage guarantee over $Q$ instead of $P$ :
105
+
106
+ $$
107
+ \mathbb {P} _ {S _ {m} \sim P ^ {m}, T _ {n} ^ {X} \sim Q _ {X} ^ {n}} \left[ \mathbb {P} _ {(X, Y) \sim Q} [ Y \in C _ {\hat {\tau} (S _ {m}, T _ {n} ^ {X})} (X) ] \geq 1 - \varepsilon \right] \geq 1 - \delta . \tag {4}
108
+ $$
109
+
110
+ Importantly, the inner probability is over the shifted distribution $Q$ instead of $P$ .
111
+
112
+ # 3 ALGORITHM
113
+
114
+ To construct prediction sets valid under label shift, we first notice that it is enough to find elementwise confidence intervals for the importance weights $w^{*}$ . Suppose that we can construct $W = \prod_{k\in \mathcal{Y}}[\underline{w}_k,\overline{w}_k]\subseteq \mathbb{R}^K$ such that $w^{*}\in W$ . Then, when adapted to our setting, the results of Park et al. (2021)—originally for the covariate shift problem—provide an algorithm that returns a threshold $\hat{\tau} (S_m,V,W,b)$ , where $V\sim \mathrm{Uniform}([0,1])^{K}$ is a vector of random variables, such that
115
+
116
+ $$
117
+ \mathbb {P} _ {S _ {m} \sim P ^ {m}, V \sim U ^ {K}} \left[ \mathbb {P} _ {(X, Y) \sim Q} [ Y \in C _ {\hat {\tau} (S _ {m}, V, W, b)} ] \geq 1 - \varepsilon \right] \geq 1 - \delta . \tag {5}
118
+ $$
119
+
120
+ This is similar to equation 4 but it accounts for the randomness used by our algorithm—via $V$ —in the outer probability. We give the details in Appendix C.
121
+
122
+ The key challenge is to construct $W = \prod_{k\in \mathcal{Y}}[\underline{w}_k,\overline{w}_k]$ such that $w^{*}\in W$ with high probability. The approach from Park et al. (2021) for the covariate shift problem relies on training a source-target discriminator, which is not possible in our case since we do not have class labels from the target domain. Furthermore, Park et al. (2021)'s approach is does not provide conditions under which one can provide a valid confidence interval for the importance weights in their setting.
123
+
124
+ Our algorithm uses a novel approach, where we propagate intervals through the computation of importance weights. The weights $w^{*}$ are determined by the system of linear equations $\mathbf{C}_P w^{*} = q^{*}$ . Since $\mathbf{C}_P$ and $q^{*}$ are unknown, we start by constructing element-wise confidence intervals
125
+
126
+ $$
127
+ \underline {{\mathbf {C}}} _ {P} \leq \mathbf {C} _ {P} \leq \overline {{\mathbf {C}}} _ {P} \quad \text {a n d} \quad \underline {{q}} ^ {*} \leq q ^ {*} \leq \bar {q} ^ {*}, \tag {6}
128
+ $$
129
+
130
+ with probability at least $1 - \delta$ over our calibration datasets $S_{m}$ and $T_{n}^{X}$ . We then propagate these confidence intervals through each step of Gaussian elimination, such that at the end of the algorithm, we obtain confidence intervals for its output—i.e.,
131
+
132
+ $$
133
+ \underline {{w}} ^ {*} \leq w ^ {*} \leq \overline {{w}} ^ {*} \quad \text {w i t h p r o b a b i l i t y a t l e a s t} 1 - \delta . \tag {7}
134
+ $$
135
+
136
+ Finally, we can use (7) with the algorithm from (Park et al., 2021) to construct PAC prediction sets under label shift. We describe our approach below.
137
+
138
+ # 3.1 ELEMENTWISE CONFIDENCE INTERVALS FOR $\mathbf{C}_P$ AND $q^{*}$
139
+
140
+ Recall that $\mathbf{C}_P = (c_{ij})_{ij\in \mathcal{Y}}$ and $q^{*} = (q_{k})_{k\in \mathcal{Y}}$ . Note that $c_{ij} = \mathbb{P}[g(X) = i,Y = j]$ is the mean of the Bernoulli random variable $\mathbb{1}(g(X) = i,Y = j)$ over the randomness in $(X,Y)\sim P$ .
141
+
142
+ Similarly, $q_{k}$ is the mean of $\mathbb{1}(g(X) = k)$ over the randomness in $X \sim Q_{X}$ . Thus, we can use the Clopper-Pearson (CP) intervals (Clopper & Pearson, 1934) for a Binomial success parameter to construct intervals around $c_{ij}$ and $q_{k}$ . Given a confidence level $\delta \in (0,1)$ and the sample mean $\hat{c}_{ij} = \frac{1}{m}\sum_{(x,y)\in S_m}\mathbb{1}(g(x) = i,y = j)$ distributed as a scaled Binomial random variable—this is an interval $\mathrm{CP}(\hat{c}_{ij},m,\delta) = [\underline{c}_{ij},\overline{c}_{ij}]$ such that
143
+
144
+ $$
145
+ \mathbb {P} _ {S _ {m} \sim P ^ {m}} [ c _ {i j} \in \mathrm {C P} (\hat {c} _ {i j}, m, \delta) ] \geq 1 - \delta .
146
+ $$
147
+
148
+ Similarly, for $q_{k}$ , we can construct CP intervals based on $\hat{q}_{k} = \frac{1}{n}\sum_{x\in T_{n}^{X}}\mathbb{1}(g(x) = k)$ . Together, for confidence levels $\delta_{ij}$ and $\delta_{k}$ chosen later, we obtain for all $i,j,k\in [K]$
149
+
150
+ $$
151
+ \mathbb {P} _ {S _ {m} \sim P ^ {m}} \left[ \underline {{c}} _ {i j} \leq c _ {i j} \leq \bar {c} _ {i j} \right] \geq 1 - \delta_ {i j}, \quad \mathbb {P} _ {T _ {n} ^ {X} \sim Q _ {X} ^ {n}} \left[ \underline {{q}} _ {k} \leq q _ {k} \leq \bar {q} _ {k} \right] \geq 1 - \delta_ {k}. \tag {8}
152
+ $$
153
+
154
+ Then, the following result holds by a union bound: Given any $\delta_{ij},\delta_k\in (0,\infty)$ , for all $i,j,k\in [K]$ letting $[\underline{c}_{ij},\overline{c}_{ij}] = \mathrm{CP}(\hat{c}_{ij},m,\delta_{ij})$ and $[\underline{q}_k,\overline{q}_k] = \mathrm{CP}(\hat{q}_k,n,\delta_k)$ , and letting $\delta = \sum_{i,j\in [K]}\delta_{ij} + \sum_{k\in [K]}\delta_k$ , we have
155
+
156
+ $$
157
+ \mathbb {P} _ {S _ {m} \sim P ^ {m}, T _ {n} ^ {X} \sim Q _ {X} ^ {n}} \left[ \bigwedge_ {i, j \in [ K ]} \underline {{c}} _ {i j} \leq c _ {i j} \leq \bar {c} _ {i j}, \bigwedge_ {k \in [ K ]} \underline {{q}} _ {k} \leq q _ {k} \leq \bar {q} _ {k} \right] \geq 1 - \delta . \tag {9}
158
+ $$
159
+
160
+ # 3.2 GAUSSIAN ELIMINATION WITH INTERVALS
161
+
162
+ We also need to set up notation for Gaussian elimination, which requires us to briefly recall the algorithm. To solve $\mathbf{C}_P w^* = q^*$ , Gaussian elimination (see e.g., Golub & Van Loan, 2013) proceeds in two phases. Starting with $c^0 = \mathbf{C}_P$ and $q^0 = q^*$ , on iteration $t \geq 1$ , Gaussian elimination uses row $k = t$ to eliminate the $k$ th column of rows $i \in \{k + 1, \dots, K\}$ (we introduce a separate variable $k$ for clarity). In particular, if $c_{kk}^t \neq 0$ , we denote
163
+
164
+ $$
165
+ c _ {i j} ^ {t + 1} = \left\{ \begin{array}{l l} c _ {i j} ^ {t} - \frac {c _ {i k} ^ {t} c _ {k j} ^ {t}}{c _ {k k} ^ {t}} & \text {i f} i > k, \\ c _ {i j} ^ {t} & \text {o t h e r w i s e}; \end{array} \right. \qquad q _ {i} ^ {t + 1} = \left\{ \begin{array}{l l} q _ {i} ^ {t} - \frac {c _ {i k} ^ {t} q _ {k} ^ {t}}{c _ {k k} ^ {t}} & \text {i f} i > k \\ q _ {i} ^ {t} & \text {o t h e r w i s e}, \end{array} \right. \qquad \forall i, j \in [ K ].
166
+ $$
167
+
168
+ If $c_{kk}^t = 0$ , but there is an element $j > k$ in the $k$ th column such that $c_{jk}^t \neq 0$ , the $k$ th and the $j$ th rows are swapped and the above steps are executed. If no such element exists, the algorithm proceeds to the next step. At the end of the first phase, the matrix $c^{K-1}$ has all elements below the diagonal equal to zero—i.e., $c_{ij}^{K-1} = 0$ if $j < i$ . In the second phase, the Gaussian elimination algorithm solves for $w_i^*$ backwards from $i = K$ to $i = 1$ , introducing the following notation. For each $i$ , if $c_{ii}^{K-1} \neq 0$ , we denote $w_i^* = (q_i - s_i) / c_{ii}^{K-1}$ , where $s_i = \sum_{j=i+1}^{K} c_{ij}^{K-1} w_j^*$ .
169
+
170
+ In our setting, we do not know $c^0$ and $q^0$ ; instead, we assume given entrywise confidence intervals as in equation 6, which amount to $\underline{c}^0 \leq c^0 \leq \overline{c}^0$ and $\underline{q}^0 \leq q^0 \leq \overline{q}^0$ . We now work on the event $\Omega$ that these bounds hold, and prove that our algorithm works on this event; later, we combine this result with Equation 9 to obtain a high-probability guarantee. Then, our goal is to compute $\underline{c}^t, \overline{c}^t, \underline{q}^t, \overline{q}^t$ such that for all iterations $t \in \{0,1,\dots,K-1\}$ , we have elementwise confidence intervals specified by $\underline{c}^t, \overline{c}^t, \underline{q}^t$ and $\overline{c}^t$ for the outputs $c^t, q^t$ of the Gaussian elimination algorithm:
171
+
172
+ $$
173
+ \underline {{c}} ^ {t} \leq c ^ {t} \leq \bar {c} ^ {t} \quad \text {a n d} \quad \underline {{q}} ^ {t} \leq q ^ {t} \leq \bar {q} ^ {t}. \tag {10}
174
+ $$
175
+
176
+ The base case $t = 0$ holds by the assumption. Next, to propagate the uncertainty through the Gaussian elimination updates for each iteration $t \in [K - 1]$ , our algorithm sets
177
+
178
+ $$
179
+ \underline {{c}} _ {i j} ^ {t + 1} = \left\{ \begin{array}{l l} 0 & \text {i f} i > k, j \leq k, \\ \underline {{c}} _ {i j} ^ {t} - \frac {\bar {c} _ {i k} ^ {t} \bar {c} _ {k j} ^ {t}}{\underline {{c}} _ {k k} ^ {t}} & \text {i f} i, j > k, \quad \forall i, j \in [ K ] \\ \underline {{c}} _ {i j} ^ {t} & \text {o t h e r w i s e} \end{array} \right. \tag {11}
180
+ $$
181
+
182
+ for the lower bound, and computes
183
+
184
+ $$
185
+ \bar {c} _ {i j} ^ {t + 1} = \left\{ \begin{array}{l l} 0 & \text {i f} i > k, j \leq k, \\ \bar {c} _ {i j} ^ {t} - \frac {\underline {{c}} _ {i k} ^ {t} \underline {{c}} _ {k j} ^ {t}}{\bar {c} _ {k k} ^ {t}} & \text {i f} i, j > k, \quad \forall i, j \in [ K ] \\ \bar {c} _ {i j} ^ {t} & \text {o t h e r w i s e} \end{array} \right. \tag {12}
186
+ $$
187
+
188
+ for the upper bound. The first case handles the fact that Gaussian elimination is guaranteed to zero out entries below the diagonal, and thus these entries have no uncertainty remaining. The second rule constructs confidence intervals based on the previous intervals and the algebraic update formulas used in Gaussian elimination for the entries for which $i,j > k$ . For instance, the above confidence intervals use that on the event $\Omega$ , and by induction on $t$ , if $c_{ij}^{t}\geq 0$ and $c_{ii}^{t} > 0$ for all $i,j\in [K]$ and for all $t$ , the Gaussian elimination update $c_{ij}^{t + 1} = c_{ij}^{t} - c_{it}^{t}c_{tj}^{t} / c_{tt}^{t}$ can be upper bounded as
189
+
190
+ $$
191
+ c _ {i j} ^ {t + 1} = c _ {i j} ^ {t} - \frac {c _ {i t} ^ {t} c _ {t j} ^ {t}}{c _ {t t} ^ {t}} \leq \bar {c} _ {i j} ^ {t} - \frac {\underline {{c}} _ {i t} ^ {t} \underline {{c}} _ {t j} ^ {t}}{\bar {c} _ {t t} ^ {t}} = \bar {c} _ {i j} ^ {t + 1}, \tag {13}
192
+ $$
193
+
194
+ The assumptions that $\underline{c}_{ij}^t \geq 0$ and $\underline{c}_{ii}^t > 0$ for all $i, j \in [K]$ and for all $t$ may appear a little stringent, but the former can be removed at the cost of slightly larger intervals propagated to the next step, see Section D. The latter condition is satisfied by any classifier that obtains sufficient accuracy on all labels. We further discuss these conditions in Section D. The third rule in equation 11 and equation 12 handles the remaining entries, which do not change; and thus the confidence intervals from the previous step can be used. The rules for $q$ are similar, and have a similar justification:
195
+
196
+ $$
197
+ \underline {{q}} _ {i} ^ {t + 1} = \left\{ \begin{array}{l l} \underline {{q}} _ {i} ^ {t} - \frac {\overline {{c}} _ {i k} ^ {t} \overline {{q}} _ {i} ^ {t}}{\underline {{c}} _ {k k} ^ {t}} & \text {i f} i > k, \\ \underline {{q}} _ {i} ^ {t} & \text {o t h e r w i s e}; \end{array} \right. \quad \overline {{q}} _ {i} ^ {t + 1} = \left\{ \begin{array}{l l} \overline {{q}} _ {i} ^ {t} - \frac {\underline {{c}} _ {i k} ^ {t} \underline {{q}} _ {i} ^ {t}}{\overline {{c}} _ {k k} ^ {t}} & \text {i f} i > k, \\ \overline {{q}} _ {i} ^ {t} & \text {o t h e r w i s e}. \end{array} \right. \quad \forall i \in [ K ]. \tag {14}
198
+ $$
199
+
200
+ For these rules, our algorithm assumes $\underline{q}_i^t \geq 0$ for all $i \in [K]$ and all $t$ , and raises an error if this fails. As with the first condition above, this one can be straightforwardly relaxed; see Appendix D.
201
+
202
+ In the second phase, we compute $w_{i}^{*}$ starting from $i = K$ and iterating to $i = 1$ . On iteration $i$ , we assume we have the confidence intervals $\underline{w}_{j}^{*} \leq w_{j}^{*} \leq \overline{w}_{j}^{*}$ for $j > i$ . Then, we compute confidence intervals for the sum $s_{i}$ , with a similar justification based on the Gaussian elimination updates:
203
+
204
+ $$
205
+ \underline {{s}} _ {i} = \sum_ {j = i + 1} ^ {n} \underline {{c}} _ {i j} ^ {K - 1} \underline {{w}} _ {j} ^ {*} \quad \text {a n d} \quad \overline {{s}} _ {i} = \sum_ {j = i + 1} ^ {n} \bar {c} _ {i j} ^ {K - 1} \bar {w} _ {j} ^ {*}, \tag {15}
206
+ $$
207
+
208
+ and show that they satisfy $\underline{s}_i\leq s_i\leq \overline{s}_i$ on the event $\Omega$ . Finally, we compute confidence intervals for $w_{i}^{*}$ , assuming $\underline{c}_{ii}^{K - 1} > 0$ :
209
+
210
+ $$
211
+ \underline {{w}} _ {i} ^ {*} = \frac {\underline {{q}} _ {i} - \bar {s} _ {i}}{\bar {c} _ {i i} ^ {K - 1}} \quad \text {a n d} \quad \overline {{w}} _ {i} ^ {*} = \frac {\bar {q} _ {i} - \underline {{s}} _ {i}}{\underline {{c}} _ {i i} ^ {K - 1}}, \tag {16}
212
+ $$
213
+
214
+ for which we can show that they satisfy $\underline{w}_i^* \leq w_i^* \leq \overline{w}_i^*$ based on the Gaussian elimination updates. Letting $W = \{w \mid \underline{w}^* \leq w \leq \overline{w}^*\}$ , we have the following (see Appendix E for a proof).
215
+
216
+ Lemma 3.1 (Elementwise Confidence Interval for Importance Weights). If (6) holds, and for all $i,j,t\in [K]$ , $\underline{c}_{ij}^{t}\geq 0$ , $\underline{c}_{ii}^{t} > 0$ , and $\underline{q}_i^t\geq 0$ , then $w^{*} = \mathbf{C}_{P}^{-1}q^{*}\in W$
217
+
218
+ We mention here that the idea of algorithmic uncertainty propagation may be of independent interest. In future work, it may further be developed to other methods for solving linear systems (e.g., the LU decomposition, Golub & Van Loan (2013)), and other linear algebraic and numerical computations.
219
+
220
+ # 3.3 OVERALL ALGORITHM
221
+
222
+ Algorithm 1 summarizes our approach. As can be seen, the coverage levels for the individual Clopper-Pearson intervals are chosen to satisfy the overall $1 - \delta$ coverage guarantee. In particular, the PAC guarantee equation 4 follows from equation 5, equation 9, Lemma 3.1, and a union bound; we provide a more detailed explanation in Appendix F.
223
+
224
+ Theorem 3.2 (PAC Prediction Sets under Label Shift). For any given $\varepsilon, \delta \in (0,1)$ , under Assumptions 2.1, 2.2 and 2.3, if $\forall i, j, t \in [K]$ , we have $\underline{c}_{ij}^t \geq 0$ , $\underline{c}_{ii}^t > 0$ , and $\underline{q}_i^t \geq 0$ , then Algorithm 1 satisfies
225
+
226
+ $$
227
+ \mathbb {P} _ {S _ {m} \sim P ^ {m}, T _ {n} ^ {X} \sim Q ^ {n}, V \sim U ^ {m}} \left[ \mathbb {P} _ {(X, Y) \sim Q} \left[ Y \in C _ {\hat {\tau} (S _ {m}, V, W, b)} (X) \right] \geq 1 - \varepsilon \right] \geq 1 - \delta .
228
+ $$
229
+
230
+ As discussed in Appendix D, we can remove the requirement that $\underline{c}_{ij}^t\geq 0$ and $\underline{q}_i^t\geq 0$ for $i\neq j$
231
+
232
+ Algorithm 1 PS-W: PAC prediction sets in the label shift setting.
233
+ 1: procedure LABELSHIFTPREDICTIONSET(Sm,Tx,f,ε,δ)
234
+ 2: c, $\overline{c},\underline{q},\overline{q}\gets$ CPINTERVAL(Sm,Tx,x→arg maxy∈yf(x,y),K(K+1)/(K(K+1)+1)δ)
235
+ 3: W←INTERVALGAUSSIANELIM(c, $\overline{c},\underline{q},\overline{q})$
236
+ 4: if W=0 then return 0
237
+ 5: return IWPREDICTIONSET(Sm,f,W,ε,δ/[K(K+1)+1])
238
+ 6: procedure CPINTERVAL(Sm,Tx,g,δ)
239
+ 7: for i,j∈[K] do
240
+ 8: Compute [cij, $\overline{c}_{ij}]$ =CP(m-1∑(x,y)∈Sm1(g(x)=i,y=j),m,δ/(K(K+1)))
241
+ 9: for k∈[K] do
242
+ 10: Compute [k, $\overline{q}_k$ ]=CP(n-1∑x∈TnX1(g(x)=k),n,δ/(K(K+1)))
243
+ 11: return c, $\overline{c},\underline{q},\overline{q}$
244
+ 12: procedure INTERVALGAUSSIANELIM(c0, $\overline{c}^0,\underline{q}^0,\overline{q}^0$ )
245
+ 13: for t∈[1,...,K-1] do
246
+ 14: for i,j∈[K] do
247
+ 15: Compute $\underline{c}_{ij}^{t},\overline{c}_{ij}^{t}$ using (11)&(12), and $\underline{q}_i^t,\overline{q}_i^t$ using (14)
248
+ 16: if $\underline{c}_{ij}^{t}< 0$ for some $i\neq j$ or $\underline{c}_{ii}^{t}\leq 0$ for some $i$ or $\underline{q}_i^t\leq 0$ for some $i$ , then return 0
249
+ 17: for i∈[K,...,1] do
250
+ 18: Compute $\underline{s}_i^t,\overline{s}_i^t$ using (15), and $\underline{w}_i,\overline{w}_i$ using (16)
251
+ 19: return W= $\prod_{i=1}^{k}[\underline{w}_i,\overline{w}_i]$
252
+ 20: procedure IWPREDICTIONSET(Sm,f,W= $\prod_{k=1}^{K}[\underline{w}_k,\overline{w}_k],\varepsilon,\delta$ )
253
+ 21: V~Uniform([0,1])m
254
+ 22: return $\hat{\tau}(S_m,V,W,\max_{k\in[K]}\overline{w}_k,\varepsilon,\delta)$ as in (18)
255
+
256
+ # 4 EXPERIMENTS
257
+
258
+ # 4.1 EXPERIMENTAL SETUP
259
+
260
+ Predictive models. We analyze four datasets: the CDC Heart dataset, CIFAR-10, Chest X-ray, and the AG News dataset; details are provided in Section 4.2. We use a two-layer MLP for the CDC Heart data with an SGD optimizer having a learning rate of 0.03 and a momentum of 0.9, using a batch size of 64 for 30 epochs. For CIFAR-10, we finetune a pretrained ResNet50 He et al. (2016), with a learning rate of 0.01 for 56 epochs. For the ChestX-ray14 dataset, we use a pre-trained CheXNet (Rajpurkar et al., 2017) with a DenseNet121 (Huang et al., 2017) backbone with a learning rate of 0.0003 for two epochs. For AGNews, we fine-tune a pre-trained Electra sequence classifier for one epoch with an AdamW optimizer using a learning rate of 0.00001.
261
+
262
+ Hyperparameter choices. There are two user-specified hyperparameters that control the guarantees, namely $\delta$ and $\varepsilon$ . In our experiments, we choose $\delta = 5 \times 10^{-4}$ to ensure that, over 100 independent datasets $S_{m}$ , there is a $95\%$ probability that the error rate is not exceeded. Specifically, this ensures that $\mathbb{P}_{(X,Y)\sim P}[Y \in C_{\hat{\tau}(S_m)}(X)] \geq 1 - \varepsilon$ holds for all 100 trials, with probability approximately $1 - 0.95^{1/100} \approx 5 \times 10^{-4}$ . We select $\varepsilon$ for each dataset in a way that the resulting average prediction set size is greater than one. This ensures that the coverage guarantee is non-trivial, as a single-valued classifier should not achieve the desired coverage rate (as $\delta$ is small).
263
+
264
+ Dataset construction. We follow the label shift simulation strategies from previous work (Lipton et al., 2018). First, we split the full dataset into training data, and "base" source and target datasets. We use the training dataset to fit a score function. Given label distributions $P_{Y}$ and $Q_{Y}$ , we generate the source dataset $S_{m}$ , target dataset $T_{n}^{X}$ , and a labeled, size $o$ target test dataset (sampled from $Q$ ) by sampling with replacement from the corresponding base datasets. We consider two choices of $P_{Y}$ and $Q_{Y}$ : (i) a tweak-one shift, where change the probability of one label, and keep the relative proportions of the other labels equally likely, and (ii) a general shift, where we shift each probability as described later.
265
+
266
+ Baselines. We compare our approach (PS-W) with several baselines (see Appendix G):
267
+
268
+ - PS: PAC prediction sets that do not account for label shift (Vovk, 2012; Park et al., 2019). This does not come with PAC guarantees under label shift.
269
+ - WCP: Weighted conformal prediction under label shift, which targets marginal coverage (Podkopaev & Ramdas, 2021). This does not come with PAC guarantees under label shift either.
270
+ - PS-R: PAC prediction sets that account for label shift but ignore uncertainty in the importance weights; again without guarantees.
271
+ - PS-C: This addresses label shift via a conservative upper bound on the empirical loss (see Appendix G for details). This is the only baseline with a PAC guarantee under label shift.
272
+
273
+ We compare to other baselines in Appendix I.5, and to an oracle with the true weights in Appendix H. Results for other hyperparameters are in Appendix I.
274
+
275
+ Metrics. We measure performance via the prediction set error, i.e., the fraction of $(x,y)\sim Q$ such that $y\notin C_{\tau}(x)$ ; and the average prediction set size, i.e., the mean of $|C_{\tau}(x)|$ , evaluated on the held-out test set. We report the results over 100 independent repetitions, randomizing both dataset generation and our algorithm.
276
+
277
+ # 4.2 RESULTS & DISCUSSION
278
+
279
+ CDC Heart. We use the CDC Heart dataset, a binary classification problem (Centers for Disease Control and Prevention (CDC), 1984). The goal is to predict the risk of heart attack given features such as level of exercise or weight. We use $\varepsilon = 0.1$ and $\delta = 5 \times 10^{-4}$ . We consider both large and small shifts. For the large shift, the label distributions—denoted $(\text{pos}\%, \text{neg})$ —are $(94\%, 6\%)$ for
280
+
281
+ ![](images/994e16da2fec4e4189b9a5a78fd2cf75038dd0dd9b34e931750647a5567f7e9e.jpg)
282
+ (a) Prediction set error and size under small shifts on the CDC Heart dataset. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
283
+
284
+ ![](images/221d9a1514d47ca2b741e0a5ae75530b5e8f3088178f36dc396c14322074bab6.jpg)
285
+
286
+ ![](images/32e2e045493e97954a1cbdaf099bd3227984699dae6bee380b7629f268918ad9.jpg)
287
+ Figure 2: Prediction set results on the CDC Heart dataset.
288
+
289
+ ![](images/00abdd3774baa192768c8d18cffc809b1cf868a0f0214e33ddd8deba1fdd5f57.jpg)
290
+ (b) Prediction set error and size under large shifts on the CDC Heart dataset, Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
291
+
292
+ source, and (63.6%, 36.4%) for target; results are in Figure 2b. We also consider a small shift with label distributions (94%, 6%) for source, and (91.3%, 8.7%) for target; results are in Figure 2a. As can be seen, our PS-W algorithm satisfies the PAC guarantee while achieving smaller prediction set size than PS-C, the only baseline to satisfy the PAC guarantee. The PS and PS-R algorithms violate the PAC guarantee.
293
+
294
+ CIFAR-10. Next, we consider CIFAR-10 (Krizhevsky et al., 2009), which has 10 labels. We use $\varepsilon = 0.1$ and $\delta = 5 \times 10^{-4}$ . We consider a large and a small tweak-one shift. For the large shift, the label probability is $10\%$ for all labels in the source, $40.0\%$ for the tweaked label, and $6.7\%$ for other labels in the target; results are in Figure 3a. For small shifts, we use $10\%$ for all labels for the source, $11.76\%$ for the tweaked label, and $9.8\%$ for other labels for the target; results are in Figure 3b. Under large shifts, our PS-W algorithm satisfies the PAC guarantee while outperforming PS-C by a large margin. When the shift is very small, PS-W still satisfies the PAC guarantee, but generates more conservative prediction sets similar in size to those of PS-C (e.g., Figure 3b) given the limited data. Results for a non-uniform source distribution and general shifts are shown in Appendix I.8.
295
+
296
+ AGNews. AG News is a subset of AG's corpus of news articles (Zhang et al., 2015). It is a text classification dataset with four labels: World, Sports, Business, and Sci/Tech. It contains 31,900 unique examples for each class. We use $\varepsilon = 0.05$ and $\delta = 5 \times 10^{-4}$ . We use tweak-one label shifts. We consider a large shift and a medium-sized calibration dataset, with label distributions equalling $(30.8\%, 30.8\%, 7.7\%, 30.8\%)$ for the source, and $(12.5\%, 12.5\%, 62.5\%, 12.5\%)$ for the target; results are in Figure 4a. As before, our PS-W approach satisfies the PAC guarantee while achieving smaller set sizes than PS-C.
297
+
298
+ ChestX-ray. ChestX-ray14 (Wang et al., 2017) is a medical imaging dataset containing about 112K frontal-view X-ray images of 30K unique patients with fourteen disease labels. This dataset contains
299
+
300
+ Figure 3: Prediction set results on the CIFAR-10 dataset.
301
+ ![](images/7bedd313e3323666f9f2ec370464f5364a3922b515015268d672ab4dffaeaad5.jpg)
302
+ (a) Prediction set error and size with larger shift on the CIFAR-10. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 27000$ , $n = 19997$ , and $t = 19997$ .
303
+
304
+ ![](images/cb0633018b79d1f61a51460a2f1077c709644c5a962cccd1bb0de2df7c3b2b2e.jpg)
305
+
306
+ ![](images/457c3d869a2411ff0ee532bda641e49aa4a05b20ba38cba94e50ebad2f4f8c53.jpg)
307
+ (b) Prediction set error and size with small shift on the CIFAR-10. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 27000$ , $n = 16500$ , and $t = 16500$ .
308
+
309
+ ![](images/7aba34de5b7e0519644ab7587f16a3bc59394557fe883d15a5bb4bfa0f928584.jpg)
310
+
311
+ Figure 4: Prediction set results on the ChestX-ray dataset.
312
+ ![](images/a0fcfea20bf30458cccad8461c153e96a01dbdd52a4689b9f78f77b199baf798.jpg)
313
+ (a) Prediction set error and size on the AGNews Dataset. Parameters are $\varepsilon = 0.05$ , $\delta = 5 \times 10^{-4}$ , $m = 26000$ , $n = 12800$ , and $t = 12800$ .
314
+
315
+ ![](images/9089e16671449cf702161aeaaa1e3dcf437e9ca2a440adddf239293b95a1dec9.jpg)
316
+ (b) Prediction set error and size on the ChestX-ray dataset. Parameters are $\varepsilon = 0.3$ , $\delta = 5 \times 10^{-4}$ , $m = 67200$ , $n = 35200$ , and $o = 3520$ .
317
+
318
+ ![](images/d907cbf6405ac040fb62a0a5e0fdcec03851de8eb1adc6322b977b47f9a330e0.jpg)
319
+
320
+ ![](images/95f8020258103bf919525acbd9f1c798ec1c348b66ff7bf59641e83e79c1ccff.jpg)
321
+
322
+ instances with multiple labels, which we omit. We also omit classes with few positively labeled datapoints, leaving six classes: Atelectasis, Effusion, Infiltration, Mass, Nodule, Pneumothorax. We consider a general label shift. We consider a large tweak-one shift, with label distributions of $(19.1\%, \ldots, 19.1\%, 4.5\%, 19.1\%)$ for the source, and $(11.1\%, \ldots, 11.1\%, 44.5\%, 11.1\%)$ for the target. Results for $\varepsilon = 0.3$ are in Figure 4b. As before, our PS-W approach satisfies the PAC guarantee while outperforming PS-C. The PS-R and WCP methods violate the constraint.
323
+
324
+ Discussion. In all our experiments, our approach satisfies the PAC guarantee; furthermore, it produces smaller prediction set sizes than PS-C—the only baseline to consistently satisfy the PAC guarantee—except when the label shift is small and the calibration dataset is limited. In contrast, the PS baseline does not account for label shift, and the PS-R baseline does not account for uncertainty in the importance weights, so they do not satisfy the PAC guarantee. The WCP baseline is designed to target a different guarantee, and it does not satisfy the PAC guarantee. Thus, these results demonstrate the efficacy of our approach.
325
+
326
+ **Limitations.** Our approach is focused on problem settings where the label shift is not too small and sufficient calibration data is available; and may produce conservative prediction sets otherwise. This reflects the intrinsic difficulty of the problem in these settings. Importantly, our PAC coverage guarantees still hold.
327
+
328
+ # 5 CONCLUSION
329
+
330
+ We have proposed a PAC prediction set algorithm for the label shift setting, and illustrated its effectiveness in experiments. Directions for future work include improving performance when the calibration dataset or the label shift is small.
331
+
332
+ Reproducibility statement. Our code is available at https://github.com/averysi224/pac-ps-label-shift for reproducing our experiments.
333
+
334
+ # ACKNOWLEDGEMENT
335
+
336
+ This work was supported in part by ARO W911NF-20-1-0080 ARO W911NF-23-1-0296, NSF 2031895, NSF 2046874, ONR N00014-21-1-2843, the Sloan Foundation, and Institute of Information & communications Technology Planning & Evaluation (IITP) grant funded by the Korea government (MSIT) (No.2019-0-01906, Artificial Intelligence Graduate School Program (POSTECH)). Any opinions, findings and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the Army Research Office (ARO), or the Department of Defense, or the United States Government.
337
+
338
+ # REFERENCES
339
+
340
+ Anastasios N Angelopoulos and Stephen Bates. A gentle introduction to conformal prediction and distribution-free uncertainty quantification. arXiv preprint arXiv:2107.07511, 2021.
341
+ Kamyar Azizzadenesheli, Anqi Liu, Fanny Yang, and Animashree Anandkumar. Regularized learning for domain adaptation under label shifts. arXiv preprint arXiv:1903.09734, 2019.
342
+ Vineeth Balasubramanian, Shen-Shyang Ho, and Vladimir Vovk. Conformal prediction for reliable machine learning: theory, adaptations and applications. Newnes, 2014.
343
+ Shai Ben-David, John Blitzer, Koby Crammer, and Fernando Pereira. Analysis of representations for domain adaptation. Advances in neural information processing systems, 19, 2006.
344
+ Shai Ben-David, John Blitzer, Koby Crammer, and Fernando Pereira. Analysis of representations for domain adaptation. In Advances in neural information processing systems, pp. 137-144, 2007.
345
+ Maxime Cauchois, Suyash Gupta, Alnur Ali, and John C Duchi. Robust validation: Confident predictions even when distributions shift. arXiv preprint arXiv:2008.04267, 2020.
346
+ Centers for Disease Control and Prevention (CDC). Behavioral risk factor surveillance system, 1984. URL https://www.cdc.gov/brfss/annual_data/annual_data.htm.
347
+ Yee Seng Chan and Hwee Tou Ng. Word sense disambiguation with distribution estimation. In *IJCAI*, volume 5, pp. 1010-5, 2005.
348
+ Charles J Clopper and Egon S Pearson. The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika, 26(4):404-413, 1934.
349
+ Edgar Dobriban and Mengxin Yu. Symmpi: Predictive inference for data with group symmetries. arXiv preprint arXiv:2312.16160, 2023.
350
+ Robin Dunn, Larry Wasserman, and Aaditya Ramdas. Distribution-free prediction sets for two-layer hierarchical models. Journal of the American Statistical Association, 0(0):1-12, 2022.
351
+ Donald Alexander Stuart Fraser. Nonparametric methods in statistics. John Wiley & Sons Inc, 1956.
352
+ Saurabh Garg, Yifan Wu, Sivaraman Balakrishnan, and Zachary Lipton. A unified view of label shift estimation. Advances in Neural Information Processing Systems, 33:3290-3300, 2020.
353
+ Saurabh Garg, Sivaraman Balakrishnan, and Zachary C Lipton. Domain adaptation under open set label shift. arXiv preprint arXiv:2207.13048, 2022.
354
+ Gene H Golub and Charles F Van Loan. Matrix computations. JHU press, 2013.
355
+ Arthur Gretton, Alex Smola, Jiayuan Huang, Marcel Schmittfull, Karsten Borgwardt, and Bernhard Schölkopf. Covariate shift by kernel mean matching. *Dataset shift in machine learning*, 3(4):5, 2009.
356
+ I. Guttman. Statistical Tolerance Regions: Classical and Bayesian. Griffin's statistical monographs & courses. Hafner Publishing Company, 1970. URL https://books.google.com/books?id=3Q7vAAAAMAAJ.
357
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770-778, 2016.
358
+ Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4700-4708, 2017.
359
+ Jiayuan Huang, Arthur Gretton, Karsten Borgwardt, Bernhard Scholkopf, and Alex Smola. Correcting sample selection bias by unlabeled data. Advances in neural information processing systems, 19, 2006.
360
+
361
+ Ramneet Kaur, Susmit Jha, Anirban Roy, Sangdon Park, Edgar Dobriban, Oleg Sokolsky, and Insup Lee. idecode: In-distribution equivariance for conformal out-of-distribution detection. In Proceedings of the AAAI Conference on Artificial Intelligence, 2022.
362
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.
363
+ Jing Lei, Alessandro Rinaldo, and Larry Wasserman. A conformal prediction approach to explore functional data. Annals of Mathematics and Artificial Intelligence, 74(1):29-43, 2015.
364
+ Lihua Lei and Emmanuel J Candès. Conformal inference of counterfactuals and individual treatment effects. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 2021.
365
+ Shuo Li, Xiayan Ji, Edgar Dobriban, Oleg Sokolsky, and Insup Lee. Pac-wrap: Semi-supervised pac anomaly detection. In Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, 2022.
366
+ Zachary Lipton, Yu-Xiang Wang, and Alexander Smola. Detecting and correcting for label shift with black box predictors. In International conference on machine learning, pp. 3122-3130. PMLR, 2018.
367
+ National Institutes of Health and others. Nih clinical center provides one of the largest publicly available chest x-ray datasets to scientific community, 2022.
368
+ Harris Papadopoulos, Kostas Proedrou, Volodya Vovk, and Alex Gammerman. Inductive confidence machines for regression. In European Conference on Machine Learning, pp. 345-356. Springer, 2002.
369
+ Sangdon Park, Osbert Bastani, Nikolai Matni, and Insup Lee. Pac confidence sets for deep neural networks via calibrated prediction. arXiv preprint arXiv:2001.00106, 2019.
370
+ Sangdon Park, Shuo Li, Insup Lee, and Osbert Bastani. Pac confidence predictions for deep neural network classifiers. arXiv preprint arXiv:2011.00716, 2020.
371
+ Sangdon Park, Edgar Dobriban, Insup Lee, and Osbert Bastani. Pac prediction sets under covariate shift. arXiv preprint arXiv:2106.09848, 2021.
372
+ Sangdon Park, Edgar Dobriban, Insup Lee, and Osbert Bastani. Pac prediction sets for meta-learning. arXiv preprint arXiv:2207.02440, 2022.
373
+ Aleksandr Podkopaev and Aaditya Ramdas. Distribution-free uncertainty quantification for classification under label shift. In Uncertainty in Artificial Intelligence, pp. 844-853. PMLR, 2021.
374
+ Hongxiang Qiu, Edgar Dobriban, and Eric Tchetgen Tchetgen. Prediction sets adaptive to unknown covariate shift. arXiv preprint arXiv:2203.06126, 2022.
375
+ Hongxiang Qiu, Eric Tchetgen Tchetgen, and Edgar Dobriban. Efficient and multiply robust risk estimation under general forms of dataset shift. arXiv preprint arXiv:2306.16406, 2023.
376
+ Pranav Rajpurkar, Jeremy Irvin, Kaylie Zhu, Brandon Yang, Hershel Mehta, Tony Duan, Daisy Ding, Aarti Bagul, Curtis Langlotz, Katie Shpanskaya, et al. Chexnet: Radiologist-level pneumonia detection on chest x-rays with deep learning. arXiv preprint arXiv:1711.05225, 2017.
377
+ Yaniv Romano, Matteo Sesia, and Emmanuel Candes. Classification with valid and adaptive coverage. Advances in Neural Information Processing Systems, 33:3581-3591, 2020.
378
+ Reuven Y Rubinstein and Dirk P Kroese. Simulation and the Monte Carlo method. John Wiley & Sons, 2016.
379
+ Mauricio Sadinle, Jing Lei, and Larry Wasserman. Least ambiguous set-valued classifiers with bounded error levels. Journal of the American Statistical Association, 114(525):223-234, 2019.
380
+ Marco Saerens, Patrice Latinne, and Christine Decaestecker. Adjusting the outputs of a classifier to new a priori probabilities: a simple procedure. Neural computation, 14(1):21-41, 2002.
381
+
382
+ Alexander Shapiro. Monte carlo sampling methods. *Handbooks in operations research and management science*, 10:353-425, 2003.
383
+ Amos Storkey et al. When training and test sets are different: characterizing learning transfer. Dataset shift in machine learning, 30:3-28, 2009.
384
+ Masashi Sugiyama, Shinichi Nakajima, Hisashi Kashima, Paul Buenau, and Motoaki Kawanabe. Direct importance estimation with model selection and its application to covariate shift adaptation. Advances in neural information processing systems, 20, 2007.
385
+ Ryan J Tibshirani, Rina Foygel Barber, Emmanuel Candes, and Aaditya Ramdas. Conformal prediction under covariate shift. Advances in neural information processing systems, 32, 2019.
386
+ John Von Neumann. Various techniques used in connection with random digits. Appl. Math Ser, 12 (36-38):3, 1951.
387
+ Vladimir Vovk. Conditional validity of inductive conformal predictors. In *Asian conference on machine learning*, pp. 475-490. PMLR, 2012.
388
+ Vladimir Vovk, Alexander Gammerman, and Glenn Shafer. Algorithmic learning in a random world. Springer Science & Business Media, 2005.
389
+ Xiaosong Wang, Yifan Peng, Le Lu, Zhiyong Lu, Mohammadhadi Bagheri, and Ronald M Summers. Chestx-ray8: Hospital-scale chest x-ray database and benchmarks on weakly-supervised classification and localization of common thorax diseases. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2097-2106, 2017.
390
+ Samuel S Wilks. Determination of sample sizes for setting tolerance limits. The Annals of Mathematical Statistics, 12(1):91-96, 1941.
391
+ Bianca Zadrozny. Learning and evaluating classifiers under sample selection bias. In Proceedings of the twenty-first international conference on Machine learning, pp. 114, 2004.
392
+ Kun Zhang, Bernhard Schölkopf, Krikamol Muandet, and Zhikun Wang. Domain adaptation under target and conditional shift. In International conference on machine learning, pp. 819-827. PMLR, 2013.
393
+ Xiang Zhang, Junbo Zhao, and Yann LeCun. Character-level convolutional networks for text classification. Advances in neural information processing systems, 28, 2015.
394
+
395
+ # A ADDITIONAL RELATED WORK
396
+
397
+ Conformal Prediction. Our work falls into the broad areas of distribution-free uncertainty quantification, conformal prediction and tolerance regions (e.g., Guttman, 1970; Vovk et al., 2005; Balasubramanian et al., 2014; Angelopoulos & Bates, 2021; Kaur et al., 2022; Li et al., 2022; Dobriban & Yu, 2023, etc), which aim to construct prediction sets with finite sample coverage guarantees. The prediction sets are often realized by a setting a threshold on the values of a traditional single-label predictor (i.e. conformity/non-conformity score function) and predict all labels with scores above this threshold. Our setting is related to inductive conformal prediction (Papadopoulos et al., 2002; Vovk, 2012; Lei et al., 2015), where the dataset is split into a training set for fitting the scoring function and a calibration set for constructing the prediction sets.
398
+
399
+ PAC Prediction Sets. A standard coverage guarantee for conformal prediction methods is marginal coverage over the training, calibration and test data. For inductive conformal prediction, training-data conditional correctness (Vovk, 2012; Park et al., 2019) aims to achieve an $(\varepsilon, \delta)$ -coverage guarantee, where coverage over test points exceeds the desired error rate level $\varepsilon$ with probability at most $\delta$ . Sets satisfying this guarantee have been termed PAC prediction sets (Park et al., 2019). This guarantee is also equivalent to the classical coverage properties of tolerance regions (Wilks, 1941; Fraser, 1956). PAC coverage may be desired when a slight excess of the desired error rate cab causes a significant safety concern.
400
+
401
+ <table><tr><td></td><td>Covariate shift</td><td>Label shift</td></tr><tr><td>Importance weights, as a function of x, y</td><td>q(x)/p(x)</td><td>q(y)/p(y)</td></tr><tr><td>Shared conditional distribution, for all x, y</td><td>p(y|x) = q(y|x)</td><td>p(x|y) = q(x|y)</td></tr></table>
402
+
403
+ Table 1: Comparison of covariate shift and label shift.
404
+
405
+ Label shift. Label shift (Zadrozny, 2004; Huang et al., 2006; Sugiyama et al., 2007; Gretton et al., 2009) supposes that the conditional covariate distribution is fixed but the label distribution may change from a source to a target distribution; see Table 1. In more detail, let $p$ and $q$ denote the probability density functions of the source and target domains with respect to a common dominating measure, respectively. Label shift assumes that for all labels $y$ , $q(y)$ may differ from $p(y)$ , but for all features $x$ and labels $y$ , we have $p(x \mid y) = q(x \mid y)$ . Label shift can arise when the representations of the classes changes, for instance in scenarios like medical diagnosis and object recognition (Storkey et al., 2009; Saerens et al., 2002; Lipton et al., 2018).
406
+
407
+ Early solutions required the estimation of $q$ and $p$ , which may scale poorly with the dimension (Chan & Ng, 2005; Storkey et al., 2009; Zhang et al., 2013). More recently, two approaches achieved scalability by assuming an approximate relationship between ground truth labels $y$ and the outputs $\hat{y}$ of a classifier (Lipton et al., 2018; Azizzadenesheli et al., 2019; Saerens et al., 2002): Black Box Shift Estimation (BBSE) (Lipton et al., 2018) and RLLS (Azizzadenesheli et al., 2019) provided consistency results and finite-sample guarantees assuming the confusion matrix is invertible. Subsequent work developed a unified framework that decomposes the error in computing importance weights into miscalibration error and estimation error, with BBSE as a special case (Garg et al., 2020); this approach was extended to open set label shift domain adaptation (Garg et al., 2022). We also mention that label shift is a special case of a more general class of distribution shifts that allow the source and target distributions to be related by sharing sequential conditional distributions (Qiu et al., 2023).
408
+
409
+ Conformal methods and distribution shift. Conformal prediction has been adapted to distribution shifts such as covariate shift (Tibshirani et al., 2019; Lei & Candès, 2021; Qiu et al., 2022). (Podkopaev & Ramdas, 2021) considers label shift when the true importance weights are exactly known. Importance weights are typically estimated with uncertainty. We address this by developing an algorithm to find confidence intervals for the importance weights. More broadly, prediction sets have been studied in the meta-learning setting (Dunn et al., 2022; Park et al., 2022), as well as the setting of robustness to all distribution shifts with bounded $f$ -divergence (Cauchois et al., 2020).
410
+
411
+ Class-conditional prediction sets. Although not designed specifically for solving the label shift problem, methods for class-conditional coverage (Sadinle et al., 2019) and adaptive prediction sets (APS) (Romano et al., 2020) can improve robustness to label shifts. However, class-conditional
412
+
413
+ coverage is a stronger guarantee that leads to prediction sets larger than for our algorithm, while APS does not satisfy a PAC guarantee; we compare empirically to these approaches in Appendix I.5.
414
+
415
+ # B BACKGROUND ON PAC PREDICTION SETS
416
+
417
+ Finding the maximum $\tau$ that satisfies (3) is equivalent to choosing the largest $\tau$ such that the empirical error
418
+
419
+ $$
420
+ \bar {L} _ {S _ {m}} \left(C _ {\tau}\right) := \sum_ {(x, y) \in S _ {m}} \mathbb {1} (y \notin C _ {\tau} (x))
421
+ $$
422
+
423
+ on the calibration set $S_{m}$ is bounded Vovk et al. (2005); Park et al. (2019). Let $F(k;m,\varepsilon) = \sum_{i=0}^{k} \binom{m}{k} \varepsilon^{i}(1 - \varepsilon)^{m - i}$ be the cumulative distribution function (CDF) of the binomial distribution $\operatorname{Binom}(m,\varepsilon)$ with $m$ trials and success probability $\varepsilon$ evaluated at $k$ . Then, Park et al. (2019) constructs $C_{\hat{\tau}}$ via
424
+
425
+ $$
426
+ \hat {\tau} = \max _ {\tau \in T} \tau \quad \text {s u b j . t o} \quad \bar {L} _ {S _ {m}} \left(C _ {\tau}\right) \leq k (m, \varepsilon , \delta), \tag {17}
427
+ $$
428
+
429
+ where $k(m,\varepsilon ,\delta) = \max_{k\in \mathbb{N}\cup \{0\}}k$ subj. to $F(k;m,\varepsilon)\leq \delta$
430
+
431
+ Their approach is equivalent to the method from Vovk (2012), but formulated in the language of learning theory. By viewing the prediction set as a binary classifier, the PAC guarantee via this construction can be connected to the Binomial distribution. Indeed, for fixed $C$ , $\bar{L}_{S_m}(C)$ has distribution $\mathrm{Bionm}(m, L_P(C))$ , since $\mathbb{1}(y \notin C(x))$ has a Bernoulli $(L_P(C))$ distribution when $(x, y) \sim P$ . Thus, $k(m, \varepsilon, \delta)$ defines a bound such that if $L_P(C) \leq \varepsilon$ , then $\bar{L}_{S_m}(C) \leq k(m, \varepsilon, \delta)$ with probability at least $1 - \delta$ .
432
+
433
+ # C BACKGROUND ON PREDICTION SETS UNDER DISTRIBUTION SHIFT
434
+
435
+ Here we demonstrate how to obtain prediction sets given intervals $\underline{w}^{*}\leq w^{*}\leq \overline{w}^{*}$ around the true importance weights. This approach is based closely on the strategy in (Park et al., 2021) for constructing prediction sets under covariate shift, but adapts it to the label shift setting (indeed, our setting is simpler since there are finitely many importance weights). The key challenge is computing the importance weight intervals, which we describe in detail below.
436
+
437
+ Given the true importance weights $w^{*}$ , one strategy would be to use rejection sampling (Von Neumann, 1951; Shapiro, 2003; Rubinstein & Kroese, 2016) to subsample $S_{m}$ to obtain a dataset that effectively consists of $N \leq m$ i.i.d. samples from $Q$ (here, $N$ is a random variable, but this turns out not to be an issue). Essentially, for each $(x_{i},y_{i}) \in S_{m}$ , we sample a random variable $V_{i} \sim \mathrm{Uniform}([0,1])$ and then accept samples where $V_{i} \leq w_{y_{i}}^{*} / b$ , where $b$ is an upper bound on $w_{y}^{*}$ :
438
+
439
+ $$
440
+ T _ {N} (S _ {m}, V, w ^ {*}, b) = \left\{(x _ {i}, y _ {i}) \in S _ {m} \middle | V _ {i} \leq \frac {w _ {y _ {i}} ^ {*}}{b} \right\}.
441
+ $$
442
+
443
+ In our setting, we can take $b = \max_{y\in \mathcal{Y}}w_y^*$ . Then, we return $\hat{\tau} (T_N(S_m,V,w^*,b))$ . Since $T_{N}(S_{m},V,w^{*},b)$ consists of an i.i.d. sample from $Q$ , we obtain the desired PAC guarantee (4).
444
+
445
+ In practice, we do not know the true importance weights $w^{*}$ . Instead, suppose we can obtain intervals $W_{y} = [\underline{w}_{y}^{*},\overline{w}_{y}^{*}]$ such that $w_{y}^{*}\in W_{y}$ with high probability. We let $W = \prod_{y\in \mathcal{Y}}W_{y}$ , and assume $w^{*}\in W$ with probability at least $1 - \delta$ . The algorithm proposed in (Park et al., 2021) adjusts the above algorithm to conservatively account for this uncertainty—i.e., it chooses $\tau$ so the PAC guarantee (4) holds for any importance weights $w\in W$ :
446
+
447
+ $$
448
+ \hat {\tau} \left(S _ {m}, V, W, b\right) = \min _ {w \in W} \hat {\tau} \left(T _ {N} \left(S _ {m}, V, w, b\right)\right). \tag {18}
449
+ $$
450
+
451
+ We minimize over $\tau$ since choosing smaller $\tau$ leads to larger prediction sets, which is more conservative. (Park et al., 2021) show how to compute (18) efficiently. We have the following guarantee:
452
+
453
+ Theorem C.1 (Theorem 4 in (Park et al., 2021)). Assume that $w^{*} \in W$ . Letting $U = \mathrm{Uniform}([0,1])$
454
+
455
+ $$
456
+ \mathbb {P} _ {S _ {m} \sim P ^ {m}, V \sim U ^ {m}} \left[ \mathbb {P} _ {(X, Y) \sim Q} [ y \in C _ {\hat {\tau} (S _ {m}, V, W, b)} ] \geq 1 - \varepsilon \right] \geq 1 - \delta .
457
+ $$
458
+
459
+ In other words, the PAC guarantee (4) holds, with the modification that the outer probability includes the randomness over the samples $V \sim U^{m}$ used by our algorithm.
460
+
461
+ # D ENSURING THE CONFIDENCE BOUNDS AT EACH STEP
462
+
463
+ The diagonal elements $c_{kk}$ of the confusion matrix of an accurate classifier, are typically much larger than the other elements. Indeed, for an accurate classifier, the probabilities of correct predictions $c_{kk} = P(g(x) = k, y = k)$ are higher than those of incorrect predictions $c_{ik} := P(g(x) = i, y = k), i \neq k$ . On the other hand, the Clopper-Pearson interval is expected to be short (for instance, the related Wald interval has length or order $1 / \sqrt{m}$ , where $m$ is the sample size). Thus, we expect that
464
+
465
+ $$
466
+ \bar {c} _ {i k} ^ {0} \ll \underline {{c}} _ {k k} ^ {0}, k = 1, \dots , K, i \neq k. \tag {19}
467
+ $$
468
+
469
+ Without loss of generality, we consider equation 11 as an example. In the Gaussian elimination process, recall that the update at step $t$ is
470
+
471
+ $$
472
+ \underline {{c}} _ {i j} ^ {t + 1} = \underline {{c}} _ {i j} ^ {t} - \frac {\bar {c} _ {i k} ^ {t}}{\underline {{c}} _ {k k} ^ {t}} \bar {c} _ {k j} ^ {t} \quad \text {i f} i, j > k. \tag {20}
473
+ $$
474
+
475
+ Combining with equation 19, the factor by which the $k$ -th row is multiplied is small, i.e., $\overline{c}_{ik}^{t} / \underline{c}_{kk}^{t}\ll 1$ . Thus the resulting $i$ -th diagonal elements
476
+
477
+ $$
478
+ \underline {{c}} _ {i i} ^ {t + 1} = \underline {{c}} _ {i i} ^ {t} - \frac {\overline {{c}} _ {i k} ^ {t}}{\underline {{c}} _ {k k} ^ {t}} \overline {{c}} _ {k i} ^ {t}
479
+ $$
480
+
481
+ change little after each elimination step, and are expected to remain positive. Next we discuss intervals for off-diagonal elements.
482
+
483
+ Balanced classifier. For a balanced classifier, when $c_{ik}$ and $c_{jk}$ are close for all $i,j$ such that $i \neq k$ , $j \neq k$ , since the factor $\overline{c}_{ik}^t / \underline{c}_{kk}^t$ is small, the lower bound in equation 20 is expected to be positive.
484
+
485
+ Imbalanced classifier. For the more general case of a possibly imbalanced classifier, $c_{ij}$ and $c_{kj}$ may not be close. This could cause non-positive bounds at certain steps, so the confidence interval may not be valid at the next steps; e.g., equation 13 may fail. However, note that since
486
+
487
+ $$
488
+ c _ {i k} ^ {t} \in [ \underline {{c}} _ {i k} ^ {t}, \overline {{c}} _ {i k} ^ {t} ], c _ {k j} ^ {t} \in [ \underline {{c}} _ {k j} ^ {t}, \overline {{c}} _ {k j} ^ {t} ],
489
+ $$
490
+
491
+ we have
492
+
493
+ $$
494
+ c _ {i k} ^ {t} c _ {k j} ^ {t} \leq \max \{\left| \underline {{c}} _ {i k} ^ {t} \right|, \left| \overline {{c}} _ {i k} ^ {t} \right| \} \cdot \max \{\left| \underline {{c}} _ {k j} ^ {t} \right|, \left| \overline {{c}} _ {k j} ^ {t} \right| \}
495
+ $$
496
+
497
+ and hence
498
+
499
+ $$
500
+ \frac {c _ {i k} ^ {t} c _ {k j} ^ {t}}{c _ {k k} ^ {t}} \leq \frac {\operatorname* {m a x} \{\left| \underline {{c}} _ {i k} ^ {t} \right| , \left| \overline {{c}} _ {i k} ^ {t} \right| \} \cdot \operatorname* {m a x} \{\left| \underline {{c}} _ {k j} ^ {t} \right| , \left| \overline {{c}} _ {k j} ^ {t} \right| \}}{\underline {{c}} _ {k k} ^ {t}}.
501
+ $$
502
+
503
+ In fact, one can derive the even tighter bound
504
+
505
+ $$
506
+ \max \left(\frac {\overline {{c}} _ {i k} ^ {t} \overline {{c}} _ {k j} ^ {t}}{\underline {{c}} _ {k k} ^ {t}}, \frac {\underline {{c}} _ {i k} ^ {t} \overline {{c}} _ {k j} ^ {t}}{\underline {{c}} _ {k k} ^ {t}}, \frac {\underline {{c}} _ {i k} ^ {t} \underline {{c}} _ {k j} ^ {t}}{\underline {{c}} _ {k k} ^ {t}}, \frac {\overline {{c}} _ {i k} ^ {t} \overline {{c}} _ {k j} ^ {t}}{\overline {{c}} _ {k k} ^ {t}}, \frac {\underline {{c}} _ {i k} ^ {t} \overline {{c}} _ {k j} ^ {t}}{\overline {{c}} _ {k k} ^ {t}}, \frac {\underline {{c}} _ {i k} ^ {t} \underline {{c}} _ {k j} ^ {t}}{\overline {{c}} _ {k k} ^ {t}}, \frac {\overline {{c}} _ {i k} ^ {t} \underline {{c}} _ {k j} ^ {t}}{\overline {{c}} _ {k k} ^ {t}}\right).
507
+ $$
508
+
509
+ This can be checked by carefully going through all possible cases of positive and negative values of the bounds. Similar changes can be made to computing the upper bounds.
510
+
511
+ It is possible for our final interval $W$ to contain negative lower bounds due to loose element-wise intervals or other factors. Since importance weights are non-negative, negative importance weight bounds act the same way as zero lower bounds in rejection sampling, and preserve our guarantees.
512
+
513
+ Finally, the requirement of an accurate classifier is already imposed by methods such as BBSE to ensure the invertibility of the confusion matrix. Therefore, our Gaussian elimination approach does not impose significantly stronger assumptions.
514
+
515
+ # E PROOF OF LEMMA 3.1
516
+
517
+ For the first phase, we prove by induction on $t$ that (10) holds for all $t$ . The base case $t = 0$ holds by assumption. For the induction step, we focus on $\underline{c}_{ij}^{t + 1}$ ; the remaining bounds $\overline{c}_{ij}^{t + 1}, \underline{q}_k^{t + 1}$ , and $\overline{q}_k^{t + 1}$ follow similarly. There are three sub-cases i, each corresponding to one of the update rules in (11). For the first update rule $\overline{c}_{ij}^{t + 1} = 0$ , equation 10 follows since the Gaussian elimination algorithm
518
+
519
+ guarantees that $c_{ij}^{t + 1} = 0$ . For the second and third update rules, equation 10 follows by direct algebra and the induction hypothesis. For instance, for $i,j > t$ , equation 13 holds, and similarly $c_{ij}^{t + 1}\geq c_{ij}^{t + 1}$
520
+
521
+ For the second phase, the fact that $\underline{s} \leq s \leq \overline{s}$ and $\underline{w}^* \leq w^* \leq \overline{w}^*$ follows by a similar induction argument. Since Gaussian elimination guarantees that $w^* = \mathbf{C}_P^{-1} q^*$ , and we have shown that $w^* \in W = \prod_{i=1}^{K} [\underline{w}_i, \overline{w}_i]$ , the claim follows.
522
+
523
+ # F PROOF SKETCH OF THEOREM 3.2
524
+
525
+ First, Theorem 3.2 follows from equation 5, assuming the given confidence intervals $W_{i} = [\underline{w}_{i}, \overline{w}_{i}]$ for each importance weight $w_{i}^{*}$ is valid—i.e., $w_{i}^{*} \in W_{i}$ . Equation 5 follows by Theorem 4 in Park et al. (2021). Roughly speaking, if $w_{i}^{*}$ is known, then we can use a standard rejection sampling procedure based on $w_{i}^{*}$ to convert $S_{m}$ into a set of i.i.d. samples from $Q$ . Then, the PAC guarantee would follow by standard conformal prediction results, e.g., Park et al. (2020). When $w_{i}^{*}$ is not known, then intuitively, Park et al. (2021) takes the worst case over all $w_{i}^{*} \in W_{i}$ . They use a reparameterization trick to do so in a computationally efficient way. Finally, by Lemma 3.1, we have $w_{i}^{*} \in W_{i}$ for all $i \in [n]$ with high probability, so Theorem 3.2 follows by a union bound.
526
+
527
+ # G CONSERVATIVE BASELINE
528
+
529
+ We describe PS-C, the conservative baseline summarized in Algorithm 2. In particular, given an upper bound $b \geq w^{*}$ on the importance weight, we use the upper bound
530
+
531
+ $$
532
+ \mathbb {E} _ {(X, Y) \sim P} [ \ell (g (X), Y) \cdot w _ {Y} ^ {*} ] \leq b \cdot \mathbb {E} _ {(X, Y) \sim P} [ \ell (g (X), Y) ].
533
+ $$
534
+
535
+ As a consequence, we can run the original prediction set algorithm from Vovk (2012); Park et al. (2019) with a more conservative choice of $\varepsilon$ that accounts for this upper bound.
536
+
537
+ Algorithm 2 PS-C: an algorithm using the CP bound in equation 21.
538
+ 1: procedure PS-C $(S_{m},T_{n}^{X},f,\mathcal{T},\varepsilon ,\delta_{w},\delta_{C})$
539
+ 2: $\underline{c},\overline{c},\underline{q},\overline{q}\gets \mathrm{CPINTERVAL}(S_m,T_n^X,x\mapsto \arg \max_{y\in \mathcal{Y}}f(x,y),\delta_w)$
540
+ 3: $W\gets \mathrm{INTERVALGAUSSIANELIM}(\underline{c},\overline{c},\underline{q},\overline{q})$
541
+ 4: $b\gets \max_{k\in [K]}\overline{w}_k$
542
+ 5: return PS(Sm,f,T,ε/b,δC)
543
+
544
+ Lemma G.1. Algorithm 2 satisfies the PAC guarantee under label shift equation 4.
545
+
546
+ Proof. Having constructed the importance weight intervals $w^{*}$ , we can use $b = \max_{k\in [K]}\overline{w}_k$ to find a conservative upper bound on the risk as follows:
547
+
548
+ $$
549
+ \begin{array}{l} E _ {(X, Y) \sim Q} [ \mathbb {1} (Y \notin C _ {\tau} (X) ] = \int q (x, y) \mathbb {1} (y \notin C _ {\tau} (x)) d x d y \\ = \int p (x, y) w (y) \mathbb {1} (y \notin C _ {\tau} (x)) d x d y \leq b E _ {(X, Y) \sim P} [ \mathbb {1} (Y \notin C _ {\tau} (X) ]. \tag {21} \\ \end{array}
550
+ $$
551
+
552
+ Hence, using the PS prediction set algorithm with parameters $(\varepsilon /b,\delta)$ , the output is $(\varepsilon ,\delta)$ -PAC.
553
+
554
+ # H ORACLE IMPORTANCE WEIGHT RESULTS
555
+
556
+ Here, we show comparisons to an oracle that is given the ground truth importance weights (which are unknown and must be estimated in most practical applications). It uses rejection sampling according to these weights rather than conservatively accounting for uncertainty in the weights. In contrast to our baselines (which need to estimate $w$ ), this oracle represents a "gold (yet not achievable) standard" to compare with. It enables us to quantify the increase in average prediction set size due to uncertainty in our estimates of $w$ , stemming from (i) finite sample error, accounted for by Clopper-Pearson intervals, and (ii) label shift, accounted for by our interval Gaussian elimination algorithm.
557
+
558
+ Figure 5: Prediction set results with comparison to the oracle importance weight (Ora).
559
+ ![](images/f78f5a4b27c1cbeef325e8e8c1d9ff800cbbdd9d0407a93d5b7cc6094a995ab5.jpg)
560
+ (a) Prediction set error and size on the CDC dataset. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
561
+
562
+ ![](images/79b8399a1fee8428160ba2261249fe53f281beda83c8cb923bba652abfcb230c.jpg)
563
+ (b) Prediction set error and size on the CIFAR10. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 27000$ , $n = 19997$ , and $t = 19997$ .
564
+
565
+ ![](images/465fa95f1d69732a52683732ea567fd48ca71afce3593e846fe6f6fb2ba2fc8a.jpg)
566
+
567
+ ![](images/7c2f233b59444b9a28fe2b0822b256073de2aa08c11426f7c33e9c91594995a6.jpg)
568
+
569
+ First, for the CDC heart dataset, we consider the following label distributions: source (94%, 6%), target: (63.6%, 36.4%); see Figure 5a for the results. Second, for the CIFAR-10 dataset, we consider the following label distributions: source (10%, 10%, 10%, 10%, 10%, 10%, 10%, 10%, 10%), target: (6.7%, 6.7%, 6.7%, 40.0%, 6.7%, 6.7%, 6.7%, 6.7%, 6.7%, 6.7%) and source (20%, 20%, 20%, 20%, 20%, 20%, 20%).
570
+
571
+ # I ADDITIONAL RESULTS
572
+
573
+ # I.1 CDC HEART
574
+
575
+ ![](images/9d9847cd96a2fe3ad7b419b1cabaad636fb5d1f1325702ab00cf7e579fea3c64.jpg)
576
+
577
+ ![](images/0242cc5cbfec52820b612e133cee33d7de42a1cc272113c0927916df3c11e455.jpg)
578
+
579
+ Figure 6: More Prediction set results with different hyperparameters on the CDC Heart dataset.
580
+ ![](images/1b096a24dcaff92b3fcac95e287967ed7133ab3adcaeb2caf2ee96a2981b0353.jpg)
581
+ (a) Prediction set error and size under small shifts on the CDC Heart dataset. Parameters are $\varepsilon = 0.05$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
582
+
583
+ ![](images/55a82c05fdc76ce36af522e2d608103685f2bfe328716e5a359145f1402f7854.jpg)
584
+ (c) Prediction set error and size under small shifts on the CDC Heart dataset. Parameters are $\varepsilon = 0.03$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
585
+
586
+ ![](images/c013b9d4fd9090f748cb57939c97e78babd75e4357c8e66e3e7dbd7f6e5480c4.jpg)
587
+
588
+ ![](images/7a10542e68d29c2aff34e37083bcb583bf7911751e7405bfea453eac90965547.jpg)
589
+
590
+ ![](images/ea333eab33b8d4af3dc5017de18b558ff09f3a8f0ac671644cf985e46cb676fd.jpg)
591
+ (b) Prediction set error and size under large shifts on the CDC Heart dataset, Parameters are $\varepsilon = 0.05$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
592
+
593
+ ![](images/dd66e594da6ce273e58b4edfbdb8746e40fa0e43d313738faa2620d7c9c41f7a.jpg)
594
+ (d) Prediction set error and size under large shifts on the CDC Heart dataset, Parameters are $\varepsilon = 0.03$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
595
+
596
+ Figure 7: More Prediction set results with different hyperparameters on the CDC Heart dataset.
597
+ ![](images/1885e78c574026b1e732f21924d69b3c8e962095b7a6925ff8484534dff73a51.jpg)
598
+ (a) Prediction set error and size under reversed small shifts $(91.3\%, 8.7\%) \rightarrow (94\%, 6\%)$ on the CDC Heart dataset. Parameters are $\varepsilon = 0.05$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
599
+
600
+ ![](images/6144ac04f70f93d9c198491e8535680942f2701c6c230f29458c670c8ee47b11.jpg)
601
+ (b) Prediction set error and size under reversed large shifts $(63.6\%, 36.4\%) \rightarrow (94\%, 6\%)$ on the CDC Heart dataset, Parameters are $\varepsilon = 0.05$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
602
+
603
+ ![](images/10bd04927155f2ca117e96171b42f700c28e7d949b28c0ef79402e9154c7dea1.jpg)
604
+
605
+ ![](images/69cae5eefe6a4fcbe534ac9d6f8c7eccd7b02173b18cddb0dbc090d0f982fab9.jpg)
606
+
607
+ # I.2 CIFAR-10
608
+
609
+ Figure 8: More Prediction set results with different hyperparameters on the CIFAR-10 dataset.
610
+ ![](images/992bd39147a0c0156f80d7336490fc2ee89eb9e934b8cd1c7046a144c11d1e82.jpg)
611
+ (a) Prediction set error and size with larger shift on the CIFAR-10. Parameters are $\varepsilon = 0.05$ , $\delta = 5 \times 10^{-4}$ , $m = 27000$ , $n = 19997$ , and $t = 19997$ .
612
+
613
+ ![](images/f27f2401c70dc1df47763e1d947f80bac3ce3d49897d6a424f598da671bd9f19.jpg)
614
+ (b) Prediction set error and size with larger shift on the CIFAR-10. Parameters are $\varepsilon = 0.03$ , $\delta = 5 \times 10^{-4}$ , $m = 27000$ , $n = 19997$ , and $t = 19997$ .
615
+
616
+ ![](images/b4feb0bc10766a75a300651e66298539f830e460582c7805fcbf63e56bd01f46.jpg)
617
+
618
+ ![](images/2c23ffe9acbd76645b16fc496ea2589d6af5e113c84e0b58e001a0180c64ec2a.jpg)
619
+
620
+ # I.3 AGNEWS
621
+
622
+ Figure 9: More Prediction set results with different hyperparameters on the AGNews dataset.
623
+ ![](images/ca260c199c5a1758c95a082e1d725f5a65f8cfe193308aa7046a85ffda4c25a3.jpg)
624
+ (a) Prediction set error and size on the AGNews Dataset. Parameters are $\varepsilon = 0.03$ , $\delta = 5 \times 10^{-4}$ , $m = 26000$ , $n = 12800$ , and $t = 12800$ .
625
+
626
+ ![](images/ab2115428db7beb852d241662306f1862fb599fbde0ef2e2349a969b68d4bdaf.jpg)
627
+
628
+ ![](images/dffe8a17385fc830050b7676640d16d378226e3722964e082f8ec3d38d1fd18d.jpg)
629
+ (b) Prediction set error and size on the AGNews Dataset. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 26000$ , $n = 12800$ , and $t = 12800$ .
630
+
631
+ ![](images/0edf579b70dad82eb208caecad83e11a021d24a63241657b1f9e1c6e8bc032de.jpg)
632
+
633
+ # I.4 CHESTX-RAY
634
+
635
+ Figure 10: More Prediction set results with different hyperparameters on the ChestX-ray dataset.
636
+ ![](images/41ef47ed9d9095d6c7c5976f353b0abfcca1262c6682cd5308e409b0428e791a.jpg)
637
+ (a) Prediction set error and size on the ChestX-ray dataset. Parameters are $\varepsilon = 0.3$ , $\delta = 5 \times 10^{-4}$ , $m = 33600$ , $n = 17600$ , and $t = 3520$ .
638
+
639
+ ![](images/71bc9f2881e28cc35c2eb6346c7ee5f4f79c64bb70036ac65f6d0d24930c7623.jpg)
640
+
641
+ ![](images/ad8de95c248a2f6b5ed422c9acfca17e9b09afa171bf99fbdb5314b6ecbc1ebf.jpg)
642
+ (b) Prediction set error and size on the ChestX-ray dataset. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 67200$ , $n = 35200$ , and $t = 3520$ .
643
+
644
+ ![](images/495dabf53d40d6f9770c90de2dcbd609cf1c83dd0d1e2120c5a6b1eaf7963ab4.jpg)
645
+
646
+ # I.5 ADDITIONAL BASELINES
647
+
648
+ Class-conditional conformal predictors fit separate thresholds for each label and demonstrate robustness to label shift. In Figure 11, we show the class-conditional results for both conformal prediction tuned for average coverage and our PAC prediction set, on the CDC and CIFAR-10 dataset. Here, LWCP is a baseline from the label-conditional setting from Sadinle et al. (2019), which does not satisfy a PAC guarantee. PS-LW adapts the standard PAC prediction set algorithm (Vovk, 2012; Park et al., 2020) to the label-conditional setting; our approach is PS-W. Most relevantly, while PS-LW approximately satisfies the desired error guarantee, it is more conservative than our approach (PS-W) and produces prediction sets that are larger on average. Intuitively, it satisfies a stronger guarantee than necessary for our setting, leading it to be overly conservative.
649
+
650
+ ![](images/42bf713520e36d5748d3322a009a9ef41f8cc4c43284fd7205ad1d0875cf3bc1.jpg)
651
+ Figure 11: Prediction set error and size on the CDC dataset under small shifts. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ .
652
+
653
+ ![](images/41d7fb9218627cbff427feafbf169aea39b923c7f7ad8d2684a2fc6f310fede8.jpg)
654
+
655
+ Empirically, we find that while APS improves coverage in the label shift setting, it does not satisfy our desired PAC guarantee. In particular, we show results for the APS scoring function with vanilla prediction sets in Figure 12; as can be seen, it does not satisfy the desired coverage guarantee. Due to its unusual structure, it is not clear how APS can be adapted to the PAC setting, which is our focus.
656
+
657
+ ![](images/23d329cc5b105aa436116906a6e12a8bcfcd0ebb14aa3f45df013e4b75b93de9.jpg)
658
+ Figure 12: Prediction set error and size on the CDC dataset. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ . Label distribution (94%, 6%) with small shift (91.3%, 8.7%) in the target.
659
+
660
+ ![](images/4c3d667149cccbefcf1fc69f43c49401e800fe9b2f7e614c5cde3bca262f4a66.jpg)
661
+
662
+ # I.6 CIFAR-100
663
+
664
+ We show results on CIFAR-100 in Figure 13. The scores are the logits of a pretrained ViT model. The results show that both PS-C and PS-W attain the desired coverage guarantee, while the remaining approaches do not do so. Furthermore, PS-W outperforms PS-C in terms of average prediction set size.
665
+
666
+ In this case, both PS-C and PS-W are quite conservative, due to two main reasons. First, the Clopper-Pearson intervals can be conservative when $\delta$ is very small, and we need to divide $\delta$ by $K(K + 1) + 1$ , since we need to take a union bound over $K(K + 1) + 1$ events in equation 8. Second, although our Gaussian "interval" elimination algorithm does uncertainty propagation in time $O(K^3)$ , the resulting confidence intervals $(\underline{w}, \overline{w})$ may be conservative, thereby amplifying the first issue. With more calibration data, our approach would be less conservative.
667
+
668
+ ![](images/fe424d43ec4e850eb2132740d952b37636949de3835da0acd6998d82b7560940.jpg)
669
+ Figure 13: Prediction set error and size on the CIFAR-100 dataset. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 270k$ , $n = 180k$ , and $o = 5950$ . Label distribution is $[1.01\%] \times 99 + [0.3\%]$ for source, and $[0.84\%] \times 99 + [16.8\%]$ for target.
670
+
671
+ ![](images/22837539f3fda118f1b0b29bf967c05601620a4c9583c45dabf78b745fabea1d.jpg)
672
+
673
+ # I.7 LARGE $\varepsilon$
674
+
675
+ We provide results on larger choices of $\varepsilon$ in Figures 14 & 15.
676
+
677
+ ![](images/05e8fa2ede2ef909ab896c7474f9a19706038bbb92e798b77af9d8d5f945999d.jpg)
678
+ Figure 14: Prediction set error and size on the CDC dataset. Parameters are $\varepsilon = 0.3$ , $\delta = 5 \times 10^{-4}$ , $m = 42000$ , $n = 42000$ , and $o = 9750$ . Label distribution is $(94\%, 6\%)$ for source, and $(63.6\%, 36.4\%)$ for target.
679
+
680
+ ![](images/298cf5c82e0a8f81c29b05bb0fe07c60a960bc0a488eaefd5545f77991ab3260.jpg)
681
+
682
+ # I.8 NON-UNIFORM SOURCE DISTRIBUTIONS
683
+
684
+ We provide results with a non-uniform source distribution in Figure 16.
685
+
686
+ ![](images/4f6a968c467a8cf33d5256a3918f84d328cf15da1dcff30d5a6c758ceeba4a7c.jpg)
687
+ Figure 15: Prediction set error and size with large shifts on the CIFAR-10 dataset. Parameters are $\varepsilon = 0.2$ , $\delta = 5 \times 10^{-4}$ , $m = 27000$ , $n = 19997$ , and $t = 19997$ .
688
+
689
+ ![](images/c4e2ade094f90ebdabb7b467bd72d4943079781178a12d2ca5c6596c2b385d2f.jpg)
690
+
691
+ ![](images/a29bd253c1e3ed082244536086d76bc93045f74d3e83dbb673f6af1d724021d9.jpg)
692
+ Figure 16: Prediction set error and size on the CIFAR-10 dataset. Parameters are $\varepsilon = 0.1$ , $\delta = 5 \times 10^{-4}$ , $m = 34k$ , $n = 45k$ , and $o = 45k$ . Label distribution is $(10.53\%, 5.26\%, 15.79\%, 5.26\%, 5.26\%, 10.53\%, 15.79\%, 10.53\%, 5.26\%, 15.79\%)$ for source, and $(3.57\%, 7.14\%, 10.71\%, 35.71\%, 3.57\%, 7.14\%, 10.71\%, 3.57\%, 7.14\%, 10.71\%)$ for target.
693
+
694
+ ![](images/f315b952feb2f282bc8374dc8c1fd722a5a00cdb53bdcedb402cf1fc14a2f634.jpg)
pacpredictionsetsunderlabelshift/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8fc308f4c2db58054f2779f33e97ee33338d921091569bcba2ca87052c33dbe9
3
+ size 912469
pacpredictionsetsunderlabelshift/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce61a1ad369170ff64bf6914e2b3f464d3d663de6a27690825ce554bdfe5ee10
3
+ size 1077102
paereinforcementlearningfromexternalknowledgeforefficientexploration/246f10dd-6824-4248-ac26-a65e26c6cf25_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3db92e3725db3a72442d3b74457d832059ff56e39a0735ac095972e49ec7e174
3
+ size 142382
paereinforcementlearningfromexternalknowledgeforefficientexploration/246f10dd-6824-4248-ac26-a65e26c6cf25_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb33349bd5e6da1952c99a2551cfd0ccf258e1d119441b3fe98c9a9106e655c9
3
+ size 168853
paereinforcementlearningfromexternalknowledgeforefficientexploration/246f10dd-6824-4248-ac26-a65e26c6cf25_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7901329789b276368cd5d49ec33c2d9ff19ed7a3f906367f7b3063ff6c82f005
3
+ size 13473066
paereinforcementlearningfromexternalknowledgeforefficientexploration/full.md ADDED
@@ -0,0 +1,595 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PAE: REINFORCEMENT LEARNING FROM EXTERNAL KNOWLEDGE FOR EFFICIENT EXPLORATION
2
+
3
+ Zhe $\mathbf{W}\mathbf{u}^{*1}$ , Haofei Lu\* 2, Junliang Xing'2,
4
+
5
+ You Wu $^{1,3}$ , Renye Yan $^{1,4}$ , Yaozhong Gan $^{1}$ , Yuanchun Shi $^{1,2}$
6
+
7
+ $^{1}$ QiYuan Lab, $^{2}$ Department of Computer Science and Technology, Tsinghua University
8
+
9
+ $^{3}$ Nanjing University, $^{4}$ Peking University
10
+
11
+ {wuzhe, wuyou, yanrenye, ganyaozhong}@qiyuanlab.com,
12
+
13
+ luhf23@mails.tsinghua.edu.cn,{jlxing, shiyc}@tsinghua.edu.cn
14
+
15
+ # ABSTRACT
16
+
17
+ Human intelligence is adept at absorbing valuable insights from external knowledge. This capability is equally crucial for artificial intelligence. In contrast, classical reinforcement learning agents lack such capabilities and often resort to extensive trial and error to explore the environment. This paper introduces PAE: Planner-Actor-Evaluator, a novel framework for teaching agents to learn to absorb external knowledge. PAE integrates the Planner's knowledge-state alignment mechanism, the Actor's mutual information skill control, and the Evaluator's adaptive intrinsic exploration reward to achieve 1) effective cross-modal information fusion, 2) enhanced linkage between knowledge and state, and 3) hierarchical mastery of complex tasks. Comprehensive experiments across 11 challenging tasks from the BabyAI and MiniHack environment suites demonstrate PAE's superior exploration efficiency with good interpretability.
18
+
19
+ # 1 INTRODUCTION
20
+
21
+ Accepting suggestions from external guidance is an integral part of human learning. Humans can absorb insightful external knowledge and seamlessly integrate it into their strategies to tackle complex tasks (Council et al., 2000; Mills et al., 2010). By leveraging existing knowledge, human players can quickly adapt to completely unfamiliar games after just a few rounds of playing. Their ability to swiftly transfer and align existing knowledge with the current environment is a true testament to human intelligence. Building intelligent systems that can learn and integrate like humans is an ultimate goal we relentlessly pursue. Currently, reinforcement learning (RL) has demonstrated its potential towards this goal, with remarkable breakthroughs in numerous domains, approaching or even surpassing human capabilities on Atari Games (Mnih et al., 2013), Go (Silver et al., 2016) and StarCraft (Vinyals et al., 2019).
22
+
23
+ However, currently RL struggles to efficiently capture and integrate the vast amount of expert
24
+
25
+ knowledge already existing in the domain. Specifically, RL faces challenges in long-term and sparse reward tasks due to a lack of guidance, requiring extensive trial and error. Our primary focus in this
26
+
27
+ ![](images/4d6f5f93a16fcec4222ef5929bc7af987f740c98d4ef28d21222505c30c78b36.jpg)
28
+ Figure 1: The Planner-Actor-Evaluator (PAE) framework consists of three key components.
29
+
30
+ work is teaching agents to leverage external knowledge and approach optimal solutions faster in sparse reward environments.
31
+
32
+ Although mimicking human capabilities benefits RL, it remains challenging for RL agents to realize the above capabilities (Chowdhury et al., 2023). Three main challenges arise when training agents to absorb external knowledge to improve their capabilities. (1) *Difficulties in knowledge acquisition and representation*. Existing approaches utilize Behavioral Cloning (BC) to acquire knowledge by imitating human behaviors directly (Codevilla et al., 2018) or adopt Inverse Reinforcement Learning (IRL) to learn reward functions for providing knowledge (Arora & Doshi, 2021). However, this necessitates many demonstrations, which are costly to label and collect. (2) *Obstacles to the integration of external knowledge and internal strategies*. Integration requires bridging the gap between the discrete nature of external knowledge and the continuous nature of internal strategies. Two potential directions emerge: one is enabling internal strategies to query external knowledge, but it faces challenges at the retrieval level (Reid et al., 2022). The other approach is directly encoding domain knowledge as propositional rules into neural networks for a warm start, leading to training difficulties and poor generalization (Silva & Gombolay, 2021). (3) *Challenge of synergistic updating of external knowledge and internal strategies*. Large Language Models (LLMs) have recently demonstrated impressive capabilities (Chowdhery et al., 2022; Brown et al., 2020), but constant changes in the external world can quickly render them obsolete for time-sensitive tasks (e.g., news question answering). While some recent studies have attempted to directly map the rich semantic knowledge within LLMs to actions (Carta et al., 2023; Mezghani et al., 2023), these mappings cannot be updated or come with high update costs.
33
+
34
+ We propose using natural language as a knowledge source to bypass the difficulties of knowledge acquisition and representation. The language contains natural and flexible prior knowledge for efficient exploration and skill acquisition, enabling rapid generalization across tasks. Truly understanding the semantics and focusing on the key information is a good start to integrating external knowledge and internal strategies. To synergize the updating of external knowledge and internal strategies, external knowledge sources and internal strategies should retain the ability to learn and improve over time.
35
+
36
+ To bridge the gap between RL and human in handling sparse reward tasks, as shown in Figure 1, we propose a novel paradigm for guiding agent learning to absorb external knowledge called PAE: Planner-Actuator-Evaluator. The Planner is equipped with a state-knowledge alignment mechanism. This mechanism enables the Planner to access external knowledge sources and retrieve suitable knowledge that aligns with the current state. This aligned knowledge is progressively provided to the Actor, increasing in complexity. The Actor leverages the state information and the external knowledge provided by the Planner for joint reasoning. It incorporates a cross-attention mechanism, allowing the Actor to precisely focus on the critical state and external knowledge features. Additionally, the Actor employs a discriminative network to reverse-infer the Planner's guidance, strengthening the connection between states and knowledge. The Evaluator calculates intrinsic rewards based on the quality of external knowledge the Planner provides and the Actor's reasoning effectiveness. These intrinsic rewards guide independent updates of the Planner and the Actor.
37
+
38
+ To summarize, our contributions are as follows:
39
+
40
+ - We present a novel framework, PAE, for learning to incorporate external knowledge to achieve better and faster solutions in sparse reward environments. We demonstrate that knowledge instructing significantly improves strategy exploration in RL.
41
+ - Our PAE framework introduces a circular feedback mechanism. The Evaluator's feedback keeps the Planner aware of the scenario. The external knowledge the Planner provides aligns with the Actor's current capabilities, enabling the Actor to master knowledge from easy to complex.
42
+ - Our proposed framework produces interpretable sequences of steps, with the Planner providing a comprehensible plan in natural language form.
43
+
44
+ We evaluated our proposed PAE framework across 11 challenging tasks from the BabyAI (Chevalier-Boisvert et al., 2018) and MiniHack (Samvelyan et al., 2021) environment suites. Compared to non-knowledge-guided baseline methods, our PAE framework improves performance by an average of $148\%$ and achieves convergence at least $40\%$ faster. Compared to baseline approaches using language guidance, the PAE framework exhibits an average performance improvement of at least $13\%$ and converges at least $31\%$ faster.
45
+
46
+ # 2 RELATED WORK
47
+
48
+ We build upon extensive work in areas related to the study of knowledge and reinforcement learning (RL). Our focus lies in knowledge acquisition and representation, the integration of external knowledge and internal strategies, and exploration in RL.
49
+
50
+ Knowledge Acquisition and Representation Converting and representing extracted knowledge effectively is the primary challenge in enhancing a reinforcement learning agent's capabilities with external knowledge. Imitation learning and inverse reinforcement learning capture domain knowledge by mimicking human actions via state-action pairs, yet these often require laborious human labeling and feedback (Codevilla et al., 2018; Ho & Ermon, 2016). Representing knowledge as a graph (Xu et al., 2020; Zhang et al., 2022), such as a knowledge or scene graph, encounters issues of limited structured data and sparse valid information. He et al. (2017) treat documents as external knowledge; the agent must learn to interpret them for task-solving. Bougie & Ichise (2018) use environmental data from object detectors as external knowledge, broadening its applicability. In contrast, our approach employs natural language directly as external knowledge, eliminating the need for preprocessing. This fosters agent exploration guided by human-intuitive, natural interaction.
51
+
52
+ External Knowledge and Internal Strategy Integration Incorporating external knowledge to enhance agent decision-making is crucial. Some methods teach AI to use language for querying external knowledge (Carta et al., 2022; Liu et al., 2022) but grapple with generating sizable, retrievable language queries. Several approaches (Humbird et al., 2018; Silva & Gombolay, 2021) aim to embed human domain knowledge into neural decision trees yet face the challenge of bridging tree-to-neural network gaps. Our focus is linking natural language with policies to guide agent learning. Like Language-conditioned RL, our approach trains agents to follow instructions in interactive environments (Luketina et al., 2019). While prior research explored this setting for various tasks in 2D or 3D environments (Colas et al., 2020; Chevalier-Boisvert et al., 2018), we aim to craft a comprehensive framework that encompasses knowledge selection and representation, the integration of external knowledge and internal strategies, and updating knowledge-guided strategy. Our approach absorbs and understands key parts of the language for joint reasoning and selects external knowledge to provide knowledge appropriate to the current agent's capabilities. This results in enhanced task performance, greater adaptability, and improved interpretability. Some more recent work (Carta et al., 2023; Du et al., 2023) have extracted and employed knowledge from LLMs for decision-making tasks. These approaches often directly map the internal knowledge of LLMs to actions. However, this mapping weakens the policy update potential of reinforcement learning algorithms and might present challenges regarding update costs for time-sensitive tasks.
53
+
54
+ Exploration in RL Exploration stands as a crucial challenge in reinforcement learning, covering $\epsilon$ -greedy action selection (Strouse et al., 2021), state counting (Bellemare et al., 2016), curiosity-driven exploration (Schmidhuber, 1991), and intrinsic motivation (Oudeyer et al., 2007). Our approach aligns with intrinsic motivation, where novelty fosters access to new states. Other forms of intrinsic motivation include empowerment (Klyubin et al., 2005), promoting agent control over the environment, and goal diversity (Pong et al., 2020), encouraging increased entropy within the goal distribution. In contrast, we propose intrinsic motivation as a "cyclic feedback mechanism": The Evaluator's intrinsic reward prompts the Planner to equip the Actor with knowledge suitable for its current capacity, guiding the Actor to execute tasks aided by external knowledge. Our approach also emphasizes enhancing reinforcement learning through language-guided exploration (Mu et al., 2022; Carta et al., 2022). This methodology typically assumes an annotator's presence to generate language descriptions for intrinsic rewards, guiding exploration. We adopt this framework while automating and unifying the entire process, encompassing knowledge representation and selection, integrating external knowledge and intrinsic strategies, and computation of guided intrinsic rewards.
55
+
56
+ # 3 PRELIMINARIES
57
+
58
+ We formally define the problem formulation of Knowledge-Instructed Reinforcement Learning. We consider augmented Partially Observable Markov Decision Processes (POMDPs) (Kaelbling et al., 1998). Our augmented POMDP can be described by a 7-tuple $\mathcal{M} = \langle S, \mathcal{A}, \mathcal{T}, \mathcal{R}, \Omega, O, \mathcal{K} \rangle$ . $\mathcal{S}$ is the state space. $\mathcal{A}$ donates the action space. $\Omega$ is the observation space. $\mathcal{K}$ is the knowledge set. $\mathcal{T}: \mathcal{S} \times \mathcal{A} \times \mathcal{S} \mapsto \mathbb{R}^{+}$ is the state transition function. $\mathcal{O}: \mathcal{S} \times \mathcal{A} \times \Omega \mapsto \mathbb{R}^{+}$ is the observation
59
+
60
+ function. $\mathcal{R}:S\times \mathcal{A}\times \mathcal{K}\mapsto \mathbb{R}$ represents the state-action reward. At each time step $t$ , the agent receives an observation $o_{t}\in \Omega$ and a knowledge $k\in \mathcal{K}$ . Based on these inputs, the agent selects an action $a_{t}\in \mathcal{A}$ , and transits to the next state $s_{t + 1}\in S$ . Via RL, our goal is to find some policy $\pi :\mathcal{S}\times \mathcal{K}\mapsto \mathcal{A}$ that maximizes the expected return.
61
+
62
+ We assume that the environment provides knowledge following previous work (Jiang et al., 2019; Mirchandani et al., 2021; Waytowich et al., 2019; Mu et al., 2022). We impose no specific representation requirements and present all knowledge in natural language. Natural language's hierarchical structure and rich semantics profoundly impact an agent's cognitive functions (Colas et al., 2022). Agents can update internal strategies guided by language's generality and abstraction, enhancing comprehension of complex concepts and alignment with human values. Many modern RL environments include language by default (Mu et al., 2022), like BabyAI (Chevalier-Boisvert et al., 2018), NetHack (Küttler et al., 2020), MiniHack (Samvelyan et al., 2021), text-based games (Côté et al., 2019; Shridhar et al., 2020; Urbanek et al., 2019), and most video games. In language-absent environments, language descriptions relevant to the agent's state can be produced by generative models of language trained on gigantic amounts of text such as GPT (Brown et al., 2020), PaLM (Chowdhery et al., 2022), and Llama (Touvron et al., 2023).
63
+
64
+ # 4 METHOD
65
+
66
+ We introduce the PAE framework, a novel approach for instructing agents to learn to absorb knowledge. As shown in Figure 1, PAE consists of three core components: (1) the Planner, a policy network that delivers language-based external knowledge guidance, adapting in complexity following both task features and the Actor's current capabilities; (2) the Actor, a knowledge-conditioned policy, designed to integrate external knowledge and environment states for joint reasoning; and (3) the Evaluator, a module that offers intrinsic rewards to both the Planner and Actor, guiding their strategy updates.
67
+
68
+ # 4.1 ALIGNING EXTERNAL KNOWLEDGE AND STATES VIA PLANNER
69
+
70
+ To enhance guidance, the Planner must progressively select increasingly challenging knowledge for the Actor during the training procedure. This presents two key challenges: 1) correctly understanding knowledge in natural language and aligning it with the current environmental state, and 2) adjusting the complexity of the chosen knowledge based on the Actors' abilities. To achieve this, we consider the Planner as a policy network $\pi_p(k|s_0,\mathcal{K};\pmb{\theta})$ modeled by an MDP: it inputs an initial state $s_0^1$ and a set of knowledge $\mathcal{K}$ and selects a piece of knowledge $k\in \mathcal{K}$ as output. The Planner provides new knowledge whenever a new episode starts, or the Actor reaches an intrinsic goal guided by the knowledge. The Planner receives rewards only when the Actor completes the task using the provided knowledge, aiming to maximize cumulative rewards. Figure 2 provides an overview of the Planner.
71
+
72
+ Encoding. To assist the Planner in better comprehending hidden information within the environment and knowledge, we introduce a state encoder and a knowledge encoder to encode state and knowledge information to embedded features separately. Specifically, for the state encoder, visual state embeddings $s_0 \in \mathbb{R}^{HW \times c}$ are fed to a shape-preserving 2D convolution layer to generate the state feature $\hat{s}_0 \in \mathbb{R}^{HW \times d_s}$ . To capture both the content and spatial characteristics of the states, position embeddings $\mathbf{E}_{pos}$ are added to $\hat{s}_0$ , which is formulated as:
73
+
74
+ $$
75
+ \hat {\mathbf {s}} _ {0} = \operatorname {C o n v} \left(s _ {0}\right) + \mathbf {E} _ {p o s}, \quad s _ {0} \in \mathbb {R} ^ {H W \times C} \quad \hat {\mathbf {s}} _ {0}, \mathbf {E} _ {p o s} \in \mathbb {R} ^ {H W \times d _ {s}}, \tag {1}
76
+ $$
77
+
78
+ where $c$ is the dimension of embedding vectors and $d_{s}$ is the channels of feature maps after convolution. For the knowledge encoder, each unit of knowledge $k_{i} \in \mathcal{K}$ is encoded using a pre-trained language model (e.g. BERT-base) with frozen parameters, yielding the knowledge embeddings $\hat{k}_{i}$ :
79
+
80
+ $$
81
+ \hat {\mathbf {k}} = \left[ \hat {k} ^ {(1)}, \hat {k} ^ {(2)}, \dots , \hat {k} ^ {(n)} \right] = \operatorname {P r o j} \left(\mathrm {L M} \left(\left[ k ^ {(1)}, k ^ {(2)}, \dots , k ^ {(n)} \right]\right)\right), \quad \hat {\mathbf {k}} \in \mathbb {R} ^ {n \times d _ {k}}, \tag {2}
82
+ $$
83
+
84
+ where $\mathrm{Proj}(\cdot)$ is a linear projection layer and $d_{k}$ is the dimension of knowledge embedding vectors.
85
+
86
+ ![](images/246c222bf3af8f902dfa118f3fd4dbfd69dafbfe2c89d699b1fb20ae8f455707.jpg)
87
+ Figure 2: Overview of the Planner Network
88
+
89
+ Alignment. To better align external knowledge with the current environment, we utilize the scaled dot-product cross-attention mechanism to enable the Planner to attend between knowledge and states. Specifically, we compute the query $Q$ using the knowledge embeddings $\hat{\mathbf{k}}$ and compute the key $K$ and value $V$ using the position-embedded state feature $\hat{\mathbf{s}}_0$ . In summary, the alignment procedure can be formulated as:
90
+
91
+ $$
92
+ \hat {\mathbf {k}} _ {s _ {0}} = \operatorname {A t t e n t i o n} (Q, K, V) = \operatorname {S o f t M a x} \left(\frac {Q K ^ {T}}{\sqrt {d _ {k}}}\right) V \tag {3}
93
+ $$
94
+
95
+ $$
96
+ \text {w h e r e} Q = \hat {\mathbf {k}} W _ {Q}, K = \hat {\mathbf {s}} _ {0} W _ {K}, V = \hat {\mathbf {s}} _ {0} W _ {V},
97
+ $$
98
+
99
+ where $W_{Q}\in \mathbb{R}^{d_{k}\times d_{k}}$ , $W_{K}\in \mathbb{R}^{d_{s}\times d_{k}}$ and $W_{V}\in \mathbb{R}^{d_{s}\times d_{k}}$ are learnable projection matrices.
100
+
101
+ **Forwarding.** The cross-attention layer produces $n$ context vectors $\hat{\mathbf{k}}_{s_0} = [\hat{k}_{s_0}^{(1)},\hat{k}_{s_0}^{(2)},\dots ,\hat{k}_{s_0}^{(n)}]$ that aggregates critical information from both the knowledge set and the state, emphasizing knowledge most relevant to the current state. Then, $\hat{\mathbf{k}}_{s_0}\in \mathbb{R}^{n\times d_k}$ will be linear projected to $n$ 1-dimensional scales and go through a softmax layer, aiding the Planner in selecting the appropriate instruction for the Actor.
102
+
103
+ $$
104
+ \pi_ {p} (k | s _ {0}, \mathcal {K}; \boldsymbol {\theta}) = \operatorname {S o f t M a x} (\mathrm {L N} (\hat {\mathbf {k}} _ {s _ {0}})). \tag {4}
105
+ $$
106
+
107
+ # 4.2 TRAINING ACTOR-SPECIFIC INIncrementAL SKILLS WITH EXTERNAL KNOWLEDGE
108
+
109
+ The Actor is a knowledge-conditioned policy parameterized as $\pi_{a}(a_{t}|^{p}s_{t},k;\omega)$ . Once the Planner provides the Actor with suitable external knowledge, we aim for the Actor's competence in two key areas. First, like the Planner, the Actor must comprehensively grasp knowledge in its natural language form. Second, we want the guiding knowledge to influence the state reached by the Actor, such that different knowledge leads to distinct skills. Accordingly, we seek to strengthen the correlation between knowledge and state.
110
+
111
+ Encoding, Alignment & Forwarding. To master language comprehension and align knowledge with current observable states, the Actor adopts a three-stage pipeline similar to the Planner: encoding, alignment, and forward. However, unlike the Planner, the Actor receives ${}^p s_t \in \mathbb{R}^{hw \times c}$ , a partially observable state of size $h \times w$ , and $k$ , a single piece of knowledge filtered by the Planner, at each time step $t$ . In the Encoding stage, due to the reduced information content of the input state ${}^p s_t$ , we remove the shape-preserving convolution and directly add position information to state embeddings. Meanwhile, we also utilize the parameter-frozen language model to encode the existing knowledge effectively:
112
+
113
+ $$
114
+ \begin{array}{c} ^ {p} \hat {\mathbf {s}} _ {t} = ^ {p} s _ {t} + \mathbf {e} _ {p o s} \\ \hat {\mathbf {\Phi}} \end{array} \quad^ {p} \hat {\mathbf {s}} _ {t}, ^ {p} s _ {t}, \mathbf {e} _ {p o s} \in \mathbb {R} ^ {h w \times c} \tag {5}
115
+ $$
116
+
117
+ $$
118
+ \hat {k} = \operatorname {P r o j} (\operatorname {L M} (k)) \quad \hat {k} \in \mathbb {R} ^ {1 \times d _ {k}}
119
+ $$
120
+
121
+ During the Alignment stage, we also incorporate the scaled dot-product cross-attention mechanism to achieve the knowledge-state alignment.
122
+
123
+ $$
124
+ { } ^ { p } \hat { k } _ { s _ { t } } = \operatorname { A t t e n t i o n } ( Q , K , V ) = \operatorname { S o f t M a x } \left( \frac { Q K ^ { T } } { \sqrt { d _ { k } } } \right) V \tag {6}
125
+ $$
126
+
127
+ $$
128
+ \text {w h e r e} Q = \hat {k} W _ {Q}, K = ^ {p} \hat {\mathbf {s}} _ {t} W _ {K}, V = ^ {p} \hat {\mathbf {s}} _ {t} W _ {V}
129
+ $$
130
+
131
+ ![](images/5690409de36f4625ee63f22198dee8f9c36492df36dcc17895d35bce40f66945.jpg)
132
+ Figure 3: Overview of the Actor Network
133
+
134
+ Moving on to the Forward stage, we aim to enhance the Actor's attention to current state information. To achieve this, we employ strided convolution to extract state information further. We then concatenate this extracted information with the state-aligned knowledge, passing it through a Linear and a softmax layer to generate the distribution over actions.
135
+
136
+ $$
137
+ \pi_ {a} \left(a _ {t} \mid s _ {t}, k; \omega\right) = \operatorname {S o f t M a x} \left(\operatorname {L N} \left(\left[ \operatorname {C o n v} \left(^ {p} s _ {t}\right), ^ {p} \hat {k} _ {s _ {t}} \right]\right)\right). \tag {7}
138
+ $$
139
+
140
+ Maximize the mutual information between knowledge and states. We utilize the mutual information maximization objective to build on the idea that knowledge should dictate the states the agent visits. Our approach maximizes the mutual information $I(s; k)$ between knowledge and states. The objective can be written as follows:
141
+
142
+ $$
143
+ \begin{array}{l} I (s; k) = \mathcal {H} (k) - \mathcal {H} (k | s) \\ = \mathbb {E} _ {k \sim p (k), s \sim \pi} [ \log p (k | s) ] - \mathbb {E} _ {k \sim p (k)} [ \log p (k) ] \tag {8} \\ \geq \mathbb {E} _ {k \sim p (k), s \sim \pi} \left[ \log q _ {\phi} (k | s) - \log p (k) \right]. \\ \end{array}
144
+ $$
145
+
146
+ As we cannot compute $p(k|s)$ exactly by integrating over all states and their associated knowledge, we approximate $p(k|s)$ using a trainable discriminative network $q_{\phi}(k|s)$ . Previous work (Eysenbach et al., 2018) has proved that maximizing the mutual information between $s$ and $k$ can translate into maximizing the variational lower bound obtained by replacing $p(k|s)$ with $q_{\phi}(k|s)$ (as shown in Equation 8). From this variational lower bound, we give the mutual information rewards $r_{MI}$ used to encourage the Actor to strengthen the connection between state and knowledge:
147
+
148
+ $$
149
+ r _ {I} = \log q _ {\phi} (k | ^ {p} s) - \log p (k). \tag {9}
150
+ $$
151
+
152
+ The discriminative network $q_{\phi}(k|^{p}s)$ is optimized using a cross-entropy loss $\mathcal{L}_{\phi}$ , denoting as:
153
+
154
+ $$
155
+ \mathcal {L} _ {\phi} \left(^ {p} s, k\right) = - \sum_ {k ^ {\prime} \in \mathcal {K}} \left(k ^ {\prime} = k\right) \cdot \log \left(q _ {\phi} \left(k ^ {\prime} \mid^ {p} s\right)\right). \tag {10}
156
+ $$
157
+
158
+ In summary, the Planner samples a piece of knowledge $k$ from the logits output by $\pi_p(k|s_0,\mathcal{K};\pmb{\theta})$ and provides it to the Actor. The Actor employs the conditional network $\pi_a(a_t|^p s_t,k;\omega)$ to make decisions in the environment guided by this knowledge $k$ . The Actor is motivated to explore states that offer higher rewards and have a close relationship with $k$ . The discriminative network $q_{\phi}(k|s)$ uses the $k$ provided by the Planner as ground truth and updates through supervised learning to better infer knowledge $k$ from the visited states. $p(k)$ is provided by the Planner's policy network $\pi_p(k|s_0,\mathcal{K};\pmb{\theta})$ . More implementation details are shown in Appendix A.3. Algorithm 1 in Appendix A.4.1 summarizes our PAE procedure.
159
+
160
+ # 4.3 EVALUATION MECHANISM
161
+
162
+ Reinforcement learning in long-term and sparse reward tasks is often difficult and requires a lot of trial and error. The standard solution to speed up this process is introducing additional reward signals to better guide learning. Incorporating external knowledge offers a more straightforward approach to reward shaping.
163
+
164
+ For the Actor, the external knowledge from the Planner serves as the missing signal in the environment. In addition to the extrinsic reward for accomplishing the final task, the Actor receives an
165
+
166
+ additional intrinsic reward of $+1$ for each subtask completed per the Planner's guidance. Consequently, the total rewards for the Actor comprise three terms: environmental extrinsic rewards $r_{ex}$ , the maximization of the mutual information term $r_{MI}$ , and intrinsic rewards $r_{in}$ :
167
+
168
+ $$
169
+ r _ {\text {a c t o r}} = r _ {e x} + r _ {i n} \left(\mathbb {I} \left(\pi_ {a} \left(a _ {t} \mid s _ {t}, k; \omega\right) \mapsto k\right)\right) + \alpha_ {I} r _ {I}, \tag {11}
170
+ $$
171
+
172
+ where $\mathbb{I}$ is the indicator function, $\pi_{a}(a_{t}|^{p}s_{t},k;\omega)\mapsto k$ denotes that the Actor completed the subtask following external knowledge guidance, $\alpha_{I} > 0$ is a scaling factor.
173
+
174
+ For the Planner, we follow the previous approach (Mu et al., 2022; Campero et al., 2020) of using the Actor's task completion as an intrinsic reward. This task is neither too easy (i.e., the knowledge given by the Planner is too simple) nor impossible (i.e., the knowledge given by the Planner is too complex) for the Actor to complete the current task, i.e., an automatic curriculum. Specifically, we evaluate the Planner using the number of steps required for the Actor to follow the guidance proposed by the Planner; if the number of steps required for the Actor to follow the guidance is within the threshold $t^*$ , or if the guidance can not be followed until the end of the episode, the Planner receives a reward of $-\beta$ , otherwise, the Planner gets a reward of $+\alpha$ :
175
+
176
+ $$
177
+ r _ {\text {p l a n n e r}} = r _ {e x} + r _ {i n}; r _ {i n} = \left\{ \begin{array}{l l} + \alpha & \text {i f} t \geq t ^ {*} \\ - \beta & \text {i f} t < t ^ {*} \text {o r} t > t _ {\max } \end{array} \right. \tag {12}
178
+ $$
179
+
180
+ For the value of $t^*$ , we use an adaptive but heuristic approach, where the threshold increases linearly by one when the Actor successfully follows the guidance ten times.
181
+
182
+ # 5 EXPERIMENTAL EVALUATION
183
+
184
+ Our experimental evaluation aims to test our central hypothesis: that external knowledge improves the exploration efficiency for RL algorithms in sparse reward environments. We conducted a series of experiments organized as follows: 1) In Section 5.1, we quantitatively evaluate the exploratory capabilities of the PAE by comparing it to various baseline methods. 2) In Section 5.2, we revealed the underlying mechanisms of the PAE through ablation experiments. 3) In Section 5.3, we elucidate the interpretability of PAE's strategy by visualizing the agent's learning process at different stages. See Appendix A.5 for additional experimental results. More implementation details of PAE are shown in Appendix A.3.
185
+
186
+ **Environments:** We evaluated our method across two task types, totaling six environments within the BabyAI environment: Key Corridor tasks (KEYCORRS3R3, KEYCORRS4R3, KEYCORRS5R3) and Obstructed Maze tasks (OBSTRMAZE1DL, OBSTRMAZE2DLHB, OBSTRMAZE1Q). The suffix signifies the environment's size; a larger environment increases the exploration difficulty in the same type of task. To demonstrate PAE's scalability, we extended our PAE approach to the more challenging MiniHack tasks. MiniHack consists of procedurally generated tasks within a Roguelike game, offering a richer observation space than the BabyAI environment. Additionally, it presents up to 75 dimensions of structured and context-sensitive action space. Our comparisons of PAE with baseline methods encompassed five MiniHack environments: LAVACROSS-RING, LAVACROSS-POTION, LAVACROSS-FULL, RIVER-MONSTER, and MULTIROOM-N4-MONSTER. See Appendix A.2 for more details.
187
+
188
+ We follow the previous work (Mu et al., 2022) to introduce knowledge. In BabyAI, the Planner receives a fully observed state and a set of 652 instructions from the BabyAI platform. Meanwhile, the Actor gets a $7 \times 7$ representation of its field of view and a single instruction filtered by the Planner. See Table 3 in Appendix A.2 for a list of knowledge provided by BabyAI. In MiniHack, the Planner and Actor have the same field of view. Observations consist of a $21 \times 79$ matrix of glyph identifiers, a 21-dimensional vector with the agent's statistics (like location and health), and a series of 256-character knowledge entries. The Planner accesses multiple knowledge entries, whereas the Actor receives a selectively filtered entry from the Planner. See Table 4 in Appendix A.2 for a list of knowledge provided by MiniHack.
189
+
190
+ # 5.1 QUALITATIVE RESULTS: COMPARE TO BASELINES
191
+
192
+ We compare PAE with six baseline algorithms across three categories to highlight PAE's advantages. 1) Vanilla Baseline Algorithms: IMPALA (Espeholt et al., 2018), a standard asynchronous
193
+
194
+ ![](images/b75707de3235204f7fe56c709373988def02e8e0515a2ee535bf05b1963fba8c.jpg)
195
+
196
+ ![](images/c9272a7ea71e2aebbcbf3df84dad59ac3cf18f6839d68c019c5898c82a7f17d2.jpg)
197
+
198
+ ![](images/19016be121b3f4ea1753c2084d9b2668db91404eef44cb8d98ca2a854f1e0245.jpg)
199
+
200
+ ![](images/a54f3f04a3b73adb48d87b605dc0573771394c4df1313945aebb4126bbf3aefc.jpg)
201
+
202
+ ![](images/baaf2055d90da70cbd2ca7274b1e7d56b56025692ed8f752d355dd2e476fadec.jpg)
203
+
204
+ ![](images/347638d333319260add4a14eef91f921ec549b043720b47b541d6102125d0f9e.jpg)
205
+
206
+ ![](images/ea58b119efc7518ed00376cbb38ed2d33ab223e9a6ca96524fcfe5a2ca7bce78.jpg)
207
+
208
+ ![](images/8e33f51d4f82aa157bc2696e6d51a59d4cde6d48e5d06ad696c7436588ac9b4f.jpg)
209
+
210
+ ![](images/71c7edaed6e90c90a7185fa31d9f0f47850b4849ebedb016545798fad9952961.jpg)
211
+ Figure 4: Performance of PAE, IMPALA, RND, ICM, AMIGo, L-AMIGo and L-NovelD in eleven environments, with error regions to indicate standard deviation over five random seeds.
212
+
213
+ ![](images/78a10d764acaf627b375eec28b964888492122d20a2ac890d786c6beca3f10ef.jpg)
214
+
215
+ ![](images/e25c5dca49f8cbc31dc668ecdc1f9d07a9fdae193aa91d5009e67d4eb3548b21.jpg)
216
+
217
+ ![](images/c20063572a6d754af83afb794202e77a31642485f0bc0084ede88ce6d1cd409b.jpg)
218
+
219
+ ![](images/e6cddbb10aed5d935bfc44cb501e5685f3d763750a4f65d67177d59f8b2e3d50.jpg)
220
+
221
+ ![](images/71f40f374961b2f18e9001e96d32ea14ad96167f995778210e13c861c5cf8291.jpg)
222
+
223
+ ![](images/2f480766bc35af4a7f2a252fedb5a568935992246b6c0b187809644d5810bb5c.jpg)
224
+
225
+ actor-critic method, focuses on rapid parallel training and learns only from raw environmental rewards, without any intrinsic motivation or external guidance. 2) Intrinsic Motivation Algorithms: RND (Burda et al., 2018) uses a randomly initialized neural network to compute prediction errors, which serve as intrinsic rewards for exploring new states. ICM (Pathak et al., 2017) encourages exploration by predicting the outcomes of actions and generating intrinsic rewards from prediction errors. AMIGo (Campero et al., 2020) pairs a goal-generating teacher with a goal-conditioned student policy, enriching environmental rewards with intrinsic goals. 3) Language-Instructed Algorithms: L-AMIGo (Mu et al., 2022) builds on AMIGo's model, using language to spotlight relevant abstract concepts in the environment. L-NovelD (Mu et al., 2022) combines natural language with an intrinsic motivation approach to reward states described in natural language that transitions from low to high novelty. While all the above baselines, except the vanilla ones, incorporate some form of external guidance, L-AMIGo is the most similar to ours. However, it introduces language knowledge solely at the level of external guidance without focusing on its integration with internal strategies. The full hyperparameter sweep for PAE and all baselines is reported in Appendix A.3.4.
226
+
227
+ As shown in Figure 4, PAE achieves almost the fastest convergence across all eleven environments. Notably, AMIGo, RND, ICM, and IMPALA fail to converge within the current step limit. Compared to the best performance in non-knowledge-guided baseline methods (AMIGo, ICM, RND), our PAE framework improves performance by an average of $148\%$ and achieves convergence at least $40\%$ faster. Compared to baseline approaches using language guidance, the PAE framework exhibits an average performance improvement of $13\%$ and converges at least $31\%$ faster. Tables 6 and 7 in Appendix A.5 give the quantitative performance of all models in the BabyAI and MiniHack environments, respectively. Furthermore, we observe excellent training stability in PAE, especially after convergence.
228
+
229
+ # 5.2 ABLATION EXPERIMENT AND ANALYSIS
230
+
231
+ To better understand the advantages PAE brings through introducing external knowledge, this section compares the mechanisms for introducing external knowledge in removing or replacing implementations. Full-Model is the full version of PAE. In w/o Curriculum, the Planner attaches equal weight to all external knowledge. w/o Planner eliminates the entire Planner's guidance to the Actor. Table 1 displays the final mean extrinsic rewards and the number of steps (in millions) needed for each model to converge. Each entry consists of two rows of results, with the top row being the average extrinsic reward at the end of training and the bottom row being the minimal stable steps to attain that reward. Lower bottom row values signify quicker convergence, and “ $>$ $x$ ” indicates a lack of convergence within the maximum training steps “ $x$ ”. Training curves for the ablation study are provided in Appendix A.5.
232
+
233
+ Table 1: Comparison of PAE and ablation models.
234
+
235
+ <table><tr><td rowspan="2">Model</td><td colspan="3">Key Corridor Tasks</td><td colspan="3">Obstructed Maze Tasks</td></tr><tr><td>KEYCORRS3R3</td><td>KEYCORRS4R3</td><td>KEYCORRS5R3</td><td>OBSTRMAZE1D1</td><td>OBSTRMAZE2D1HB</td><td>OBSTRMAZE1Q</td></tr><tr><td>Full-Model</td><td>0.89 ± 0.0026M</td><td>0.92 ± 0.00530M</td><td>0.94 ± 0.00190M</td><td>0.93 ± 0.0046M</td><td>0.87 ± 0.018150M</td><td>0.89 ± 0.006150M</td></tr><tr><td>w/o Curriculum</td><td>0.86 ± 0.02020M</td><td>0.00 ± 0.000&gt;60M</td><td>0.00 ± 0.000&gt;200M</td><td>0.93 ± 0.00412M</td><td>0.71 ± 0.324&gt;200M</td><td>0.85 ± 0.047250M</td></tr><tr><td>w/o Planner</td><td>0.00 ± 0.000&gt;20M</td><td>0.00 ± 0.000&gt;60M</td><td>0.00 ± 0.000&gt;200M</td><td>0.00 ± 0.000&gt;20M</td><td>0.00 ± 0.000&gt;200M</td><td>0.00 ± 0.000&gt;300M</td></tr></table>
236
+
237
+ We can see that the 'w/o Curriculum,' the Planner attaches equal weight to all external knowledge, performs well in four of the six environments (KEYCORRS3R3, OBSTRMAZE1DL, OBSTRMAZE2DLHB, OBSTRMAZE1Q) but requires at least $54\%$ more training steps compared to the FULL-MODEL in these four environments. 'w/o Curriculum' earned zero rewards in the other two environments (KEYCORRS4R3, KEYCORRS5R3). We analyze this because tasks like ObstructedMaze require more robust exploration to unlock critical states, while tasks like KeyCorridor emphasize easy-to-difficult completion of the final task. The 'w/o Planner' model earned no external rewards in all six environments. The above results and analysis prove the critical role of introducing external knowledge, especially of suitable difficulty, for exploration in sparse reward environments.
238
+
239
+ # 5.3 INTERPRETABILITY
240
+
241
+ One advantage of PAE's introduction of language knowledge is that it can provide insights into developing an agent's abilities during training. We first show in Figure 5 (a) that PAE has a similar capability to the approach of the automatic curriculum: Planner generates an interpretable curriculum. In the KeyCorridorS3R3 environment, the Planner first provides the Actor with easily achievable external knowledge (open the door) and gradually increases the difficulty as training progresses (go to the door, pick up the key), ultimately converging to the final goal (pick up a ball).
242
+
243
+ ![](images/5b4aa1f44e635d3656f2ecbe2f9c3c373b7eaa1e6da0a915c327081a544ff7ea.jpg)
244
+ (a) Planner, Knowledge curriculum
245
+
246
+ ![](images/7a7f9e2df330b3c90bcf7447c23f422d33c19eb46b162c82c8cefc7444437f7f.jpg)
247
+ (b) Actor, Knowledge acquisition
248
+ Figure 5: Interpretation of knowledge-instructed exploration. The knowledge curriculum introduced by the Planner (left) and the Actor's knowledge acquisition process (right) are illustrated in the KeyCorridorS3R3 environment.
249
+
250
+ In addition to generating a similar curriculum, Figure 5 (b) also visualizes the number of steps required for the Actor to follow each external knowledge, offering insights into this incremental capability acquisition. We can see that the Planner provides increasingly difficult knowledge during the training process, reflected in a gradual increase in the probability of complex knowledge being presented. Conversely, the Actor gradually improves his proficiency in mastering each knowledge fragment during the training process, reflected in a gradual decrease in the required steps.
251
+
252
+ # 6 CONCLUSION
253
+
254
+ In this work, we propose Planner-Actor-Evaluator (PAE), a knowledge-instructed reinforcement learning framework for efficient exploration in sparse reward environments. PAE has several desirable properties: it achieves alignment and joint inference of external knowledge and internal agent states and emerges as an interpretable curriculum. Moreover, PAE is algorithm agnostic, making it compatible with any deep reinforcement learning algorithm.
255
+
256
+ # ACKNOWLEDGEMENT
257
+
258
+ This work was partly supported by the Natural Science Foundation of China under Grant No. 62222606 and 62076238.
259
+
260
+ # REFERENCES
261
+
262
+ Saurabh Arora and Prashant Doshi. A survey of inverse reinforcement learning: Challenges, methods and progress. Artificial Intelligence, 297:103500, 2021.
263
+ Marc Bellemare, Sriram Srinivasan, Georg Ostrovski, Tom Schaul, David Saxton, and Remi Munos. Unifying count-based exploration and intrinsic motivation. Advances in Neural Information Processing Systems, 29, 2016.
264
+ Nicolas Bougie and Ryutaro Ichise. Deep reinforcement learning boosted by external knowledge. In Proceedings of the 33rd Annual ACM Symposium on Applied Computing, pp. 331-338, 2018.
265
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in Neural Information Processing Systems, 33:1877-1901, 2020.
266
+ Yuri Burda, Harrison Edwards, Amos Storkey, and Oleg Klimov. Exploration by random network distillation. arXiv preprint arXiv:1810.12894, 2018.
267
+ Andres Campero, Roberta Raileanu, Heinrich Kuttler, Joshua B Tenenbaum, Tim Rocktaschel, and Edward Grefenstette. Learning with amigo: Adversarily motivated intrinsic goals. arXiv preprint arXiv:2006.12122, 2020.
268
+ Thomas Carta, Pierre-Yves Oudeyer, Olivier Sigaud, and Sylvain Lamprier. Eager: Asking and answering questions for automatic reward shaping in language-guided rl. Advances in Neural Information Processing Systems, 35:12478-12490, 2022.
269
+ Thomas Carta, Clément Romac, Thomas Wolf, Sylvain Lamprier, Olivier Sigaud, and Pierre-Yves Oudeyer. Grounding large language models in interactive environments with online reinforcement learning. arXiv preprint arXiv:2302.02662, 2023.
270
+ Liting Chen, Lu Wang, Hang Dong, Yali Du, Jie Yan, Fangkai Yang, Shuang Li, Pu Zhao, Si Qin, Saravan Rajmohan, et al. Introspective tips: Large language model for in-context decision making. arXiv preprint arXiv:2305.11598, 2023.
271
+ Maxime Chevalier-Boisvert, Dzmitry Bahdanau, Salem Lahlou, Lucas Willems, Chitwan Saharia, Thien Huu Nguyen, and Yoshua Bengio. Babyai: A platform to study the sample efficiency of grounded language learning. arXiv preprint arXiv:1810.08272, 2018.
272
+ Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
273
+ Tanmoy Chowdhury, Chen Ling, Xuchao Zhang, Xujiang Zhao, Guangji Bai, Jian Pei, Haifeng Chen, and Liang Zhao. Knowledge-enhanced neural machine reasoning: A review. arXiv preprint arXiv:2302.02093, 2023.
274
+ Felipe Codevilla, Matthias Müller, Antonio López, Vladlen Koltun, and Alexey Dosovitskiy. End-to-end driving via conditional imitation learning. In 2018 IEEE International Conference on Robotics and Automation, pp. 4693-4700. IEEE, 2018.
275
+ Cédric Colas, Tristan Karch, Nicolas Lair, Jean-Michel Dussoux, Clément Moulin-Frier, Peter Dominey, and Pierre-Yves Oudeyer. Language as a cognitive tool to imagine goals in curiosity driven exploration. Advances in Neural Information Processing Systems, 33:3761-3774, 2020.
276
+ Cédric Colas, Tristan Karch, Clément Moulin-Frier, and Pierre-Yves Oudeyer. Language and culture internalization for human-like autotelic ai. Nature Machine Intelligence, 4(12):1068-1076, 2022.
277
+
278
+ Marc-Alexandre Côté, Akos Kádár, Xingdi Yuan, Ben Kybartas, Tavian Barnes, Emery Fine, James Moore, Matthew Hausknecht, Layla El Asri, Mahmoud Adada, et al. Textworld: A learning environment for text-based games. In Computer Games: 7th Workshop, CGW 2018, pp. 41-75. Springer, 2019.
279
+ National Research Council et al. How people learn: Brain, mind, experience, and school: Expanded edition, volume 1. National Academies Press, 2000.
280
+ Yuqing Du, Olivia Watkins, Zihan Wang, Cédric Colas, Trevor Darrell, Pieter Abbeel, Abhishek Gupta, and Jacob Andreas. Guiding pretraining in reinforcement learning with large language models. arXiv preprint arXiv:2302.06692, 2023.
281
+ Lasse Espeholt, Hubert Soyer, Remi Munos, Karen Simonyan, Vlad Mnih, Tom Ward, Yotam Doron, Vlad Firoiu, Tim Harley, Iain Dunning, et al. Impala: Scalable distributed deep-rl with importance weighted actor-learner architectures. In International Conference on Machine Learning, pp. 1407-1416. PMLR, 2018.
282
+ Benjamin Eysenbach, Abhishek Gupta, Julian Ibarz, and Sergey Levine. Diversity is all you need: Learning skills without a reward function. arXiv preprint arXiv:1802.06070, 2018.
283
+ Ji He, Mari Ostendorf, and Xiaodong He. Reinforcement learning with external knowledge and two-stage q-functions for predicting popular reddit threads. arXiv preprint arXiv:1704.06217, 2017.
284
+ Jonathan Ho and Stefano Ermon. Generative adversarial imitation learning. Advances in Neural Information Processing Systems, 29, 2016.
285
+ Kelli D Humbird, J Luc Peterson, and Ryan G McClarren. Deep neural network initialization with decision trees. IEEE Transactions on Neural Networks and Learning Systems, 30(5):1286-1295, 2018.
286
+ Yiding Jiang, Shixiang Shane Gu, Kevin P Murphy, and Chelsea Finn. Language as an abstraction for hierarchical deep reinforcement learning. Advances in Neural Information Processing Systems, 32, 2019.
287
+ Leslie Pack Kaelbling, Michael L Littman, and Anthony R Cassandra. Planning and acting in partially observable stochastic domains. Artificial Intelligence, 101(1-2):99-134, 1998.
288
+ Alexander S Klyubin, Daniel Polani, and Chystopher L Nehaniv. Empowerment: A universal agent-centric measure of control. In IEEE Congress on Evolutionary Computation, volume 1, pp. 128-135. IEEE, 2005.
289
+ Heinrich Küttler, Nantas Nardelli, Thibaut Lavril, Marco Selvatici, Viswanath Sivakumar, Tim Rocktäschel, and Edward Grefenstette. Torchbeast: A pytorch platform for distributed rl. arXiv preprint arXiv:1910.03552, 2019.
290
+ Heinrich Kuttler, Nantas Nardelli, Alexander Miller, Roberta Raileanu, Marco Selvatici, Edward Grefenstette, and Tim Rocktäschel. The nethack learning environment. Advances in Neural Information Processing Systems, 33:7671-7684, 2020.
291
+ Iou-Jen Liu, Xingdi Yuan, Marc-Alexandre Côté, Pierre-Yves Oudeyer, and Alexander Schwing. Asking for knowledge (afk): Training rl agents to query external knowledge using language. In International Conference on Machine Learning, pp. 14073-14093. PMLR, 2022.
292
+ Jelena Luketina, Nantas Nardelli, Gregory Farquhar, Jakob Foerster, Jacob Andreas, Edward Grefenstette, Shimon Whiteson, and Tim Rocktäschel. A survey of reinforcement learning informed by natural language. arXiv preprint arXiv:1906.03926, 2019.
293
+ Lina Mezghani, Piotr Bojanowski, Karteek Alahari, and Sainbayar Sukhbaatar. Think before you act: Unified policy for interleaving language reasoning with actions. In Workshop on Reincarnating Reinforcement Learning at ICLR, 2023.
294
+
295
+ Candice M Mills, Christine H Legare, Megan Bills, and Caroline Mejias. Preschoolers use questions as a tool to acquire knowledge from different sources. Journal of Cognition and Development, 11 (4):533-560, 2010.
296
+ Suvir Mirchandani, Siddharth Karamcheti, and Dorsa Sadigh. Ella: Exploration through learned language abstraction. Advances in Neural Information Processing Systems, 34:29529-29540, 2021.
297
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602, 2013.
298
+ Jesse Mu, Victor Zhong, Roberta Raileanu, Minqi Jiang, Noah Goodman, Tim Roktäschel, and Edward Grefenstette. Improving intrinsic exploration with language abstractions. Advances in Neural Information Processing Systems, 35:33947-33960, 2022.
299
+ Pierre-Yves Oudeyer, Frédric Kaplan, and Verena V Hafner. Intrinsic motivation systems for autonomous mental development. IEEE Transactions on Evolutionary Computation, 11(2):265-286, 2007.
300
+ Deepak Pathak, Pulkit Agrawal, Alexei A Efros, and Trevor Darrell. Curiosity-driven exploration by self-supervised prediction. In International Conference on Machine Learning, pp. 2778-2787. PMLR, 2017.
301
+ Vitchyr H Pong, Murtaza Dalal, Steven Lin, Ashvin Nair, Shikhar Bahl, and Sergey Levine. Skewfit: state-covering self-supervised reinforcement learning. In International Conference on Machine Learning, pp. 7783-7792, 2020.
302
+ Roberta Raileanu and Tim Rocktäschel. Ride: Rewarding impact-driven exploration for procedurally-generated environments. arXiv preprint arXiv:2002.12292, 2020.
303
+ Machel Reid, Yutaro Yamada, and Shixiang Shane Gu. Can wikipedia help offline reinforcement learning? arXiv preprint arXiv:2201.12122, 2022.
304
+ Mikayel Samvelyan, Robert Kirk, Vitaly Kurin, Jack Parker-Holder, Minqi Jiang, Eric Hambro, Fabio Petroni, Heinrich Kuttler, Edward Grefenstette, and Tim Roktaschel. Minihack the planet: A sandbox for open-ended reinforcement learning research. In Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2021.
305
+ Jürgen Schmidhuber. A possibility for implementing curiosity and boredom in model-building neural controllers. In Proc. of the International Conference on Simulation of Adaptive Behavior: From animals to animals, pp. 222-227, 1991.
306
+ Mohit Shridhar, Xingdi Yuan, Marc-Alexandre Côté, Yonatan Bisk, Adam Trischler, and Matthew Hausknecht. Alfworld: Aligning text and embodied environments for interactive learning. arXiv preprint arXiv:2010.03768, 2020.
307
+ Andrew Silva and Matthew Gombolay. Encoding human domain knowledge to warm start reinforcement learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 5042-5050, 2021.
308
+ David Silver, Aja Huang, Chris J Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. Mastering the game of go with deep neural networks and tree search. Nature, 529(7587):484-489, 2016.
309
+ DJ Strouse, Kate Baumli, David Warde-Farley, Volodymyr Mnih, and Steven Stenberg Hansen. Learning more skills through optimistic exploration. In International Conference on Learning Representations, 2021.
310
+ Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.
311
+
312
+ Jack Urbanek, Angela Fan, Siddharth Karamcheti, Saachi Jain, Samuel Humeau, Emily Dinan, Tim Rocktäschel, Douwe Kiela, Arthur Szlam, and Jason Weston. Learning to speak and act in a fantasy text adventure game. arXiv preprint arXiv:1903.03094, 2019.
313
+ Oriol Vinyals, Igor Babuschkin, Wojciech M Czarnecki, Michael Mathieu, Andrew Dudzik, Junyoung Chung, David H Choi, Richard Powell, Timo Ewalds, Petko Georgiev, et al. Grandmaster level in starcraft ii using multi-agent reinforcement learning. Nature, 575(7782):350-354, 2019.
314
+ Nicholas Waytowich, Sean L Barton, Vernon Lawhern, and Garrett Warnell. A narration-based reward shaping approach using grounded natural language commands. arXiv preprint arXiv:1911.00497, 2019.
315
+ Yunqiu Xu, Meng Fang, Ling Chen, Yali Du, Joey Tianyi Zhou, and Chengqi Zhang. Deep reinforcement learning with stacked hierarchical attention for text-based games. Advances in Neural Information Processing Systems, 33:16495-16507, 2020.
316
+ Yifeng Zhang, Ming Jiang, and Qi Zhao. Query and attention augmentation for knowledge-based explainable reasoning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 15576-15585, 2022.
317
+
318
+ # A APPENDIX
319
+
320
+ The supplementary material provides additional results, discussions, and implementation details.
321
+
322
+ - In Section A.1, we discuss the limitations of our PAE approach and provide insights on related work.
323
+ - In Section A.2, we detail the BabyAI and MiniHack environments and the chosen testing tasks.
324
+ - In Section A.3, we provide the implementation and training details for the PAE and the baseline algorithms.
325
+ - In Section A.4, we describe our PAE algorithm and the baseline algorithms.
326
+ - In Section A.5, we present additional experimental results and analysis.
327
+
328
+ # A.1 LIMITATIONS AND DISCUSSIONS
329
+
330
+ Limitations Despite the impressive results of our approach, we acknowledge at least two limitations. Firstly, our framework relies on environments like BabyAI and MiniHack to provide knowledge. This dependency means that applying PAE in environments lacking Oracle knowledge is challenging. However, we are fully committed to exploring the use of Large Language Models to provide knowledge. Secondly, our current approach only accepts unimodal knowledge in natural language. More exciting extensions will involve human interaction to provide more natural and multimodal knowledge, which deserves further exploration.
331
+
332
+ Relationship with LLM-based frameworks LLM-based agents are gaining popularity in solving RL tasks, and very recent studies have shown considerable potential (Carta et al., 2023; Chen et al., 2023). There are currently two main categories of LLM-based agents for decision-making: 1. Finetuning LLMs using RL for decision-making, and 2. Employing LLMs directly for decision-making as plug-ins. These differ significantly from PAE, which uses external knowledge to enhance RL algorithms. In contrast, recent LLM-based agent studies primarily showcase the abilities of LLMs or expand their capabilities using RL methods. In our PAE approach, LLMs are a tool to aid agents in understanding the semantics of knowledge.
333
+
334
+ # A.2 ENVIRONMENT AND TASK DETAILS
335
+
336
+ BabyAI and Minigrid The BabyAI platform enables research in grounded language learning involving humans. In BabyAI, agents maximize rewards by completing tasks within limited steps, guided by language instructions. The platform utilizes a grid world environment (Minigrid), a partially observable 2D grid world housing agents and objects (available in 6 colors): boxes, balls, doors, and keys. These entities occupy $N \times M$ tiled rooms interconnected by doors, which may be locked or closed. Agents can pick up, drop, and move objects, while doors require color-matching keys for unlocking. As shown in Figure 6, we evaluated our approach in the BabyAI across six environments spanning two task types: the Key Corridor task (KEYCORRS3R3, KEYCORRS4R3, KEYCORRS5R3) and the Obstructed Maze task (OBSTRMAZE1DL, OBSTRMAZE2DLHB, OBSTRMAZE1Q). Table 2 illustrates critical properties of the Minigrid environment. Table 3 shows the 66 categories of templates provided by BabyAI, totaling 652 pieces of language knowledge.
337
+
338
+ Key Corridor In the Key Corridor task, the 'S' in the environment name's suffix indicates the room's size, while 'R' signifies the number of rows. The agent must retrieve an item behind a locked door. The key, concealed in a different room, must be found by the agent exploring the environment. Figure 11 illustrates the flow chart for the agent to complete the Key Corridor tasks.
339
+
340
+ Obstructed Maze In the Obstructed Maze task, a small blue ball is concealed in a corner. With the door locked and blocked by the ball, the key to unlock it is hidden inside a box. The agent must execute a series of precise steps. Typically, this involves opening the box to obtain the correctly colored key, using the key to unlock the door, and subsequently accessing the door to reach the objective. Figure 12 illustrates the flow chart for the agent to complete the Obstructed Maze tasks.
341
+
342
+ MiniHack The MiniHack environment is a graphical adaptation of NetHack (Küttler et al., 2020), featuring a richer observation space compared to BabyAI. It includes more symbols and supports
343
+
344
+ ![](images/766636263f841ff7dbc02097b8ad8a3688aefa92177b284582225c73b67984df.jpg)
345
+ (a) KeyCorridorS3R3
346
+
347
+ ![](images/f3ab33bf6c7f8e91ba78803160e4c1076f7945413545b75767436c78e82517b8.jpg)
348
+ (b) KeyCorridorS4R3
349
+
350
+ ![](images/5061233e8f35c5784237ecf9263f8d1a81bf62651837683b39de2dcb7ee715c8.jpg)
351
+ (c) KeyCorridorS5R3
352
+
353
+ ![](images/9f26f4f032f6d74f5af1d4d83bb582c791807ae31e3d0b28052be79cfc9c8fe2.jpg)
354
+ (d) ObstructedMaze-1Dl
355
+
356
+ ![](images/e216b3895385446c00ae96f5186237fd3dcb30ad95074538ace015967df17a2f.jpg)
357
+ (e) ObstructedMaze-2D1hb
358
+
359
+ ![](images/2bf1deddd111d4ffd279e0512db180ef82f503c37e12cbfecd74cd0ee4ce3ab2.jpg)
360
+ (f)ObstructedMaze-1Q
361
+ Figure 6: Six challenging environments in BabyAI we used to evaluate PAE.
362
+
363
+ up to 75 different actions. Observations comprise a $21 \times 79$ matrix of glyph identifiers, a 21-dimensional vector detailing agent statistics, location and health, and real natural language messages received during gameplay. As shown in Figure 7, we evaluate our approach in five environments of MiniHack, including two task types: navigation tasks (RIVER-MONSTER, MULTIROOM-N4-MONSTER) and skill acquisition tasks (LAVACROSS-RING, LAVACROSS-POTION, LAVACROSS-FULL). Navigation tasks in MiniHack challenge the agent program to navigate various obstacles, like crossing a river by maneuvering boulders or traversing intricate or randomly generated mazes to reach a specific destination. Skill Acquisition tasks leverage the extensive variety of NetHack's objects, monsters, and dungeon features, including their interplay. For instance, to wear a ring, the agent must choose the PUTON action, select the ring from the inventory, and decide which hand to wear it on. Table 2 details MiniHack's main features, while Table 4 enumerates some real natural language messages received by the agent during gameplay.
364
+
365
+ Knowledge in BabyAI and MiniHack (1) The knowledge presented in Table 3 for BabyAI and in Table 4 for MiniHack can be regarded as target states. For example, in MiniGrid, the message "go to the door" can be interpreted as "(in this state), go to the door." In MiniHack, the message "the o is killed!" can be interpreted as "(in this state), kill the o!). We can view these system text descriptions as the required states that the Planner hopes the Actor will achieve after taking a series of actions. Consequently, the Actor must either take the appropriate action to achieve these goals or extract useful strategies from the actions (trajectories) previously taken toward these goals. (2) Much of the knowledge in MiniHack does not directly contribute to task completion. Given that MiniHack's knowledge is derived from actual player feedback during gameplay, it naturally includes irrelevant or emotional messages, such as "ouch!" and "never mind." A rough estimate is provided here: an agent capable of solving the Lavacross task will encounter approximately 80 messages, of which only 6-10 (8-13%) are necessary for a successful trajectory. This requires the Planner to semantically understand these environment messages and filter and exclude those useless knowledge.
366
+
367
+ # A.3 IMPLEMENTATION DETAILS
368
+
369
+ # A.3.1 MODEL ARCHITECTURE DETAILS OF PLANNER
370
+
371
+ This section provides more details of the Planner architecture used in our method. Planner consists of three components, i.e., encoding, alignment, and forwarding of states and knowledge.
372
+
373
+ Encoding Following BabyAI, the environment observation is a symbolic $H \times W \times 3$ fully observed representation, with $N$ varying according to the environment's size. Each cell in the $H \times W$ grid has 3 features indicating the object's type (e.g., boxes, balls, doors, keys), color (from 6 possible
374
+
375
+ Table 2: Examples of BabyAI and MiniHack environments and their entity labeling.
376
+
377
+ <table><tr><td>Illustration</td><td>Observation</td><td>Other Properties</td></tr><tr><td>Goal
378
+ Door
379
+ Agent
380
+ Obstruction</td><td>Observation: In BabyAI, the agent&#x27;s observation space is an ego-centric 7x7 grid representation oriented in the direction the agent faces. Each cell within this grid has three defining features: object, color, and state. These features identify the object in the cell, its color, and its state (e.g., distinguishing between a locked and unlocked door).</td><td>Action:
381
+ Turn left, Turn right, Move forward, Pick up an object, Drop, Toggle, Done
382
+ Reward:
383
+ A reward of ‘1 - 0.9 × (step_count / max_steps)’ is given for success and 0 for failure.
384
+ Termination:
385
+ The agent picks up the correct object.
386
+ Timeout.</td></tr><tr><td></td><td>Observation: In MiniHack, the agent&#x27;s observation consists of a 21 × 79 matrix of glyph identifiers, a 21-dimensional vector with the agent&#x27;s statistics (like location and health), and a series of messages. A “message” is the UTF-8 encoding of the on-screen message displayed at the top of the screen, represented as a 256-dimensional vector. Each glyph represents a completely unique entity, with integers ranging from 0 to MAX_GLYPH (5991).</td><td>Action:
387
+ MiniHack contains 75 actions, including movement commands, managing inventory, casting spells, chopping wands, and more.
388
+ Reward &amp; Termination:
389
+ MiniHack&#x27;s RewardManager allows you to specify one or more events that can yield varying (positive or negative) rewards. It also enables you to control which subsets of events are sufficient or required for episode termination.</td></tr></table>
390
+
391
+ choices), and its state (like open or closed for doors). The Planner embeds these features into type/color/state embeddings with dimensions of 5, 3, and 2, resulting in a visual embedding $s_0$ of size $HW \times 10$ . To process $s_0$ , the Planner employs a 4-layer shape-preserving convolution neural network interleaved with the Exponential Linear Units, where each convolution layer has 16 filters with a size of 3times3, a stride of 1 and padding of 1. The convolution neural network's output $\hat{s}_t$ provides an embedding layer sized $HW \times 16$ . The Planner integrates a randomly initialized, trainable position embedding $\mathbf{E}_{pos}$ with $\mathrm{Conv}(s_0)$ to encapsulate the state's content and spatial features and make preparations for alignment.
392
+
393
+ Meanwhile, the Planner utilized a pre-trained BERT model with frozen parameters to understand the semantics and encode knowledge. Specifically, we use the vector output of the encoder (in this case, BERT) in the [CLS] position for the sentence embedding. This model encoded a set of $n$ natural language instructions, supplied by the Oracle, into instruction embeddings with dimensions of $n \times 768$ . Subsequently, a linear projection layer transformed these embeddings to produce outputs with dimensions of $n \times 16$ , denoting as $\hat{\mathbf{k}}$ .
394
+
395
+ **Alignment** To integrate the two types of input embeddings, $\hat{\mathbf{s}}_0 \in \mathbb{R}^{HW \times 10}$ , $\hat{\mathbf{k}} \in \mathbb{R}^{n \times 16}$ , we employ the scaled dot-product cross-attention mechanism. The query $Q$ is computed using $\hat{\mathbf{k}} W_{Q}$ , and the key and value are derived from $\hat{\mathbf{s}}_t W_K$ and $\hat{\mathbf{s}}_t W_V$ , respectively.
396
+
397
+ Forward After aligning knowledge and environment states, the cross-attention layer yields an output, $\hat{\mathbf{k}}_{s_0}$ , which is a $n \times 16$ context vector capturing the correlation between the knowledge set and the current state. We project this context vector onto n-dimensional logits through a linear layer and finally get the most suitable external knowledge for the Actor after softmax sampling.
398
+
399
+ Table 3: All knowledge is provided by BabyAI and covers 66 template categories totaling 652 entries. [C] is one of 6 possible colors: green, grey, yellow, blue, purple, and red.
400
+
401
+ <table><tr><td>Go to the &lt;Object&gt;</td><td>Open the &lt;Object&gt;</td><td>Pick Up the &lt;Object&gt;</td></tr><tr><td>go to the ball</td><td></td><td></td></tr><tr><td>go to the box</td><td></td><td>pick up the ball</td></tr><tr><td>go to the door</td><td>open the box</td><td>pick up the box</td></tr><tr><td>go to the key</td><td>open the door</td><td>pick up the key</td></tr><tr><td>go to the &lt;C&gt; ball</td><td>open the &lt;C&gt; box</td><td>pick up the &lt;C&gt; ball</td></tr><tr><td>go to the &lt;C&gt; box</td><td>open the &lt;C&gt; door</td><td>pick up the &lt;C&gt; box</td></tr><tr><td>go to the &lt;C&gt; door</td><td></td><td>pick up the &lt;C&gt; key</td></tr><tr><td>go to the &lt;C&gt; key</td><td></td><td></td></tr><tr><td colspan="3">Put the &lt;Object&gt; Next to the &lt;Object&gt;</td></tr><tr><td>put the ball next to the ball</td><td>put the ball next to the &lt;C&gt; ball</td><td></td></tr><tr><td>put the ball next to the box</td><td>put the ball next to the &lt;C&gt; box</td><td></td></tr><tr><td>put the ball next to the door</td><td>put the ball next to the &lt;C&gt; door</td><td>put the &lt;C&gt; box next to the &lt;C&gt; ball</td></tr><tr><td>put the ball next to the key</td><td>put the ball next to the &lt;C&gt; key</td><td>put the &lt;C&gt; box next to the &lt;C&gt; box</td></tr><tr><td>put the box next to the ball</td><td>put the box next to the &lt;C&gt; ball</td><td>put the &lt;C&gt; box next to the &lt;C&gt; key</td></tr><tr><td>put the box next to the box</td><td>put the box next to the &lt;C&gt; box</td><td>put the &lt;C&gt; key next to the &lt;C&gt; ball</td></tr><tr><td>put the box next to the door</td><td>put the box next to the &lt;C&gt; door</td><td>put the &lt;C&gt; key next to the &lt;C&gt; box</td></tr><tr><td>put the box next to the key</td><td>put the box next to the &lt;C&gt; key</td><td>put the &lt;C&gt; key next to the &lt;C&gt; door</td></tr><tr><td>put the key next to the ball</td><td>put the key next to the &lt;C&gt; ball</td><td>put the &lt;C&gt; key next to the &lt;C&gt; key</td></tr><tr><td>put the key next to the box</td><td>put the key next to the &lt;C&gt; box</td><td></td></tr><tr><td>put the key next to the door</td><td>put the key next to the &lt;C&gt; door</td><td></td></tr><tr><td>put the key next to the key</td><td>put the key next to the &lt;C&gt; key</td><td></td></tr></table>
402
+
403
+ ![](images/95b29aacb00ef9fe7c0bbcb19f1ff450e477651b037ee0e57d1d00ec0c3bfc06.jpg)
404
+ (a) LavaCross-Ring
405
+
406
+ ![](images/51ae489dc87e5ae59f98f4b045e7fc7760535541ffe9158a0249b4f418661c8f.jpg)
407
+ (b) LavaCross-Potion
408
+
409
+ ![](images/44a922f8de44af505002a9b9976cc1abb395d133cb7a46d499684974c551b0de.jpg)
410
+ (c) LavaCross-Full
411
+
412
+ ![](images/0d231952c4d592e09332cc080e1cf2e70512bebe342036c7c80a1d422af0edd9.jpg)
413
+ (d) MultiRoom-N4-Monster
414
+
415
+ ![](images/43c67bbd65081b4e71d39ef3a99127683f0efe850217cf16b1fb6b6620453c4c.jpg)
416
+ (e) River-Monster
417
+
418
+ ![](images/6381f7bc7946a1ebe1e6eb419488360cc7f7150004f043ba14f8745923050184.jpg)
419
+ Figure 7: Five challenging environments in MiniHack we used to evaluate PAE.
420
+
421
+ # A.3.2 MODEL ARCHITECTURE DETAILS OF ACTOR
422
+
423
+ This section details the Actor architecture used in our approach. The Actor consists of a policy network and a discriminative network.
424
+
425
+ The policy network adopts a similar network architecture as the Planner, with the difference that the inputs to the policy network at each time step $t$ are a partial observation of size $7 \times 7 \times 3$ and a single piece of knowledge $k$ filtered by the Planner. Due to the reduction of the information content of the input state, we remove the shape-preserving convolution and add the position information directly to the state embedding ${}^p s_t$ , obtaining ${}^p\hat{s}_t$ of size $(7 \times 7) \times 10$ . For the knowledge selected by the Planner, we utilize the same parameter-frozen BERT model to get the knowledge embedding $\hat{k}$ of dimension 64 after a linear projection. We compute the cross attention of ${}^p\hat{s}_t$ and $\hat{k}$ by using
426
+
427
+ Table 4: Some natural language messages in MiniHack. A "message" is the UTF-8 encoding of the on-screen message displayed at the top of the screen.
428
+
429
+ <table><tr><td>River-Monster</td><td>MultiRoom-N4-Monster</td><td>LavaCross</td></tr><tr><td>-the stairs are solidly fixed to the floor.</td><td>-in what direction?</td><td>-what do you want to throw?</td></tr><tr><td>-with great effort you move the boulder.</td><td>-that hurts!</td><td>-you would burn to a crisp trying to pick things up.</td></tr><tr><td>-that was close.</td><td>-it&#x27;s a wall.</td><td>-what do you want to use or apply?</td></tr><tr><td>-it&#x27;s solid stone.</td><td>-you see no door there.</td><td>-you move over some lava.</td></tr><tr><td>-you don&#x27;t have anything to zap.</td><td>-you kick at empty space.</td><td>-the flint stone falls down the stairs.</td></tr><tr><td>-you hit the o.</td><td>-you strain a muscle.</td><td>-the flint stone hits another object.</td></tr><tr><td>-you try to crawl out of the water.</td><td>-this door is locked.</td><td>-you see here a uncursed flint stone.</td></tr><tr><td>-your movements are slowed slightly because of your load.</td><td>-dumb move!</td><td>-sorry, i don&#x27;t know how to use that.</td></tr><tr><td>-the o is killed!</td><td>-ouch!</td><td>-you float in the opposite direction.</td></tr><tr><td>-you try to move the boulder but in vain.</td><td>-as you kick the door, it crashes open!</td><td>-there is a staircase up here.</td></tr><tr><td>-you pull free from the o.</td><td>-this door is broken.</td><td>-you don&#x27;t have anything to drink.</td></tr><tr><td>-you are almost hit by a dart.</td><td>-as you kick the door, it shatters to pieces!</td><td>-in what direction?</td></tr><tr><td>-the o picks up a food ration.</td><td>-this doorway has no door.</td><td>-it&#x27;s a wall.</td></tr><tr><td>-you have a little trouble lifting i-a scroll.</td><td>-what a strange direction!</td><td>-there is nothing here to pick up.</td></tr><tr><td>-you have a little trouble lifting j-a o corpse.</td><td>-your leg feels better.</td><td>-you don&#x27;t have anything to use or apply.</td></tr><tr><td>-...</td><td>-never mind.</td><td>-emile&#x27;s ghost touches you!</td></tr><tr><td></td><td>-...</td><td>-agent&#x27;s ghost touches you!</td></tr></table>
430
+
431
+ $\hat{k}_t$ to generate query $Q$ , ${}^p\hat{s}_t$ for key $K$ and value $Q$ . Then, we used four strided convolution layers to extract the state information to get $1 \times 1 \times 32$ state embedding. Finally, we concatenated state embedding and knowledge-state alignment embedding and passed it through one linear layer and softmax layer to get the logit distribution over the seven actions.
432
+
433
+ The Actor uses a separate discriminative network $q_{\phi}(k|^{p}s_{t})$ to infer the knowledge provided by the Planner from the learned strategies. Intuitively, the Actor is motivated to bridge the connection between knowledge and states and explore states with a close relationship with $k$ . The discriminative network $q_{\phi}(k|^{p}s_{t})$ is optimized using a cross-entropy loss $\mathcal{L}_{\phi}$ , denoting as:
434
+
435
+ $$
436
+ \mathcal {L} _ {\phi} \left(^ {p} s _ {t}, k\right) = - \sum_ {k ^ {\prime} \in \mathcal {K}} \left(k ^ {\prime} = k\right) \cdot \log \left(q _ {\phi} \left(k ^ {\prime} \mid^ {p} s _ {t}\right)\right) \tag {13}
437
+ $$
438
+
439
+ Specifically, we employ a same-structure strided convolution network in the policy network to get the state feature ${}^p{\widetilde{s}}_t$ , and knowledge embeddings $\widehat{\mathbf{k}}$ similar to the Planner:
440
+
441
+ $$
442
+ \tilde {s} _ {t} = \mathrm {C o n v} \left(^ {p} s _ {t}\right) \qquad \qquad \qquad \in \mathbb {R} ^ {1 \times 3 2}
443
+ $$
444
+
445
+ $$
446
+ \hat {\mathbf {k}} _ {a} = \operatorname {P r o j} \left(\mathrm {L M} \left([ k ^ {(1)}, k ^ {(2)}, \dots , k ^ {(n)} ]\right)\right) \quad \in \mathbb {R} ^ {n \times 3 2} \tag {14}
447
+ $$
448
+
449
+ Then a dot-product operation between ${}^p\tilde{s}_t$ and knowledge embeddings is performed, followed by a softmax layer outputting $q_{\phi}(k|^{p}s_{t})$ :
450
+
451
+ $$
452
+ q _ {\phi} (k | ^ {p} s _ {t}) = \operatorname {S o f t M a x} \left(\hat {\mathbf {k}} _ {a} \cdot^ {p} \tilde {s} _ {t} ^ {T}\right) \tag {15}
453
+ $$
454
+
455
+ Interestingly, whereas the discriminative network was initially derived from the definition of mutual information, we find that the discriminative network can be viewed as predicting and modeling the knowledge distribution of the planner from its perspective to strengthen the connection between state and knowledge.
456
+
457
+ # A.3.3 TRAINING DETAILS
458
+
459
+ Each model was trained using five independent seeds on a system with 112 Intel® Xeon® Platinum 8280 cores and 6 Nvidia RTX 3090 GPUs. Run times ranged from 10 hours (for OBSTRUCTED-MAZE1DL) to 100 hours (for the longest KEYCORRIDORS5R3 task).
460
+
461
+ # A.3.4 HYPERPARAMETERS
462
+
463
+ For PAE, we ran a grid search over batch size $\in \{8,32,150\}$ , unroll length $\in \{20,40,100,200\}$ , entropy cost for the Actor $\in \{0.0001,0.0005,0.001\}$ , the Actor learning rate $\in \{0.0001,0.0005,0.001\}$ , the Planner learning rate $\in \{0.0001,0.0005,0.001\}$ , entropy cost for the Planner $\in \{0.001,0.005,0.01\}$ . Table 5 shows the best parameters obtained from the search.
464
+
465
+ For RND and ICM, we followed previous work (Raileanu & Rocktäschel, 2020) and used batch size of 32, unroll length of 100, RMSProp optimizer learning rate of 0.0001 with $\epsilon = 0.01$ and momentum of 0, intrinsic reward coefficient of 0.1, and entropy coefficient of 0.0005, which were the best values they found using grid searches in the same tasks.
466
+
467
+ For AMIGo and L-AMIGo, we followed previous work (Campero et al., 2020; Mu et al., 2022) and used teacher policy batch size of 32, student policy batch size of 32, teacher grounder batch size of 100, RMSProp optimizer learning rate of 0.0001 with $\epsilon = 0.01$ and momentum of 0, intrinsic reward coefficient of 1, unroll length of 100, value loss cost of 0.5, entropy cost of 0.0005, which were the best values for the same tasks described in their paper.
468
+
469
+ Table 5: Hyperparameters of PAE adopted in all the experiments.
470
+
471
+ <table><tr><td>Parameter</td><td>Value</td></tr><tr><td>Actor batch size B</td><td>32</td></tr><tr><td>Planner batch size Bp</td><td>32</td></tr><tr><td>Unroll Length</td><td>100</td></tr><tr><td>Discount</td><td>0.99</td></tr><tr><td>Value loss cost</td><td>0.5</td></tr><tr><td>Actor entropy cost</td><td>0.0005</td></tr><tr><td>Planner entropy cost</td><td>0.5</td></tr><tr><td>Actor mutual information cost αI</td><td>0.0001</td></tr><tr><td>Actor cross attention head number</td><td>1</td></tr><tr><td>Planner cross attention head number</td><td>1</td></tr><tr><td>Pretrained language model</td><td>Bert-base</td></tr><tr><td>Pretrained language model output dim</td><td>768</td></tr><tr><td>Actor language embedding dim</td><td>64</td></tr><tr><td>Planner language embedding dim</td><td>256</td></tr><tr><td>Planner embedding projection dim</td><td>16</td></tr><tr><td>Actor learning rate</td><td>5e-4</td></tr><tr><td>Planner learning rate</td><td>5e-4</td></tr><tr><td>Adam betas</td><td>(0.9, 0.999)</td></tr><tr><td>Adam ε</td><td>1e-8</td></tr><tr><td>Clip gradient norm</td><td>40.0</td></tr></table>
472
+
473
+ # A.4 ALGORITHMS DETAILS
474
+
475
+ # A.4.1 ALGORITHMS DETAILS OF THE PAE
476
+
477
+ Algorithm 1 illustrates the overall rollout process of PAE. We implemented the PAE and reproduction baseline algorithms using TorchBeast $^2$ (Küttler et al., 2019), an IMPALA-based PyTorch platform for rapid asynchronous parallel training in reinforcement learning.
478
+
479
+ Algorithm 1: Asynchronous learning algorithm for PAE
480
+ Input: Buffer B, Actor batch $\mathbb{B}$ , Planner batch $\mathbb{B}_p$ , Actor batch size $B$ , Planner batch size $B_{p}$ Initialize: $\mathbf{B}\gets \varnothing ,\mathbb{B}\gets \varnothing ,\mathbb{B}_p\gets \varnothing ,\pi_a(a_st,k;\omega)\gets \omega_0,\pi_p(k|s_0,\mathcal{K};\theta)\gets \theta_0$
481
+ Function INTERACT(Actor Policy: $\pi_{a}^{*}$ , Planner Policy: $\pi_{p}^{*}$ , Buffer: B):
482
+ $\{s_0,p_s_0\} \leftarrow$ Env Reset(0) $\triangleright s_0$ denotes full observation, $^p s_0$ denotes partial observation
483
+ $k\gets \pi_p^* (k_0|s_0,\mathcal{K};\boldsymbol {\theta}^*)$ $k_{steps}\gets 0$
484
+ while True do
485
+ $at\gets \pi_a^* (at|^p st,k;\omega^*)$ $\{s_{t + 1},{}^p s_{t + 1},r_t,k_{done},s_{done}\} \leftarrow$ Env.Step $(a_{t})$ Interact with the environment
486
+ $k_{steps}\gets k_{steps} + 1$
487
+ if $s_{done}$ then
488
+ $\{s_0,p_s_0\} \leftarrow$ Env Reset(0) This episode is finished
489
+ $k\gets \pi_p^* (k_0|s_0,\mathcal{K};\boldsymbol{\theta}^*)$ $k_{steps}\gets 0$
490
+ end
491
+ if $k_{done}$ then
492
+ $k\gets \pi_p^* (k|s_0,\mathcal{K};\boldsymbol{\theta}^*)$ The Actor successfully followed the Planner's guidance
493
+ $k_{steps}\gets 0$
494
+ end
495
+ Update B Update Buffer B using newly collected experience
496
+ end
497
+ end
498
+ Function MAIN():
499
+ $\pi_a^*\gets \pi_a.\mathrm{copy()}$ Make a parameter-fixed copy of $\pi_{a}$ for environment interacting
500
+ $\pi_p^*\gets \pi_p.\mathrm{copy()}$ Make a parameter-fixed copy of $\pi_p$ for environment interacting
501
+ Th $\leftarrow$ Thread(INTERACT, $\pi_a^*,\pi_p^*,\mathbf{B})$ Create a thread for environment interacting
502
+ while not converged do
503
+ Update $\mathbb{B}\gets \mathbb{B}$ Sample batch $\mathbb{B}$ of size $B$ from Buffer B
504
+ Train $\pi_a(at)^p s_t,k;\omega)$ on $\mathbb{B}$ Training policy $\pi_{a}$ using reinforcement learning
505
+ Train $q_{\phi}(k|^{p}s_{t})$ on $\mathbb{B}$ Training discriminative network $q_{\phi}$ using supervised learning
506
+ Update $\pi_a^*\gets \pi_a.\mathrm{copy()}$ Update $\pi_a^*$ with latest model $\pi_{a}$
507
+ Update $\mathbb{B}_p$ with $\{s_0,k,k_{steps},s_{done}\}$ from $\mathbb{B}_p$
508
+ if $|\mathbb{B}_p| > B_p$ then
509
+ Train $\pi_p(k|s_0,\mathcal{K};\boldsymbol {\theta})$ on $\mathbb{B}_p$ Training policy $\pi_p$ using reinforcement learning
510
+ $\mathbb{B}_p\gets \emptyset$
511
+ Update $\pi_p^*\gets \pi_p.\mathrm{copy()}$ Update $\pi_p^*$ with latest model $\pi_p$
512
+ end
513
+ end
514
+ Th. join () Stop interacting with the environment
515
+
516
+ # A.4.2 DETAILS OF THE BASELINE ALGORITHMS
517
+
518
+ Below, we describe the implementation details of the various baseline algorithms. IMPALA is an off-policy actor-critic framework. The actor-critic agent maintains a policy $\pi_{\theta}(a|x)$ and a value function $v_{\theta}(x)$ , both parameterized by $\theta$ . Both the policy and value functions are refined using the actor-critic update rule. IMPALA also incorporates an entropy regularization loss. The update is derived from the gradient of a specific pseudo-loss function:
519
+
520
+ $$
521
+ \begin{array}{l} \mathcal {L} _ {\mathrm {V a l u e}} (\theta) = \sum_ {s \in \mathrm {T}} \left(v _ {s} - V _ {\theta} (x _ {s})\right) ^ {2} \\ \mathcal {L} _ {\text {P o l i c y}} (\theta) = - \sum_ {s \in \mathrm {T}} \rho_ {s} \log \pi_ {\theta} \left(a _ {s} \mid x _ {s}\right) \left(r _ {s} + \gamma v _ {s + 1} - V _ {\theta} \left(x _ {s}\right)\right) \tag {16} \\ \end{array}
522
+ $$
523
+
524
+ $$
525
+ \mathcal {L} _ {\text {E n t r o p y}} (\theta) = - \sum_ {s \in \mathrm {T}} \sum_ {a} \pi_ {\theta} (a | x _ {s}) \log \pi_ {\theta} (a | x _ {s})
526
+ $$
527
+
528
+ $$
529
+ \mathcal {L} (\theta) = g _ {v} \mathcal {L} _ {\text {V a l u e}} (\theta) + g _ {p} \mathcal {L} _ {\text {P o l i c y}} (\theta) + g _ {e} \mathcal {L} _ {\text {E n t r o p y}} (\theta).
530
+ $$
531
+
532
+ This decoupled architecture facilitates high throughput. Nonetheless, there can be a bias since the policy generating the trajectory might lag several updates behind the learner's policy when computing the gradient. IMPALA addresses this potential bias by employing the V-trace, which balances the variance-contraction trade-off in these off-policy updates.
533
+
534
+ RND The main idea of RND is to calculate intrinsic reward based on the prediction error linked to an agent's transfer. RND employs two neural networks: a fixed, randomly initialized target network that defines the prediction task and a predictor network trained on the agent's collected data. RND considers the prediction error from the predictor network, based on features produced by the target network, as a reward for novel states. We followed AMIGo (Campero et al., 2020), using a re-implemented version based on TorchBeast (Küttler et al., 2019) provided by (Raileanu & Roektäschel, 2020).
535
+
536
+ ICM utilizes curiosity as an intrinsic reward, defining it as the agent's error in predicting its own behavior's consequences within a feature space learned through a self-supervised inverse dynamics model. Specifically, ICM encodes states $s_t$ and $s_{t+1}$ as features $\phi(s_t)$ and $\phi(s_{t+1})$ , respectively, trained to predict $a_t$ (i.e., the inverse dynamics model). The forward model takes $\phi(s_t)$ and $a_t$ as inputs and predicts the feature representation $\phi(s_{t+1})$ for $s_{t+1}$ . The prediction error within the feature space serves as a curiosity-driven intrinsic reward. We followed AMIGo (Campero et al., 2020) using a re-implemented version of ICM provided by (Raileanu & Roktaschel, 2020). based on TorchBeast (Küttler et al., 2019).
537
+
538
+ AMIGo is a meta-learning method that automatically learns to self-propose adversarial motivational intrinsic goals. AMIGo consists of two subsystems: a goal-conditioned student policy that outputs the agent's actions in the environment and a goal-generating teacher that guides the student's training. These two components train in adversarial training, where the student maximizes rewards by reaching the goal as quickly as possible, and the teacher maximizes rewards by proposing goals that the student can reach but not too quickly. We use the open-source AMIGo (Campero et al., 2020) code<sup>3</sup> as a baseline for our PAE method.
539
+
540
+ L-AMIGo utilizes language as a generalized medium to emphasize relevant environmental abstractions. It is an extension of AMIGo where the teacher presents goals using language instead of coordinates $(x, y)$ . The student is a conditional policy, receiving language goals $g_{t}$ instead of $(x, y)$ . Specifically, the student network is decomposed into policy and grounding networks. The policy network produces a distribution of goals based on the student's state, while the grounding network predicts the probability of achieving the goal.
541
+
542
+ L-NovelD combines natural language with an intrinsic motivation approach to reward states described in natural language that transitions from low to high novelty. It is an extension of NovelD, which includes two main terms. The first term measures the novelty of state transitions, encouraging exploration without penalizing revisiting less novel states. The second term rewards the agent only for first-time state visits in an episode.
543
+
544
+ # A.5 ADDITIONAL RESULTS
545
+
546
+ # A.5.1 QUANTITATIVE RESULTS
547
+
548
+ Figure 4 shows the training curves of our PAE method alongside the IMPALA, RND, ICM, AMIGo, L-NovelD, and L-AMIGo baseline algorithms. Each model was trained using five independent random seeds. The results reported for each baseline and each environment are the best performance configuration of the policy for that environment. Tables 6 and 7 give the quantitative results of these comparison experiments in the BabyAI and MiniHack environments, respectively, and show the average extrinsic reward and the number of steps (in millions) required for each model to converge. Each entry consists of two rows of results, with the top row being the average extrinsic reward at the end of training and the bottom row being the minimal stable steps to attain that reward. Lower bottom row values signify quicker convergence, and “ $>$ $x$ ” indicates a lack of convergence within the maximum training steps “ $x$ ”.
549
+
550
+ Table 6: Comparison of PAE and baseline methods in BabyAI environment
551
+
552
+ <table><tr><td rowspan="2">Model</td><td colspan="3">Key Corridor Tasks</td><td colspan="3">Obstructed Maze Tasks</td></tr><tr><td>KEYCORRS3R3</td><td>KEYCORRS4R3</td><td>KEYCORRS5R3</td><td>OBSTRMAZE1D1</td><td>OBSTRMAZE2D1HB</td><td>OBSTRMAZE1Q</td></tr><tr><td>PAE (Ours)</td><td>0.89 ± 0.0026M</td><td>0.92 ± 0.00530M</td><td>0.94 ± 0.00190M</td><td>0.93 ± 0.0046M</td><td>0.87 ± 0.018150M</td><td>0.89 ± 0.006150M</td></tr><tr><td>L-AMIGo</td><td>0.86 ± 0.04012M</td><td>0.90 ± 0.01160M</td><td>0.93 ± 0.016160M</td><td>0.90 ± 0.03020M</td><td>0.23 ± 0.403&gt;200M</td><td>0.47 ± 0.029&gt;300M</td></tr><tr><td>L-NovelD</td><td>0.63 ± 0.097&gt;20M</td><td>0.15 ± 0.195&gt;60M</td><td>0.55 ± 0.484&gt;200M</td><td>0.79 ± 0.255&gt;20M</td><td>0.57 ± 0.164&gt;200M</td><td>0.60 ± 0.107&gt;300M</td></tr><tr><td>AMIGo</td><td>0.43 ± 0.246&gt;20M</td><td>0.22 ± 0.343&gt;60M</td><td>0.43 ± 0.599&gt;200M</td><td>0.45 ± 0.366&gt;20M</td><td>0.10 ± 0.175&gt;200M</td><td>0.18 ± 0.023&gt;300M</td></tr><tr><td>ICM</td><td>0.04 ± 0.052&gt;20M</td><td>0.30 ± 0.511&gt;60M</td><td>0.00 ± 0.000&gt;200M</td><td>0.31 ± 0.54215M</td><td>0.00 ± 0.000&gt;200M</td><td>0.00 ± 0.000&gt;300M</td></tr><tr><td>IMPALA</td><td>0.00 ± 0.000&gt;20M</td><td>0.00 ± 0.000&gt;60M</td><td>0.00 ± 0.000&gt;200M</td><td>0.00 ± 0.006&gt;20M</td><td>0.00 ± 0.000&gt;200M</td><td>0.00 ± 0.000&gt;300M</td></tr><tr><td>RND</td><td>0.00 ± 0.000&gt;20M</td><td>0.00 ± 0.000&gt;60M</td><td>0.00 ± 0.000&gt;200M</td><td>0.00 ± 0.000&gt;20M</td><td>0.00 ± 0.000&gt;200M</td><td>0.00 ± 0.000&gt;300M</td></tr></table>
553
+
554
+ Table 7: Comparison of PAE and baseline methods in MiniHack environment
555
+
556
+ <table><tr><td>Model</td><td>LAVACROSS-RING</td><td>LAVACROSS-POTION</td><td>LAVACROSS-FULL</td><td>MULTIROOM-N4-MONSTER</td><td>RIVER-MONSTER</td></tr><tr><td>PAE (Ours)</td><td>1.00 ± 0.00122M</td><td>0.99 ± 0.00235M</td><td>1.00 ± 0.00124M</td><td>0.72 ± 0.020&gt;40M</td><td>0.13 ± 0.018&gt;20M</td></tr><tr><td>L-AMIGo</td><td>0.57 ± 0.223&gt;40M</td><td>0.58 ± 0.214&gt;40M</td><td>0.45 ± 0.111&gt;40M</td><td>0.31 ± 0.035&gt;40M</td><td>0.09 ± 0.016&gt;20M</td></tr><tr><td>L-NovelD</td><td>0.88 ± 0.197&gt;40M</td><td>0.99 ± 0.00930M</td><td>0.98 ± 0.01530M</td><td>0.51 ± 0.122&gt;40M</td><td>0.02 ± 0.017&gt;20M</td></tr><tr><td>AMIGo</td><td>0.46 ± 0.116&gt;40M</td><td>0.54 ± 0.048&gt;40M</td><td>0.44 ± 0.101&gt;40M</td><td>0.29 ± 0.026&gt;40M</td><td>0.08 ± 0.009&gt;20M</td></tr><tr><td>ICM</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;40M</td><td>0.18 ± 0.199&gt;40M</td><td>0.12 ± 0.028&gt;20M</td></tr><tr><td>IMPALA</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;20M</td></tr><tr><td>RND</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;40M</td><td>0.00 ± 0.000&gt;20M</td></tr></table>
557
+
558
+ # A.5.2 ABLATION EXPERIENTIAL RESULTS
559
+
560
+ Figure 8 illustrates the effect of introducing external knowledge on PAE performance. Full-Model is the full version of PAE. w/o Curriculum provides randomized guidance to the Actors through external knowledge, while w/o Planner eliminates the Planner's guidance.
561
+
562
+ ![](images/3b28442df3faf2781094eb011545b36d033da33f36a7cc238805d422384bee94.jpg)
563
+
564
+ ![](images/c35a352f67b06b659a745983788b08afcb382812dcbd617d3096d85ce51bdfa8.jpg)
565
+
566
+ ![](images/0cf30c8d80f50372a857941cdd71ece15015f30546bffe3f6fc9e4bca02ec30f.jpg)
567
+
568
+ Figure 8: Ablation of PAE's external knowledge.
569
+ ![](images/007579c06ff324edd2718486f81b7896b4267925b6ab1e65dc8fb2b074156c59.jpg)
570
+ Full-Model (Ours)
571
+
572
+ ![](images/da60447131d05f713a2138c56ea24bc7e23fb73c033c0e3be64ee84d53d5f3b9.jpg)
573
+ w/o Curriculum
574
+
575
+ ![](images/e6cbc10149a248416d64db17cb8044cfc86748e5114f058c3ddd3b5bbf76e192.jpg)
576
+ w/o Planner
577
+
578
+ # A.5.3 QUALITATIVE RESULTS
579
+
580
+ Figure 9 shows an example of PAE completing a task in KeyCorRS5R3. In this example, the Actor first needs to explore the environment to find the key, then open the door of the corresponding color, drop the key, and retrieve the item behind the door. Figure 10 shows the flow of the Planner forming an automatic curriculum in KeyCorS5R3 and the progressive acquisition of skills by the Actor. Typically, in the early stages, the Planner provides easy guidance. As the training progresses and the Actor's ability increases, the Planner provides more hard guidance. We can see in the trajectory that the Planner and Actor are progressing together and eventually complete the task successfully.
581
+
582
+ ![](images/6f83b5e87de83a31acfbbff4b63c87146fe08d66c767f35a013506084ecdb755.jpg)
583
+ Figure 9: Example of PAE in completing a task in KeyCORRS5R3. To save space, we only sampled one sub-trajectory for display.
584
+
585
+ ![](images/dd5b1594b57f09de35470e53d73721ca988c1f22ebfad8377792fcb51e1ca6e0.jpg)
586
+ Figure 10: An illustration of the training process. The Planner forms an automatic curriculum as the training progresses, and the Actor progressively masters the skills.
587
+
588
+ # A.6 FLOW CHART
589
+
590
+ ![](images/9fc1b840a611f8e32fafc03be9ed564553e82ca7442dfd02c7dc07d8c7c45c08.jpg)
591
+ Figure 11 and Figure 12 show flowcharts of the agent completing the Key Corridor task and the Obstructed Maze task, respectively.
592
+
593
+ ![](images/2f4ce8e8c8fef3b46311ff524d2e4c9997ed3740a60464fe88befd645f51519d.jpg)
594
+ Figure 11: Flow chart of an agent completing Key Corridor tasks.
595
+ Figure 12: Flow chart of an agent completing Obstructed Maze tasks.
paereinforcementlearningfromexternalknowledgeforefficientexploration/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5cd621203cb674c1349ad190459f6f43caea218cf2e987ae481f575ac3998b73
3
+ size 1512750
paereinforcementlearningfromexternalknowledgeforefficientexploration/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b582bd6b7d583674b7fd65c8605db2a2cc061208b1ea5dd94af1fcdc2891b1ce
3
+ size 759368
pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/b39aaa9f-61cc-44c3-a665-5d8f55ab0c3f_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67ea1489d8b985cf3e1aac01992a8ec1d55549067f1a5419f290d7024b2d1bf3
3
+ size 114394
pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/b39aaa9f-61cc-44c3-a665-5d8f55ab0c3f_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3993bc3eb1f66289cd2a06f08812a3c485e78ea8d62093de36bb7e40ff13ec47
3
+ size 143837
pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/b39aaa9f-61cc-44c3-a665-5d8f55ab0c3f_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc113212202bcc77497eebe010df18c9743e66d3c957b6551e74bbdfb145873c
3
+ size 3877295
pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/full.md ADDED
@@ -0,0 +1,362 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PANDALM: AN AUTOMATIC EVALUATION BENCHMARK FOR LLM INSTRUCTION TUNING OPTIMIZATION
2
+
3
+ Yidong Wang $^{1,2*}$ , Zhuohao Yu $^{1*}$
4
+
5
+ Wenjin Yao $^{1}$ , Zhengran Zeng $^{1}$ , Linyi Yang $^{2}$ , Cunxiang Wang $^{2}$
6
+
7
+ Hao Chen $^{3}$ , Chaoya Jiang $^{1}$ , Rui Xie $^{1}$ , Jindong Wang $^{3}$ , Xing Xie $^{3}$
8
+
9
+ Wei Ye $^{1\dagger}$ , Shikun Zhang $^{1\dagger}$ , Yue Zhang $^{2\dagger}$
10
+
11
+ $^{1}$ Peking University $^{2}$ Westlake University $^{3}$ Microsoft Research Asia
12
+
13
+ # ABSTRACT
14
+
15
+ Instruction tuning large language models (LLMs) remains a challenging task, owing to the complexity of hyperparameter selection and the difficulty involved in evaluating the tuned models. To determine the optimal hyperparameters, an automatic, robust, and reliable evaluation benchmark is essential. However, establishing such a benchmark is not a trivial task due to the challenges associated with evaluation accuracy and privacy protection. In response to these challenges, we introduce a judge large language model, named PandaLM, which is trained to distinguish the superior model given several LLMs. PandaLM's focus extends beyond just the objective correctness of responses, which is the main focus of traditional evaluation datasets. It addresses vital subjective factors such as relative conciseness, clarity, adherence to instructions, comprehensiveness, and formality. To ensure the reliability of PandaLM, we collect a diverse human-annotated test dataset, where all contexts are generated by humans and labels are aligned with human preferences. On evaluations using our collected test dataset, our findings reveal that PandaLM-7B offers performance comparable to both GPT-3.5 and GPT-4. Impressively, PandaLM-70B surpasses their performance. PandaLM enables the evaluation of LLM to be fairer but with less cost, evidenced by significant improvements achieved by models tuned through PandaLM compared to their counterparts trained with default Alpaca's hyperparameters. In addition, PandaLM does not depend on API-based evaluations, thus avoiding potential data leakage.
16
+
17
+ # 1 INTRODUCTION
18
+
19
+ Large language models (LLMs) have attracted increasing attention in the field of artificial intelligence (OpenAI, 2023; Google, 2023; Zeng et al., 2022a; Brown et al., 2020; Chowdhery et al., 2022; Anil et al., 2023; Zhang et al., 2023), with various applications from question answering (Hirschman & Gaizauskas, 2001; Kwiatkowski et al., 2019; Wang et al., 2021), machine translation (Vaswani et al., 2017; Stahlberg, 2020) to content creation (Biswas, 2023; Adams & Chuah, 2022). The Alpaca project (Taori et al., 2023) has been a pioneering effort in instruction tuning of LLaMA (Touvron et al., 2023), setting a precedent for instruction tuning LLMs, followed by Vicunna (Chiang et al., 2023). Subsequent research (Diao et al., 2023; Ji et al., 2023; Chaudhary, 2023) have typically adopted Alpaca's hyperparameters as a standard for training their LLMs. Given the necessity of instruction tuning for these pre-trained models to effectively understand and follow natural language instructions (Wang et al., 2022c; Taori et al., 2023; Peng et al., 2023), optimizing their tuning hyperparameters is crucial for peak performance. Critical factors such as optimizer selection, learning rate, number of training epochs, and quality and size of training data significantly influence the model's performance (Liaw et al., 2018; Tan & Le, 2019). However, a research gap remains in the area of hyperparameter optimization specifically designed for instruction tuning LLMs. To address this issue,
20
+
21
+ we aim to construct an automated, reliable, and robust evaluation method, which can be integrated into any open-sourced LLMs and used as the judging basis for hyperparameter optimization.
22
+
23
+ The development of such an evaluation method presents its challenges (Guo et al., 2023; Chang et al., 2023), including ensuring evaluation reliability and privacy protection. In the context of our paper, when we refer to "privacy", we primarily allude to the principles ingrained in federated learning (Zhang et al., 2021a) which enables model training across multiple devices or servers while keeping the data localized, thus offering a degree of privacy. Current methods often involve either crowd-sourcing work or API usage, which could be costly, and time-consuming. Besides, these methods face challenges in terms of consistency and reproducibility. This is primarily due to the lack of transparency regarding language model change logs and the inherent subjectivity of human annotations. Note that utilizing API-based evaluations carries the risk of potentially high costs associated with addressing data leaks. Although open-sourced LLMs can be alternative evaluators, they are not specifically designed for assessment, thus making it difficult to deploy them directly as evaluators.
24
+
25
+ On the other hand, the labels of previous evaluation methods (Zheng et al., 2023; Gao et al., 2021; Wang et al., 2023b;c) simply definite answers and fail to consider the language complexity in practice. The evaluation metrics of these procedures are typically accuracy and F1-score, without considering the subjective evaluation metrics that autoregressive generative language models should pay attention to, thus not reflecting the potential of such models to generate contextually relevant text. The appropriate subjective evaluation metrics can be relative conciseness, clarity, adherence to instructions, comprehensiveness, formality, and context relevance.
26
+
27
+ To tackle these challenges, we introduce a judge language model, aiming for Reproducible and Automated Language Model Assessment (PandaLM). Tuned from LLaMA, PandaLM is used to distinguish the most superior model among various candidates, each fine-tuned with different hyperparameters, and is also capable of providing the rationale behind its choice based on the reference response for the context. PandaLM surpasses the limitations of traditional evaluation methods and focuses on more subjective aspects, such as relative conciseness, clarity, comprehensiveness, formality, and adherence to instructions. Furthermore, the robustness of PandaLM is strengthened by its ability to identify and rectify problems such as logical fallacies, unnecessary repetitions, grammatical inaccuracies, and context irrelevance. By considering these diverse aspects, we leverage PandaLM's ability to distinguish the most superior model among candidates on the validation set and then provide insights for facilitating hyperparameter optimization of instruction tuning.
28
+
29
+ In practice, we generate paired responses from a diverse set of similarly sized foundation models including LLaMA-7B (Touvron et al., 2023), Bloom-7B (Scao et al., 2022), Cerebras-GPT-6.7B (Dey et al., 2023), OPT-7B (Zhang et al., 2022a), and Pythia-6.9B (Biderman et al., 2023). Each of these models is fine-tuned using the same data and hyperparameters as Alpaca (Taori et al., 2023). The paired responses from these tuned LLMs constitute the input of training data for PandaLM. The most straightforward approach to generate the corresponding target of training data is through human annotation, but this method can be costly and time-consuming (Wang et al., 2023h). And the lack of sufficiently annotated training data has always been a significant issue in the era of deep learning Ouali et al. (2020); Wang et al. (2023e); Zhang et al. (2021b); Chen et al. (2023); Wang et al. (2022a). Considering that GPT-3.5 can provide a reliable evaluation to some extent, to reduce costs, we follow self-instruct (Wang et al., 2022c), which is a methodology that capitalizes on pre-existing knowledge within large language models to generate annotations or outputs through self-generated instructions. To distil data from GPT-3.5 and apply heuristic data filtering strategies to mitigate noise. Specifically, we filter out invalid evaluations from gpt-3.5-turbo with hand-crafted rules. To address position bias, we also filter out inconsistent samples when swapping the orders of responses in the prompt. Despite the utilization of data distilled from GPT-3.5, the active removal of noise enhances the quality of the training data, fostering a more efficient and robust training process for PandaLM.
30
+
31
+ To ensure the reliability of PandaLM, we develop a test dataset that aligns with human preference and covers a wide range of tasks and contexts. The instructions and inputs of test data are sampled from the human evaluation dataset of self-instruct (Wang et al., 2022c), with responses generated by different LLMs and each label independently provided by three different human evaluators. Samples with significant divergences are excluded to ensure the Inter Annotator Agreement (IAA) of each annotator remains larger than 0.85. As illustrated in Table 2, PandaLM-7B showcases robust and competitive performance. Remarkably, the efficacy of PandaLM-70B is even more pronounced,
32
+
33
+ ![](images/2d3fd85c05fcda5666b2e51acf4b74e829227ad22236b0aa2938f87bd97033ee.jpg)
34
+ (a) Comparison Results of GPT-3.5.
35
+
36
+ ![](images/03d5d7f21e19d9d959b3cb57f9272f659758bd292c98cde4623aba0700ff78de.jpg)
37
+ Figure 1: The models are evaluated and compared using both GPT-3.5, GPT-4 and human annotators. The 'Win' count represents the number of responses where models fine-tuned with PandaLM-selected optimal hyperparameters outperform models using Alpaca's hyperparameters. Conversely, the 'Lose' count represents the number of responses where models utilizing Alpaca's hyperparameters produce superior responses compared with those fine-tuned with the optimal hyperparameters determined by PandaLM. Note that the overall test set comprises 170 instances, and 'Tie' scenarios are not considered in this illustration.
38
+
39
+ ![](images/b71ced35c4a799d4268babe70e4ae867e1c96b28993a5a18fb0244f32b9a4941.jpg)
40
+ (b) Comparison Results of GPT-4.
41
+ (c) Comparison Results of Human.
42
+
43
+ exceeding the performance metrics of GPT-4. This enhancement is largely attributable to the effective noise mitigation strategies employed during the training phase.
44
+
45
+ Moreover, as illustrated in Figure 1, adopting PandaLM's selected optimal hyperparameters covering optimizer selection, learning rate, number of training epochs, and learning rate scheduler brings noteworthy improvements. When assessed using GPT-4 with a set of 170 instructions, a group of five open language models, tuned with optimal hyperparameters selected by PandaLM, achieves an average of 47.0 superior responses and 26.2 inferior responses, outperforming those trained using Alpaca's hyperparameters. Note that the training data remains the same for conducting fair comparisons. Moreover, when these LLMs are evaluated by human experts, using the same set of 170 instructions, they exhibit an average of 79.8 superior responses and 25.2 inferior responses, once again surpassing the performance of models trained with Alpaca's hyperparameters. The experimental results underline the effectiveness of PandaLM in determining optimal hyperparameters for choosing the best LLMs. In addition, when the fine-tuned LLMs are assessed using the lm-eval (Gao et al., 2021), a unified framework to test LLM on a large number of different traditional evaluation tasks, the results further reinforce the superiority of LLMs optimized by PandaLM.
46
+
47
+ In conclusion, our work delivers three key contributions:
48
+
49
+ - We introduce PandaLM, a privacy-protected judge language model for evaluating and optimizing hyperparameters for LLMs.
50
+ - We create a reliable human-annotated dataset, essential for validating PandaLM's performance and further research.
51
+ - We make use of PandaLM to optimize the hyperparameters of a series of open-sourced LLMs. In comparison to those LLMs tuned using hyperparameters identified by Alpaca, tuning models with PandaLM-selected hyperparameters yields substantial performance enhancements.
52
+
53
+ # 2 RELATED WORK
54
+
55
+ This section reviews the relevant literature on the topic of hyperparameter optimization and the evaluation of language models.
56
+
57
+ Hyperparameter Optimization The importance of hyperparameter optimization in machine learning (Yu & Zhu, 2020; Falkner et al., 2018; Li et al., 2017; Xu et al., 2023; Wang et al., 2023a; Wu et al., 2019), particularly in the context of fine-tuning deep learning language models such as BERT (Kenton & Toutanova, 2019) and GPT (Radford et al.), cannot be ignored. For these models, the choice of hyperparameters like the learning rate, batch size, or the number of training epochs can significantly influence their performance (Godbole et al., 2023; Sun et al., 2019; Tunstall et al., 2022). This selection process becomes even more critical when fine-tuning these models on domain-specific tasks,
58
+
59
+ ![](images/c072e20942ef658b2243385f4b6e68111d70fa03db28b6d49d00c1f882db8d4b.jpg)
60
+ Figure 2: The pipeline of instruction tuning LLMs.
61
+
62
+ where the optimal set of hyperparameters can vary significantly among different domains (Dodge et al., 2020; Sun et al., 2019).
63
+
64
+ Evaluation of Language Models Accurate evaluation of language models is crucial in determining optimal hyperparameters, thus improving the models' overall performance (Sun et al., 2019; Godbole et al., 2023). Conventional objective metrics like perplexity (Mallio et al., 2023) and accuracy (Xu et al., 2020; Wang et al.; Yang et al., 2022a; Zhong et al., 2023) on downstream tasks (Gao et al., 2021) provide valuable insights, but they may not effectively guide the choice of hyperparameters to enhance LLMs (Rogers et al., 2021) because evaluating LLMs requires other subjective metrics. Advanced language models, such as GPT-4 (OpenAI, 2023) and Bard (Google, 2023), incorporate human evaluations as part of their testing method for LLMs, aiming to better align with human judgements (Wang et al., 2023h). Although human-based evaluation methods offer considerable insight into a model's performance, they are costly and labor-intensive, making it less feasible for iterative hyperparameter optimization processes. Recent advancements in NLP have brought forth model-based metrics such as BERTScore (Zhang et al., 2019) and MAUVE (Pillutla et al., 2021). While these metrics offer valuable insights, there are significant areas where they may not align perfectly with the objectives of response evaluation. Firstly, BERTScore and MAUVE are engineered to measure the similarity between generated content and reference text. However, they are not inherently designed to discern which of multiple responses is superior. A response is closer to a human-written reference doesn't necessarily mean it adheres better to given instructions or satisfies a specific context. Secondly, while these metrics yield scores that represent content similarity, they aren't always intuitive to users. Interpreting these scores and translating them into actionable feedback can be a challenge. In contrast, PandaLM offers a more straightforward approach. It is tailored to directly output the evaluation result in an interpretable manner, making the feedback process transparent and easily understood by humans. In conclusion, while metrics like BERTScore and MAUVE provide valuable insights into content similarity, there is a pressing need for specialized evaluation tools like PandaLM. Tools that not only discern response quality but also do so in a user-friendly, human-comprehensible manner.
65
+
66
+ Subjective qualitative analysis of a model's outputs, such as its ability to handle ambiguous instructions and provide contextually appropriate responses, is increasingly being recognized as a valuable metric for evaluating models (Zheng et al., 2023). Optimizing hyperparameters with considerations towards these qualitative measures could lead to models that perform more robustly in diverse real-world scenarios. The previous qualitative analysis can be achieved either through human evaluators or through APIs of advanced language models, which is different from our motivation.
67
+
68
+ # 3 METHODOLOGY
69
+
70
+ As shown in Figure 2, the process of instruction tuning begins with a foundation model, which is then fine-tuned using instructions. The performance of each tuned model is evaluated to determine the best output. This involves exploring numerous models, each tuned with different hyperparameters, to identify the optimal one. To facilitate this pipeline, a reliable and automated language model assessment system is essential. To address this, we introduce PandaLM - a judge LLM specifically designed to assess the performance of LLMs fine-tuned with various parameters. Our goal is to identify the superior model from a pool of candidates accurately.
71
+
72
+ ![](images/0d459c70f93d1a88a897da7ea9b0c702b7edf3080c117bb6b8be1e59e3b42477.jpg)
73
+ Figure 3: The top 16 words used in the PandaLM-7B evaluation reasons from randomly sampled $80\mathrm{k}$ evaluation outputs. An example of evaluation reason and evaluation outputs can be found in Figure 5. Stop words are filtered.
74
+
75
+ # 3.1 TRAIN DATA COLLECTION AND PREPROCESSING
76
+
77
+ The training data collection aims to create a rich dataset that allows the model to evaluate different responses in a given context and generate an evaluation reason and a reference response using the same context. As demonstrated in Appendix A, each training data instance consists of an input tuple (instruction, input, response1, response2) and an output tuple (evaluation result, evaluation reason, reference response). The instructions and inputs in the input tuple are sampled from the Alpaca 52K dataset (Taori et al., 2023). The response pairs are produced by various instruction-tuned models: LLaMA-7B (Touvron et al., 2023), Bloom-7B (Scao et al., 2022), Cerebras-GPT-6.7B (Dey et al., 2023), OPT-7B (Zhang et al., 2022a), and Pythia-6.9B (Biderman et al., 2023). These models are selected due to their comparable sizes and the public availability of their model weights. Each is fine-tuned using the same instruction data and hyperparameters following Alpaca (Taori et al., 2023). The corresponding output tuple includes an evaluation result, a brief explanation for the evaluation, and a reference response. The evaluation result would be either '1' or '2', indicating that response 1 or response 2 is better, and 'Tie' indicates that two responses are similar in quality. The training prompt of PandaLM is shown at Appendix A. As it is impractical to source millions of output tuples from human annotators, and given that GPT-3.5 is capable of evaluating LLMs to some degree, we follow self-instruct (Wang et al., 2022c) to generate output tuples using GPT-3.5. As illustrated in Figure 3, we design prompts carefully to guide the generation of training data for PandaLM. The goal is to ensure PandaLM not only prioritizes objective response correctness but also emphasizes critical subjective aspects such as relative conciseness, clarity, comprehensiveness, formality, and adherence to instructions. Besides, we encourage PandaLM to identify and rectify issues like logical fallacies, unnecessary repetitions, grammatical inaccuracies, and the absence of context relevance. A heuristic data filtering strategy is then applied to remove noisy data. Specifically, to address the observed inherent bias in GPT-3.5 regarding the order of input responses even with carefully designed prompts, samples from the training dataset are removed if their evaluation results conflict when the orders of input responses are swapped. We finally obtain a filtered dataset containing 300K samples.
78
+
79
+ # 3.2 PANDALM TRAINING
80
+
81
+ In this subsection, we provide details about the training procedure for PandaLM. The backbone of PandaLM is LLaMA model, as it exhibits strong performance on multiple complicated NLP tasks (Beeching et al., 2023).
82
+
83
+ During the fine-tuning phase of PandaLM, we use the standard cross-entropy loss targeting the next token prediction. The model operates in a sequence-to-sequence paradigm without the necessity for a separate classification head. We train PandaLM with the DeepSpeed (Rasley et al., 2020) library, and Zero Redundancy Optimizer (ZeRO) (Rajbhandari et al., 2020; Ren et al., 2021) Stage 2, on 8 NVIDIA A100-SXM4-80GB GPUs. We use the bfloat16 (BF16) computation precision option to further optimize the model's speed and efficiency. Regarding the training hyperparameters, we apply the AdamW (Loshchilov & Hutter, 2017) optimizer with a learning rate of 2e-5 and a cosine learning rate scheduler. The model is trained for 2 epochs. The training process uses a warmup ratio of 0.03 to
84
+
85
+ ![](images/dadd657a64a40c6003594e1039f8b4a377652d0e4c8317e711c8e895603acae4.jpg)
86
+ (a) DAG of GPT-3.5.
87
+
88
+ ![](images/c7661fd08e1efdb7166c36b325c9d48d0d37f0ef31fedd858b639ae9272234b6.jpg)
89
+ (b) DAG of GPT-4.
90
+
91
+ ![](images/0695a930b56453d51c6ad0f789f75ac5f168df1ec101a21c8071f33daaf080cf.jpg)
92
+ (c) DAG of humans.
93
+ Figure 4: Comparative Visualization of Model Performance. The instruction-tuned models use the same training data and hyperparameters. A directed edge from node A to B indicates model A's significant superiority over B, while a dashed undirected edge indicates the two models are similar in performance. The number associated with the directed edge (A, B) represents the difference between the number of wins and losses for model A compared to model B. The absence of a number on the dashed undirected edge indicates that the difference between the number of wins and losses for the models is smaller than 5. We swap the order of two responses to perform inference twice on each data. The conflicting evaluation results are then modified to 'Tie'.
94
+
95
+ ![](images/bba78058bace5fc74dbe6b3a396cf7c91d81c419b8a3db856d6f4fdd5250e127.jpg)
96
+ (d) DAG of PandaLM.
97
+
98
+ avoid large gradients at the beginning of training. We use a batch size of 2 per GPU with all inputs truncated to a maximum of 1024 tokens and employ a gradient accumulation strategy with 8 steps.
99
+
100
+ # 4 RELIABILITY EVALUATION OF PANDALM
101
+
102
+ To ensure the reliability of PandaLM, we create a test dataset that is labeled by humans and designed to align with human preferences for responses. Each instance of this test dataset consists of one instruction and input, and two responses produced by different instruction-tuned LLMs. The paired responses are provided by LLaMA-7B, Bloom-7B, Cerebras-GPT-6.7B, OPT-7B, and Pythia-6.9B, all instruction tuned using the same instruction data and hyperparameters following Alpaca (Taori et al., 2023). The test data is sampled from the diverse human evaluation dataset of self-instruct (Wang et al., 2022c), which includes data from Grammarly, Wikipedia, National Geographic and nearly one hundred apps or websites. The inputs and labels are solely human-generated and include a range of tasks and contents. Three different human evaluators independently annotate the labels indicating the preferred response. Samples with significant divergences are excluded to ensure the Inter Annotator Agreement (IAA) of each annotator remains larger than 0.85. This is because such samples demand additional knowledge or hard-to-obtain information, making them challenging for humans to evaluate. The filtered test dataset contains 1K samples, while the original unfiltered dataset has 2.5K samples.
103
+
104
+ To maintain high-quality crowdsourcing work, we involve three experts to annotate the same data point concurrently during the annotation process. There is no prior relationship between the experts and the authors. The experts are hired from an annotation company. These experts receive specialized training that goes beyond evaluating response correctness, enabling them to emphasize other crucial aspects like relative conciseness, clarity, comprehensiveness, formality, and adherence to instructions. Furthermore, we guide these annotators in identifying and addressing issues such as logical fallacies, unnecessary repetitions, grammatical inaccuracies, and a lack of contextual relevance. All human ratings are collected consistently within the same session. To ensure clarity and consistency, we provide comprehensive instructions for every annotator. After the trial phase of data annotation, we eliminate some low-quality labeled data. The final IAA amongst the three annotators, as measured by Cohen's Kappa (Cohen, 1960), yields average scores of 0.85, 0.86, and 0.88 respectively, indicating a relatively high level of reliability for our test dataset. To refine the model's performance assessment compared to human evaluators, we can use the inter-annotator agreement (IAA) of 0.85 as a benchmark. If our model exceeds this, it indicates strong performance. However, setting a realistic target slightly above this human IAA, say around 0.90, offers a challenging yet achievable goal. The distribution of the test data comprises 105 instances of ties, 422 instances where Response 1 wins, and 472 instances where Response 2 takes the lead. Note that the human-generated dataset has no
105
+
106
+ Table 1: Comparative analysis of evaluation results from various annotation models. The tuple in the table means (#win,#lose,#tie). Specifically, (72,28,11) in the first line of the table indicates that LLaMA-7B outperforms Bloom-7B in 72 responses, underperforms in 28, and matches the quality in 11 responses. The 'Judged By' column represents different methods of response evaluation. 'Human' indicates that humans evaluate the result, and 'PandaLM' indicates that our proposed PandaLM model evaluates the result.
107
+
108
+ <table><tr><td>Judged By</td><td>Base Model</td><td>LLaMA-7B</td><td>Bloom-7B</td><td>Cerebras-6.7B</td><td>OPT-7B</td><td>Pythia-6.9B</td></tr><tr><td rowspan="5">Human</td><td>LLaMA-7B</td><td>/</td><td>(72,28,11)</td><td>(80,24,6)</td><td>(71,24,11)</td><td>(58,27,9)</td></tr><tr><td>Bloom-7B</td><td>(28,72,11)</td><td>/</td><td>(59,30,11)</td><td>(43,35,11)</td><td>(47,49,11)</td></tr><tr><td>Cerebras-6.7B</td><td>(24,80,6)</td><td>(30,59,11)</td><td>/</td><td>(33,49,9)</td><td>(27,53,11)</td></tr><tr><td>OPT-7B</td><td>(24,71,11)</td><td>(35,43,11)</td><td>(49,33,9)</td><td>/</td><td>(32,53,15)</td></tr><tr><td>Pythia-6.9B</td><td>(27,58,9)</td><td>(49,47,11)</td><td>(53,27,11)</td><td>(53,32,15)</td><td>/</td></tr><tr><td rowspan="5">GPT-3.5</td><td>LLaMA-7B</td><td>/</td><td>(59,19,33)</td><td>(71,13,26)</td><td>(58,17,31)</td><td>(49,16,29)</td></tr><tr><td>Bloom-7B</td><td>(19,59,33)</td><td>/</td><td>(40,19,41)</td><td>(36,30,23)</td><td>(33,34,40)</td></tr><tr><td>Cerebras-6.7B</td><td>(13,71,26)</td><td>(19,40,41)</td><td>/</td><td>(24,38,29)</td><td>(22,43,26)</td></tr><tr><td>OPT-7B</td><td>(17,58,31)</td><td>(30,36,23)</td><td>(38,24,29)</td><td>/</td><td>(30,30,40)</td></tr><tr><td>Pythia-6.9B</td><td>(16,49,29)</td><td>(34,33,40)</td><td>(43,22,26)</td><td>(30,30,40)</td><td>/</td></tr><tr><td rowspan="5">GPT-4</td><td>LLaMA-7B</td><td>/</td><td>(58,15,38)</td><td>(69,9,32)</td><td>(58,14,34)</td><td>(52,17,25)</td></tr><tr><td>Bloom-7B</td><td>(15,58,38)</td><td>/</td><td>(47,16,37)</td><td>(35,31,23)</td><td>(32,33,42)</td></tr><tr><td>Cerebras-6.7B</td><td>(9,69,32)</td><td>(16,47,37)</td><td>/</td><td>(23,40,28)</td><td>(17,41,33)</td></tr><tr><td>OPT-7B</td><td>(14,58,34)</td><td>(31,35,23)</td><td>(40,23,28)</td><td>/</td><td>(25,37,38)</td></tr><tr><td>Pythia-6.9B</td><td>(17,52,25)</td><td>(33,32,42)</td><td>(41,17,33)</td><td>(37,25,38)</td><td>/</td></tr><tr><td rowspan="5">PandaLM-7B</td><td>LLaMA-7B</td><td>/</td><td>(46,29,36)</td><td>(68,18,24)</td><td>(52,26,28)</td><td>(35,28,31)</td></tr><tr><td>Bloom-7B</td><td>(29,46,36)</td><td>/</td><td>(50,18,32)</td><td>(36,30,23)</td><td>(36,31,40)</td></tr><tr><td>Cerebras-6.7B</td><td>(18,68,24)</td><td>(18,50,32)</td><td>/</td><td>(28,39,24)</td><td>(24,46,21)</td></tr><tr><td>OPT-7B</td><td>(26,52,28)</td><td>(30,36,23)</td><td>(39,28,24)</td><td>/</td><td>(30,32,38)</td></tr><tr><td>Pythia-6.9B</td><td>(28,35,31)</td><td>(31,36,40)</td><td>(46,24,21)</td><td>(32,30,38)</td><td>/</td></tr></table>
109
+
110
+ Table 2: Comparison between Human Annotation results and Judged Model evaluation results.
111
+
112
+ <table><tr><td>Judged Model</td><td>Accuracy</td><td>Precision</td><td>Recall</td><td>F1</td></tr><tr><td>GPT-3.5</td><td>0.6296</td><td>0.6195</td><td>0.6359</td><td>0.5820</td></tr><tr><td>GPT-4</td><td>0.6647</td><td>0.6620</td><td>0.6815</td><td>0.6180</td></tr><tr><td>PandaLM-7B</td><td>0.5926</td><td>0.5728</td><td>0.5923</td><td>0.5456</td></tr><tr><td>PandaLM-70B,LoRA</td><td>0.6186</td><td>0.7757</td><td>0.6186</td><td>0.6654</td></tr><tr><td>PandaLM-70B</td><td>0.6687</td><td>0.7402</td><td>0.6687</td><td>0.6923</td></tr></table>
113
+
114
+ personally identifiable information or offensive content, and all annotators receive redundant labor fees.
115
+
116
+ After obtaining the human-labeled test dataset, we can assess and compare the evaluation performances of GPT-3.5, GPT-4, and PandaLM. An interesting observation from Table 1 is the shared similar partial order graph between GPT-3.5, GPT-4, PandaLM-7B, and humans. Furthermore, Figure 4 illustrates directed orders of model superiority (if model A outperforms model B, a directed edge from A to B is drawn; if model A and model B perform similarly, a dashed line from A to B is drawn.), and provides a visual representation of comparative model effectiveness. The experimental results indicate similarities in the preferences of GPT-3.5, GPT-4, PandaLM-7B, and humans. Note that for PandaLM, GPT-3.5, and GPT-4, we swap the input response order and infer twice to procure the final evaluation output. The conflicting evaluation results are revised to 'Tie'.
117
+
118
+ As shown in Table 2, we conduct a statistical analysis comparing the accuracy, precision, recall, and F1-score of GPT-3.5, GPT-4, and PandaLM against human annotations. The performance of PandaLM-70B even surpasses that of GPT-4. The results indicate the efficacy of removing noise in training data and the choosing of foundational model architectures and instructions.
119
+
120
+ To prove the robustness and adaptability of PandaLM across distribution shifts, we also concentrate our evaluations on distinct areas, with a particular emphasis on the legal (LSAT) and biological (PubMedQA and BioASQ) domains. The introduction of the used datasets can be found at Appendix D. Note that for generating responses, we employ open-sourced language models such as Vicuna and Alpaca. Due to constraints in time, GPT-4 is adopted to produce the gold standard answers (win/tie/lose of responses) instead of human annotators. The results illustrated in Table 3 underscore PandaLM's prowess not only in general contexts but also in specific domains such as law (via LSAT) and biology (via PubMedQA and BioASQ). Since we are addressing a three-category classification task (win/lose/tie), where a random guess would lead to around $33\%$ in the precision, recall, and F1 score. PandaLM-7B's results are notably above this level. To further validate PandaLM-7B, we conducted a human evaluation with 30 samples on the BioASQ evaluation. The human evaluation showed that both PandaLM-7B and GPT-4 tended to favor Vicuna over Alpaca, indicating a consistent trend in their evaluations. The marked improvement in performance as the model scales up reaffirms PandaLM's promise across varied applications, further emphasizing its reliability amidst different content distributions.
121
+
122
+ We further investigate the performance of PandaLM by contrasting its efficacy when trained solely on numerical comparisons (win/tie/lose) — akin to a traditional reward model — with the holistic
123
+
124
+ Table 3: Performance evaluation of PandaLM across diverse domains. The table showcases the accuracy, precision, recall, and F1 scores achieved by PandaLM of two different sizes (finetuned from LLaMA-7B and LLaMA2-70B) on three distinct datasets: LSAT, PubMedQA, and BioASQ. These datasets are representative of the legal and biological domains, chosen to demonstrate the robustness and adaptability of PandaLM to different distribution shifts. It's worth noting that GPT-4 was employed for generating the gold standard answers instead of human annotations.
125
+
126
+ <table><tr><td></td><td>Accuracy</td><td>Precision</td><td>Recall</td><td>F1 Score</td></tr><tr><td>LSAT (PandaLM-7B)</td><td>0.4717</td><td>0.7289</td><td>0.4717</td><td>0.5345</td></tr><tr><td>LSAT (PandaLM-70B)</td><td>0.6604</td><td>0.7625</td><td>0.6604</td><td>0.6654</td></tr><tr><td>PubMedQA (PandaLM-7B)</td><td>0.6154</td><td>0.8736</td><td>0.6154</td><td>0.6972</td></tr><tr><td>PubMedQA (PandaLM-70B)</td><td>0.7692</td><td>0.7811</td><td>0.7692</td><td>0.7663</td></tr><tr><td>BioASQ (PandaLM-7B)</td><td>0.5152</td><td>0.7831</td><td>0.5152</td><td>0.5602</td></tr><tr><td>BioASQ (PandaLM-70B)</td><td>0.7727</td><td>0.8076</td><td>0.7727</td><td>0.7798</td></tr></table>
127
+
128
+ Table 4: Comparison of PandaLM performance w/ and w/o reasons and references.
129
+
130
+ <table><tr><td></td><td>Accuracy</td><td>Precision</td><td>Recall</td><td>F1 Score</td></tr><tr><td>PandaLM-7B with only win/tie/lose</td><td>0.4725</td><td>0.4505</td><td>0.4725</td><td>0.3152</td></tr><tr><td>PandaLM-7B</td><td>0.5926</td><td>0.5728</td><td>0.5923</td><td>0.5456</td></tr></table>
131
+
132
+ Table 5: Evaluation of the effectiveness of PandaLM's selected hyperparameters and Alpaca's hyperparameters. The tuple in the table means (#win,#lose,#tie). Specifically, (45,26,99) in the first line of the table indicates that PandaLM's hyperparameter-tuned LLaMA-7B outperforms Alpaca's version in 45 responses, underperforms in 26, and matches the quality in 99 instances. The 'Judged By' column represents different methods of response evaluation.
133
+
134
+ <table><tr><td>Judge Model</td><td>LLaMA-7B</td><td>Bloom-7B</td><td>Cerebras-6.7B</td><td>OPT-7B</td><td>Pythia-6.9B</td></tr><tr><td>GPT-3.5</td><td>(45,26,99)</td><td>(48,24,98)</td><td>(58,21,91)</td><td>(48,34,88)</td><td>(59,20,91)</td></tr><tr><td>GPT-4</td><td>(40,17,113)</td><td>(44,34,92)</td><td>(60,20,90)</td><td>(39,30,101)</td><td>(52,30,88)</td></tr><tr><td>Human</td><td>(82,21,67)</td><td>(79,23,68)</td><td>(88,25,57)</td><td>(68,26,76)</td><td>(82,31,57)</td></tr></table>
135
+
136
+ approach of the standard PandaLM that incorporates evaluation reasons and reference responses. As shown in Table 4, it become evident that the evaluation reasons and reference responses significantly aid LLMs in understanding the evaluation tasks. Note that in Appendix G, the results clearly demonstrate that a smaller model, when precisely tuned, has the capability to outperform a larger, untuned model in evaluation metrics. This finding emphasizes the significant impact of targeted tuning on model performance in evaluation scenarios. We also provide an analysis on PandaLM across model shifts in Appendix K.
137
+
138
+ In addition, beyond performance metrics, PandaLM introduces unique advantages that are not present in models like GPT-3.5 and GPT-4. It offers open-source availability, enabling reproducibility, and protecting data privacy. Furthermore, it provides unlimited access, removing any restrictions that might hinder comprehensive evaluation and application.
139
+
140
+ # 5 USING PANDALM TO INSTRUCTION TUNE LLMS
141
+
142
+ To highlight the effectiveness of using PandaLM for instruction tuning LLMs, we compare the performance of models tuned with PandaLM's selected optimal hyperparameters against those tuned with Alpaca's parameters using GPT-3.5, GPT-4, and human experts. It is noteworthy that PandaLM-7B is employed for this comparison due to considerations regarding computational resources. Given the proven effectiveness of PandaLM-7B, there is a grounded expectation that the performance of PandaLM-70B will exhibit further enhancement. This comparison evaluates multiple tuned LLMs: LLaMA-7B, Bloom-7B, Cerebras-GPT-6.7B, OPT-7B, and Pythia-6.9B. The assessment is conducted on a validation set comprising 170 distinct instructions and inputs obtained from our 1K test set introduced in Section 4. Alpaca's tuning protocol involves training for three epochs with the final iteration's checkpoints being used. It uses the AdamW (Loshchilov & Hutter, 2017) optimizer with a learning rate of 2e-5 and a cosine learning rate scheduler. We perform a wider range of hyperparameters to tune LLMs using PandaLM-7B. Specifically, we explore checkpoints from each epoch (ranging from epoch 1 to epoch 5), four different learning rates (2e-6, 1e-5, 2e-5, 2e-4), two types of optimizers (SGD (Goodfellow et al., 2016) and AdamW), and two learning rate schedulers (cosine and linear). In total, this creates a configuration space of 80 different possibilities per model.
143
+
144
+ We search for optimal hyperparameters among the 80 configurations. These are divided into four blocks, each containing 20 configurations. Sequential comparisons identify the best configuration in each block. The top configurations from each block are then compared to determine the overall best configuration. We repeat each comparison twice for robustness and carry out 800 comparisons in total. The conflicting evaluation results are modified to 'Tie'. Key insights from our tuning process include: Bloom-7B performs best with SGD, a learning rate of 2e-5, and a cosine schedule over 5 epochs. Cerebras-GPT-6.7B also favors SGD with the same learning rate but with a linear schedule. LLaMA-7B prefers AdamW, a learning rate of 1e-5, and a linear schedule over 4 epochs. OPT-6.7B achieves top results with AdamW, a learning rate of 2e-5, and a linear scheduler over 5 epochs. Pythia-6.9B prefers SGD, a learning rate of 1e-5, a cosine schedule, and 5 epochs. This highlights the importance of customized hyperparameter tuning for different models to achieve peak performance. We also provide the analysis on data size, quality and LoRA in Appendix E and Appedix F.
145
+
146
+ As illustrated in Table 5, for GPT-3.5, GPT-4, and human, all base models achieve superior performance when tuned with PandaLM's selected hyperparameters compared to Alpaca's hyperparameters. Note that the procedure of switching the order of input responses, as applied for PandaLM, is also implemented for GPT-3.5 and GPT-4 to acquire more robust evaluation results. This outcome not only supports the claim that PandaLM-7B can enhance the performance of models but also highlights its potential to further improve various large language models. Besides, as shown in Appendix B, based on PandaLM's evaluation, the model demonstrating superior performance is LLaMA-PandaLM. Note that the base foundation model's characteristics can be a significant factor in performance, as evidenced by LLaMA models securing the top two positions. The ranking pattern observed aligns closely with the base model rankings presented in Figure 4. We also provide a hyperparameter optimization analysis in Appendix J.
147
+
148
+ Moreover, Table 6 in Appendix C compares fine-tuned LLMs on various traditional tasks with lm-eval (Gao et al., 2021). Interestingly, while most language models display enhanced performance with PandaLM finetuning, Cerebras experiences a dip. This underscores the value of subjective evaluation (win/tie/lose of responses), as evaluations from humans, GPT-4, and GPT-3.5 all indicate superior performance for Cerebras with PandaLM.
149
+
150
+ # 6 LIMITATIONS
151
+
152
+ While the outcomes of our study are encouraging, we discuss several limitations here. Firstly, the selected range of hyperparameters used in this work is based on common practice and prior literature, and thus may not encompass the absolute optimal hyperparameters. While extending the search bond will inevitably increase the computational cost. While the core data, derived from GPT-3.5, may not fully resonate with human preferences, it's essential to recognize that the efficacy of LLMs hinges not just on training data but also on foundational model architectures and instructions. Currently, our emphasis is primarily on outcome-based evaluation, which is indeed resource-intensive. However, integrating behavior prediction (e.g., using rational analysis Lu et al. (2022); Wang et al. (2023d; 2020); Yang et al. (2021; 2023a)) into an evaluation framework could offer a more comprehensive understanding of LLM performance. For instance, analyzing and evaluating the extended text outputs of an untuned LLM can help predict how a tuned version might behave in various scenarios. This approach could provide a more efficient and insightful way to balance resource-heavy outcome assessments. Besides, we only research on supervised training of LLMs, but the realistic data could be imbalanced or unlabeled, hence semi-supervised Wang et al. (2023e); Chen et al. (2023); Wang et al. (2022b), noisy Zhang et al. (2022b); Chen et al. (2024) and imbalanced training Yang et al. (2022b); Wang et al. (2023f,g) are also our future directions.
153
+
154
+ # 7 CONCLUSION
155
+
156
+ In our exploration of hyperparameter optimization, we apply PandaLM: an automatic and reliable judge model for the tuning of LLMs. Our findings demonstrate that the use of PandaLM is feasible and consistently produces models of superior performance compared to those tuned with Alpaca's default parameters. We are dedicated to continually enhancing PandaLM by expanding its capacity to support larger models and analyzing its intrinsic features, thereby developing increasingly robust versions of the judging model in the future.
157
+
158
+ # ACKNOWLEDGEMENT
159
+
160
+ We would like to thank the anonymous reviewers for their insightful comments and suggestions to help improve the paper. This publication has emanated from research conducted with the financial support of the Pioneer and "Leading Goose" R&D Program of Zhejiang under Grant Number 2022SDXHDX0003 and the National Natural Science Foundation of China Key Program under Grant Number 62336006.
161
+
162
+ # REFERENCES
163
+
164
+ Donnie Adams and Kee-Man Chuah. Artificial intelligence-based tools in research writing: Current trends and future potentials. Artificial Intelligence in Higher Education, pp. 169-184, 2022.
165
+ Rohan Anil, Andrew M Dai, Orhan Firat, Melvin Johnson, Dmitry Lepikhin, Alexandre Passos, Siamak Shakeri, Emanuel Taropa, Paige Bailey, Zhifeng Chen, et al. Palm 2 technical report. arXiv preprint arXiv:2305.10403, 2023.
166
+ Edward Beeching, Sheon Han, Nathan Lambert, Nazneen Rajani, Omar Sanseviero, Lewis Tunstall, and Thomas Wolf. Open llm leaderboard. https://huggingface.co/spaces/HuggingFaceH4/open_11m_leaderboard, 2023.
167
+ Stella Biderman, Hailey Schoelkopf, Quentin Anthony, Herbie Bradley, Kyle O'Brien, Eric Hallahan, Mohammad Aflah Khan, Shivanshu Purohit, USVSN Sai Prashanth, Edward Raff, et al. Pythia: A suite for analyzing large language models across training and scaling. arXiv preprint arXiv:2304.01373, 2023.
168
+ Som Biswas. Chatgpt and the future of medical writing, 2023.
169
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877-1901, 2020.
170
+ Yupeng Chang, Xu Wang, Jindong Wang, Yuan Wu, Kaijie Zhu, Hao Chen, Linyi Yang, Xiaoyuan Yi, Cunxiang Wang, Yidong Wang, et al. A survey on evaluation of large language models. arXiv preprint arXiv:2307.03109, 2023.
171
+ Sahil Chaudhary. Code alpaca: An instruction-following llama model for code generation. https://github.com/sahil280114/codealpaca, 2023.
172
+ Hao Chen, Ran Tao, Yue Fan, Yidong Wang, Jindong Wang, Bernt Schiele, Xing Xie, Bhiksha Raj, and Marios Savvides. Softmatch: Addressing the quantity-quality trade-off in semi-supervised learning. 2023.
173
+ Hao Chen, Jindong Wang, Lei Feng, Xiang Li, Yidong Wang, Xing Xie, Masashi Sugiyama, Rita Singh, and Bhiksha Raj. A general framework for learning from weak supervision. arXiv preprint arXiv:2402.01922, 2024.
174
+ Wei-Lin Chiang, Zhuohan Li, Zi Lin, Ying Sheng, Zhanghao Wu, Hao Zhang, Lianmin Zheng, Siyuan Zhuang, Yonghao Zhuang, Joseph E Gonzalez, et al. Vicuna: An open-source chatbot impressing gpt-4 with $90\%$ chatgpt quality. See https://vicuna.lmsys.org (accessed 14 April 2023), 2023.
175
+ Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
176
+ Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, et al. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.
177
+ Jacob Cohen. Kappa: Coefficient of concordance. Educ Psych Measurement, 20(37):37-46, 1960.
178
+
179
+ Nolan Dey, Gurpreet Gosal, Hemant Khachane, William Marshall, Ribhu Pathria, Marvin Tom, Joel Hestness, et al. Cerebras-gpt: Open compute-optimal language models trained on the cerebras wafer-scale cluster. arXiv preprint arXiv:2304.03208, 2023.
180
+ Shizhe Diao, Rui Pan, Hanze Dong, KaShun Shum, Jipeng Zhang, Wei Xiong, and Tong Zhang. Lmflow: An extensible toolkit for finetuning and inference of large foundation models. https://optimalscale.github.io/LmFlow/, 2023.
181
+ Jesse Dodge, Gabriel Ilharco, Roy Schwartz, Ali Farhadi, Hannaneh Hajishirzi, and Noah Smith. Fine-tuning pretrained language models: Weight initializations, data orders, and early stopping. arXiv preprint arXiv:2002.06305, 2020.
182
+ Qingxiu Dong, Lei Li, Damai Dai, Ce Zheng, Zhiyong Wu, Baobao Chang, Xu Sun, Jingjing Xu, and Zhifang Sui. A survey on in-context learning. arXiv preprint arXiv:2301.00234, 2022.
183
+ Stefan Falkner, Aaron Klein, and Frank Hutter. Bohb: Robust and efficient hyperparameter optimization at scale. In International Conference on Machine Learning, pp. 1437-1446. PMLR, 2018.
184
+ Leo Gao, Jonathan Tow, Stella Biderman, Sid Black, Anthony DiPofi, Charles Foster, Laurence Golding, Jeffrey Hsu, Kyle McDonell, Niklas Muennighoff, Jason Phang, Laria Reynolds, Eric Tang, Anish Thite, Ben Wang, Kevin Wang, and Andy Zou. A framework for few-shot language model evaluation, September 2021. URL https://doi.org/10.5281/zenodo.5371628.
185
+ Varun Godbole, George E. Dahl, Justin Gilmer, Christopher J. Shallue, and Zachary Nado. Deep learning tuning playbook, 2023. URL http://github.com/google-research/tuningPlaybook. Version 1.0.
186
+ Ian Goodfellow, Yoshua Bengio, Aaron Courville, and Yoshua Bengio. Deep learning, volume 1. MIT Press, 2016.
187
+ Google.Bard.2023
188
+ Zishan Guo, Renren Jin, Chuang Liu, Yufei Huang, Dan Shi, Linhao Yu, Yan Liu, Jiaxuan Li, Bojian Xiong, Deyi Xiong, et al. Evaluating large language models: A comprehensive survey. arXiv preprint arXiv:2310.19736, 2023.
189
+ Lynette Hirschman and Robert Gaizauskas. Natural language question answering: the view from here. natural language engineering, 7(4):275-300, 2001.
190
+ Edward J Hu, Phillip Wallis, Zeyuan Allen-Zhu, Yanzhi Li, Shean Wang, Lu Wang, Weizhu Chen, et al. Lora: Low-rank adaptation of large language models. In International Conference on Learning Representations.
191
+ Yunjie Ji, Yong Deng, Yiping Peng Yan Gong, Qiang Niu, Lei Zhang, Baochang Ma, and Xiangang Li. Exploring the impact of instruction data scaling on large language models: An empirical study on real-world use cases. arXiv preprint arXiv:2303.14742, 2023.
192
+ Jacob Devlin Ming-Wei Chang Kenton and Lee Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of NAACL-HLT, pp. 4171-4186, 2019.
193
+ Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, et al. Natural questions: a benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:453-466, 2019.
194
+ Lisha Li, Kevin Jamieson, Giulia DeSalvo, Afshin Rostamizadeh, and Ameet Talwalkar. Hyperband: A novel bandit-based approach to hyperparameter optimization. The Journal of Machine Learning Research, 18(1):6765-6816, 2017.
195
+ Richard Liaw, Eric Liang, Robert Nishihara, Philipp Moritz, Joseph E Gonzalez, and Ion Stoica. Tune: A research platform for distributed model selection and training. arXiv preprint arXiv:1807.05118, 2018.
196
+
197
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
198
+ Jinghui Lu, Linyi Yang, Brian Mac Namee, and Yue Zhang. A rationale-centric framework for human-in-the-loop machine learning. arXiv preprint arXiv:2203.12918, 2022.
199
+ Carlo A Mallio, Andrea C Sertorio, Caterina Bernetti, and Bruno Beomonte Zobel. Large language models for structured reporting in radiology: performance of gpt-4, chatgpt-3.5, perplexity and bing. La radiologia medica, pp. 1-5, 2023.
200
+ OpenAI. Gpt-4 technical report. 2023.
201
+ Yassine Ouali, Céline Hudelot, and Myriam Tami. An overview of deep semi-supervised learning. arXiv preprint arXiv:2006.05278, 2020.
202
+ Baolin Peng, Chunyuan Li, Pengcheng He, Michel Galley, and Jianfeng Gao. Instruction tuning with gpt-4. arXiv preprint arXiv:2304.03277, 2023.
203
+ Krishna Pillutla, Swabha Swayamdipta, Rowan Zellers, John Thickstun, Sean Welleck, Yejin Choi, and Zaid Harchaoui. Mauve: Measuring the gap between neural text and human text using divergence frontiers. Advances in Neural Information Processing Systems, 34:4816-4828, 2021.
204
+ Alec Radford, Karthik Narasimhan, Tim Salimans, Ilya Sutskever, et al. Improving language understanding by generative pre-training.
205
+ Samyam Rajbhandari, Jeff Rasley, Olatunji Ruwase, and Yuxiong He. Zero: Memory optimizations toward training trillion parameter models. In SC20: International Conference for High Performance Computing, Networking, Storage and Analysis, pp. 1-16. IEEE, 2020.
206
+ Jeff Rasley, Samyam Rajbhandari, Olatunji Ruwase, and Yuxiong He. Deepspeed: System optimizations enable training deep learning models with over 100 billion parameters. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 3505-3506, 2020.
207
+ Jie Ren, Samyam Rajbhandari, Reza Yazdani Aminabadi, Olatunji Ruwase, Shuangyan Yang, Minjia Zhang, Dong Li, and Yuxiong He. Zero-offload: Democratizing billion-scale model training. In USENIX Annual Technical Conference, pp. 551-564, 2021.
208
+ Anna Rogers, Olga Kovaleva, and Anna Rumshisky. A primer in bertology: What we know about how bert works. Transactions of the Association for Computational Linguistics, 8:842-866, 2021.
209
+ Teven Le Scao, Angela Fan, Christopher Akiki, Ellie Pavlick, Suzana Ilic, Daniel Hesslow, Roman Castagné, Alexandra Sasha Luccioni, François Yvon, Matthias Galle, et al. Bloom: A 176b-parameter open-access multilingual language model. arXiv preprint arXiv:2211.05100, 2022.
210
+ Anastasia Shimorina and Anya Belz. The human evaluation datasheet: A template for recording details of human evaluation experiments in NLP. In Proceedings of the 2nd Workshop on Human Evaluation of NLP Systems (HumEval), pp. 54-75, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.humeval-1.6. URL https://aclanthology.org/2022.humeval-1.6.
211
+ Felix Stahlberg. Neural machine translation: A review. Journal of Artificial Intelligence Research, 69:343-418, 2020.
212
+ Chi Sun, Xipeng Qiu, Yige Xu, and Xuanjing Huang. How to fine-tune bert for text classification? In Chinese Computational Linguistics: 18th China National Conference, CCL 2019, Kunming, China, October 18-20, 2019, Proceedings 18, pp. 194-206. Springer, 2019.
213
+ Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International conference on machine learning, pp. 6105-6114. PMLR, 2019.
214
+ Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. Stanford alpaca: An instruction-following llama model. https://github.com/tatsu-lab/stanford_alpaca, 2023.
215
+
216
+ Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Roziere, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.
217
+ Lewis Tunstall, Leandro Von Werra, and Thomas Wolf. Natural language processing with transformers. "O'Reilly Media, Inc.", 2022.
218
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
219
+ Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. In International Conference on Learning Representations.
220
+ Chi Wang, Susan Xueqing Liu, and Ahmed H Awadallah. Cost-effective hyperparameter optimization for large language model generation inference. arXiv preprint arXiv:2303.04673, 2023a.
221
+ Cunxiang Wang, Shuailong Liang, Yue Zhang, Xiaonan Li, and Tian Gao. Does it make sense? and why? a pilot study for sense making and explanation, 2020.
222
+ Cunxiang Wang, Pai Liu, and Yue Zhang. Can generative pre-trained language models serve as knowledge bases for closed-book qa?, 2021.
223
+ Cunxiang Wang, Sirui Cheng, Qipeng Guo, Yuanhao Yue, Bowen Ding, Zhikun Xu, Yidong Wang, Xiangkun Hu, Zheng Zhang, and Yue Zhang. Evaluating open-QA evaluation. In Thirty-seventh Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2023b. URL https://openreview.net/forum?id=UErNpveP6R.
224
+ Cunxiang Wang, Xiaoze Liu, Yuanhao Yue, Xiangru Tang, Tianhang Zhang, Cheng Jiayang, Yunzhi Yao, Wenyang Gao, Xuming Hu, Zehan Qi, Yidong Wang, Linyi Yang, Jindong Wang, Xing Xie, Zheng Zhang, and Yue Zhang. Survey on factuality in large language models: Knowledge, retrieval and domain-specificity, 2023c.
225
+ Cunxiang Wang, Haofei Yu, and Yue Zhang. RFiD: Towards rational fusion-in-decoder for open-domain question answering. In Anna Rogers, Jordan Boyd-Graber, and Naoaki Okazaki (eds.), Findings of the Association for Computational Linguistics: ACL 2023, pp. 2473-2481, Toronto, Canada, July 2023d. Association for Computational Linguistics. doi: 10.18653/v1/2023.findings-acl.155. URL https://aclanthology.org/2023-findings-acl.155.
226
+ Yidong Wang, Hao Chen, Yue Fan, Wang Sun, Ran Tao, Wenxin Hou, Renjie Wang, Linyi Yang, Zhi Zhou, Lan-Zhe Guo, Heli Qi, Zhen Wu, Yu-Feng Li, Satoshi Nakamura, Wei Ye, Marios Savvides, Bhiksha Raj, Takahiro Shinozaki, Bernt Schiele, Jindong Wang, Xing Xie, and Yue Zhang. Usb: A unified semi-supervised learning benchmark for classification. In Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2022a. doi: 10.48550/ARXIV.2208.07204. URL https://arxiv.org/abs/2208.07204.
227
+ Yidong Wang, Hao Wu, Ao Liu, Wenxin Hou, Zhen Wu, Jindong Wang, Takahiro Shinozaki, Manabu Okumura, and Yue Zhang. Exploiting unlabeled data for target-oriented opinion words extraction. arXiv preprint arXiv:2208.08280, 2022b.
228
+ Yidong Wang, Hao Chen, Qiang Heng, Wenxin Hou, Yue Fan, , Zhen Wu, Jindong Wang, Marios Savvides, Takahiro Shinozaki, Bhiksha Raj, Bernt Schiele, and Xing Xie. Freematch: Self-adaptive thresholding for semi-supervised learning. 2023e.
229
+ Yidong Wang, Zhuohao Yu, Jindong Wang, Qiang Heng, Hao Chen, Wei Ye, Rui Xie, Xing Xie, and Shikun Zhang. Exploring vision-language models for imbalanced learning. International Journal of Computer Vision, 2023f.
230
+ Yidong Wang, Bowen Zhang, Wenxin Hou, Zhen Wu, Jindong Wang, and Takahiro Shinozaki. Margin calibration for long-tailed visual recognition. In Asian Conference on Machine Learning, pp. 1101-1116. PMLR, 2023g.
231
+
232
+ Yiming Wang, Zhuosheng Zhang, and Rui Wang. Element-aware summarization with large language models: Expert-aligned evaluation and chain-of-thought method. arXiv preprint arXiv:2305.13412, 2023h.
233
+ Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A Smith, Daniel Khashabi, and Hannaneh Hajishirzi. Self-instruct: Aligning language model with self generated instructions. arXiv preprint arXiv:2212.10560, 2022c.
234
+ Jia Wu, Xiu-Yun Chen, Hao Zhang, Li-Dong Xiong, Hang Lei, and Si-Hao Deng. Hyperparameter optimization for machine learning models based on bayesian optimization. Journal of Electronic Science and Technology, 17(1):26-40, 2019.
235
+ Canwen Xu, Daya Guo, Nan Duan, and Julian McAuley. Baize: An open-source chat model with parameter-efficient tuning on self-chat data. arXiv preprint arXiv:2304.01196, 2023.
236
+ Liang Xu, Hai Hu, Xuanwei Zhang, Lu Li, Chenjie Cao, Yudong Li, Yechen Xu, Kai Sun, Dian Yu, Cong Yu, et al. Clue: A Chinese language understanding evaluation benchmark. In Proceedings of the 28th International Conference on Computational Linguistics, pp. 4762-4772, 2020.
237
+ Linyi Yang, Jiazheng Li, Pádraig Cunningham, Yue Zhang, Barry Smyth, and Ruihai Dong. Exploring the efficacy of automatically generated counterfactuals for sentiment analysis. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 306-316, 2021.
238
+ Linyi Yang, Shuibai Zhang, Libo Qin, Yafu Li, Yidong Wang, Hanmeng Liu, Jindong Wang, Xing Xie, and Yue Zhang. Glue-x: Evaluating natural language understanding models from an out-of-distribution generalization perspective. arXiv preprint arXiv:2211.08073, 2022a.
239
+ Linyi Yang, Yaoxian Song, Xuan Ren, Chenyang Lyu, Yidong Wang, Jingming Zhuo, Lingqiao Liu, Jindong Wang, Jennifer Foster, and Yue Zhang. Out-of-distribution generalization in natural language processing: Past, present, and future. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pp. 4533-4559, 2023a.
240
+ Linyi Yang, Shuibai Zhang, Zhuohao Yu, Guangsheng Bao, Yidong Wang, Jindong Wang, Ruochen Xu, Wei Ye, Xing Xie, Weizhu Chen, et al. Supervised knowledge makes large language models better in-context learners. arXiv preprint arXiv:2312.15918, 2023b.
241
+ Lu Yang, He Jiang, Qing Song, and Jun Guo. A survey on long-tailed visual recognition. International Journal of Computer Vision, 130(7):1837-1872, 2022b.
242
+ Tong Yu and Hong Zhu. Hyper-parameter optimization: A review of algorithms and applications. arXiv preprint arXiv:2003.05689, 2020.
243
+ Zhuohao Yu, Chang Gao, Wenjin Yao, Yidong Wang, Wei Ye, Jindong Wang, Xing Xie, Yue Zhang, and Shikun Zhang. Kieval: A knowledge-grounded interactive evaluation framework for large language models. arXiv preprint arXiv:2402.15043, 2024.
244
+ Aohan Zeng, Xiao Liu, Zhengxiao Du, Zihan Wang, Hanyu Lai, Ming Ding, Zhuoyi Yang, Yifan Xu, Wendi Zheng, Xiao Xia, et al. Glm-130b: An open bilingual pre-trained model. arXiv preprint arXiv:2210.02414, 2022a.
245
+ Zhengran Zeng, Hanzhuo Tan, Haotian Zhang, Jing Li, Yuqun Zhang, and Lingming Zhang. An extensive study on pre-trained models for program understanding and generation. In Sukyoung Ryu and Yannis Smaragdakis (eds.), ISSTA '22: 31st ACM SIGSOFT International Symposium on Software Testing and Analysis, Virtual Event, South Korea, July 18 - 22, 2022, pp. 39-51. ACM, 2022b. doi: 10.1145/3533767.3534390. URL https://doi.org/10.1145/3533767.3534390.
246
+ Chen Zhang, Yu Xie, Hang Bai, Bin Yu, Weihong Li, and Yuan Gao. A survey on federated learning. Knowledge-Based Systems, 216:106775, 2021a.
247
+ Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, et al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068, 2022a.
248
+
249
+ Tianyi Zhang, Varsha Kishore, Felix Wu, Kilian Q Weinberger, and Yoav Artzi. Bertscore: Evaluating text generation with bert. In International Conference on Learning Representations, 2019.
250
+ Xin Zhang, Guangwei Xu, Yueheng Sun, Meishan Zhang, and Pengjun Xie. Crowdsourcing learning as domain adaptation: A case study on named entity recognition. In Chengqing Zong, Fei Xia, Wenjie Li, and Roberto Navigli (eds.), Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 5558-5570, Online, August 2021b. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.432. URL https://aclanthology.org/2021.acl-long.432.
251
+ Xin Zhang, Guangwei Xu, Yueheng Sun, Meishan Zhang, Xiaobin Wang, and Min Zhang. Identifying Chinese opinion expressions with extremely-noisy crowdsourcing annotations. In Smaranda Muresan, Preslav Nakov, and Aline Villavicencio (eds.), Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2801-2813, Dublin, Ireland, May 2022b. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long.200. URL https://aclanthology.org/2022.acl-long.200.
252
+ Xin Zhang, Zehan Li, Yanzhao Zhang, Dingkun Long, Pengjun Xie, Meishan Zhang, and Min Zhang. Language models are universal embeddings. arXiv preprint arXiv:2310.08232, 2023.
253
+ Lianmin Zheng, Ying Sheng, Wei-Lin Chiang, Hao Zhang, Joseph Gonzalez, E., and Ion Stoica. Chatbot arena: Benchmarking llms in the wild with elo ratings. *GitHub repository*, 2023.
254
+ Qihuang Zhong, Liang Ding, Juhua Liu, Bo Du, and Dacheng Tao. Can chatgpt understand too? a comparative study on chatgpt and fine-tuned bert. arXiv preprint arXiv:2302.10198, 2023.
255
+
256
+ ![](images/b2d5584e7d647eb04f093ed6e6744666b86772d074b87811239f681df88eda80.jpg)
257
+ Figure 5: A training data example for PandaLM.
258
+
259
+ ![](images/eef8004860121b3ce5a026ece12462754b632b3e2e0db8e4bd8563d9d73e06e2.jpg)
260
+ Figure 6: The prompt for training PandaLM.
261
+
262
+ # A TRAINING PROMPT DETAILS
263
+
264
+ We introduce the detailed prompt of training PandaLM in Figure 6.
265
+
266
+ # B DIRECTED ACYCLIC GRAPH DEPICTING THE MIXTURE RANKING OF MODELS TRAINED USING BOTH ALPACA'S AND PANDALM'S HYPERPARAMETERS.
267
+
268
+ A directed acyclic graph (DAG) is presented in Figure 7, illustrating the relative rankings of various models fine-tuned with different sets of hyperparameters. Notably, this ranking differs from those in Figure4, due to the variance in the test data: the test data for 7 is a sampled subset from that used in Figure4 which is deliberately chosen to ensure a high Inter-Annotator Agreement (IAA). A discernible pattern emerges from the rankings: models fine-tuned using PandaLM's hyperparameters consistently outshine their counterparts fine-tuned with Alpaca's. The top-rated model is PandaLM-LLaMA, followed by Alpaca-LLaMA, PandaLM-Bloom, PandaLM-Pythia, PandaLM-OPT, PandaLM-Cerebras-GPT, Alpaca-OPT, Alpaca-Bloom, Alpaca-Pythia, and Alpaca-Cerebras-GPT, in descending order of performance. This juxtaposition accentuates the effectiveness of PandaLM's hyperparameter selection in improving model performance, as models optimized with PandaLM consistently rank higher than those using Alpaca's hyperparameters in the hybrid ranking. These findings underscore the potential of PandaLM as a powerful tool in enhancing the performance of large language models, further supporting the assertion of its efficacy.
269
+
270
+ ![](images/239a73335014af008e8c055ee11c8aba73c22dca524594c19b365d40caae6029.jpg)
271
+ Figure 7: Directed Acyclic Graph depicting the mixture ranking of models trained using both Alpaca's and PandaLM's hyperparameters. The models are ranked from strongest to weakest in the following order: PandaLM-LLaMA, Alpaca-LLaMA, PandaLM-Bloom, PandaLM-Pythia, PandaLM-OPT, PandaLM-Cerebras-GPT, Alpaca-OPT, Alpaca-Bloom, Alpaca-Pythia, Alpaca-Cerebras-GPT.
272
+
273
+ Table 6: Comparison on several downstream tasks using lm-eval(Gao et al., 2021) between foundation models fine-tuned on Alpaca's hyperparameters, and foundation models fine-tuned with PandaLM. Note that the MMLU task consists of 57 subtasks, which means providing a comprehensive standard deviation here is not feasible.
274
+
275
+ <table><tr><td></td><td>ARC-Challenge-acc_norm(25-shot)</td><td>Hellaswag-acc_norm(10-shot)</td><td>MMLU-average-acc(5-shot)</td><td>TruthfulQA-mc2(0-shot)</td><td>Average</td></tr><tr><td>llama-7b original</td><td>0.4923±0.0146</td><td>0.7583±0.0043</td><td>0.3306</td><td>0.3703±0.0141</td><td>0.4879</td></tr><tr><td>llama-7b w/ PandaLM</td><td>0.5162±0.0146</td><td>0.7764±0.0042</td><td>0.3396</td><td>0.3801±0.0145</td><td>0.5031</td></tr><tr><td>opt-6.7b original</td><td>0.3805±0.0142</td><td>0.6535±0.0047</td><td>0.2476</td><td>0.3587±0.0139</td><td>0.4101</td></tr><tr><td>opt-6.7b w/ PandaLM</td><td>0.3771±0.0142</td><td>0.6540±0.0047</td><td>0.2502</td><td>0.3609±0.0142</td><td>0.4106</td></tr><tr><td>pythia-6.9b original</td><td>0.3848±0.0142</td><td>0.6093±0.0049</td><td>0.2490</td><td>0.4187±0.0148</td><td>0.4155</td></tr><tr><td>pythia-6.9b w/ PandaLM</td><td>0.4130±0.0144</td><td>0.6337±0.0048</td><td>0.2581</td><td>0.3972±0.0144</td><td>0.4255</td></tr><tr><td>bloom-7b original</td><td>0.3985±0.0143</td><td>0.6086±0.0049</td><td>0.2635</td><td>0.3975±0.0148</td><td>0.4170</td></tr><tr><td>bloom-7b w/ PandaLM</td><td>0.3951±0.0143</td><td>0.6084±0.0049</td><td>0.2520</td><td>0.3997±0.0149</td><td>0.4138</td></tr><tr><td>Cerebras-GPT-6.7B original</td><td>0.3524±0.0140</td><td>0.5613±0.0050</td><td>0.2584</td><td>0.3624±0.0140</td><td>0.3836</td></tr><tr><td>Cerebras-GPT-6.7B w/ PandaLM</td><td>0.3558±0.0140</td><td>0.5550±0.0050</td><td>0.2452</td><td>0.3448±0.0141</td><td>0.3752</td></tr></table>
276
+
277
+ # C COMPARISONS BETWEEN ORIGINAL MODELS AND MODELS TUNED USING PANDALM ON TRADITIONAL TASKS
278
+
279
+ We compare fine-tuned LLMs on various traditional tasks with lm-eval (Gao et al., 2021). Although the majority of language models exhibit improved performance after finetuning with PandaLM, Cerebras exhibits a decline. This highlights the importance of nuanced, subjective evaluations (win/tie/lose of responses). Human evaluations, as well as assessments from GPT-4 and GPT-3.5, all concur in indicating a better performance from Cerebras when paired with PandaLM. This is also confirmed in (Yu et al., 2024).
280
+
281
+ As shown in Table 7, the evaluation results of language models show that lower perplexity, indicating better predictive ability in pretraining or other tasks, does not always mean better overall performance of instruction-tuned models. For example, LLaMA-PandaLM has a higher perplexity than LLaMA-Alpaca but outperforms it in both pairwise comparisons (PandaLM, GPT, Human) and traditional
282
+
283
+ Table 7: Analysis on perplexity and other evaluation metrics. Note that we report the win rate over 170 samples of PandaLM, GPT, and Human.
284
+
285
+ <table><tr><td>Model</td><td>Perplexity (↓)</td><td>PandaLM-7B (↑)</td><td>PandaLM-70B (↑)</td><td>GPT-3.5 (↑)</td><td>GPT-4 (↑)</td><td>Human (↑)</td><td>lm-eval avg. score (↑)</td></tr><tr><td>LLaMA-Alpaca</td><td>2.75</td><td>15.88%</td><td>22.94%</td><td>15.29%</td><td>10.00%</td><td>12.35%</td><td>0.4879</td></tr><tr><td>LLaMA-PandaLM</td><td>2.81</td><td>19.41%</td><td>35.88%</td><td>26.47%</td><td>23.53%</td><td>48.24%</td><td>0.5031</td></tr></table>
286
+
287
+ tasks (lm-eval). This suggests that while perplexity is not feasible for instruction-tuned models where lower perplexity might mean overfitting and less generalizability.
288
+
289
+ # D LAW / BIOMEDICAL DATASETS INTRODUCTION
290
+
291
+ Specifically, we assess PandaLM's proficiency using the LSAT (Law School Admission Test) dataset, which serves as an entrance exam question set for American law schools. This dataset incorporates 1,009 questions, further divided into three subsets: AR, LR, and RC. In the realm of biomedicine, we use the PubMedQA dataset—a vast repository for biomedical retrieval QA data, boasting 1k expert annotations, 61.2k unlabeled entries, and a massive 211.3k human-generated QA instances. For our evaluation, we rely on the labeled section (PubMedQA-1) that contains 1k instances. Each instance encompasses a question, context, and label. Additionally, we tap into the BioASQ dataset, specifically leveraging the task b dataset from its 11th challenge. This dataset is renowned for its biomedical semantic indexing and question-answering (QA) capabilities. From it, we use 1k samples for our assessment. We will test code/math dataset Cobbe et al. (2021); Zeng et al. (2022b) in future work.
292
+
293
+ # E DATA SIZE AND QUALITY ANALYSIS IN INSTRUCTION TUNING
294
+
295
+ We conduct an ablation study to investigate the impact of training data size (up to 1,344,000) on the performance of the model, given optimal hyperparameters. Importantly, a relationship exists between the size and quality of training data. Thus, we focus on an ablation study of data size here, but conducting a similar experiment on data quality is feasible. We derive the results from PandaLM-7B. The objective is to discern how much training data is required to reach each model's peak performance. Table 8 reveals the optimal quantity of training data varies among models. More training data typically enhances model performance. However, an optimal point exists for each model, beyond which further data doesn't improve performance. For example, the OPT model peaks at 992,000 data points, indicating additional data does not enhance the model's performance.
296
+
297
+ Table 8: Optimal training data size for each model.
298
+
299
+ <table><tr><td>Model</td><td>Bloom</td><td>Cerebras-GPT</td><td>LLaMA</td><td>OPT</td><td>Pythia</td></tr><tr><td>Optimal Training Data Size</td><td>1,216,000</td><td>1,344,000</td><td>11,520,000</td><td>992,000</td><td>1,344,000</td></tr></table>
300
+
301
+ # F LORA ANALYSIS IN INSTRUCTION TUNING
302
+
303
+ We further aim to evaluate the efficacy of Low-Rank Adaptation (LoRA) (Hu et al.) compared to full fine-tuning across various models, utilizing optimal hyperparameters. The results are also obtained from PandaLM-7B. Our analysis seeks to provide a comparative understanding of these tuning methodologies. As shown in Table 9, the results for the Bloom model reveal a distinct advantage for full fine-tuning, which triumphs over LoRA in 66 instances as opposed to LoRA's 35. Notably, they tie in 69 instances. In the case of the Cerebras model, full fine-tuning again proves superior, leading in 59 cases compared to LoRA's 40, despite drawing even 71 times. The trend of full fine-tuning superiority is consistent in the LLaMA model. Out of 170 instances, full fine-tuning results in better performance in 48 instances, whereas LoRA emerges victorious in only 28 instances. The majority of the results are tied, amounting to 94 instances. In the OPT model, full fine-tuning once more showcases its advantage with 64 instances of superior performance compared to LoRA's 33, while recording a tie in 73 instances. Lastly, for the Pythia model, full fine-tuning leads the race with 71 instances of better performance against LoRA's 21, and a tie occurring in 78 instances. These results
304
+
305
+ underscore that full fine-tuning generally yields more favorable results compared to the use of LoRA, though the outcomes can vary depending on the model. Despite the considerable number of ties, full fine-tuning holds the upper hand in most models, thereby highlighting its effectiveness. This suggests that while LoRA may provide comparable results in some instances, a strategy of full fine-tuning often proves to be the more beneficial approach in enhancing model performance.
306
+
307
+ Table 9: Comparison of LoRA and Full Fine-tuning.
308
+
309
+ <table><tr><td>Model</td><td>LoRA Wins</td><td>Full Fine-tuning Wins</td><td>Ties</td></tr><tr><td>Bloom</td><td>35</td><td>66</td><td>69</td></tr><tr><td>Cerebras-GPT</td><td>40</td><td>59</td><td>71</td></tr><tr><td>LLaMA</td><td>28</td><td>48</td><td>94</td></tr><tr><td>OPT</td><td>33</td><td>64</td><td>73</td></tr><tr><td>Pythia</td><td>21</td><td>71</td><td>78</td></tr></table>
310
+
311
+ # G LEVERAGING PRE-TRAINED MODELS AND OTHER INSTRUCTION TUNED MODELS FOR EVALUATION
312
+
313
+ Employing LLMs for response evaluation without additional training is a natural direction for the task. However, implementing evaluation criteria through zero-shot or few-shot methods is challenging for LLMs due to the necessity for extended context lengths.
314
+
315
+ We have undertaken experiments using zero-shot and few-shot (in-context learning Dong et al. (2022); Yang et al. (2023b)) evaluations with LLaMA. Our observations indicate that an un-tuned LLaMA struggles with adhering to user-specified format requirements. Consequently, our experiments focused on computing and comparing the log-likelihood of generating continuations (e.g., determining whether "Response 1 is better," "Response 2 is better," or if both responses are similar in quality) from the same context. We regard the choice with the highest log-likelihood as the prediction result. We also alternated response order in our experiments to reduce position bias. Furthermore, we undertook experiments with Vicuna, a finetuned version of LLaMA. The experiments demonstrated that the evaluation capabilities of instruction-tuned models possess significant potential for enhancement.
316
+
317
+ The results in Table 10 highlight the importance of tailored tuning for evaluation, a precisely-tuned smaller model outperforms a larger one in zero and few-shot scenarios.
318
+
319
+ # H ENHANCING PANDALM WITH REFINED SUPERVISION.
320
+
321
+ In our supervision goal, we incorporate not only the comparative result of responses but also a succinct explanation and a reference response. This methodology augments PandaLM's comprehension of the evaluation criteria.
322
+
323
+ Table 10: Ablation study of directly using pre-trained models and instruction tuned models for evaluation.
324
+
325
+ <table><tr><td>Model</td><td>Accuracy</td><td>Precision</td><td>Recall</td><td>F1 score</td></tr><tr><td>LLaMA-7B 0-shot (log-likelihood)</td><td>12.11</td><td>70.23</td><td>34.52</td><td>8.77</td></tr><tr><td>LLaMA-30B 0-shot (log-likelihood)</td><td>31.43</td><td>56.48</td><td>43.12</td><td>32.83</td></tr><tr><td>LLaMA-7B 5-shot (log-likelihood)</td><td>24.82</td><td>46.99</td><td>39.79</td><td>25.43</td></tr><tr><td>LLaMA-30B 5-shot (log-likelihood)</td><td>42.24</td><td>61.99</td><td>51.76</td><td>42.93</td></tr><tr><td>Vicuna-7B (log-likelihood)</td><td>15.92</td><td>57.53</td><td>34.90</td><td>14.90</td></tr><tr><td>Vicuna-13B (log-likelihood)</td><td>35.24</td><td>57.45</td><td>43.65</td><td>36.29</td></tr><tr><td>PandaLM-7B</td><td>59.26</td><td>57.28</td><td>59.23</td><td>54.56</td></tr><tr><td>PandaLM-7B (log-likelihood)</td><td>59.26</td><td>59.70</td><td>63.07</td><td>55.78</td></tr></table>
326
+
327
+ Table 11: Ablation study of supervision goal.
328
+
329
+ <table><tr><td>Model</td><td>Accuracy</td><td>Precision</td><td>Recall</td><td>F1</td></tr><tr><td>PandaLM-7B (with only eval label)</td><td>0.4725</td><td>0.4505</td><td>0.4725</td><td>0.3152</td></tr><tr><td>PandaLM-7B</td><td>0.5926</td><td>0.5728</td><td>0.5923</td><td>0.5456</td></tr></table>
330
+
331
+ To empirically gauge the significance of this explanation, an experiment was executed. Here, the explanation and reference were omitted during training, and only the categorical outcomes (0/1/2 or Tie/Win/Lose) were retained in the dataset for training a fresh iteration of PandaLM. The results, as depicted in Table 11, demonstrate that in the absence of the explanation, PandaLM encounters difficulties in precisely determining the preferable response.
332
+
333
+ # I HUMAN EVALUATION DATASHEET
334
+
335
+ We employ human annotators from a crowdsourcing company and pay them fairly. In particular, we pay our annotators 50 dollars per hour, which is above the average local income level. We have filled out the Google Sheet provided in (Shimorina & Belz, 2022).
336
+
337
+ # J HYPERPARAMETER OPTIMIZATION ANALYSIS
338
+
339
+ In our hyperparameter searching process, we explored a range of learning rates, epochs, optimizers, and schedulers. The learning rates tested varied from 2e-6 to 2e-4, with model checkpoints saved at the end of each epoch. Performance was rigorously assessed through pairwise comparisons between checkpoints, counting the win rounds for each model, as detailed in Figure 8.
340
+
341
+ Our analysis, as depicted in Figure 8a, suggests a tendency towards a learning rate of 2e-5, although this preference was not uniformly clear across all models. Figure 8b demonstrates the variability in the optimal number of epochs, with a trend showing that peak performance often occurs around the fourth or fifth epoch. This evidence points to the complex interplay of hyperparameters with model performance, which is further influenced by data distribution, optimizer, and scheduler choices.
342
+
343
+ The findings from our hyperparameter optimization process highlight that there is no universally optimal setting for different models and training setups. While a pattern emerged suggesting that a learning rate around 2e-5 and an epoch count near 4 might be beneficial in some cases, these results are not conclusive. This reinforces the need for specific hyperparameter searches for different models, as demonstrated in our visualizations. A tailored approach to hyperparameter optimization is essential, as it allows for a more nuanced understanding of model performance across various scenarios.
344
+
345
+ Besides, we implemented an early stopping strategy using Pandalm. We focus specifically on LLaMA. Our experiments showed that in some cases, a model's performance at epoch 3 was inferior to that at epoch 2. However, subsequent epochs demonstrated performance improvements. This indicates that early stopping may not always be suitable for large model fine-tuning, as it could prematurely halt training before reaching optimal performance.
346
+
347
+ Table 12: Analysis of PandaLM's Evaluation Capability on Unseen Models.
348
+
349
+ <table><tr><td>Model Comparison</td><td>PandaLM</td><td>Human</td><td>Metrics (P, R, F1)</td></tr><tr><td>llama1-7b vs llama2-7b</td><td>(23,61,16)</td><td>(23,70,7)</td><td>(0.7061, 0.7100, 0.6932)</td></tr><tr><td>llama1-13b vs llama2-13b</td><td>(18,73,9)</td><td>(20,68,12)</td><td>(0.7032, 0.6800, 0.6899)</td></tr><tr><td>llama1-65b vs llama2-70b</td><td>(20,66,14)</td><td>(34,56,10)</td><td>(0.7269, 0.6600, 0.6808)</td></tr></table>
350
+
351
+ # K MODEL SHIFT ANALYSIS
352
+
353
+ In Table 12, we provide a detailed comparison of PandaLM's performance against human benchmarks and in the context of different versions of instruction-tuned LLaMA models. Note that llama1-13b, llama1-65b and llama2 are indicative of model shift. The results demonstrate that PandaLM aligns
354
+
355
+ ![](images/0f48d5d5348ba7854d64a64b2b0fad2237c1c4ee2a14d24e24f76d70bd0fb3a0.jpg)
356
+ (a) Comparison Results of GPT-4.
357
+
358
+ ![](images/3baa3622758afc4bef2b6ac1e63d7520fe75a4e938d1cd3d658366e28cd21995.jpg)
359
+ (b) Comparison Results of Human.
360
+ Figure 8: Hyperparameter Optimization Analysis in PandaLM. The figure illustrates the performance across different learning rates and variability in model performance across epochs.
361
+
362
+ closely with humans, consistently showing a preference for the LLama-2 model. This alignment is in line with expectations, as LLama-2 benefits from more pre-training data. Such findings highlight the significance of extensive pre-training in developing language models that are more skilled at understanding and correctly responding to various instructions.
pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:36f0762c11316884455970d819c2969d0a793df7c1789e5000668f69b846edb0
3
+ size 587819
pandalmanautomaticevaluationbenchmarkforllminstructiontuningoptimization/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62553ff364fe25099d3d46938be7daacf60d70ca64e710391a70c12a86b75d9e
3
+ size 462129
panodiffusion360degreepanoramaoutpaintingviadiffusion/f283e772-e24b-4d76-8ec5-dab59382e974_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d61c694bb0fe95c6db439f4f66e54f2875b4f66c24df79dde7c9443d609af56
3
+ size 127414
panodiffusion360degreepanoramaoutpaintingviadiffusion/f283e772-e24b-4d76-8ec5-dab59382e974_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad67f2022cac9f969006e889ee6265b75f695f715b4d618922e47f053a3bdc5f
3
+ size 152627
panodiffusion360degreepanoramaoutpaintingviadiffusion/f283e772-e24b-4d76-8ec5-dab59382e974_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f8d3783de3f07c3e4b41ca279ace7620762107e5737886afde9a0f7c4e97faa
3
+ size 2022210
panodiffusion360degreepanoramaoutpaintingviadiffusion/full.md ADDED
@@ -0,0 +1,556 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PANODIFFUSION: 360-DEGREE PANORAMA OUTPAINTING VIA DIFFUSION
2
+
3
+ Tianhao Wu $^{1\dagger}$ , Chuanxia Zheng $^{2}$ & Tat-Jen Cham $^{1}$
4
+
5
+ †S-Lab, Nanyang Technological University
6
+
7
+ tianhao001@e.ntu.edu.sg, astjcham@ntu.edu.sg
8
+
9
+ $^{2}$ University of Oxford
10
+
11
+ cxzheng@robots.ox.ac.uk
12
+
13
+ # ABSTRACT
14
+
15
+ Generating complete $360^{\circ}$ panoramas from narrow field of view images is ongoing research as omnidirectional RGB data is not readily available. Existing GAN-based approaches face some barriers to achieving higher quality output, and have poor generalization performance over different mask types. In this paper, we present our $360^{\circ}$ indoor RGB-D panorama outpainting model using latent diffusion models (LDM), called PanoDiffusion. We introduce a new bi-modal latent diffusion structure that utilizes both RGB and depth panoramic data during training, which works surprisingly well to outpaint depth-free RGB images during inference. We further propose a novel technique of introducing progressive camera rotations during each diffusion denoising step, which leads to substantial improvement in achieving panorama wraparound consistency. Results show that our PanoDiffusion not only significantly outperforms state-of-the-art methods on RGB-D panorama outpainting by producing diverse well-structured results for different types of masks, but can also synthesize high-quality depth panoramas to provide realistic 3D indoor models.
16
+
17
+ # 1 INTRODUCTION
18
+
19
+ Omnidirectional $360^{\circ}$ panoramas serve as invaluable assets in various applications, such as lighting estimation (Gardner et al., 2017; 2019; Song & Funkhouser, 2019) and new scene synthesis (Somanath & Kurz, 2021) in the Augmented and Virtual Reality (AR & VR). However, an obvious limitation is that capturing, collecting, and restoring a dataset with $360^{\circ}$ images is a high-effort and high-cost undertaking (Akimoto et al., 2019; 2022), while manually creating a 3D space from scratch can be a demanding task (Lee et al., 2017; Choi et al., 2015; Newcombe et al., 2011).
20
+
21
+ ![](images/8052fa67185f204e340489f6541c1c0f6d21d83952647a6698dee2e25fbd3fd7.jpg)
22
+ (a) Masked input
23
+ Figure 1: Example results of $360^{\circ}$ Panorama Outpainting on various masks. Compared to BIPS (Oh et al., 2022) and OmniDreamer (Akimoto et al., 2022), our model not only effectively generates semantically meaningful content and plausible appearances with many objects, such as beds, sofas and TV's, but also provides multiple and diverse solutions for this ill-posed problem. (Masked regions are shown in blue for better visualization. Zoom in to see the details.)
24
+
25
+ ![](images/4f1c159e04d0217f7d5924c6a95129a3c25bbdadc5df488b2a309e721a130758.jpg)
26
+ (b) Ours PanoDiffusion
27
+
28
+ ![](images/106528e6a9f2de588aaf8c4c5b871d3cf42488d20be8378aef194a728b7f7297.jpg)
29
+ (c) BIPS
30
+
31
+ ![](images/5623931f3a440bf3595b280806902109978851546979d73643b1869c226ae548.jpg)
32
+ (d) OmniDreamer
33
+
34
+ To mitigate this dataset issue, the latest learning methods (Akimoto et al., 2019; Somanath & Kurz, 2021; Akimoto et al., 2022; Oh et al., 2022) have been proposed, with a specific focus on generating omnidirectional RGB panoramas from narrow field of view (NFOV) images. These methods are typically built upon Generative Adversarial Networks (GANs) (Goodfellow et al., 2014), which have shown remarkable success in creating new content. However, GAN architectures face some notable problems, including 1) mode collapse (seen in Fig. 1(c)), 2) unstable training (Salimans et al., 2016), and 3) difficulty in generating multiple structurally reasonable objects (Epstein et al., 2022). These limitations lead to obvious artifacts in synthesizing complex scenes (Fig. 1).
35
+
36
+ The recent endeavors of (Lugmayr et al., 2022; Li et al., 2022; Xie et al., 2023; Wang et al., 2023) directly adopt the latest latent diffusion models (LDMs) (Rombach et al., 2022) in image inpainting tasks, which achieve a stable training of generative models and spatially consistent images. However, specifically for a $360^{\circ}$ panorama outpainting scenario, these inpainting works usually lead to grossly distorted results. This is because: 1) the missing (masked) regions in $360^{\circ}$ panorama outpainting is generally much larger than masks in normal inpainting and 2) it necessitates generating semantically reasonable objects within a given scene, as opposed to merely filling in generic background textures in an empty room (as shown in Fig. 1 (c)). To achieve this, we propose an alternative method for $360^{\circ}$ indoor panorama outpainting via the latest latent diffusion models (LDMs) (Rombach et al., 2022), termed as PanoDiffusion. Unlike existing diffusion-based inpainting methods, we introduce depth information through a novel bi-modal latent diffusion structure during the training, which is also significantly different from the latest concurrent works (Tang et al., 2023; Lu et al., 2023) that aims for text-guided $360^{\circ}$ panorama image generation. Our key motivation for doing so is that the depth information is crucial for helping the network understand the physical structure of objects and the layout of the scene (Ren et al., 2012). It is worth noting that our model only uses partially visible RGB images as input during inference, without requirement for any depth information, yet achieving significant improvement on both RGB and depth synthesis (Tables 1 and 2).
37
+
38
+ Another distinctive challenge in this task stems from the unique characteristic of panorama images: 3) both ends of the image must be aligned to ensure the integrity and wraparound consistency of the entire space, given that the indoor space lacks a definitive starting and ending point. To enhance this property in the generated results, we introduce two strategies: First, during the training process, a camera-rotation approach is employed to randomly crop and stitch the images for data augmentation. It encourages the networks to capture information from different views in a $360^{\circ}$ panorama. Second, a two-end alignment mechanism is applied at each step of the inference denoising process (Fig. 4), which explicitly enforces the two ends of an image to be wraparound-consistent.
39
+
40
+ We evaluate the proposed method on the Structured3D dataset (Zheng et al., 2020). Experimental results demonstrate that our PanoDiffusion not only significantly outperforms previous state-of-the-art methods, but is also able to provide multiple and diverse well-structured results for different types of masks (Fig. 1). In summary, our main contributions are as follows:
41
+
42
+ - A new bi-modal latent diffusion structure that utilizes both RGB and depth panoramic data to better learn spatial layouts and patterns during training, but works surprisingly well to outpaint normal RGB-D coronas during inference, even without depth input;
43
+ - A novel technique of introducing progressive camera rotations during each diffusion denoising step, which leads to substantial improvement in achieving panorama wraparound consistency;
44
+ - With either partially or fully visible RGB inputs, our PanoDiffusion can synthesize high-quality indoor RGB-D panoramas simultaneously to provide realistic 3D indoor models.
45
+
46
+ # 2 RELATED WORK
47
+
48
+ # 2.1 IMAGE INPAINTING/OUTPAINTING
49
+
50
+ Driven by advances in various generative models, such as VAEs (Kingma & Welling, 2014) and GANs (Goodfellow et al., 2014), a series of learning-based approaches (Pathak et al., 2016; Iizuka et al., 2017; Yu et al., 2018; Zheng et al., 2019; Zhao et al., 2020; Wan et al., 2021; Zheng et al., 2022) have been proposed to generate semantically meaningful content from a partially visible image. More recently, state-of-the-art methods (Lugmayr et al., 2022; Li et al., 2022; Xie et al., 2023;
51
+
52
+ ![](images/9dc01410c55bc3aad101612fcb74397ab39b686df055af38c1380e4e9e9ccc07.jpg)
53
+ Figure 2: The overall pipeline of our proposed PanoDiffusion method. (a) During training, the model is optimized for RGB-D panorama synthesis, without the mask. (b) During inference, however, the depth information is no longer needed for masked panorama outpainting. (c) Finally, a super-resolution model is implemented to further enhance the high-resolution outpainting. We only show the input/output of each stage and omit the details of circular shift and adding noise. Note that the VQ-based encoder-decoders are pre-trained in advance, and fixed in the rest of our framework.
54
+
55
+ Wang et al., 2023) directly adopt the popular diffusion models (Rombach et al., 2022) for image inpainting, achieving high-quality completed images with consistent structure and diverse content. However, these diffusion-based models either focus on background inpainting, or require input text as guidance to produce plausible objects within the missing regions. This points to an existing gap in achieving comprehensive and contextually rich inpainting/outpainting results across a wider spectrum of scenarios, especially in the large scale $360^{\circ}$ Panorama scenes.
56
+
57
+ # 2.2 $360^{\circ}$ PANORAMA OUTPAINTING
58
+
59
+ Unlike NFoV images, $360^{\circ}$ panorama images are subjected to nonlinear perspective distortion, such as equirectangular projection. Consequently, objects and layouts within these images appear substantially distorted, particularly those closer to the top and bottom poles. The image completion has to not only preserve the distorted structure but also ensure visual plausibility, with the additional requirement of wraparound-consistency at both ends. Previous endeavors (Akimoto et al., 2019; Somanath & Kurz, 2021) mainly focused on deterministic completion of $360^{\circ}$ RGB images, with BIPS (Oh et al., 2022) further extending this to RGB-D panorama synthesis. In order to generate diverse results (Zheng et al., 2019; 2021), various strategies have been employed. For instance, SIG-SS (Hara et al., 2021) leverages a symmetry-informed CVAE, while OmniDreamer (Akimoto et al., 2022) employs transformer-based sampling. In contrast, our PanoDiffusion is built upon DDPM, wherein each reverse diffusion step inherently introduces stochastic, naturally resulting in multiple and diverse results. Concurrently with our work, MVDiffusion (Tang et al., 2023) generates panorama images by sampling consistent multi-view images, and AOGNet (Lu et al., 2023) does $360^{\circ}$ outpainting through an autoregressive process. Compared to the concurrent models, our PanoDiffusion excels in generating semantically multi-objects for large masked regions, without the need of text prompts. More importantly, PanoDiffusion is capable of simultaneously generating the corresponding RGB-D output, using only partially visible RGB images as input during the inference.
60
+
61
+ # 3 METHODS
62
+
63
+ Given a $360^{\circ}$ image $x \in \mathbb{R}^{H \times W \times C}$ , degraded by a number of missing pixels to become a masked image $x_{m}$ , our main goal is to infer semantically meaningful content with reasonable geometry for the missing regions, while simultaneously generating visually realistic appearances. While this task is conceptually similar to conventional learning-based image inpainting, it presents greater challenges due to the following differences: 1) our output is a $360^{\circ}$ RGB- $D$ panorama that requires wraparound consistency; 2) the masked/missing areas are generally much larger than the masks in traditional inpainting; 3) our goal is to generate multiple appropriate objects within a scene, instead of simply filling in with the generic background; 4) the completed results should be structurally plausible, which can be reflected by a reasonable depth map.
64
+
65
+ ![](images/174563ef7a0bd1886a4260f5507e3288d8d6c089c0d989f79a2d789076afb2e4.jpg)
66
+ Figure 3: Our LDM outpainting structure with camera rotation mechanism. During training (a), we randomly select a rotation angle to generate a new panorama for data augmentation. During inference (b), we sample the visible region from the encoded features (above) and the invisible part from the denoising output (below). The depth map is not needed, and is set to random noise. At each denoising step, we crop a $90^{\circ}$ -equivalent area of the intermediate result from the right and stitch it to the left, denoted by the circle following $z_{t}^{mixed}$ — this strongly improves wraparound consistency.
67
+
68
+ To tackle these challenges, we propose a novel diffusion-based framework for $360^{\circ}$ panoramic outpainting, called PanoDiffusion. The training process, as illustrated in Fig. 2(a), starts with two branches dedicated to RGB $x$ and depth $d_x$ information. Within each branch, following (Rombach et al., 2022), the input data is first embedded into the latent space using the corresponding pretrained VQ model. These representations are then concatenated to yield $z_{rgbd}$ , which subsequently undergoes the forward diffusion step to obtain $z_T$ . The resulting $z_T$ is then subjected to inverse denoising, facilitated by a trained UNet, ultimately returning to the original latent domain. Finally, the pre-trained decoder is employed to rebuild the completed RGB-D results.
69
+
70
+ During inference, our system takes a masked RGB image as input and conducts panoramic outpainting. It is noteworthy that our proposed model does not inherently require harder-to-acquire depth maps as input, relying solely on a partial RGB image (Fig. 2(b)). The output is further super-resolved into the final image in a refinement stage (Fig. 2(c)).
71
+
72
+ # 3.1 PRELIMINARIES
73
+
74
+ Latent Diffusion. Our PanoDiffusion builds upon the latest Latent Diffusion Model (LDM) (Rombach et al., 2022), which executes the denoising process in the latent space of an autoencoder. This design choice yields a twofold advantage: it reduces computational costs while maintaining a high level of visual quality by storing the domain information in the encoder $\mathcal{E}(\cdot)$ and decoder $\mathcal{D}(\cdot)$ . During the training, the given image $x_0$ is initially embedded to yield the latent representation $z_0 = \mathcal{E}(x_0)$ , which is then perturbed by adding the noise in a Markovian manner:
75
+
76
+ $$
77
+ q \left(z _ {t} \mid z _ {t - 1}\right) = \mathcal {N} \left(z _ {t}; \sqrt {1 - \beta_ {t}} z _ {t - 1}, \beta_ {t} I\right), \tag {1}
78
+ $$
79
+
80
+ where $t = [1, \dots, T]$ is the number of steps in the forward process. The hyperparameters $\beta_{t}$ denote the noise level at each step $t$ . For the denoising process, the network in LDM is trained to predict the noise as proposed in DDPM (Ho et al., 2020), where the training objective can be expressed as:
81
+
82
+ $$
83
+ \mathcal {L} = \mathbb {E} _ {\mathcal {E} (x _ {0}), \epsilon \sim \mathcal {N} (0, I), t} [ \| \epsilon_ {\theta} (z _ {t}, t) - \epsilon \| _ {2} ^ {2} ] \tag {2}
84
+ $$
85
+
86
+ Diffusion Outpainting. The existing pixel-level diffusion inpainting methods (Lugmayr et al., 2022; Horita et al., 2022) are conceptually similar to that used for image generation, except $x_{t}$ incorporates partially visible information, rather than purely sampling from a Gaussian distribution during the inference. In particular, let $x_{0}$ denote the original image in step 0, while $x_{0}^{visible} = m\odot x_{0}$ and $x_{0}^{invisible} = (1 - m)\odot x_{0}$ contain the visible and missing pixels, respectively. Then, as shown in Fig. 3, the reverse denoising sampling process unfolds as follows:
87
+
88
+ $$
89
+ x _ {t} ^ {\text {v i s i b l e}} \sim q \left(x _ {t} \mid x _ {t - 1}\right), \tag {3}
90
+ $$
91
+
92
+ $$
93
+ x _ {t - 1} ^ {\text {i n v i s i b l e}} \sim p _ {\theta} \left(x _ {t - 1} \mid x _ {t}\right), \tag {4}
94
+ $$
95
+
96
+ $$
97
+ x _ {t - 1} = m \odot x _ {t - 1} ^ {\text {v i s i b l e}} + (1 - m) \odot x _ {t - 1} ^ {\text {i n v i s i b l e}}. \tag {5}
98
+ $$
99
+
100
+ ![](images/5b95b4bf2f1c80be5e492b01f58750402a2f3f3254fad4c789ac288de0b4ef8a.jpg)
101
+ Figure 4: An example of our two-end alignment mechanism. During inference, we rotate the scene for $90^{\circ}$ in each denoising step. Within a total of 200 sampling steps, our PanoDiffusion will effectively achieve wraparound consistency.
102
+
103
+ Here, $q$ is the forward distribution in the diffusion process and $p_{\theta}$ is the inverse distribution. After $T$ iterations, $x_0$ is restored to the original image space.
104
+
105
+ Relation to Prior Work. In contrast to these inpainting methods at pixel-level, our PanoDiffusion builds upon the LDM. Despite the fact that the original LDM provided the ability to inpainting images, such inpainting focuses on removing objects from the image, rather than generating a variety of meaningful objects in panoramic outpainting. In short, the $x_0$ is embedded into the latent space, yielding $z_0 = \mathcal{E}(x_0)$ , while the subsequent sampling process follows the equations (3)-(5). The key motivation behind this is to perform our task on higher resolution $512 \times 1024$ panoramas. More importantly, we opt to go beyond RGB outpainting, and to deal with RGB-D synthesis (Sec. 3.3), which is useful for downstream tasks in 3D reconstruction. Additionally, existing approaches can not ensure the wraparound consistency during completion, while our proposed rotational outpainting mechanism in Sec. 3.2 significantly improves such a wraparound consistency.
106
+
107
+ # 3.2 WRAPAROUND CONSISTENCY MECHANISM
108
+
109
+ Camera Rotated Data Augmentation. It is expected that the two ends of any $360^{\circ}$ panorama should be seamlessly aligned, creating a consistent transition from one end to the other. This is especially crucial in applications where a smooth visual experience is required, such as 3D reconstruction and rendering. To promote this property, we implement a circular shift data augmentation, termed camera-rotation, to train our PanoDiffusion. As shown in Fig. 3(a), we randomly select a rotation angle, which is subsequently employed to crop and reassemble image patches, generating a new panorama for training purposes.
110
+
111
+ Two-Ends Alignment Sampling. While the above camera-rotation technique can improve the model's implicit grasp of the wraparound consistency using the augmentation of data examples, it may not impose strong enough constraints on wraparound alignment of the results. Therefore, in the inference process, we introduce a novel two-end alignment mechanism that can be seamlessly integrated into our latent diffusion outpainting process. In particular, the reverse denoising process within the DDPM is characterized by multiple iterations, rather than a single step. During each iteration, we apply the camera-rotation operation, entailing $90^{\circ}$ rotation of both the latent vectors and mask, before performing a denoising outpainting step. This procedure more effectively connects the two ends of the panorama from the previous step, resulting in significant improvement in visual results (as shown in Fig. 8). Without changing the size of the images, generating overlapping content, or introducing extra loss functions, we provide 'hints' to the model by rotating the panorama horizontally, thus enhancing the effect of alignment at both ends (examples shown in Fig. 4).
112
+
113
+ # 3.3 BI-MODAL LATENT DIFFUSION MODEL
114
+
115
+ In order to deal with RGB-D synthesis, one straightforward idea could be to use Depth as an explicit condition during training and inference, where the depth information may be compressed into latent space and then introduced into the denoising process of the RGB images via concatenation or cross-attention. However, we found that such an approach often leads to blurry results in our experiments (as shown in Fig. 11). Alternatively, using two parallel LDMs to reconstruct Depth and RGB images separately, together with a joint loss, may also appear to be an intuitive solution. Nonetheless, this idea presents significant implementation challenges due to the computational resources required for multiple LDMs.
116
+
117
+ Therefore, we devised a bi-modal latent diffusion structure to introduce depth information while generating high-quality RGB output. It is important to note that this depth information is solely
118
+
119
+ ![](images/840a314b8d80c736fab39ea8244e4ca9e14f29b86fe97719174f0557cc44b671.jpg)
120
+ (a) NFoV
121
+
122
+ ![](images/0c0526e4c5ff63ca3825d364cb65efcaa35bb2e1c60ffc693daa490b11087606.jpg)
123
+ (b) Camera
124
+
125
+ ![](images/e95e7c627ba9408528ab12aac4d856539d241b719bb2e12e3402675949dad28c.jpg)
126
+ (c) Random
127
+
128
+ ![](images/8dcc2bc843ec9923eda1c46c4b723318cd37974a101c4ef3093a4646bb3434f6.jpg)
129
+ (d) Layout
130
+ Figure 5: Examples of various mask types. See text for details.
131
+
132
+ necessary during the training phase. Specifically, we trained two VAE models independently for RGB and depth images, and then concatenate $z_{rgb} \in \mathbb{R}^{h \times w \times 3}$ with $z_{depth} \in \mathbb{R}^{h \times w \times 1}$ at the latent level to get $z_{rgbd} \in \mathbb{R}^{h \times w \times 4}$ . The training of VAEs is exactly the same as in (Rombach et al., 2022) with downsampling factor $f = 4$ . Then we follow the standard process to train an unconditional DDPM with $z_{rgbd}$ via a variant of the original LDM loss:
133
+
134
+ $$
135
+ \mathcal {L} _ {R G B - D} = \mathbb {E} _ {z _ {r g b d}, \epsilon \sim \mathcal {N} (0, 1), t} [ \| \epsilon_ {\theta} (z _ {t}, t) - \epsilon \| _ {2} ^ {2} ], z _ {r g b d} = \mathcal {E} _ {1} (x) \oplus \mathcal {E} _ {2} (d _ {x}) \tag {6}
136
+ $$
137
+
138
+ Reconstructed RGB-D images can be obtained by decoupling $z_{rgbd}$ and decoding. It is important to note that during training, we use the full RGB-D image as input, without masks. Conversely, during the inference stage, the model can perform outpainting of the masked RGB image directly without any depth input, with the fourth channel of $z_{rgbd}$ replaced by random noise.
139
+
140
+ # 3.4 REFINENET
141
+
142
+ Although mapping images to a smaller latent space via an autoencoder prior to diffusion can save training space and thus allow larger size inputs, the panorama size of $512 \times 1024$ is still a heavy burden for LDM (Rombach et al., 2022). Therefore, we adopt a two-stage approach to complete the outpainting task. Initially, the original input is downscaled to $256 \times 512$ as the input to the LDM. Correspondingly, the image size of the LDM output is also $256 \times 512$ . Therefore, an additional module is needed to upscale the output image size to $512 \times 1024$ . Since panorama images are distorted and the objects and layouts do not follow the regular image patterns, we trained a super-resolution GAN model for panoramas to produce visually plausible results at a higher resolution.
143
+
144
+ # 4 EXPERIMENTS
145
+
146
+ # 4.1 EXPERIMENTAL DETAILS
147
+
148
+ Dataset. We estimated our model on the Structured3D dataset (Zheng et al., 2020), which provides $360^{\circ}$ indoor RGB-D data following equirectangular projection with a $512 \times 1024$ resolution. We split the dataset into 16930 train, 2116 validation, and 2117 test instances.
149
+
150
+ Metrics. For RGB outpainting, due to large masks, we should not require the completed image to be exactly the same as the original image, since there are many plausible solutions (e.g. new furniture and ornaments, and their placement). Therefore, we mainly report the following dataset-level metrics: 1) Fréchet Inception Distance (FID) (Heusel et al., 2017), 2) Spatial FID (sFID) (Nash et al., 2021), 3) density and coverage (Naeem et al., 2020). FID compares the distance between distributions of generated and original images in a deep feature domain, while sFID is a variant of FID that uses spatial features rather than the standard pooled features. Additionally, density reflects how accurate the generated data is to the real data stream, while coverage reflects how well the generated data generalizes the real data stream. For depth synthesis, we use RMSE, MAE, AbsREL, and Delta1.25 as implemented in (Cheng et al., 2018; Zheng et al., 2018), which are commonly used to measure the accuracy of depth estimates. Implementation details can be found in section 5.
151
+
152
+ Mask Types. Most works focused on generating omnidirectional images from NFoV images (Fig. 5(a)). However, partial observability may also occur due to sensor damage in $360^{\circ}$ cameras. Such masks can be roughly simulated by randomly sampling a number of NFoV camera views within the panorama (Fig. 5(b)). We also experimented with other types of masks, such as randomly generated regular masks (Fig. 5(c)). Finally, the regions with floors and ceilings in panoramic images are often less interesting than the central regions. Hence, we also generated layout masks that muffle all areas except floors and ceilings, to more incisively test the model's generative power (Fig. 5(d)).
153
+
154
+ ![](images/16ded2d74b42edd6e639a6ffd524c58dac76bbbef1469f0bc81400126f7c0d9d.jpg)
155
+ (a) Ground Truth
156
+
157
+ ![](images/29c3ff708eb5371dac53105a070ce0ad80e104a0cabca12a891aba75aae789d7.jpg)
158
+ (b) Masked Input
159
+
160
+ ![](images/7eea9441cc82cd271371c44b5d0dc5d8ef0713c701b50fa6878b26ccd81a776c.jpg)
161
+ (c) PanoDiffusion (RGB)
162
+ (d) PanoDiffusion (RGB-D)
163
+
164
+ ![](images/0ca82c052d4479342c176abc653ee48e33195a77c38c05e6ff95f0118113d97e.jpg)
165
+
166
+ ![](images/d75fd7bbcfc7aa1e13ebc11cb6601bb6884b66e5ee64e6fdb2959a5b75509927.jpg)
167
+ (e) $\mathrm{BIPS}_{\mathrm{ECCV}^{\prime}2022}$
168
+
169
+ ![](images/8a0463384343c96f350a78468c97271ca80b690e0af8c582f13605b8dd4e4e08.jpg)
170
+ (f) OmniDreamerCVPR'2022
171
+ Figure 6: Qualitative comparison for RGB panorama outpainting. Our PanoDiffusion generated more objects with appropriate layout, and with better visual quality. For BIPS and OmniDreamer, despite the seemingly reasonable results, the outpainted areas tend to fill the walls and lack diverse items. As for TFill, it generates blurry results for large invisible areas. For Inpaint anything, it generates multiple objects but they appear to be structurally and semantically implausible. Compared to them, PanoDiffusion generates more reasonable details in the masked region, such as pillows, paintings on the wall, windows, and views outside. More comparisons are provided in Appendix.
172
+
173
+ ![](images/169e478243eee135105bddf1d905e82370d3f51fbe2286c239351479ce626c3e.jpg)
174
+ (g) TFillCVPR'2022
175
+ (h) Inpaint AnythingarXiv'2023
176
+
177
+ ![](images/922b74eeec1ce698f80e2be9f35d7edd4bb3cc68204bf530cc2e61b10f3ddce0.jpg)
178
+
179
+ Table 1: Quantitative results for RGB outpainting. All models were re-trained and evaluated using the same standardized dataset. Note that, we tested all models without the depth input.
180
+
181
+ <table><tr><td rowspan="2">Methods</td><td colspan="4">Camera Mask</td><td colspan="4">NFoV Mask</td><td colspan="4">Layout Mask</td><td colspan="4">Random Box Mask</td></tr><tr><td>FID ↓</td><td>sFID ↓</td><td>D ↑</td><td>C ↑</td><td>FID ↓</td><td>sFID ↓</td><td>D ↑</td><td>C ↑</td><td>FID ↓</td><td>sFID ↓</td><td>D ↑</td><td>C ↑</td><td>FID ↓</td><td>sFID ↓</td><td>D ↑</td><td>C ↑</td></tr><tr><td>BIPS</td><td>31.70</td><td>28.89</td><td>0.769</td><td>0.660</td><td>57.69</td><td>44.68</td><td>0.205</td><td>0.277</td><td>32.25</td><td>24.66</td><td>0.645</td><td>0.579</td><td>25.35</td><td>22.60</td><td>0.676</td><td>0.798</td></tr><tr><td>OmniDreamer</td><td>65.47</td><td>37.04</td><td>0.143</td><td>0.175</td><td>62.56</td><td>36.24</td><td>0.125</td><td>0.184</td><td>82.71</td><td>28.40</td><td>0.103</td><td>0.120</td><td>45.10</td><td>24.12</td><td>0.329</td><td>0.576</td></tr><tr><td>LaMa</td><td>115.92</td><td>107.69</td><td>0.034</td><td>0.082</td><td>125.77</td><td>136.32</td><td>0.002</td><td>0.006</td><td>129.77</td><td>35.23</td><td>0.018</td><td>0.043</td><td>45.25</td><td>24.21</td><td>0.429</td><td>0.701</td></tr><tr><td>TFill</td><td>83.84</td><td>61.40</td><td>0.075</td><td>0.086</td><td>93.62</td><td>76.13</td><td>0.037</td><td>0.027</td><td>97.99</td><td>43.40</td><td>0.046</td><td>0.052</td><td>46.84</td><td>30.72</td><td>0.368</td><td>0.574</td></tr><tr><td>Inpainting Anything</td><td>97.38</td><td>54.73</td><td>0.076</td><td>0.133</td><td>105.77</td><td>59.70</td><td>0.054</td><td>0.035</td><td>92.18</td><td>32.00</td><td>0.116</td><td>0.085</td><td>46.30</td><td>26.71</td><td>0.372</td><td>0.632</td></tr><tr><td>RePaint</td><td>82.84</td><td>84.39</td><td>0.096</td><td>0.105</td><td>95.38</td><td>82.35</td><td>0.0639</td><td>0.078</td><td>69.14</td><td>31.63</td><td>0.294</td><td>0.263</td><td>55.47</td><td>38.78</td><td>0.433</td><td>0.581</td></tr><tr><td>PanoDiffusion</td><td>21.55</td><td>26.95</td><td>0.867</td><td>0.708</td><td>21.41</td><td>27.80</td><td>0.790</td><td>0.669</td><td>23.06</td><td>22.39</td><td>1.000</td><td>0.737</td><td>16.13</td><td>20.39</td><td>1.000</td><td>0.883</td></tr></table>
182
+
183
+ Baseline Models. For RGB panorama outpainting, we mainly compared with the following state-of-the-art methods: including image inpainting models LaMa (Suvorov et al., 2022) $_{\mathrm{WACV}^{\prime}2022}$ and TFill (Zheng et al., 2022) $_{\mathrm{CVPR}^{\prime}2022}$ , panorama outpainting models BIPS (Oh et al., 2022) $_{\mathrm{ECCV}^{\prime}2022}$ and OmniDreamer (Akimoto et al., 2022) $_{\mathrm{CVPR}^{\prime}2022}$ , diffusion-based image inpainting models Repaint (Lugmayr et al., 2022) $_{\mathrm{CVPR}^{\prime}2022}$ and Inpaint Anything (Yu et al., 2023) $_{\mathrm{arXiv}^{\prime}2023}$ . To evaluate the quality of depth panorama, we compare our method with three image-guided depth synthesis methods including BIPS (Oh et al., 2022), NLSPN (Park et al., 2020), and CSPN (Cheng et al., 2018). All models are retrained on the Structured3D dataset using their publicly available codes.
184
+
185
+ # 4.2 MAIN RESULTS
186
+
187
+ Following prior works, we report the quantitative results for RGB panorama outpainting with camera masks in Table 1. All instantiations of our model significantly outperform all state-of-the-art models. Specifically, the FID score is substantially better (relative $67.0\%$ improvement).
188
+
189
+ It is imperative to note that our model is trained unconditionally, with masks only employed during the inference phase. Therefore, it is expected to handle a broader spectrum of mask types. To validate this assertion, we further evaluated our model with the baseline models across all four different mask types (displayed in Fig. 5). The results in Table 1 show that PanoDiffusion consistently outperforms the baseline models on all types of masks. Conversely, baseline models' performance displays significant variability in the type of mask used. Although the visible regions of the layout masks are always larger than the camera masks, the performances of baseline models on camera masks are significantly better. This is likely because the masks in the training process are closer to the NFoV distribution. In contrast, PanoDiffusion has a more robust performance, producing high-quality and diverse output images for all mask distributions.
190
+
191
+ The qualitative results are visualized in Fig. 6. Here we show an example of outpainting on a layout mask (more comparisons in Appendix). Besides the fact that PanoDiffusion generates more visually realistic results than baseline models, comparing the RGB (trained without depth) and RGB-D versions of our PanoDiffusion, in Fig. 6(c), some unrealistic structures are generated on the center
192
+
193
+ ![](images/14709b0af64d810ed8340a0f5e7e30451f1c8520c6d703e65d44d99d1469fe0f.jpg)
194
+ (a) RGB Input
195
+
196
+ ![](images/5f41db801577e0d75ac7395edee5707d1b0bab0f1f102327fd33ea1985dd8054.jpg)
197
+ (b) Depth GT
198
+
199
+ ![](images/572b7786aa7d2ec7881b06a5c45b702e9ca620607e076758c4a95214b1840bef.jpg)
200
+ (c) Ours PanoDiffusion
201
+
202
+ ![](images/e133b713638816a24342fc81ee2d1f63416260785896c0a33764da5ac9ddfe50.jpg)
203
+ (d)CSPN
204
+ Figure 7: Qualitative comparison for depth panorama synthesis.
205
+
206
+ ![](images/cf72182bea15d5ee2ad62dc4cf0f654111a6ae37fcb474673e7a42ff74b14158.jpg)
207
+ (e) BIPS
208
+
209
+ ![](images/d31d293b40c51925b77387ec053b5490e9bc1aef7b9b8bce4bed3fc4e1ee9863.jpg)
210
+ (f) NLSPN
211
+
212
+ Table 2: Depth map ablations. All models are trained and evaluated on the Structured3D dataset.
213
+
214
+ <table><tr><td rowspan="2">Noise Level</td><td colspan="4">Camera Mask</td><td colspan="4">NFoV Mask</td><td colspan="4">Layout Mask</td><td colspan="4">Random Box Mask</td></tr><tr><td>FID ↓</td><td>sFID ↓</td><td>D ↑</td><td>C ↑</td><td>FID ↓</td><td>sFID ↓</td><td>D ↑</td><td>C ↑</td><td>FID ↓</td><td>sFID ↓</td><td>D ↑</td><td>C ↑</td><td>FID ↓</td><td>sFID ↓</td><td>D ↑</td><td>C ↑</td></tr><tr><td>no depth</td><td>24.33</td><td>29.00</td><td>0.667</td><td>0.635</td><td>24.01</td><td>30.00</td><td>0.639</td><td>0.617</td><td>25.37</td><td>22.92</td><td>0.785</td><td>0.677</td><td>17.88</td><td>21.21</td><td>0.913</td><td>0.857</td></tr><tr><td>50%</td><td>21.65</td><td>28.12</td><td>0.678</td><td>0.660</td><td>21.99</td><td>29.37</td><td>0.678</td><td>0.561</td><td>24.24</td><td>23.05</td><td>0.855</td><td>0.724</td><td>17.02</td><td>21.22</td><td>0.919</td><td>0.837</td></tr><tr><td>30%</td><td>21.78</td><td>27.96</td><td>0.714</td><td>0.674</td><td>21.78</td><td>29.39</td><td>0.643</td><td>0.658</td><td>24.11</td><td>23.00</td><td>0.919</td><td>0.724</td><td>16.87</td><td>21.25</td><td>0.937</td><td>0.855</td></tr><tr><td>10%</td><td>21.68</td><td>27.79</td><td>0.721</td><td>0.658</td><td>21.49</td><td>29.74</td><td>0.558</td><td>0.620</td><td>24.02</td><td>22.68</td><td>0.938</td><td>0.741</td><td>16.60</td><td>21.02</td><td>0.932</td><td>0.853</td></tr><tr><td>full depth</td><td>21.55</td><td>26.95</td><td>0.867</td><td>0.708</td><td>21.41</td><td>27.80</td><td>0.790</td><td>0.669</td><td>23.06</td><td>22.39</td><td>1.000</td><td>0.737</td><td>16.13</td><td>20.39</td><td>1.000</td><td>0.883</td></tr></table>
215
+
216
+ (a) Usage of depth maps (training). We use different sparsity levels of depth for training and the results (more intense color means better performance) verify the effectiveness of depth for RGB outpainting. It also proves that the model can accept sparse depth as input.
217
+
218
+ <table><tr><td>Methods</td><td>Input Depth</td><td>FID ↓</td><td>sFID ↓</td><td>D ↑</td><td>C ↑</td></tr><tr><td>BIPS</td><td rowspan="2">fully visible</td><td>29.74</td><td>30.59</td><td>0.931</td><td>0.721</td></tr><tr><td>PanoDiffusion</td><td>21.90</td><td>26.78</td><td>0.829</td><td>0.693</td></tr><tr><td>BIPS</td><td rowspan="2">partial visible</td><td>31.70</td><td>28.89</td><td>0.769</td><td>0.660</td></tr><tr><td>PanoDiffusion</td><td>22.34</td><td>26.74</td><td>0.856</td><td>0.686</td></tr><tr><td>BIPS</td><td rowspan="2">fully masked</td><td>68.79</td><td>42.62</td><td>0.306</td><td>0.412</td></tr><tr><td>PanoDiffusion</td><td>21.55</td><td>26.95</td><td>0.867</td><td>0.708</td></tr></table>
219
+
220
+ (b) Usage of depth maps (inference). BIPS heavily relies on the availability of input depth during inference, while our model is minimally affected.
221
+
222
+ <table><tr><td>Methods</td><td>Input Depth</td><td>RMSE↓</td><td>MAE↓</td><td>AbsREL↓</td><td>Delta1.25 ↑</td></tr><tr><td>BIPS</td><td></td><td>323</td><td>207</td><td>0.1842</td><td>0.8436</td></tr><tr><td>CSPN</td><td></td><td>374</td><td>282</td><td>0.2273</td><td>0.6618</td></tr><tr><td>NLSPN</td><td>fully masked</td><td>284</td><td>183</td><td>0.1692</td><td>0.8544</td></tr><tr><td>PanoDiffusion</td><td></td><td>276</td><td>193</td><td>0.1355</td><td>0.9060</td></tr><tr><td>BIPS</td><td></td><td>247</td><td>136</td><td>0.1098</td><td>0.9032</td></tr><tr><td>CSPN</td><td></td><td>291</td><td>195</td><td>0.1547</td><td>0.8182</td></tr><tr><td>NLSPN</td><td>partial visible</td><td>221</td><td>124</td><td>0.1058</td><td>0.9143</td></tr><tr><td>PanoDiffusion</td><td></td><td>219</td><td>123</td><td>0.1127</td><td>0.9278</td></tr></table>
223
+
224
+ (c) Depth panorama synthesis. Our model outperforms baseline models in most of the metrics.
225
+
226
+ wall, and when we look closely at the curtains generated by the RGB model, the physical structure of the edges is not quite real. In contrast, the same region of RGB-D result (Fig. 6(d)) appears more structurally appropriate. Such improvement proves the advantages of jointly learning to synthesize depth data along with RGB images, even when depth is not used during test time, suggesting the depth information is significant for assisting the RGB completion.
227
+
228
+ # 4.3 ABLATION EXPERIMENTS
229
+
230
+ We ran a number of ablations to analyze the effectiveness of each core component in our PanoDiffusion. Results are shown in tables 2 and 3 and figs. 7 and 8 and discussed in detail next.
231
+
232
+ Depth Maps. In practice applications, depth data may exhibit sparsity due to the hardware limitations (Park et al., 2020). To ascertain the model's proficiency in accommodating sparse depth maps as input, we undertook a training process using depth maps with different degrees of sparsity (i.e., randomized depth value will be set to 0). The result is reported in Table 2(a). The denser colors in the table represent better performance. As the sparsity of the depth input decreases, the performance of RGB outpainting constantly improves. Even if we use $50\%$ sparse depth for training, the result is overall better than the original LDM.
233
+
234
+ We then evaluated the importance of depth maps during inference, and compared it with the state-of-the-art BIPS (Oh et al., 2022), which is also trained with RGB-D images. The quantitative results are reported in Table 2(b). As can be seen, BIPS's performance appears to deteriorate significantly when
235
+
236
+ ![](images/fd7b5c6c436682b3382e9d9431f753bfa240b36ec165b18f85840a6dbde82b62.jpg)
237
+ (a) PanoDiffusion w/ TA
238
+ Figure 8: Examples of stitched ends of the outpainted images. For each image, the left half was unmasked (i.e. ground truth), while the right half was masked and synthesized. The results generated with rotation are more naturally connected at both ends (a).
239
+
240
+ ![](images/0a8658004b3eb8b8ab8bdf2ffe1d618907fb8809694b750a77d55eea1ff77841.jpg)
241
+
242
+ ![](images/dc3f55d49d01c0c66470a1e077badf957425534ef5b1eb8c1febd011883209b8.jpg)
243
+ (b) PanoDiffusion w/o TA
244
+
245
+ ![](images/d019adab394bbd818a1a3307a91d3a5ffd677ac24e921ac90a636ed3c74ac9cd.jpg)
246
+
247
+ ![](images/36cf979fc504751d3ef8f1e5b05224f3ecc6aa3bb0a8e27cf36d049511b931b9.jpg)
248
+
249
+ ![](images/09d4efce21595e58a1834a26e613b371eba98f8d982be4d9388149deb4a1a708.jpg)
250
+ (c) OmniDreamer
251
+
252
+ ![](images/238f456e523abb4c68ff0ce7e881da4c8216a61d61a461c4c4e668b8356e8898.jpg)
253
+
254
+ ![](images/7c87b8b57830e2fdb27d2b7d8e7e9ea4ec80eb39b7a50bee651421dcac5ef16b.jpg)
255
+
256
+ ![](images/fff1fd5d9ecb9d489f06c2b391e1d9efb347aacc14a65b1623426880872679d0.jpg)
257
+ (d) BIPS
258
+
259
+ ![](images/6c6c138936b3e075940157397fad4b71d042c9018c2e5d3fec38d74a40c701bb.jpg)
260
+
261
+ ![](images/5bafc56aee8d5e33ea390deffbce3cb2b1d9860116a55ef0d51182c6872f2371.jpg)
262
+
263
+ Table 3: Two-end alignment ablations. Using rotational outpainting, we achieve optimal consistency at both ends of the PanoDiffusion output.
264
+
265
+ <table><tr><td>Methods\Mask Type</td><td>Camera</td><td>NfoV</td><td>Layout</td><td>Random Box</td><td>Methods\Mask Type</td><td>Camera</td><td>NfoV</td><td>Layout</td><td>Random Box</td></tr><tr><td>PanoDiffusion (w/ rotation)</td><td>90.41</td><td>89.74</td><td>88.01</td><td>85.04</td><td>PanoDiffusion (w/o rotation)</td><td>125.82</td><td>128.33</td><td>128.10</td><td>128.19</td></tr><tr><td>BIPS</td><td>117.59</td><td>96.82</td><td>132.15</td><td>148.78</td><td>OmniDreamer</td><td>115.6</td><td>109.00</td><td>146.37</td><td>136.68</td></tr><tr><td>LaMa</td><td>119.51</td><td>119.39</td><td>133.54</td><td>136.35</td><td>TFill</td><td>155.16</td><td>157.60</td><td>136.94</td><td>122.96</td></tr></table>
266
+
267
+ the input depth visual area is reduced. Conversely, our PanoDiffusion is not sensitive to these depth maps, indicating that the generic model has successfully handled the modality. Interestingly, we noticed that having fully visible depth at test time did not improve the performance of PanoDiffusion, and in fact, the result deteriorated slightly. A reasonable explanation is that during the training process, the signal-to-noise ratios (SNR) of RGB and depth pixels are roughly the same within each iteration since no masks were used. However, during outpainting, the SNR balance will be disrupted when RGB input is masked and depth input is fully visible. Therefore, the results are degraded, but only slightly because PanoDiffusion has effectively learned the distribution of spatial visual patterns across all modalities, without being overly reliant on depth. This also explains why our model is more robust to depth inputs with different degrees of visibility.
268
+
269
+ Finally, we evaluated the depth synthesis ability of PanoDiffusion, seen in Table 2(c) and Fig. 7. The results show that our model achieves the best performance on most of the metrics and the qualitative results also show that PanoDiffusion is able to accurately estimate the depth map. This not only indicates that PanoDiffusion can be used for depth synthesis and estimation but also proves that it has learned the spatial patterns of panorama images.
270
+
271
+ Two-end Alignment. Currently, there is no metric to evaluate the performance of aligning the two ends of an image. To make a reasonable comparison, we make one side of the input image fully visible, and the other side fully masked and then compare the two ends of output. Based on the Left-Right Consistency Error (LRCE) (Shen et al., 2022) which is used to evaluate the consistency of two ends of the depth maps, we designed a new RGB-LRCE to calculate the difference between the two ends of the image: $LRCE = \frac{1}{N}\sum_{i=1}^{N}|P_{first}^{col} - P_{last}^{col}|$ , and reported results in table 3.
272
+
273
+ The qualitative results are shown in fig. 8. To compare as many results, we only show the end regions that are stitched together to highlight the contrast. They show that the consistency of the two ends of the results is improved after the use of rotational outpainting, especially the texture of the walls and the alignment of the layout. Still, differences can be found with rotated outpainting. We believe it is mainly due to the fact that rotational denoising is based on the latent level, which may introduce extra errors during decoding.
274
+
275
+ # 5 CONCLUSION
276
+
277
+ In this paper, we show that our proposed method, the two-stage RGB-D PanoDiffusion, achieves state-of-the-art performance for indoor RGB-D panorama outpainting. The introduction of depth information via our bi-modal LDM structure significantly improves the performance of the model. Such improvement illustrates the effectiveness of using depth during training as an aid to guide RGB panorama generation. In addition, we show that the alignment mechanism we employ at each step of the denoising process of the diffusion model enhances the wraparound consistency of the results. With the use of these novel mechanisms, our two-stage structure is capable of generating high-quality RGB-D panoramas at $512 \times 1024$ resolution.
278
+
279
+ # ACKNOWLEDGEMENT
280
+
281
+ This study is supported under the RIE2020 Industry Alignment Fund - Industry Collaboration Projects (IAF-ICP) Funding Initiative, as well as cash and in-kind contribution from the industry partner(s).
282
+
283
+ # REFERENCES
284
+
285
+ Naofumi Akimoto, Seito Kasai, Masaki Hayashi, and Yoshimitsu Aoki. 360-degree image completion by two-stage conditional gans. In 2019 IEEE International Conference on Image Processing (ICIP), pp. 4704-4708. IEEE, 2019.
286
+ Naofumi Akimoto, Yuhi Matsuo, and Yoshimitsu Aoki. Diverse plausible 360-degree image outpainting for efficient 3dcbg background creation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11441-11450, 2022.
287
+ Xinjing Cheng, Peng Wang, and Ruigang Yang. Depth estimation via affinity learned with convolutional spatial propagation network. In Proceedings of the European conference on computer vision (ECCV), pp. 103-119, 2018.
288
+ Sungjoon Choi, Qian-Yi Zhou, and Vladlen Koltun. Robust reconstruction of indoor scenes. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5556-5565, 2015.
289
+ Dave Epstein, Taesung Park, Richard Zhang, Eli Shechtman, and Alexei A Efros. Blobgan: Spatially disentangled scene representations. In Computer Vision-ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23-27, 2022, Proceedings, Part XV, pp. 616-635. Springer, 2022.
290
+ Marc-Andre Gardner, Kalyan Sunkavalli, Ersin Yumer, Xiaohui Shen, Emiliano Gambaretto, Christian Gagné, and Jean-François Lalonde. Learning to predict indoor illumination from a single image. ACM Transactions on Graphics (TOG), 36(6):1-14, 2017.
291
+ Marc-Andre Gardner, Yannick Hold-Geoffroy, Kalyan Sunkavalli, Christian Gagne, and Jean-François Lalonde. Deep parametric indoor lighting estimation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 7175-7183, 2019.
292
+ Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in neural information processing systems, 27, 2014.
293
+ Takayuki Hara, Yusuke Mukuta, and Tatsuya Harada. Spherical image generation from a single image by considering scene symmetry. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 1513-1521, 2021.
294
+ Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30, 2017.
295
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840-6851, 2020.
296
+ Daichi Horita, Jiaolong Yang, Dong Chen, Yuki Koyama, and Kiyoharu Aizawa. A structure-guided diffusion model for large-hole diverse image completion. arXiv preprint arXiv:2211.10437, 2022.
297
+ Satoshi Iizuka, Edgar Simo-Serra, and Hiroshi Ishikawa. Globally and locally consistent image completion. ACM Transactions on Graphics (ToG), 36(4):1-14, 2017.
298
+ Diederik P Kingma and Max Welling. Auto-encoding variational bayes. In editor (ed.), Proceedings of the International Conference on Learning Representations (ICLR), 2014.
299
+ Jeong-Kyun Lee, Jaewon Yea, Min-Gyu Park, and Kuk-Jin Yoon. Joint layout estimation and global multi-view registration for indoor reconstruction. In Proceedings of the IEEE international conference on computer vision, pp. 162-171, 2017.
300
+
301
+ Wenbo Li, Xin Yu, Kun Zhou, Yibing Song, Zhe Lin, and Jiaya Jia. Sdm: Spatial diffusion model for large hole image inpainting. arXiv preprint arXiv:2212.02963, 2022.
302
+ Zhuqiang Lu, Kun Hu, Chaoyue Wang, Lei Bai, and Zhiyong Wang. Autoregressive omni-aware outpainting for open-vocabulary 360-degree image generation. arXiv preprint arXiv:2309.03467, 2023.
303
+ Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, and Luc Van Gool. Repaint: Inpainting using denoising diffusion probabilistic models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11461-11471, 2022.
304
+ Muhammad Ferjad Naeem, Seong Joon Oh, Youngjung Uh, Yunjoy Choi, and Jaejun Yoo. Reliable fidelity and diversity metrics for generative models. In International Conference on Machine Learning, pp. 7176-7185. PMLR, 2020.
305
+ Charlie Nash, Jacob Menick, Sander Dieleman, and Peter W Battaglia. Generating images with sparse representations. arXiv preprint arXiv:2103.03841, 2021.
306
+ Richard A Newcombe, Shahram Izadi, Otmar Hilliges, David Molyneaux, David Kim, Andrew J Davison, Pushmeet Kohi, Jamie Shotton, Steve Hodges, and Andrew Fitzgibbon. Kinectfusion: Real-time dense surface mapping and tracking. In 2011 10th IEEE international symposium on mixed and augmented reality, pp. 127-136. IEEE, 2011.
307
+ Changgyoon Oh, Wonjune Cho, Yujeong Chae, Daehee Park, Lin Wang, and Kuk-Jin Yoon. Bips: Bi-modal indoor panorama synthesis via residual depth-aided adversarial learning. In Computer Vision-ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23-27, 2022, Proceedings, Part XVI, pp. 352-371. Springer, 2022.
308
+ Jinsun Park, Kyungdon Joo, Zhe Hu, Chi-Kuei Liu, and In So Kweon. Non-local spatial propagation network for depth completion. In Computer Vision-ECCV 2020: 16th European Conference, Glasgow, UK, August 23-28, 2020, Proceedings, Part XIII 16, pp. 120-136. Springer, 2020.
309
+ Deepak Pathak, Philipp Krahenbuhl, Jeff Donahue, Trevor Darrell, and Alexei A Efros. Context encoders: Feature learning by inpainting. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2536-2544, 2016.
310
+ Xiaofeng Ren, Liefeng Bo, and Dieter Fox. Rgb-(d) scene labeling: Features and algorithms. In 2012 IEEE Conference on Computer Vision and Pattern Recognition, pp. 2759-2766. IEEE, 2012.
311
+ Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10684-10695, 2022.
312
+ Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. Advances in neural information processing systems, 29, 2016.
313
+ Zhijie Shen, Chunyu Lin, Kang Liao, Lang Nie, Zishuo Zheng, and Yao Zhao. Panofformer: Panorama transformer for indoor 360-degree depth estimation. In European Conference on Computer Vision, pp. 195-211. Springer, 2022.
314
+ Gowri Somanath and Daniel Kurz. HDR environment map estimation for real-time augmented reality. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11298-11306, 2021.
315
+ Shuran Song and Thomas Funkhouser. Neural illumination: Lighting prediction for indoor environments. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 6918-6926, 2019.
316
+ Roman Suvorov, Elizaveta Logacheva, Anton Mashikhin, Anastasia Remizova, Armenii Ashukha, Aleksei Silvestrov, Naejin Kong, Harshith Goka, Kiwoong Park, and Victor Lempitsky. Resolution-robust large mask inpainting with fourier convolutions. In Proceedings of the IEEE/CVF winter conference on applications of computer vision, pp. 2149-2159, 2022.
317
+
318
+ Shitao Tang, Fuyang Zhang, Jiacheng Chen, Peng Wang, and Yasutaka Furukawa. Mvdiffusion: Enabling holistic multi-view image generation with correspondence-aware diffusion. arXiv preprint arXiv:2307.01097, 2023.
319
+ Ziyu Wan, Jingbo Zhang, Dongdong Chen, and Jing Liao. High-fidelity pluralistic image completion with transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 4692-4701, October 2021.
320
+ Su Wang, Chitwan Sahara, Ceslee Montgomery, Jordi Pont-Tuset, Shai Noy, Stefano Pellegrini, Yasumasa Onoe, Sarah Laszlo, David J Fleet, Radu Soricut, et al. Imagen editor and editbench: Advancing and evaluating text-guided image inpainting. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 18359-18369, 2023.
321
+ Shaoan Xie, Zhifei Zhang, Zhe Lin, Tobias Hinz, and Kun Zhang. Smartbrush: Text and shape guided object inpainting with diffusion model. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 22428-22437, 2023.
322
+ Fisher Yu, Ari Seff, Yinda Zhang, Shuran Song, Thomas Funkhouser, and Jianxiong Xiao. Lsun: Construction of a large-scale image dataset using deep learning with humans in the loop. arXiv preprint arXiv:1506.03365, 2015.
323
+ Jiahui Yu, Zhe Lin, Jimei Yang, Xiaohui Shen, Xin Lu, and Thomas S Huang. Generative image inpainting with contextual attention. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5505-5514, 2018.
324
+ Tao Yu, Runseng Feng, Ruoyu Feng, Jinming Liu, Xin Jin, Wenjun Zeng, and Zhibo Chen. Inpaint anything: Segment anything meets image inpainting. arXiv preprint arXiv:2304.06790, 2023.
325
+ Shengyu Zhao, Jonathan Cui, Yilun Sheng, Yue Dong, Xiao Liang, I Eric, Chao Chang, and Yan Xu. Large scale image completion via co-modulated generative adversarial networks. In International Conference on Learning Representations, 2020.
326
+ Chuanxia Zheng, Tat-Jen Cham, and Jianfei Cai. T2net: Synthetic-to-realistic translation for solving single-image depth estimation tasks. In Proceedings of the European conference on computer vision (ECCV), pp. 767-783, 2018.
327
+ Chuanxia Zheng, Tat-Jen Cham, and Jianfei Cai. Pluralistic image completion. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1438-1447, 2019.
328
+ Chuanxia Zheng, Tat-Jen Cham, and Jianfei Cai. Pluralistic free-form image completion. International Journal of Computer Vision, 129:2786-2805, 2021.
329
+ Chuanxia Zheng, Tat-Jen Cham, Jianfei Cai, and Dinh Phung. Bridging global context interactions for high-fidelity image completion. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11512-11522, 2022.
330
+ Jia Zheng, Junfei Zhang, Jing Li, Rui Tang, Shenghua Gao, and Zihan Zhou. Structured3d: A large photo-realistic dataset for structured 3d modeling. In Computer Vision-ECCV 2020: 16th European Conference, Glasgow, UK, August 23-28, 2020, Proceedings, Part IX 16, pp. 519-535. Springer, 2020.
331
+
332
+ # APPENDIX
333
+
334
+ The supplementary materials are organized as follows:
335
+
336
+ 1. A video is added to illuminate the work with more results.
337
+ 2. The reproducible code is included.
338
+ 3. An additional PDF for implementation, training, metrics details, as well as more quantitative and qualitative results.
339
+
340
+ # IMPLEMENT DETAILS
341
+
342
+ # TRAINING OF VQ MODELS FOR RGB AND DEPTH PANorama
343
+
344
+ The reason why LDMs (Rombach et al., 2022) can be trained on larger image scales is that perceptual image compression is used so that the diffusion process can be conducted in latent space, with the decoder $\mathcal{D}$ used for returning the latent vector $z\in \mathbb{R}^{h\times w\times c}$ to high-resolution image $x\in \mathbb{R}^{H\times W\times C}$ . During this process, the inherent spatial structure of the image does not change but is downscaled. Such spatial constancy is critical for our work as the partially visible regions will not be changed during outpainting, shown in Fig. 9.
345
+
346
+ ![](images/ec208bf7a5c2d07abc3b81aad8fb7dda7a1f0f702668b1046ac1dd237718f388.jpg)
347
+ (a) Masked Image
348
+
349
+ ![](images/d0d51dde3aa7f4a1e7480ea65c02ae105f39ad581617a57320ea842efe28c625.jpg)
350
+ Figure 9: Masking at different levels. (a)(c) are pixel-level masked images, while (b)(d) are corresponding latent-level masked images. They are aligned well, except for the different mask values.
351
+
352
+ ![](images/cee9bdb482eb09071a9d12f09bed18d6da60a89d6f7c6498da2c689e1450925c.jpg)
353
+ (b) Masked Latent Image
354
+ (c) Masked Image
355
+
356
+ ![](images/34f5079068db788c2d4a2406bcdba93b5662a9c39e89f45499516bbaea55a13a.jpg)
357
+ (d) Masked Latent Image
358
+
359
+ Two VQ models, $VQ_{rgb}$ and $VQ_{depth}$ with downsampling factor $f = 4$ are trained using RGB and depth data respectively. The output channel numbers of $VQ_{rgb}$ and $VQ_{depth}$ are set to 3 and 1. For the training of $VQ_{rgb}$ , we finetuned on the pre-trained VQ-f4 model provided by Rombach et al. (Rombach et al., 2022). Due to the lack of a pre-trained model, $VQ_{depth}$ is trained from scratch. Both $VQ_{rgb}$ and $VQ_{depth}$ are trained for 30 epochs and we select the models that perform best on the validation data for the training of bi-modal LDM. Throughout the process, the datasets used during training, validation, and testing are exactly matched for $VQ_{rgb}$ and $VQ_{depth}$ .
360
+
361
+ # TRAINING OF LATENT DIFFUSION MODEL
362
+
363
+ The training of PanoDiffusion initially loaded the LSUN-Bedrooms (Yu et al., 2015) pre-trained model provided by official LDM (Rombach et al., 2022). Despite the fact that the LSUN-Bedrooms images are in normal view, where the objects and the layout are not subjected to equirectangular projection, we believe that it can provide useful priori knowledge of item semantics, texture, etc. for the outpainting of the indoor panoramas. At the same time, pre-trained $VQ_{rgb}$ and $VQ_{depth}$ are loaded and fixed during the training of our bi-modal LDM.
364
+
365
+ # CAMERA-ROTATION DIRECTION
366
+
367
+ During the training stage, we restrict random angle rotation solely to the horizontal direction. As panorama images typically follow equirectangular projection, the distortion increases non-uniformly towards the top and bottom poles. Introducing random angle rotation in the vertical direction would lead to substantial changes in the projection results, and require more complex preprocessing, which will increase training costs. Conversely, distortion is uniform horizontally - image manipulation here only involves horizontal cropping and splicing, without the need for reprojection.
368
+
369
+ Here we show two examples where the camera has a 90-degree vertical rotation as Fig 10.
370
+
371
+ ![](images/b94e5cbfa67b1a343055d038940c95859a56b8165a5175298d4f1f35b0599718.jpg)
372
+ Horizontal Rotation
373
+
374
+ ![](images/6f352a07385d11764ad4be1a5c3d9f0315e08dd5b5fdacc33a81dce5f955a28f.jpg)
375
+ Original View
376
+ Figure 10: Examples of vertical and horizontal camera rotation. No matter how many degrees the panorama is rotated horizontally, the distortion of each component remains unchanged. However, when the panorama is rotated vertically, even by a small angle, the distortion of the entire scene changes significantly, which can be a hindrance for PanoDiffusion to learn.
377
+
378
+ ![](images/5df3e19324ce6dc81e9a895a95b89fa01d93300da09d029b51d00317a2aaab2c.jpg)
379
+ Vertical Rotation
380
+
381
+ # REFINENET IMPLEMENTATION
382
+
383
+ For the second stage of our structure, to generate visually plausible $512 \times 1024$ results, we trained a GAN for super-resolution. It consists of a generator G and a discriminator D. For training G, we use a weighted sum of the pixel-wise L1 loss and adversarial loss. The pixel-wise L1 loss is denoted as $L_{pixel}$ , measuring the difference between the GT and the output panorama.
384
+
385
+ $$
386
+ L _ {\text {p i x e l}} = L _ {1} \left(g t, G \left(g t _ {l r}\right)\right), \tag {7}
387
+ $$
388
+
389
+ $$
390
+ L _ {a d v} = \frac {1}{2} \mathbb {E} \left[ \left(D \left(G \left(g t _ {l r}\right) - 1\right) ^ {2} \right], \right. \tag {8}
391
+ $$
392
+
393
+ $$
394
+ L _ {G} = \lambda L _ {\text {p i x e l}} + L _ {\text {a d v}}. \tag {9}
395
+ $$
396
+
397
+ The training data is randomly downscaled from $512 \times 1024$ GT images to $128 \times 256$ or $256 \times 512$ and upscaled back to $512 \times 1024$ using the traditional interpolation method, which will erase details from GT images. Then they are used as the input of our super-resolution GAN, denoted as $gt_{lr}$ . Here the value of $\lambda$ is set to 20 during the training.
398
+
399
+ # QUANTITIVE METRICS
400
+
401
+ In this section, we will describe how the quantitative metrics used in this paper are implemented.
402
+
403
+ Fréchet inception distance (FID) FID (Heusel et al., 2017) is used to capture the similarity of generated images to real ones. We used the official PyTorch implementation of FID to evaluate the similarity between the final average pooling features of GT images and model outputs.
404
+
405
+ Spatial FID (sFID) Spatial FID (Nash et al., 2021) is a variant of FID, using spatial features rather than the standard pooled features. As standard pool_3 features compress spatial information to a large extent, making it less sensitive to spatial variability, mixed 6/conv features can provide a sense of spatial distributional similarity between models. sFID is calculated using the first 7 channels from the intermediate mixed 6/conv feature maps in order to obtain a feature space of size $7 \times 17 \times 17 = 2023$ , which is comparable to the final average pooling features of size 2048.
406
+
407
+ Density and Coverage Density and coverage metrics are proposed by Naeem et al. (Naeem et al., 2020), who argue that even the latest version of the precision and recall metrics are still not reliable. Therefore, they proposed density and coverage, which can provide more interpretable and reliable signals. In this paper, we used their official implementation with nearest neighbor $k = 3$ to calculate the density and coverage of the final average pooling features of the GT panoramas and the generated output.
408
+
409
+ Depth Estimation Metrics Given ground truth depth $D_{gt} = \{d_{gt}\}$ and predicted depth $D_{pred} = \{d_{pred}\}$ , we use the following metrics to evaluate the quality of our depth estimates.
410
+
411
+ $$
412
+ R M S E = \sqrt {\frac {1}{| D |} \sum \left\| d _ {g t} - d _ {p r e d} \right\| ^ {2}}, \tag {10}
413
+ $$
414
+
415
+ $$
416
+ M A E = \frac {1}{| D |} \sum \left| d _ {g t} - d _ {p r e d} \right|, \tag {11}
417
+ $$
418
+
419
+ $$
420
+ A b s R E L = \frac {1}{| D |} \sum \frac {\left| d _ {g t} - d _ {p r e d} \right|}{d _ {g t}}, \tag {12}
421
+ $$
422
+
423
+ $$
424
+ D e l t a 1.25 = \% o f d _ {p r e d} i n D _ {p r e d}, s. t. \max \left(\frac {d _ {p r e d}}{d _ {g t}}, \frac {d _ {g t}}{d _ {p r e d}}\right) < 1.25 \tag{13}
425
+ $$
426
+
427
+ # ADDITIONAL RESULTS AND EXAMPLES
428
+
429
+ # QUANTITATIVE COMPARISON FOR DEPTH-CONDITIONED LDM
430
+
431
+ As described in the main paper, to introduce depth information to aid RGB generation, an intuitive idea would be to use depth information as an explicit condition during training and inference. By compressing depth information into latent space $z_{depth}$ , it can be introduced into the denoising process of the RGB images via cross-attention, denoted as depth-conditioned LDM (DC LDM). However, we have found that such an approach often leads to blurry results, as the image examples we have shown in the main paper (more examples are shown in Fig. 11).
432
+
433
+ ![](images/d6bd0680ef6e673dfd06b98aa6b235b843b1c60d69e96862da32cf73e1c8090f.jpg)
434
+ Figure 11: Outpainting with a basic depth-conditioned LDM. This leads to blurry results.
435
+
436
+ Since DC LDM is also trained with RGB-D images, here we report its performance on depth inputs with different degrees of visibility together with BIPS and our RGB-D PanoDiffusion, shown in Table 4.
437
+
438
+ Table 4: Full quantitative results for RGB outpainting with different depth input at test time.
439
+
440
+ <table><tr><td>Methods</td><td>Input Depth</td><td>FID ↓</td><td>sFID ↓</td><td>Density ↑</td><td>Coverage ↑</td></tr><tr><td>BIPS</td><td></td><td>29.74</td><td>30.59</td><td>0.931</td><td>0.721</td></tr><tr><td>DC LDM</td><td>fully visible</td><td>77.75</td><td>44.47</td><td>0.051</td><td>0.086</td></tr><tr><td>RGB-D PanoDiffusion</td><td></td><td>21.90</td><td>26.87</td><td>0.829</td><td>0.693</td></tr><tr><td>BIPS</td><td></td><td>31.70</td><td>28.89</td><td>0.769</td><td>0.660</td></tr><tr><td>DC LDM</td><td>partially visible</td><td>77.77</td><td>44.44</td><td>0.054</td><td>0.080</td></tr><tr><td>RGB-D PanoDiffusion</td><td></td><td>22.34</td><td>26.74</td><td>0.856</td><td>0.686</td></tr><tr><td>BIPS</td><td></td><td>68.79</td><td>42.62</td><td>0.306</td><td>0.412</td></tr><tr><td>DC LDM</td><td>fully masked</td><td>78.15</td><td>44.29</td><td>0.048</td><td>0.073</td></tr><tr><td>RGB-D PanoDiffusion</td><td></td><td>21.55</td><td>26.95</td><td>0.867</td><td>0.708</td></tr></table>
441
+
442
+ The results show that the DC LDM does not perform well in terms of both visual and quantitative results. Even if complete depth information is provided as a condition, the improvement in results is very marginal. This indicates that the conditional LDM structure cannot make good use of depth information to assist RGB panorama outpainting, which proves the effectiveness of our bi-modal LDM structure.
443
+
444
+ # FULL QUANTITATIVE COMPARISON FOR REFINENET
445
+
446
+ As we only show the results of our RefineNet on camera and NFoV mask in the main paper, here we report the full quantitative results on all types of masks with both RGB and RGB-D PanoDiffusion
447
+
448
+ ![](images/e503ddf8d260691e909179292e20a0a5f79b09b40c75072b18af524a47f134c3.jpg)
449
+ (a) Classical Interpolation Output
450
+
451
+ ![](images/a5d9f95281435e2bd9c77000ad473090e68d87b9fc1bd1bdf07057d96d068a56.jpg)
452
+ (b) Super Resolution Output
453
+ Figure 12: Examples of upscaled results using classical interpolation method and out superresolution GAN.
454
+
455
+ (Table 5). A visualized comparison example is shown in Fig. 12. The results show that our superresolution GAN improves the quality of PanoDiffusion output comprehensively, except for a slight degradation of the sFID of RGB PanoDiffusion on the NFoV mask.
456
+
457
+ Table 5: Full quantitative results for RefineNet. (-): classical interpolation. (+): super-resolution.
458
+
459
+ <table><tr><td>Mask Type</td><td>Version</td><td>SR</td><td>FID ↓</td><td>sFID ↓</td><td>Density ↑</td><td>Coverage ↑</td><td>Mask Type</td><td>Version</td><td>SR</td><td>FID ↓</td><td>sFID ↓</td><td>Density ↑</td><td>Coverage ↑</td></tr><tr><td rowspan="4">Camera</td><td rowspan="2">RGB-D</td><td>-</td><td>24.29</td><td>28.05</td><td>0.805</td><td>0.663</td><td rowspan="4">Layout</td><td rowspan="2">RGB-D</td><td>-</td><td>26.16</td><td>24.21</td><td>0.920</td><td>0.689</td></tr><tr><td>+</td><td>21.55</td><td>26.95</td><td>0.867</td><td>0.708</td><td>+</td><td>23.06</td><td>22.39</td><td>1.000</td><td>0.737</td></tr><tr><td rowspan="2">RGB</td><td>-</td><td>26.75</td><td>29.89</td><td>0.581</td><td>0.570</td><td rowspan="2">RGB</td><td>-</td><td>28.18</td><td>24.50</td><td>0.751</td><td>0.650</td></tr><tr><td>+</td><td>24.33</td><td>29.00</td><td>0.667</td><td>0.635</td><td>+</td><td>25.37</td><td>22.92</td><td>0.785</td><td>0.677</td></tr><tr><td rowspan="4">NFoV</td><td rowspan="2">RGB-D</td><td>-</td><td>23.96</td><td>28.19</td><td>0.775</td><td>0.645</td><td rowspan="4">Random Box</td><td rowspan="2">RGB-D</td><td>-</td><td>20.05</td><td>22.77</td><td>0.996</td><td>0.836</td></tr><tr><td>+</td><td>21.41</td><td>27.80</td><td>0.790</td><td>0.669</td><td>+</td><td>16.13</td><td>20.39</td><td>1.000</td><td>0.883</td></tr><tr><td rowspan="2">RGB</td><td>-</td><td>26.72</td><td>29.94</td><td>0.648</td><td>0.595</td><td rowspan="2">RGB</td><td>-</td><td>21.77</td><td>23.72</td><td>0.853</td><td>0.800</td></tr><tr><td>+</td><td>24.01</td><td>30.00</td><td>0.639</td><td>0.617</td><td>+</td><td>17.88</td><td>21.21</td><td>0.913</td><td>0.857</td></tr></table>
460
+
461
+ # ABLATION STUDY ON CAMERA-ROTATION ANGLES
462
+
463
+ We additionally explored the effect of different rotation angles, including $180^{\circ}$ , $90^{\circ}$ (chosen for our final result), and $45^{\circ}$ , on the outpainting results, seen as Table 6. The results show that the wrap-around consistency of outpainting results is improved across all settings. Compared to $180^{\circ}$ , $90^{\circ}$ leads to better consistency. However, diminishing the angle further to $45^{\circ}$ did not lead to additional improvements. We believe this is reasonable, as the model is expected to generate coherent content when the two ends are in contact for enough denoising steps. Therefore, smaller rotation angles than $90^{\circ}$ and longer connections do not necessarily lead to more consistent results.
464
+
465
+ Table 6: Camera-rotation angles ablations.
466
+
467
+ <table><tr><td>Methods \ Mask Type</td><td>Camera</td><td>NfoV</td><td>Layout</td><td>Random Box</td><td>End</td></tr><tr><td>PanoDiffusion(w/o rotation)</td><td>125.82</td><td>128.33</td><td>128.10</td><td>128.19</td><td>132.69</td></tr><tr><td>PanoDiffusion(180°)</td><td>95.11</td><td>96.57</td><td>90.93</td><td>85.23</td><td>119.60</td></tr><tr><td>PanoDiffusion(90°)</td><td>90.41</td><td>89.74</td><td>88.01</td><td>85.04</td><td>116.77</td></tr><tr><td>PanoDiffusion(45°)</td><td>90.67</td><td>90.25</td><td>87.65</td><td>86.50</td><td>112.47</td></tr></table>
468
+
469
+ # ADDITIONAL VISUALIZATION EXAMPLES OF RGB PANorama OUTPAINTING
470
+
471
+ Due to page limitations, we only provide one group of comparative results for RGB outpainting in the main paper. Here we will provide more visualization examples, shown in Fig. 13. Same as in the main paper, we compare PanoDiffusion with LaMa (Suvorov et al., 2022), TFill (Zheng et al., 2022), OmniDreamer (Akimoto et al., 2022), BIPS (Oh et al., 2022), Repaint (Lugmayr et al., 2022), and Inpaint Anything (Yu et al., 2023) on different types of masks. It can be seen that our method outperforms the baseline models by generating various objects with appropriate layout, and with better visual quality. Besides, to prove that our PanoDiffusion can perform diverse and plausible completions on a given input, we provide two different outpainting results for each example.
472
+
473
+ # ADDITIONAL VISUALIZATION EXAMPLES OF DEPTH PANorama SYNTHESIS
474
+
475
+ Due to page limitations, we only provide one group of comparative results for Depth synthesis in the main paper. Here we will provide more visualization examples, shown in Fig. 14. Same as in the main paper, we compare PanoDiffusion with BIPS (Oh et al., 2022), NLSPN (Park et al., 2020), and CSPN (Cheng et al., 2018). It can be seen that our method outperforms the baseline models by accurately estimating the depth map.
476
+
477
+ <table><tr><td>GT RGB
478
+ Image</td><td></td><td></td><td></td><td></td></tr><tr><td>Masked RGB
479
+ Image (Input)</td><td></td><td></td><td></td><td></td></tr><tr><td>Ours 1</td><td></td><td></td><td></td><td></td></tr><tr><td>Ours 2</td><td></td><td></td><td></td><td></td></tr><tr><td>LaMa</td><td></td><td></td><td></td><td></td></tr><tr><td>TFill</td><td></td><td></td><td></td><td></td></tr><tr><td>BIPS</td><td></td><td></td><td></td><td></td></tr><tr><td>OmniDreamer</td><td></td><td></td><td></td><td></td></tr><tr><td>Inpaint
480
+ Anything</td><td></td><td></td><td></td><td></td></tr><tr><td>RePaint</td><td></td><td></td><td></td><td></td></tr></table>
481
+
482
+ ![](images/2840a1554abda81a3d9205a17d59c0d1fca43de961ff7b59748131d79650ff2c.jpg)
483
+ Figure 13: Additional qualitative comparisons for RGB panorama outpainting. Our PanoDiffusion generated more objects with appropriate layout, and with better visual quality. Please zoom in to see the details.
484
+
485
+ # QUALITATIVE RESULTS OF ZERO-SHOT TEST ON MATTERPORT3D DATASET.
486
+
487
+ To test the generalization capability of PanoDiffusion, we conducted additional tests using a set of panorama images from the Matterport3D dataset. Here we provide six groups of examples from the outpainting results, which show that our model can have a decent outpainting effect on the real panorama dataset as well.
488
+
489
+ ![](images/efefceb307027b366cf51c388d72f84888ea60fe497b43e23fe3d68c9a359f08.jpg)
490
+ Figure 14: Additional qualitative comparisons for Depth panorama synthesis. Our PanoDiffusion achieves most accurate estimation. Please zoom in to see the details.
491
+
492
+ ![](images/768e90f6b24c34bfdfff3834cb63bfc84b7064700d6153f30571a78387b26303.jpg)
493
+ Figure 15: Results of zero-shot test on Matterport3D dataset. Zoom in to see the details.
494
+
495
+ # QUALITATIVE RESULTS OF DISCRETE MASK ABLATION.
496
+
497
+ To explicitly assess our model's performance with discrete masks, we flipped the camera mask - swapping the originally visible and invisible parts to simulate this situation. This type of mask is equivalent to randomly sampling several NFoV masks and making them invisible. Here we provide examples from the outpainting results as Fig 16.
498
+
499
+ ![](images/ec136098e8c4251913c1b186ca701f50407ca50c72fa09effee5e65deed922ff.jpg)
500
+
501
+ ![](images/d7254617b004ec41b8fcff91f6be91d5ec5e3675c3911e922eb10ca82ec52e0b.jpg)
502
+
503
+ ![](images/52b9e581e637a8829f165c0023ed0ae0f2089532dde4ad957d9cdadea632dcf2.jpg)
504
+
505
+ ![](images/5f36adbf1805f1de793914a90f33a77f50edb6f7c69ea1c29238348d96e83943.jpg)
506
+
507
+ ![](images/6d108e09d0bb2ed8cb2b2ab74b004d4faa98eb1e256d957168991f238a8f47cd.jpg)
508
+ Figure 16: Outpainting Results on discrete masks.
509
+
510
+ ![](images/aa8778cab5ccbdf60b653ceb6b93666c229e2f3ece8003f1bd5ee0ea579f36fc.jpg)
511
+
512
+ ![](images/cbaec71d48665587b3364167b7076640c107ee442f490a5cb69d26c51784f289.jpg)
513
+
514
+ ![](images/d56a18fdb3e53540345501bf29e80be2e0f8c3b407c19bcfd214bf5debc04db8.jpg)
515
+
516
+ ![](images/9b535cfc1623cd83e221dc964b803c0e015e0c6e26e3b92e83793c2ca82c9262.jpg)
517
+
518
+ ![](images/d1fbce5f02c3cafa0b7d25cc8d27a67f83252ebc67aa03d5916c4205ee8b4a1d.jpg)
519
+
520
+ ![](images/6c0133bb1f034d878d59b4ee0c194f75b63db5052ba282a7d77907f3254e2413.jpg)
521
+
522
+ ![](images/7adc87892550d18a9c52f1bb5e128a0d4549edd3dc565b224a49a6b056e10e1a.jpg)
523
+
524
+ ![](images/ba83527f517012e57a578422f288522d0345dd7c037cc54867cc0530d4794c3b.jpg)
525
+
526
+ ![](images/694dab00b75adf1943ccaa848d4a7b2edd7441c987fb95b787f9ab7044982e93.jpg)
527
+
528
+ ![](images/a1d18d402539b48c7019545c0d8bbc0735829bfb96c7465ca3ea5e804a2672d4.jpg)
529
+
530
+ ![](images/6b05cfe6e4d99fd8205e441d57cf1ddf7784a77af0aefdb0f5f2d521d63346c6.jpg)
531
+
532
+ ![](images/322c660c1219055ad5c7f05c62f4a325520f198647fbd01428e56ee53d4492bc.jpg)
533
+
534
+ ![](images/17188fac6c290f2c71788cdce0d2f2adc6b53ffa897c2a0e7de47f6c4c9f54ff.jpg)
535
+ Masked Image (Input)
536
+
537
+ ![](images/5d583334eb3a320d8ac39e95bffb49aa7f4bc7bcf9c26a49e98683bc02ceb4bc.jpg)
538
+ Generated RGB
539
+
540
+ ![](images/daa7e2efb3e1ba578b1fec3802a95b746d77f66392cfec30daf3714edee48a79.jpg)
541
+ Generated Depth
542
+ Figure 17: Synthesized RGB-D Panorama Outpainting Results.
543
+
544
+ QUALITATIVE RESULTS OF SYNTHESIZED RGB-D PANorama RESULTS.
545
+
546
+ In Fig. 17 we provide some synthesized RGB-D panorama examples where RGB is partially visible and depth is fully masked. The results show that our PanoDiffusion can outpainting plausible and consistent RGB-D panoramas simultaneously.
547
+
548
+ # COMPLEXITY ANALYSIS
549
+
550
+ Table 7: Training and inference time comparison
551
+
552
+ <table><tr><td>Method</td><td>Type</td><td>Depth</td><td>Training (mins/epoch)</td><td>Inference (sec/image)</td></tr><tr><td>PanoDiffusion</td><td>bi-modal LDM</td><td>+</td><td>82</td><td>5</td></tr><tr><td>BIPS</td><td>GAN</td><td>+</td><td>131</td><td>&lt;1</td></tr><tr><td>RePaint</td><td>Diffusion model</td><td>-</td><td>78</td><td>45</td></tr><tr><td>LDM</td><td>LDM</td><td>-</td><td>72</td><td>4</td></tr><tr><td>OmniDreamer</td><td>Transformer + VQGAN</td><td>-</td><td>158</td><td>61</td></tr></table>
553
+
554
+ For training, we compared average training time (minutes) for one epoch of PanoDiffusion against baseline models on the same devices, using the same batch size 4 and the same training dataset. For inference, we compared the time (seconds) required to infer a single image.
555
+
556
+ The results show that while our model is not the fastest, it remains within a reasonable and acceptable range. It's also noteworthy that, compared to the original LDM framework, our bi-modal structure achieves a significant improvement in the quality of outpainting. This improvement comes without a proportionate increase in resource consumption – we observed only a modest increase of $13.8\%$ in training time and $25\%$ in inference time.
panodiffusion360degreepanoramaoutpaintingviadiffusion/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:732223d8ab69a97d5eed0f84b64f1506c702df43826d504f97cfe9ab821b4b2e
3
+ size 1517447
panodiffusion360degreepanoramaoutpaintingviadiffusion/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82a9850115a7f7de276690a03fb6b7a4d7fcd969c85a15b403dc869af5676f27
3
+ size 665308
parallelizingnonlinearsequentialmodelsoverthesequencelength/780516c7-792c-4bed-a463-a618813362e0_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c09864fb4ddfd678ce96c6fa32620ec19a84b026deef6a4d343a23cf35e75574
3
+ size 175802
parallelizingnonlinearsequentialmodelsoverthesequencelength/780516c7-792c-4bed-a463-a618813362e0_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e429a764077365219e05480178103e94e62f30e49e264d6eff7c3fbb7531a52
3
+ size 203458