kelseye commited on
Commit
511d7b1
·
verified ·
1 Parent(s): 13cd5f1

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +0 -0
  2. .ms_upload_cache +0 -0
  3. README.md +106 -0
  4. assets/pipeline.png +3 -0
  5. manifest.jsonl +0 -0
  6. md/dev/-70L8lpp9DF/-70L8lpp9DF.md +0 -0
  7. md/dev/-Aw0rrrPUF/-Aw0rrrPUF.md +0 -0
  8. md/dev/-H48S9ePSUC/-H48S9ePSUC.md +424 -0
  9. md/dev/-NOQJw5z_KY/-NOQJw5z_KY.md +260 -0
  10. md/dev/-P7G-8dmSh4/-P7G-8dmSh4.md +452 -0
  11. md/dev/-QHUWgkh1OY/-QHUWgkh1OY.md +439 -0
  12. md/dev/-h6WAS6eE4/-h6WAS6eE4.md +286 -0
  13. md/dev/-kS21GWVJU/-kS21GWVJU.md +420 -0
  14. md/dev/-ltZ1uw8ZE7/-ltZ1uw8ZE7.md +409 -0
  15. md/dev/03RLpj-tc_/03RLpj-tc_.md +470 -0
  16. md/dev/08Yk-n5l2Al/08Yk-n5l2Al.md +372 -0
  17. md/dev/09hVcSDkea/09hVcSDkea.md +392 -0
  18. md/dev/0EXmFzUn5I/0EXmFzUn5I.md +386 -0
  19. md/dev/0I3su3mkuL/0I3su3mkuL.md +370 -0
  20. md/dev/0IywQ8uxJx/0IywQ8uxJx.md +708 -0
  21. md/dev/0LXEvcD3dB/0LXEvcD3dB.md +428 -0
  22. md/dev/0Q6BzWbvg0P/0Q6BzWbvg0P.md +482 -0
  23. md/dev/0RDcd5Axok/0RDcd5Axok.md +365 -0
  24. md/dev/0RTJcuvHtIu/0RTJcuvHtIu.md +249 -0
  25. md/dev/0U0C2pXfTZl/0U0C2pXfTZl.md +467 -0
  26. md/dev/0YXmOFLb1wQ/0YXmOFLb1wQ.md +323 -0
  27. md/dev/0c2SbGJ3Lt/0c2SbGJ3Lt.md +432 -0
  28. md/dev/0gouO5saq6K/0gouO5saq6K.md +324 -0
  29. md/dev/0sEIBFb4cs/0sEIBFb4cs.md +383 -0
  30. md/dev/0xiJLKH-ufZ/0xiJLKH-ufZ.md +0 -0
  31. md/dev/10uNUgI5Kl/10uNUgI5Kl.md +386 -0
  32. md/dev/157Usp_kbi/157Usp_kbi.md +298 -0
  33. md/dev/17RDXeF-skZ/17RDXeF-skZ.md +343 -0
  34. md/dev/1KaSx3GrBBm/1KaSx3GrBBm.md +341 -0
  35. md/dev/1PL1NIMMrw/1PL1NIMMrw.md +549 -0
  36. md/dev/1QQnYd02etI/1QQnYd02etI.md +280 -0
  37. md/dev/1W0z96MFEoH/1W0z96MFEoH.md +250 -0
  38. md/dev/1W8UwXAQubL/1W8UwXAQubL.md +235 -0
  39. md/dev/1YEF6TA8Di/1YEF6TA8Di.md +475 -0
  40. md/dev/1qvx610Cu7/1qvx610Cu7.md +217 -0
  41. md/dev/1sx0Drq4jfT/1sx0Drq4jfT.md +613 -0
  42. md/dev/1wVvweK3oIb/1wVvweK3oIb.md +474 -0
  43. md/dev/2-REuflJDT/2-REuflJDT.md +220 -0
  44. md/dev/2EDqbSCnmF/2EDqbSCnmF.md +376 -0
  45. md/dev/2EufPS5ABlJ/2EufPS5ABlJ.md +0 -0
  46. md/dev/2PSrjVtj6gU/2PSrjVtj6gU.md +404 -0
  47. md/dev/2clwrA2tfik/2clwrA2tfik.md +298 -0
  48. md/dev/2hMEdc35xZ6/2hMEdc35xZ6.md +452 -0
  49. md/dev/2jUKhUrBxP/2jUKhUrBxP.md +377 -0
  50. md/dev/2nJdh_C-UWe/2nJdh_C-UWe.md +413 -0
.gitattributes CHANGED
The diff for this file is too large to render. See raw diff
 
.ms_upload_cache ADDED
The diff for this file is too large to render. See raw diff
 
README.md ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ pretty_name: RPC-Bench
4
+ task_categories:
5
+ - question-answering
6
+ language:
7
+ - en
8
+ tags:
9
+ - research-paper
10
+ - document-understanding
11
+ - multimodal
12
+ - benchmark
13
+ - llm
14
+ - vlm
15
+ ---
16
+
17
+ <div align="center">
18
+
19
+ # RPC-Bench: A Fine-grained Benchmark for Research Paper Comprehension
20
+
21
+ </div>
22
+
23
+ <p align="center">
24
+ 🌐 <a href="https://rpc-bench.github.io/" target="_blank">Project Page</a> •
25
+ 💻 <a href="https://github.com/zai-org/RPC-Bench" target="_blank">GitHub</a> •
26
+ 📖 <a href="https://arxiv.org/abs/2601.14289" target="_blank">Paper</a>
27
+ </p>
28
+
29
+ <div align="center">
30
+ <img src="assets/pipeline.png" width="100%" />
31
+ </div>
32
+
33
+ RPC-Bench is a fine-grained benchmark for research paper comprehension. It is built from review-rebuttal exchanges of high-quality academic papers and supports both text-only and visual evaluation through complementary paper representations.
34
+
35
+ ## Data Structure
36
+
37
+ RPC-Bench is organized into `train`, `dev`, and `test` subsets. Split assignments are recorded in `manifest.jsonl`, and the original split JSON files are provided in `split_metadata/` (`train.json`, `dev.json`, `test.json`).
38
+
39
+ `md/` contains Markdown files parsed from each paper by MinerU. These files provide the text input for LLM-oriented evaluation.
40
+
41
+ `parse/` contains the full MinerU parsing outputs for each paper, including structured layout and content artifacts.
42
+
43
+ `pdf/` contains the original paper PDFs.
44
+
45
+ `vlm/` contains page images rendered from the PDFs with PyMuPDF at 200 DPI for VLM-oriented evaluation.
46
+
47
+ ```text
48
+ RPC-Bench/
49
+ ├── README.md
50
+ ├── manifest.jsonl
51
+ ├── split_metadata/
52
+ │ ├── train.json
53
+ │ ├── dev.json
54
+ │ └── test.json
55
+ ├── parse/
56
+ │ ├── train/
57
+ │ │ └── <paper_id>/
58
+ │ ├── dev/
59
+ │ │ └── <paper_id>/
60
+ │ └── test/
61
+ │ └── <paper_id>/
62
+ ├── md/
63
+ │ ├── train/
64
+ │ │ └── <paper_id>/
65
+ │ │ └── <paper_id>.md
66
+ │ ├── dev/
67
+ │ │ └── <paper_id>/
68
+ │ │ └── <paper_id>.md
69
+ │ └── test/
70
+ │ └── <paper_id>/
71
+ │ └── <paper_id>.md
72
+ ├── pdf/
73
+ │ ├── train/
74
+ │ │ └── <paper_id>.pdf
75
+ │ ├── dev/
76
+ │ │ └── <paper_id>.pdf
77
+ │ └── test/
78
+ │ └── <paper_id>.pdf
79
+ └── vlm/
80
+ ├── train/
81
+ │ └── <paper_id>/
82
+ ├── dev/
83
+ │ └── <paper_id>/
84
+ └── test/
85
+ └── <paper_id>/
86
+ ```
87
+
88
+ ## Practical Uses
89
+
90
+ RPC-Bench can be used to try paper-centric systems that require broader document understanding rather than local snippet matching.
91
+
92
+ - Research paper comprehension: try models on full-paper understanding, including core concepts, methods, and experimental findings.
93
+ - Long-context evaluation: try whether longer context windows or long-context architectures improve document-level reasoning.
94
+ - Multimodal reasoning: try models that combine textual evidence with page-level figures, tables, and diagrams in the original PDF layout.
95
+ - RAG system diagnosis: try retrieval, chunking, and evidence-fusion strategies for paper-centric workflows beyond snippet-level retrieval accuracy.
96
+
97
+ ## Citation
98
+
99
+ ```bibtex
100
+ @article{chen2026rpc,
101
+ title={RPC-Bench: A Fine-grained Benchmark for Research Paper Comprehension},
102
+ author={Chen, Yelin and Zhang, Fanjin and Sun, Suping and Pang, Yunhe and Wang, Yuanchun and Song, Jian and Li, Xiaoyan and Hou, Lei and Zhao, Shu and Tang, Jie and others},
103
+ journal={arXiv preprint arXiv:2601.14289},
104
+ year={2026}
105
+ }
106
+ ```
assets/pipeline.png ADDED

Git LFS Details

  • SHA256: bb03e2d775cebe05337e1a27e4b79e62e4e8285585af19b949bc677d0d18c530
  • Pointer size: 131 Bytes
  • Size of remote file: 202 kB
manifest.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/-70L8lpp9DF/-70L8lpp9DF.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/-Aw0rrrPUF/-Aw0rrrPUF.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/-H48S9ePSUC/-H48S9ePSUC.md ADDED
@@ -0,0 +1,424 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FUNDAMENTAL LIMITS OF TRANSFER LEARNING IN BINARY CLASSIFICATIONS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ A critical performance barrier in modern machine learning is scarcity of labeled data required for training state of the art massive models, especially in quickly emerging problems with lack of extensive data sets or scenarios where data collection and labeling is expensive/time consuming. Transfer learning is gaining traction as a promising technique to alleviate this barrier by utilizing the data of a related but different source task to compensate for the lack of data in a target task where there are few labeled training data. While there has been many recent algorithmic advances in this domain, a fundamental understanding of when and how much one can transfer knowledge from a related domain to reduce the amount of labeled training data is far from understood. We provide a precise answer to this question for binary classification problems by deriving a novel lower bound on the generalization error that can be achieved by any transfer learning algorithm (regardless of its computational complexity) as a function of the amount of source and target samples. Our lower bound depends on a natural notion of distance that can be easily computed on real world data sets. Other key features of our lower bound are that it applies to any arbitrary source/target data distributions and requires minimal assumptions that enables it application to a broad range of problems. We also consider a more general setting where there are more than one source domains for knowledge transfer to the target task and develop new bounds on generalization error in this setting. We also corroborate our theoretical findings on real image classification and action recognition data sets. These experiments demonstrate that our natural notion of distance is indicative of the difficulty of knowledge transfer between different pairs of source/target tasks, allowing us to investigate the effect of different sources on the target generalization error. Furthermore, to evaluate the sharpness of our bounds we compare our developed lower bounds with upper-bounds achieved by transfer learning base-lines that utilize weighted empirical risk minimization on the combination of source(s) and target data sets.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Modern machine learning models such as deep neural networks have enjoyed wide success in many domains Krizhevsky et al. (2012). The success of such deep models critically relies on an enormous amount of data required for training these massive models. For instance, GPT3 which is the state of the art model for natural language process has 175 billion parameters and requires a data set of size 45 terabytes for training. However, in new or emerging application domains it is often extremely difficult or costly to gather such large labeled training data.
12
+
13
+ A promising approach to this problem has been via transfer learning which aims at leveraging abundant available labeled data from a related source task to reduce the amount of labeled data required for the target task Pan & Yang (2009); Weiss et al. (2016). From a practical perspective transfer learning has been rather successful empirically. In particular, state of the art transfer learning approaches based on pretrained models and fine tuning has led to significant improvements on various benchmark datasets. Despite this empirical success however there is a huge gap between theory and practice in transfer learning and the fundamental limits and benefits of transfer learning are not well understood. Key challenging questions include: What is an appropriate notion of similarity between different tasks and how can it be quantitatively defined and computed on real data? What is the best achievable accuracy of any transfer learning algorithm with only a limited number of source and target samples? How does this accuracy depend on the number of samples and the similarity between the source and target tasks?
14
+
15
+ While the answer to these challenging questions are still not fully understood, they have indeed attracted a lot of interesting theoretical work in this area Galanti et al. (2016). We will discuss this literature in thorough detail in Section 2. In this paper, we take a step towards answering the aforementioned key questions enabling a better understanding of the fundamental limits of transfer learning. We focus on binary classifications where the goal is to learn a classifier from a hypothesis class with a finite VC-dimension. This covers most contemporary classification models including the training deep neural networks for binary classification. In this setting, we first define a natural notion of similarity between source and target tasks via the performance of the best source hypothesis on the target task. Then equipped with this notion of similarity, we derive a statistical minimax lower bound on the target generalization error in terms of the number of labeled data from source and target tasks as well as the VC dimension of the hypothesis class and the similarity between source and target tasks. Furthermore, we extend this result to the case where there are multiple sources with different similarity to the target. Our results demonstrate that sources with high similarity to the target are more effective at reducing the target generalization error. Towards bridging the theory-practice gap in transfer learning we also demonstrate the utility of our theoretical result in concrete applications. Indeed, a key feature of our result is that our lower bounds can be easily and efficiently computed on real data sets and apply to a broad class of practical settings.
16
+
17
+ In summary our key contributions are as follows:
18
+
19
+ • We develop a novel statistical minimax lower bound on the generalization error that can be achieved by any transfer learning algorithm as a function of the amount of source and target samples and a natural notion of similarity between source and target tasks.
20
+ • A key features of our lower bound (including our notion of similarity) is that it can be easily computed on real world data sets. Furthermore, our lower bound holds for any source/target distribution and applies with minimal assumptions to a wide variety of contemporary learning models including deep neural networks.
21
+ • We investigate the sharpness of our lower bounds and demonstrate their utility via experiments on action recognition and image classification.
22
+
23
+ # 2 PRIOR WORKS
24
+
25
+ A closely related literature to transfer learning is domain adaptation where there is no or very few labeled target data and the goal is to adapt the hypothesis learned on the source domain to achieve a low target generalization error Chen et al. (2019); Blitzer et al. (2007); Azizzadenesheli et al. (2018); Long et al. (2016); Shen et al. (2018). Most of this literature assume that source and target share a common labeling rule but there is a shift in the marginal distributions. There are many upper bounds for the target generalization error in this setting this setting. For instance, Ben-David et al. (2007; 2010) gives an upper bound for the target generalization error in terms of source generalization error and a divergence measure between the domains that can be estimated by finitely many unlabeled data from the source and target. In another work Mansour et al. (2009) introduces a new discrepancy distance and generalizes the results of Ben-David et al. (2007) for a wide family of loss functions using Rademacher complexity. Similar to this setting, but for multiple source domain adaption scheme, Mansour et al. (2021) proposes a family of algorithms based on the idea of model selection under the assumption that target distribution is close to some convex combination of sources. A more recent work Lei et al. (2021) studies linear regression under shift distribution including covariate shift (i.e. conditional distributions of source and target are the same) as well as model shift (i.e. only distributions of the features of the source and target are the same) and develops algorithms achieving near optimal minimax risk in this setting.
26
+
27
+ In addition to upper bounds, there are also a few results which provide lower bounds for target generalization error. David et al. (2010) provides impossibility results under the assumption of covariate shift and small discrepancy of unlabeled distributions. Mousavi Kalan et al. (2020) studies transfer learning with one hidden layer neural networks for regression problems. This result defines a notion of similarity between the source and target tasks based on a distance between the ground truth parameters of the source and target networks. Using this distance this paper develops a statistical minimax lower bound for the target generalization error in terms of the number of source and target samples as well as the defined similarity of the source and target under the distribution shift with the assumption that the features are generated by Gaussian distributions. Compared to Mousavi Kalan et al. (2020) our result has quite a few unique advantages: (1) We do not assume that the source and target data are generated according to a planted (teacher) network and our results now even hold in the agnostic setting. (2) Mousavi Kalan et al. (2020) applies to regression problems but this result covers classification (3) Mousavi Kalan et al. (2020) only considered one-hidden layer neural networks for predicting the labels of extracted features. In this result we can handle arbitrary deep neural networks. (4) Our notion of similarity between the source and target distributions can be much more easily estimated by using only a few target data without the need for estimating the ground truth target parameters which requires lots of labeled target data.
28
+
29
+ More closely related to this work Hanneke & Kpotufe (2019) derives a minimax lower bound for target generalization error in binary classification under the assumption of a relaxed version of covariate shift and small transfer exponent parameter which is defined to measure the discrepancy of the source and target distributions. Our work differs from this previous work as except for assuming the VC dimension of the model is finite we do not make any further assumptions. This makes our results applicable in a much broader set of classifications or decision making problems. Furthermore, our lower bound can be evaluated on real data sets and serve as a guideline to practitioners helping them decide when utilizing additional knowledge from a source domain is useful for a given target task.
30
+
31
+ Most of the literature in transfer learning try to provide sufficiency and necessity results by deriving upper and lower bounds for target generalization error in a relatively general setting. However, these papers often require a variety of assumptions to find the optimal classifier in a target domain in closed form. For instance, Karbalayghareh et al. (2019; 2018) defines a joint prior distribution of source and target domains using a Wishart distribution which relate the source and target tasks and then makes it possible to study and understand the transferability between domains. Furthermore, in this setting, the authors develop a closed form optimal Bayesian transfer learning and demonstrate its advantage over a classifier obtained by only target data. Related to this setting but for regressions, Karbalayghareh et al. (2018) obtains the optimal Bayesian transfer learning under setting of joint Gaussian feature/label distribution. In contrast with the above in our paper we do not make any assumptions about the distribution of the data.
32
+
33
+ # 3 PROBLEM FORMULATION
34
+
35
+ We consider a transfer learning problem where there are some labeled training data from a source task and a target task with the goal of inferring a hypothesis function with small generalization error in the target task. More specifically, we assume have $n _ { S }$ and $n _ { T }$ source and target labeled data where each training data consists of an input/feature as well as an output/label. We denote the source and training data by $( \pmb { x } _ { S } , y _ { S } ) \sim \mathbb { P }$ and $\bar { \mathbf { \Omega } } ( \mathbf { x } _ { T } , y _ { T } ) \sim \mathbb { Q }$ , respectively, where $y _ { S } , y _ { T } \in \{ 0 , 1 \}$ and $\mathbb { P } , \mathbb { Q }$ are the joint feature-label distributions of source and target data. Additionally, we assume that source and target features/inputs share a same domain, ${ \pmb x } _ { S } , { \pmb x } _ { T } \in { \chi }$ , and $\mathcal { H } \subset 2 ^ { \chi }$ denotes a fixed hypothesis class with $d _ { \mathcal { H } }$ VC-dimension.
36
+
37
+ In transfer learning the goal is to find a hypothesis from $\mathcal { H }$ that minimizing the target excess risk defined below based on a combination of source and target data.
38
+
39
+ Definition 1 (Excess risk) For a hypothesis function $h \in \mathcal H$ and source and target label-feature data generated according to distributions $\mathbb { P }$ and $\mathbb { Q }$ $( ( \pmb { x } _ { S } , y _ { S } ) \sim \mathbb { P }$ and $( \pmb { x } _ { T } , \pmb { y } _ { T } ) \sim \mathbb { Q } )$ , we define the source and target excess risks as follows
40
+
41
+ $$
42
+ \mathcal { E } _ { T } ( h ) = \mathbb { Q } [ h ( \mathbf { x } _ { T } ) \neq y _ { T } ] - \mathbb { Q } [ h _ { T } ^ { * } ( \mathbf { x } _ { T } ) \neq y _ { T } ]
43
+ $$
44
+
45
+ and
46
+
47
+ $$
48
+ \begin{array} { c } { \displaystyle \varepsilon _ { S } ( h ) = \mathbb { P } [ h ( \pmb { x } _ { S } ) \neq y _ { S } ] - \mathbb { P } [ h _ { S } ^ { \ast } ( \pmb { x } _ { S } ) \neq y _ { S } ] } \\ { \displaystyle h _ { T } ^ { \ast } = \arg \operatorname* { m i n } _ { h \in \mathcal { H } } \mathbb { Q } [ h ( \pmb { x } _ { T } ) \neq y _ { T } ] a n d h _ { S } ^ { \ast } = \arg \operatorname* { m i n } _ { h \in \mathcal { H } } \mathbb { P } [ h ( \pmb { x } _ { S } ) \neq y _ { S } ] } \end{array}
49
+ $$
50
+
51
+ Next, we need to define an appropriate notion of distance between the source and target. In the literature of domain adaptation, where the conditional expectation remains unchanged and there is
52
+
53
+ only a shift in input distributions, it is common to define the distance as the error of performance of the best source hypothesis in the target task. We also define the distance between source and target as the target excess risk of the best source hypothesis.
54
+
55
+ Definition 2 (Transfer distance) We define the transfer distance between a source and a target with distributions $\mathbb { P }$ and $\mathbb { Q }$ as follows
56
+
57
+ $$
58
+ \rho ( \mathbb { P } , \mathbb { Q } ) : = \mathbb { Q } [ h _ { S } ^ { \ast } ( \pmb { x } _ { T } ) \neq y _ { T } ] - \mathbb { Q } [ h _ { T } ^ { \ast } ( \pmb { x } _ { T } ) \neq y _ { T } ]
59
+ $$
60
+
61
+ Since we aim to derive a minimax lower bound for transfer learning in binary classifications, we consider the class of pairs of distributions whose transfer distance is within a fixed number $\Delta$ . As we will elaborate further in Remark 7 below this notion of distance can be easily estimated/computed in practice.
62
+
63
+ # 4 MAIN RESULTS
64
+
65
+ In this section we characterize the fundamental limits of transfer learning in binary classifications by deriving a minimax lower bound via information-theoretic arguments.
66
+
67
+ Theorem 1 Consider a transfer learning problem where there are $n _ { S }$ and $n _ { T }$ number of source as well as target data and the hypothesis class $\mathcal { H }$ has $V C$ dimension $d _ { \mathcal { H } }$ obeying $d _ { \mathcal { H } } \geq 1 0$ . Furthermore, suppose that $\hat { h } = \hat { h } ( S _ { \mathbb { P } } , S _ { \mathbb { Q } } )$ is an estimated hypothesis for the target task using source and target data in which $S _ { \mathbb { P } }$ and $S _ { \mathbb { Q } }$ denote i.i.d. feature-label data p rs $\{ ( \pmb { x } _ { S } ^ { ( i ) } , \pmb { y } _ { S } ^ { ( i ) } ) \} _ { i = 1 } ^ { n _ { S } }$ and $\{ ( \pmb { x } _ { T } ^ { ( i ) } , \pmb { y } _ { T } ^ { ( i ) } ) \} _ { i = 1 } ^ { n _ { T } }$ generated according to the source and target distributions $\mathbb { P }$ and $\mathbb { Q }$ . Fix a transfer distance $\Delta < 0 . 9 9$ . Then for any $\hat { h }$ there exists $( \mathbb { P } , \mathbb { Q } )$ with $\rho ( \mathbb { P } , \mathbb { Q } ) \leq \Delta$ and a universal constant $c$ such that
68
+
69
+ $$
70
+ P _ { \mathit { P } , \mathit { S } _ { \mathbb { Q } } } \bigg ( \mathcal { E } _ { T } ( \hat { h } ) > c \cdot \epsilon ( n _ { S } , n _ { T } , d _ { \mathcal { H } } , \Delta ) \bigg ) \geq \frac { 3 - 2 \sqrt { 2 } } { 8 } ,
71
+ $$
72
+
73
+ where
74
+
75
+ $$
76
+ \epsilon ( n _ { S } , n _ { T } , d _ { \mathcal { H } } , \Delta ) = \sqrt { \frac { 1 } { \frac { n _ { T } } { d _ { \mathcal { H } } } + \frac { n _ { S } } { d _ { \mathcal { H } } + n _ { S } \Delta } } } .
77
+ $$
78
+
79
+ This also implies that
80
+
81
+ $$
82
+ \operatorname* { i n f } _ { \hat { h } } \operatorname* { s u p } _ { \rho ( \mathbb { P } , \mathbb { Q } ) \leq \Delta } \operatorname* { \mathbb { E } } _ { S _ { \mathbb { P } } , S _ { \mathbb { Q } } } \Big [ \mathcal E _ { T } ( \hat { h } ) \Big ] \geq c \cdot \epsilon ( n _ { S } , n _ { T } , d _ { \mathcal H } , \Delta ) .
83
+ $$
84
+
85
+ Remark 1 The bound above characterizes the fundamental limits of transfer learning by providing a lower bound on the excess risk of any algorithm (regardless of computational tractability) as a function of the number of source and target training data, the similarity/distance between the source and target tasks and the dimension of the hypothesis class used.
86
+
87
+ Remark 2 The assumption $\Delta < 0 . 9 9$ in the statement of Theorem 1 is just made for simplifying the analysis and the upper bound of 0.99 can be replaced by any constant in the interval $( 0 , 1 )$ .
88
+
89
+ Remark 3 One can show that the numerical constant c in equation 4.1 obeys c > 3−2 248 .
90
+
91
+ Remark 4 (Connection to PAC learning) We note that the well-known agnostic PAC learning result for a single task gives a lower bound of $c \cdot \sqrt { \frac { d _ { \mathscr { H } } } { n } }$ where $n$ is the number of samples of the task. Theorem 1 recovers this result when there is not any source task, namely $n _ { S } = 0$ , and the transfer learning problem reduces to learning a task without any prior knowledge from the source.
92
+
93
+ Remark 5 (Identical source and target) When the source and target tasks are identical, then the transfer learning problem reduces to learning a single task with $n _ { S } + n _ { T }$ training data. Theorem 1, also leads to the same conclusion in this special case as when the source and target data are identical ∆ = 0 and thus  = q $\begin{array} { r } { \epsilon = \sqrt { \frac { d _ { \mathcal { H } } } { n _ { S } + n _ { T } } } } \end{array}$ which states that the lower bound is proportional to reciprocal of combination of source and target samples as expected.
94
+
95
+ Remark 6 (Sharpness in a special case) We note that the above lower bound is known to be tight in special cases. For instance when there is a small amount of source data and $\Delta$ is rather large, the lower bound reduces to dHn which is known to be tight based on known agnostic PAC learning bounds.
96
+
97
+ Remark 7 (How to apply Theorem 1 in practical settings.) In this remark we explain how Theorem 1 can be applied when using contemporary machine learning models involving artificial neural networks. In this case, the hypothesis class corresponds to all neural networks with a fixed architecture but different parameters. It is known that the class of neural networks with a fixed architecture has finite VC dimension and Harvey et al. (2017) gives upper and lower bounds for VC dimension of neural networks with ReLU activation functions. Thus, to apply Theorem 1, one only needs to have an estimate of the transfer distance per Definition 2. We note that the transfer distance 3.1 consists of two terms: To estimate the first term, we note that $h _ { S } ^ { * }$ can be easily estimated due to the abundance of source data in most applications. Also with an estimate of $h _ { S } ^ { * }$ in hand one can estimate $\mathbb { Q } [ h _ { S } ^ { * } ( { \pmb x } _ { T } ) \neq { \ - { \boldsymbol y } _ { T } } ]$ rather accurately using a simple empirical average with a few target test data as well-known concentration of bounded functions imply that this empirical average is well concentrated around $\mathbb { Q } [ h _ { S } ^ { * } ( { \pmb x } _ { T } ) \neq { \ - { \boldsymbol y } _ { T } } ]$ . Up on first glance it seems that estimating the second term which corresponds to the lowest possible error in the target domain among the hypothesis class, requires a large amount of labeled target data which is not available in a practical problem. However, in an overparametrized setting, it is typical to assume that there exists a network which achieves very small target generalization error so we can ignore the second term in most practical problems. Finally we note that as stated earlier the lower bound on the target excess risk gives an estimate of what generalization performance we can expect with a certain number of source and target samples. Furthermore, by comparing the estimated transfer distance of different pairs of tasks, we can find the pairs that are more suitable for transfer learning. This knowledge can in turn significantly reduce the required number of target samples to achieve a certain accuracy.
98
+
99
+ Next, we extend our result to a multiple source transfer learning setup where instead of only one source task there are several source tasks available and the goal is to transfer knowledge from multiple sources to a given target task to achieve a small target generalization error.
100
+
101
+ Theorem 2 Suppose that there are $n _ { S _ { 1 } } , n _ { S _ { 2 } } , . . . , n _ { S _ { N } }$ number of samples from $N$ source tasks as well as $n _ { T }$ number of samples from a target task and the hypothesis class $\mathcal { H }$ has VC dimension $d _ { \mathcal { H } }$ obeying $d _ { \mathcal { H } } \ge \operatorname* { m a x } { ( N + 9 , N / 2 ) }$ . Furthermore, suppose that $\hat { h } = \hat { h } ( S _ { \mathbb { P } _ { 1 } } , S _ { \mathbb { P } _ { 2 } } , . . . , S _ { \mathbb { P } _ { N } } , S _ { \mathbb { Q } } )$ is an estimated e tarand $N$ sources and target data where generated according to souce a $S _ { \mathbb { P } _ { j } }$ and targe $S _ { \mathbb { Q } }$ denstrib e i.i.ions dataand {(x(i)Sj , y(i)Sj )} ji=1 $\{ ( \pmb { x } _ { T } ^ { ( i ) } , \pmb { y } _ { T } ^ { ( i ) } ) \} _ { i = 1 } ^ { n _ { T } }$ $\mathbb { P } _ { j }$ $\mathbb { Q }$ for $j = 1 , . . . , N$ . Fix transfer distances $\{ \Delta _ { j } \} _ { j = 1 } ^ { N }$ where $0 \leq \Delta _ { j } \leq 1$ . Then for any $\hat { h }$ there exists $( \mathbb { P } _ { 1 } , . . . , \mathbb { P } _ { M } , \mathbb { Q } )$ with $\rho ( \mathbb { P } _ { j } , \mathbb { Q } ) \leq \Delta _ { j }$ and a universal constant c such that
102
+
103
+ $$
104
+ \operatorname* { P r o b } _ { S _ { \mathrm { P } _ { 1 } } , \dots , S _ { \mathrm { P } _ { N } } , S _ { \mathrm { Q } } } \Bigg ( \mathcal { E } _ { T } ( \hat { h } ) > c \cdot \epsilon ( n _ { S _ { 1 } } , \dots , n _ { S _ { N } } , n _ { T } , d _ { \mathcal { H } } , \Delta _ { 1 } , . . . , \Delta _ { N } ) \Bigg ) \geq \frac { 3 - 2 \sqrt { 2 } } { 8 } ,
105
+ $$
106
+
107
+ where
108
+
109
+ $$
110
+ \epsilon ( n _ { S _ { 1 } } , . . . , n _ { S _ { N } } , n _ { T } , d _ { \mathcal { H } } , \Delta _ { 1 } , . . . , \Delta _ { N } ) = \sqrt { \frac { 1 } { \frac { n _ { T } } { d _ { \mathcal { H } } } + \frac { n _ { S _ { 1 } } } { d _ { \mathcal { H } } + n _ { S _ { 1 } } \Delta _ { 1 } } + . . . + \frac { n _ { S _ { N } } } { d _ { \mathcal { H } } + n _ { S _ { N } } \Delta _ { N } } } } .
111
+ $$
112
+
113
+ This in turn implies that
114
+
115
+ $$
116
+ \operatorname* { i n f } _ { \hat { h } } \operatorname* { s u p } _ { \rho ( \mathbb { P } _ { j } , \mathbb { Q } ) \leq \Delta _ { j } } S _ { \mathbb { P } _ { 1 } , \ldots , \mathbb { P } _ { N } , S _ { \mathbb { Q } } } \Big [ \mathcal { E } _ { T } ( \hat { h } ) \Big ] \geq c \cdot \epsilon ( n _ { S _ { 1 } } , . . . , n _ { S _ { N } } , n _ { T } , d _ { \mathcal { H } } , \Delta _ { 1 } , . . . , \Delta _ { N } ) .
117
+ $$
118
+
119
+ Remark 8 Similar to the previous theorem, Theorem 2 provides a minimax lower bound for target excess risk with the key distinction that now it applies in the setting where there are multiple source with different transfer distances to the target. This theorem characterizes the exces risk achievable by any algorithm as a function of these transfer distances as well as the number of samples from the different sources and the target data. Theorem 2 indicates that the more sources we have, the better performance we can achieve in the target domain. However, this performance gain maybe marginal for source tasks that have a large transfer distance to the target or where there are very few training data. In these cases of course it may be more computationally efficient to discard these sources given the marginal improvement in the generalization performance suggested by this theorem.
120
+
121
+ Remark 9 (Identical sources) if all the source tasks are identical, then there are effectively $n _ { S _ { 1 } } ~ + ~ . . . ~ + ~ n _ { S _ { N } }$ number of source samples and by Theorem 1 the lower bound would be 1PNj=1 nSj . Theorem 2 also gives the same order wise lower bound as nT + dH dH+∆ PNj=1 nSj
122
+
123
+ $$
124
+ \begin{array} { r } { \sqrt { \frac { 1 } { \frac { n _ { T } } { d _ { \mathcal { H } } } + \sum _ { j = 1 } ^ { N } \frac { n _ { j } } { d _ { \mathcal { H } } + \Delta n _ { j } } } } \le \sqrt { \frac { 1 } { \frac { n _ { T } } { d _ { \mathcal { H } } } + \frac { \sum _ { j = 1 } ^ { N } n _ { S _ { j } } } { d _ { \mathcal { H } } + \Delta \sum _ { j = 1 } ^ { N } n _ { S _ { j } } } } } \le \sqrt { N } \cdot \sqrt { \frac { 1 } { \frac { n _ { T } } { d _ { \mathcal { H } } } + \sum _ { j = 1 } ^ { N } \frac { n _ { j } } { d _ { \mathcal { H } } + \Delta n _ { j } } } } } \end{array}
125
+ $$
126
+
127
+ Remark 10 (Infinitely many source samples) When ∆i > 0 and nSi → ∞, the fraction nSidH+nS ∆i saturates at $\frac { 1 } { \Delta _ { i } }$ which shows that when the source and target have positive distance, the source can never compensate for the target samples.
128
+
129
+ Remark 11 In the lower bound, the product terms $\Delta _ { i } n _ { S _ { i } }$ appear which indicate that a source with large transfer distance can sometimes be as useful as a source with small transfer distance when there is a large amount of training data available from that source.
130
+
131
+ # 5 EXPERIMENTAL RESULTS
132
+
133
+ In this section we evaluate our theoretical results on real data sets for action recognition and image classification tasks. By estimating the parameters appearing in Theorem 1 for different pairs of tasks, we first plot the lower bounds and then by running weighted empirical risk minimization investigate the sharpness of the bounds. We also investigate the effectiveness of different source tasks with different transfer distances on the target generalization error.
134
+
135
+ # 5.1 ACTION RECOGNITION
136
+
137
+ Experimental setup. We first perform experiments on the UCF101 action recognition data set. We pick CricketBowling and TableTennis videos from UCF101 as the target task as well as three different pairs of classes as the source tasks: 1- CricketBowling and BaseballPitch, 2- Cricketshot and Archery, 3- BasketballDunk and Basketball. We pass the videos through an i3d network pretrained on kinetics400 Carreira & Zisserman (2017) with the fully connected top classifier removed and extract the corresponding features of dimension 2048 from the raw videos. We then work with the extracted features instead of the raw videos.
138
+
139
+ Training. We train a one hidden layer neural network with 15 number of hidden units and ReLU activation functions for each pair of data sets. Table 3 consists of test accuracy on CricketBowling vs. TableTennis, when using the network trained on each source task. We use these accuracies for deriving the corresponding lower bounds. Furthermore, we run weighted empirical risk minimization as a simple transfer learning approach to find some upper bounds on the target generalization error. Given $n _ { S }$ and $n _ { T }$ number of source and target samples, for estimating the corresponding one hidden layer neural network parameters we minimize the following weighted empirical risk
140
+
141
+ $$
142
+ \operatorname* { m i n } _ { W _ { 1 } , W _ { 2 } } \frac { 1 - \lambda } { n _ { T } } \sum _ { i = 1 } ^ { n _ { T } } \mathbf { C o s t } ( W _ { 2 } \mathbf { R e L U } ( W _ { 1 } \pmb { x } _ { T } ^ { ( i ) } ) , y _ { T } ^ { ( i ) } ) + \frac { \lambda } { n _ { S } } \sum _ { i = 1 } ^ { n _ { S } } \mathbf { C o s t } ( W _ { 2 } \mathbf { R e L U } ( W _ { 1 } \pmb { x } _ { S } ^ { ( i ) } ) , y _ { S } ^ { ( i ) } )
143
+ $$
144
+
145
+ where the function Cost denotes the logistic regression cost and $\lambda \in \{ 0 , 0 . 2 , 0 . 4 , 0 . 6 , 0 . 8 , 1 \}$ . We then pick the lambda which minimizes the target test error.
146
+
147
+ Results. First we calculate the transfer distance by Definition 2 for each source/target pairs using Table 1. To this end, we assume that best target generalization error is zero and using the Table 1 we obtain the transfer distance for each pair which is demonstrated in Table 2. As it can be observed by Table 2, the pair of Source1 and Target has the lowest transfer distance among other pairs since both of the source and target tasks share a same class which is CricketBowling. Furthermore, Table 2 determines which pairs are more suitable for transferring the source knowledge to the target.
148
+
149
+ Table 1
150
+
151
+ <table><tr><td>Task</td><td>Test accuracy of Target us- ing the source network</td></tr><tr><td>Target:CricketBowlingvs.TableTennis Source1: CricketBowling vs.Baseball Pitch Source2: Cricketshot vs.Archery Source3:BasketballDunk vs.Basketball</td><td>1 0.946 0.61 0.52</td></tr></table>
152
+
153
+ <table><tr><td>pair of tasks</td><td>p(Source,Target)</td></tr><tr><td>(Source1, Target)</td><td>0.053</td></tr><tr><td>(Source2, Target)</td><td>0.39</td></tr><tr><td>(Source3,Target)</td><td>0.48</td></tr></table>
154
+
155
+ Table 2: Transfer distance of pairs of source and target on UCF101 action recognition.
156
+
157
+ ![](images/2c241193221490f096d20c1db5bb3ebe4553c3e1b29a5f9a4c43fa4d3551c9e2.jpg)
158
+ Figure 1: (a) depicts our lower bounds for three pairs of source and target tasks on action classification. (b) depicts the lower bounds along with the upper bounds obtained via weighted empirical risk minimization.
159
+
160
+ Next, we draw the lower bound curves for each pair in Fig 1a. To this end, we need to find the VC dimension of the hypothesis class which consists of neural networks with the architecture of $2 0 4 8 * 1 5 * 1$ with ReLU activation functions. Theorem 1 in Harvey et al. (2017) gives a lower bound for VC dimension of neural networks with ReLU activation functions by $\begin{array} { r } { \frac { 1 } { 6 4 0 } \dot { W } \dot { L } \log _ { 2 } \frac { W } { L } } \end{array}$ where $W$ and are the number of parameters and layers, respectively. Then in Figure 1b we plot the lower bounds along with the upper bounds obtained via Formula 5.1 for three different pairs of source and target as well as using only target samples. We obtained these upper bounds by running Formula 5.1 five times and then averaging the results. Fig 1b shows that when the distance of a source from the target is small it would be more effective in achieving small target generalization error. We would like to mention that in all of these plots we choose the same number of source samples for each pair.
161
+
162
+ Figure 2 shows the average $\lambda$ , the weight appearing in Formula 5.1, when the number of target samples is 100 to 150. It shows that in the pair Source1 and Target the average $\lambda$ is high which demonstrate the usefulness of the source in the target task. Furthermore, the small value of $\lambda$ in the pair Source3 and Target suggests that when the transfer distance is high, source samples are no longer usefull.
163
+
164
+ # 5.2 IMAGE CLASSIFICATION
165
+
166
+ Experimental setup. In this section we focus on image classification tasks and utilize Theorem 1 to recognize appropriate pairs of tasks that are suitable for transfer learning. We choose some classes of the DomainNet data set Peng et al. (2019) as source and target tasks. We pick Clock and Ambulance from DomainNet Clipart for the target task and three different pairs of classes as the source tasks: 1- Clock and Ambulance, 2- Cricketshot and TableTennis, 3- TableTennis and FrontCraw. Here we
167
+
168
+ ![](images/1df4f1137b5f43be56ef563df21cd603dfe5643d8bffa4d7a5b2e8b91d2fa116.jpg)
169
+ Figure 2: Average $\lambda$ in weighted empirical risk minimization for three different pairs of source and target tasks for action recognition.
170
+
171
+ Table 3
172
+
173
+ <table><tr><td>Task</td><td>Test Accuracy of Target using the source network</td></tr><tr><td>Target: Clock vs. Ambulance (Clipart) Source1: Clock vs.Ambulance (Sketch) Source2: Clock vs. Crow(Sketch)</td><td>0.916 0.697</td></tr></table>
174
+
175
+ ![](images/13e028571da16adec8995d8d638a4e0ce066f5cf2190ce602d12a912311c3bd1.jpg)
176
+ Figure 3: (a) depicts our lower bounds for three pairs of source and target tasks on image classification. (b) depicts the lower bounds along with the upper bounds obtained via weighted empirical risk minimization.
177
+
178
+ <table><tr><td>pair of tasks</td><td>p(Source, Target)</td></tr><tr><td>(Source1, Target)</td><td>0.083</td></tr><tr><td>(Source2, Target)</td><td>0.3</td></tr><tr><td>(Source3, Target)</td><td>0.35</td></tr></table>
179
+
180
+ Table 4: Transfer distance of pairs of source and target on DomainNet image classifications].
181
+
182
+ use ResNet50 network pretrained on Imagenet for extracting features of dimension 2048 and in the sequel we work with the extracted features rather than the raw image data.
183
+
184
+ Training. We train a one hidden layer neural network with 15 number of hidden units and ReLU activation functions for each of pairs of the tasks. Table 3 includes the test accuracy on the target task when using the networks trained on different sources, which is necessary for estimating/calculating the transfer distance as demonstrated in Table 4. Similar to the subsection 5.1, we also run weighted empirical risk minimization for finding upper bounds for the pairs of the source and target tasks.
185
+
186
+ Results. Similar to the previous section on action recognition, using Table 3 we can obtain the transfer distances and based on this distance we can identify suitable pairs of source and target tasks for transfer learning. In the pair1 Source and target tasks share the same objects which are Clock and Ambulance which results in low transfer distance. In pair2, still one of the objects which is Clock is the same in the source and target and we can see that the transfer distance for pair2 is lower than that for pair3. Then we plot the lower bounds in Fig 3a and the corresponding upper bounds obtained by weighted empirical risk minimization in Fig 3b. One can see that sources that are closer to the target according to our notion of distance are more effective in achieving small target generalization error.
187
+
188
+ ![](images/7a303c3706559f7a90ce3dfe420c8b7330324be99f6ba51d8e74ec5e3805fcc7.jpg)
189
+ Figure 4: Average $\lambda$ in weighted empirical risk minimization for three different pairs of source and target tasks for image classification.
190
+
191
+ CricketBowling is common both in the source and Target1. This suggests that these tasks are similar to each other and the estimated transfer distance conforms with this intuition. Furthermore, CricketBowling and Cricketshot are intuitively similar to one another and this is also reflected in the lower transfer distance between source and Target2.
192
+
193
+ In Fig 4 we plot the average $\lambda$ , the weight appearing in Formula 5.1 when the number of target samples varies from 150 to 200. 4 demonstrates that when a source is close to the target the weight of source risk in weighted empirical risk becomes high which shows the effectiveness of source samples in achieving small target generalization error.
194
+
195
+ # 6 PROOF OUTLINE
196
+
197
+ The main idea of proof is based on the following proposition proved in Tsybakov (2009)
198
+
199
+ Proposition 1 [Theorem 2.5 of Tsybakov (2009)] Assume that $M \geq 2$ and the function $d ( \cdot , \cdot )$ is a semi-distance. Also suppose that $\{ P _ { \theta _ { j } } \} _ { \theta _ { j } \in \Theta }$ is a family of distributions indexed over a parameter space, $\Theta$ , and $\Theta$ contains elements $\theta _ { 0 } , \bar { \theta } _ { 1 } , . . . , \theta _ { M }$ such that:
200
+
201
+ $$
202
+ d ( \theta _ { i } , \theta _ { j } ) \geq 2 s > 0 , \ \forall 0 \leq j < k \leq M
203
+ $$
204
+
205
+ (ii) $P _ { j } \ll P _ { 0 } , \ \forall \ j = 1 , . . . , M .$ , and
206
+
207
+ $$
208
+ \frac { 1 } { M } \sum _ { j = 1 } ^ { M } { \mathcal { D } } _ { k l } ( P _ { j } | P _ { 0 } ) \leq \alpha \log M
209
+ $$
210
+
211
+ with $0 < \alpha < 1 / 8$ and $P _ { j } = P _ { \theta _ { j } }$ , $j = 0 , 1 , . . . , M$ and $\mathcal { D } _ { k l }$ denotes the KL-divergence. Then
212
+
213
+ $$
214
+ \operatorname* { i n f } _ { \hat { \theta } } \operatorname* { s u p } _ { \theta \in \Theta } P _ { \theta } ( d ( \hat { \theta } , \theta ) \geq s ) \geq \frac { \sqrt { M } } { 1 + \sqrt { M } } \big ( 1 - 2 \alpha - \sqrt { \frac { 2 \alpha } { \log M } } \big )
215
+ $$
216
+
217
+ Based on Proposition 1 we construct a family of pairs of distributions, namely source and target distributions, whose transfer distances satisfy the $\Delta$ -constraint. To do so we pick some points from the domain $\chi$ shattered by the hypothesis class and define appropriate distributions on this set of points. Furthermore, this family of distributions are indexed in the space of $\{ - 1 , 1 \} ^ { d }$ which can be a metric space using Hamming distance. In order to satisfy the condition (i) in Proposition 1, the indexes have to be well separated which can be achieved using the well-known Gilbert-Varshamov’s bound. Finally we show that estimating a parameter with small hamming distance is equivalent to estimating an appropriate hypothesis with small excess risk error.
218
+
219
+ # REFERENCES
220
+
221
+ Kamyar Azizzadenesheli, Anqi Liu, Fanny Yang, and Animashree Anandkumar. Regularized learning for domain adaptation under label shifts. In International Conference on Learning Representations, 2018.
222
+
223
+ Shai Ben-David, John Blitzer, Koby Crammer, Fernando Pereira, et al. Analysis of representations for domain adaptation. Advances in neural information processing systems, 19:137, 2007.
224
+
225
+ Shai Ben-David, John Blitzer, Koby Crammer, Alex Kulesza, Fernando Pereira, and Jennifer Wortman Vaughan. A theory of learning from different domains. Machine learning, 79(1):151–175, 2010.
226
+
227
+ John Blitzer, Koby Crammer, Alex Kulesza, Fernando Pereira, and Jennifer Wortman. Learning bounds for domain adaptation. In NIPS, 2007.
228
+
229
+ Joao Carreira and Andrew Zisserman. Quo vadis, action recognition? a new model and the kinetics dataset. In proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 6299–6308, 2017.
230
+
231
+ Xinyang Chen, Sinan Wang, Mingsheng Long, and Jianmin Wang. Transferability vs. discriminability: Batch spectral penalization for adversarial domain adaptation. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research. PMLR, 2019.
232
+
233
+ Shai Ben David, Tyler Lu, Teresa Luu, and David P ´ al. Impossibility theorems for domain adaptation. ´ In Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, pp. 129–136. JMLR Workshop and Conference Proceedings, 2010.
234
+
235
+ Tomer Galanti, Lior Wolf, and Tamir Hazan. A theoretical framework for deep transfer learning. Information and Inference: A Journal of the IMA, 5(2):159–209, 2016.
236
+
237
+ Steve Hanneke and Samory Kpotufe. On the value of target data in transfer learning. In NeurIPS, 2019.
238
+
239
+ Nick Harvey, Christopher Liaw, and Abbas Mehrabian. Nearly-tight vc-dimension bounds for piecewise linear neural networks. In Conference on learning theory, pp. 1064–1068. PMLR, 2017.
240
+
241
+ Alireza Karbalayghareh, Xiaoning Qian, and Edward R Dougherty. Optimal bayesian transfer regression. IEEE Signal Processing Letters, 25(11):1655–1659, 2018.
242
+
243
+ Alireza Karbalayghareh, Xiaoning Qian, and Edward Russell Dougherty. Optimal bayesian transfer learning for count data. IEEE/ACM transactions on computational biology and bioinformatics, 2019.
244
+
245
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems, 25:1097–1105, 2012.
246
+
247
+ Qi Lei, Wei Hu, and Jason Lee. Near-optimal linear regression under distribution shift. In International Conference on Machine Learning, pp. 6164–6174. PMLR, 2021.
248
+
249
+ Mingsheng Long, Han Zhu, Jianmin Wang, and Michael I Jordan. Unsupervised domain adaptation with residual transfer networks. Advances in Neural Information Processing Systems, 2016.
250
+
251
+ Yishay Mansour, Mehryar Mohri, and Afshin Rostamizadeh. Domain adaptation: Learning bounds and algorithms. In 22nd Conference on Learning Theory, COLT 2009, 2009.
252
+
253
+ Yishay Mansour, Mehryar Mohri, Jae Ro, Ananda Theertha Suresh, and Ke Wu. A theory of multiplesource adaptation with limited target labeled data. In International Conference on Artificial Intelligence and Statistics, pp. 2332–2340. PMLR, 2021.
254
+
255
+ Seyed Mohammadreza Mousavi Kalan, Zalan Fabian, Salman Avestimehr, and Mahdi Soltanolkotabi. Minimax lower bounds for transfer learning with linear and one-hidden layer neural networks. In Advances in Neural Information Processing Systems, 2020.
256
+
257
+ Sinno Jialin Pan and Qiang Yang. A survey on transfer learning. IEEE Transactions on knowledge and data engineering, 22(10):1345–1359, 2009.
258
+
259
+ Xingchao Peng, Qinxun Bai, Xide Xia, Zijun Huang, Kate Saenko, and Bo Wang. Moment matching for multi-source domain adaptation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 1406–1415, 2019.
260
+
261
+ Jian Shen, Yanru Qu, Weinan Zhang, and Yong Yu. Wasserstein distance guided representation learning for domain adaptation. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
262
+
263
+ Alexandre B Tsybakov. Introduction to Nonparametric Estimation. Springer series in statistics. Springer, Dordrecht, 2009. doi: 10.1007/b13794.
264
+
265
+ Karl Weiss, Taghi M Khoshgoftaar, and DingDing Wang. A survey of transfer learning. Journal of Big data, 3(1):1–40, 2016.
266
+
267
+ # 7 APPENDIX
268
+
269
+ # 7.1 PROOF OF THEOREM 1
270
+
271
+ We also use the following famous result in information theory known as Gilbert-Varhsamov’s bound for packing argument.
272
+
273
+ Proposition 2 (Lemma 2.9 of Tsybakov (2009)) Let $d \_ 8$ . Then there exists a subset $\{ w ^ { ( 0 ) } , . . . , w ^ { ( M ) } \}$ of $\Omega = \{ - 1 , \mathrm { \bar { 1 } } \} ^ { d }$ such that $w ^ { ( 0 ) } = ( 1 , 1 , . . . , 1 )$ ,
274
+
275
+ $$
276
+ d i s t ( w ^ { ( j ) } , w ^ { ( k ) } ) \geq \frac { d } { 8 } , \ \forall 0 \leq j < k \leq M a n d M \geq 2 ^ { d / 8 } ,
277
+ $$
278
+
279
+ where $\begin{array} { r } { d i s t ( w , w ^ { \prime } ) = \sum _ { k = 1 } ^ { d } I ( w _ { k } \ne w _ { k } ^ { \prime } ) } \end{array}$ is the Hamming distance between binary sequences $w = ( w _ { 1 } , . . . , w _ { d } )$ and $\boldsymbol { w } ^ { \prime } = \bar { ( } w _ { 1 } ^ { \prime } , . . . , w _ { d } ^ { \prime } )$ .
280
+
281
+ We will also use the following lemma proved in Hanneke & Kpotufe (2019). We would like to mention that some ideas of the proof are similar to those in Hanneke & Kpotufe (2019). However, as discussed in section 2, the problem setting of Hanneke & Kpotufe (2019) is different from that of this work which results in constructing a different set of distributions.
282
+
283
+ Lemma 1 Let $0 < \epsilon < 1 / 2$ and $z \in \{ - 1 , 1 \}$ . Then
284
+
285
+ $$
286
+ \mathcal { D } _ { k l } \bigg ( B e r \big ( 1 / 2 + ( z / 2 ) \cdot \epsilon \big ) , B e r \big ( 1 / 2 - ( z / 2 ) \cdot \epsilon \big ) \bigg ) \le c _ { 0 } \cdot \epsilon ^ { 2 } f o r s o m e c _ { 0 } \le 4 i n d e p ,
287
+ $$
288
+
289
+ Now we are in place to provide the proof of Theorem 1. Let $d = d _ { \mathcal { H } } - 2$ and pick $\pmb { x } _ { - 1 } , \pmb { x } _ { 0 } , . . . , \pmb { x } _ { d }$ from $\chi$ shattered by $\mathcal { H }$ .
290
+
291
+ Next, we construct a family of pairs of distributions $\left( \mathbb { P } _ { w } , \mathbb { Q } _ { w } \right)$ indexed by $w \in \{ - 1 , 1 \} ^ { d }$ where $\{ - 1 , 1 \} ^ { d }$ is the parameter space playing the role of $\Theta$ in Proposition 1. For the following, fix $\epsilon =$ $\begin{array} { r } { \dot { c } _ { 1 } \cdot \epsilon ( \dot { n _ { S } } , n _ { T } , d _ { \mathcal { H } } ^ { \cdot } , \Delta ) \leq \frac { 1 } { 2 } } \end{array}$ for some constant $c _ { 1 }$ to be determined later in proof and $\epsilon ( n _ { S } , n _ { T } , d _ { \mathcal { H } } , \Delta )$ is defined in Theorem 1.
292
+
293
+ Distribution $\mathbb { Q } _ { w } \colon \mathbb { Q } _ { w }$ is composed of a marginal and a conditional distribution, namely $\mathbb { Q } _ { w } =$ $\mathbb { Q } _ { x } ^ { w } \times \mathbb { Q } _ { y | x } ^ { w }$ . We define the marginaldistributions as follows:
294
+
295
+ $$
296
+ \begin{array} { l l l } { \mathbb { Q } _ { x } ^ { w } ( { \pmb x } = { \pmb x } _ { - 1 } ) = \Delta } \\ { \mathbb { Q } _ { x } ^ { w } ( { \pmb x } = { \pmb x } _ { 0 } ) = 0 . 9 9 - \Delta } \\ { \mathbb { Q } _ { \pmb x } ^ { w } ( { \pmb x } = { \pmb x } _ { i } ) = \displaystyle \frac { 1 } { 1 0 0 d } \mathrm { f o r } i = 1 , . . , d } \end{array}
297
+ $$
298
+
299
+ For the conditional distributions:
300
+
301
+ $$
302
+ \begin{array} { r l } & { \mathbb { Q } _ { y | \pmb { x } } ^ { w } ( y = 1 | \pmb { x } = \pmb { x } _ { - 1 } ) = \mathbb { Q } _ { y | \pmb { x } } ^ { w } ( y = 1 | \pmb { x } = \pmb { x } _ { 0 } ) = 1 } \\ & { \mathbb { Q } _ { y | \pmb { x } } ^ { w } ( y = 1 | \pmb { x } = \pmb { x } _ { i } ) = 1 / 2 + ( w _ { i } ) \epsilon \mathrm { ~ f o r ~ } i = 1 , . . , d } \end{array}
303
+ $$
304
+
305
+ Distribution $\mathbb { P } _ { w }$ : $\mathbb { P } _ { w }$ is composed of a marginal and a conditional distribution, namely $\mathbb { P } _ { w } =$ $\mathbb { P } _ { x } ^ { w } \times \mathbb { P } _ { y | x } ^ { w }$ . We define the marginal distributions as follows:
306
+
307
+ $$
308
+ \begin{array} { l l l } { \displaystyle \mathbb { P } _ { \pmb { x } } ^ { w } ( \pmb { x } = \pmb { x } _ { - 1 } ) = \mathbb { P } _ { \pmb { x } } ^ { w } ( \pmb { x } = \pmb { x } _ { 0 } ) = 1 / 2 \big ( 1 - \frac { d } { d + n _ { S } \Delta } \big ) } \\ { \displaystyle \mathbb { P } _ { \pmb { x } } ^ { w } ( \pmb { x } = \pmb { x } _ { i } ) = \frac { 1 } { d + n _ { S } \Delta } \mathrm { ~ f o r ~ } i = 1 , . . , d } \end{array}
309
+ $$
310
+
311
+ For the conditional distributions:
312
+
313
+ $$
314
+ \begin{array} { r l } & { \mathbb { P } _ { y | \pmb { x } } ^ { w } ( y = 1 | \pmb { x } = \pmb { x } _ { - 1 } ) = 0 } \\ & { \mathbb { P } _ { y | \pmb { x } } ^ { w } ( y = 1 | \pmb { x } = \pmb { x } _ { 0 } ) = 1 } \\ & { \mathbb { P } _ { y | \pmb { x } } ^ { w } ( y = 1 | \pmb { x } = \pmb { x } _ { i } ) = 1 / 2 + ( w _ { i } ) \epsilon \mathrm { ~ f o r ~ } i = 1 , . . , d } \end{array}
315
+ $$
316
+
317
+ Verifying $\rho ( \mathbb { P } _ { w } , \mathbb { Q } _ { w } ) \leq \Delta$ : Bayes classifier of the domain generated by $\mathbb { P } _ { w }$ is as follows:
318
+
319
+ $$
320
+ \begin{array} { r l } & { h _ { S } ^ { * } ( { \pmb x } _ { - 1 } ) = 0 } \\ & { h _ { S } ^ { * } ( { \pmb x } _ { 0 } ) = 1 } \\ & { h _ { S } ^ { * } ( { \pmb x } _ { i } ) = 1 \mathrm { i f } w _ { i } = 1 \mathrm { , , o t h e r w i s e } h _ { S } ^ { * } ( { \pmb x } _ { i } ) = 0 \mathrm { f o r } i = 1 , . . , d } \end{array}
321
+ $$
322
+
323
+ Similarly for the domain generated by $\mathbb { Q } _ { w }$ , we have
324
+
325
+ $$
326
+ \begin{array} { r l } & { h _ { T } ^ { * } ( { \pmb x } _ { - 1 } ) = h _ { T } ^ { * } ( { \pmb x } _ { 0 } ) = 1 } \\ & { h _ { T } ^ { * } ( { \pmb x } _ { i } ) = 1 \mathrm { i f } w _ { i } = 1 \mathrm { , o t h e r w i s e } h _ { T } ^ { * } ( { \pmb x } _ { i } ) = 0 \mathrm { f o r } i = 1 , . . , d } \end{array}
327
+ $$
328
+
329
+ So $h _ { S } ^ { * }$ and $h _ { T } ^ { * }$ disagree only on ${ \pmb x } _ { - 1 }$ which implies that
330
+
331
+ $$
332
+ \rho ( \mathbb { P } _ { w } , \mathbb { Q } _ { w } ) = \mathbb { Q } [ h _ { S } ^ { \ast } ( { \pmb x } _ { T } ) \neq y _ { T } ] - \mathbb { Q } [ h _ { T } ^ { \ast } ( { \pmb x } _ { T } ) \neq y _ { T } ] = \Delta
333
+ $$
334
+
335
+ Since we want to derive a lower bound for the minimax risk stated in Theorem 1, among the hypotheses that they agree on $\mathbf { \boldsymbol { x } } _ { i }$ for $i = 1 , . . . , d$ , the hypothesis that outputs ${ \pmb x } _ { - 1 }$ and $\scriptstyle { \pmb x } _ { 0 }$ as 1 results in a smaller target error. Hence, we can restrict ourselves to $\tilde { \mathcal { H } }$ which is the projection of $\mathcal { H }$ onto $\{ - 1 , 1 \} ^ { d }$ with the constraint that $h ( \pmb { x } _ { - 1 } ) = h ( \pmb { x } _ { 0 } ) = 1$ for all $h \in \tilde { \mathcal { H } }$ . Furthermor, for any $w , w ^ { \prime } \in \{ - 1 , 1 \} ^ { d }$ we have
336
+
337
+ $$
338
+ \mathcal { E } _ { T } ( h _ { w ^ { \prime } } ) = \frac { \mathrm { d i s t } ( w , w ^ { \prime } ) } { 1 0 0 d } \cdot \epsilon , ~ \forall ~ h _ { w ^ { \prime } } \in \tilde { \mathcal { H } }
339
+ $$
340
+
341
+ when the target domain is generated by $\mathbb { Q } _ { w }$
342
+
343
+ Reduction to a packing: By using Proposition 2, we can get a subset $\Sigma$ of $\{ - 1 , 1 \} ^ { d }$ whose cardinality is $M \geq 2 ^ { d / 8 }$ and for any $w , w ^ { \prime }$ belonging to $\Sigma$ we have $\operatorname* { l i s t } ( w , w ^ { \prime } ) \geq d / 8$ . Furthermore, for any $w , w ^ { \prime } \in \Sigma$ we have
344
+
345
+ $$
346
+ \mathcal { E } _ { T } ( h _ { w ^ { \prime } } ) \geq \frac { d } { 8 } \cdot \frac { \epsilon } { 1 0 0 d } = \frac { \epsilon } { 8 0 0 }
347
+ $$
348
+
349
+ On the other hand, there is a bijective map between $\{ - 1 , 1 \} ^ { d }$ and elements of $\tilde { \mathcal { H } }$ and any classifier $\hat { h } : \{ { \pmb x } _ { i } \} \{ 0 , 1 \}$ with $\hat { h } ( { \pmb x } _ { - 1 } ) = \hat { h } ( { \pmb x } _ { 0 } ) = 1$ can be reduced to a $w \in \{ - 1 , 1 \} ^ { d }$ . So we can choose $\Sigma$ as the set of indices in Proposition 1 with Hamming distance as the semi-metric and the expression $P _ { w } ( \mathrm { d i s t } ( \hat { w } , w ) > d / 8 )$ translates into $P _ { w } ( \mathcal { E } _ { T } ( h _ { \hat { w } } ) > c \cdot \epsilon )$ .
350
+
351
+ KL divergence bound (part (ii) of Proposition 1): Define $P _ { w } = \mathbb { P } _ { w } ^ { n _ { S } } \times \mathbb { Q } _ { w } ^ { n _ { T } }$ . For any $w , w ^ { \prime } \in \Sigma$ we have
352
+
353
+ $$
354
+ \begin{array} { l } { \mathcal { D } _ { k l } ( P _ { w } | P _ { w ^ { \prime } } ) = n _ { S } \cdot \mathcal { D } _ { k l } ( \mathbb { P } _ { w } | \mathbb { P } _ { w } ^ { \prime } ) + n _ { T } \cdot \mathcal { D } _ { k l } ( \mathbb { Q } _ { w } | \mathbb { Q } _ { w ^ { \prime } } ) } \\ { \displaystyle \quad = n _ { S } \cdot \frac { \mathbb { E } } { \mathbb { P } _ { \alpha } } \mathcal { D } _ { k l } ( \mathbb { P } _ { y | \alpha } ^ { w } | \mathbb { P } _ { y | \alpha } ^ { w ^ { \prime } } ) + n _ { T } \cdot \mathbb { E } \mathcal { D } _ { k l } ( \mathbb { Q } _ { y | x } ^ { w } | \mathbb { Q } _ { y | x } ^ { w ^ { \prime } } ) } \\ { \displaystyle \quad = n _ { S } \cdot \sum _ { i = 1 } ^ { d } \frac { 1 } { d + n _ { S } \Delta } \mathcal { D } _ { k l } ( \mathbb { P } _ { y | x _ { i } } ^ { w } | \mathbb { P } _ { y | x _ { i } } ^ { w ^ { \prime } } ) + n _ { T } \cdot \sum _ { i = 1 } ^ { d } \frac { 1 } { 1 0 0 d } \mathcal { D } _ { k l } ( \mathbb { Q } _ { y | x _ { i } } ^ { w } | \mathbb { Q } _ { y | x _ { i } } ^ { w ^ { \prime } } ) } \\ { \displaystyle \quad \leq n _ { S } \cdot \frac { d } { d + n _ { S } \Delta } c _ { 0 } \epsilon ^ { 2 } + n _ { T } \cdot \frac { 1 } { 1 0 0 } c _ { 0 } \epsilon ^ { 2 } } \\ { \displaystyle \quad \leq c _ { 0 } c _ { 1 } ^ { 2 } . } \end{array}
355
+ $$
356
+
357
+ if $\begin{array} { r } { c _ { 1 } < \frac { 1 } { 6 } } \end{array}$ then $c _ { 0 } c _ { 1 } ^ { 2 } < \frac { 1 } { 8 }$ and we can apply Proposition 1.
358
+
359
+ Proof of Theorem 2 is similar to that of Theorem 1. However, we construct different target and source probability distributions.
360
+
361
+ Let $d \ = \ d _ { \mathcal { H } } \ - \ N - \ 1$ and pick $x _ { - M } , . . . , x _ { 0 } , x _ { 1 } , . . . , x _ { d }$ from $\chi$ shattered by $\mathcal { H }$ . Then we construct a family of distributions $( \mathbb { P } _ { w } ^ { ( 1 ) } , . . . , \mathbb { P } _ { w } ^ { ( N ) } , \mathbb { Q } _ { w } )$ indexed by $w ~ \in ~ \{ - 1 , 1 \} ^ { d }$ . Let $\epsilon =$ $c _ { 1 } \cdot \epsilon ( n _ { S _ { 1 } } , . . . , n _ { S _ { N } } , n _ { T } , d _ { \mathcal { H } } , \Delta _ { 1 } , . . . , \Delta _ { N } )$ for some constant $c _ { 1 } < 1$ to be determined later in proof. Furthermore, without loss of generality assume that $1 \ge \Delta _ { 1 } \ge \Delta _ { 2 } \ge . . . \ge \Delta _ { N } \ge 0$ .
362
+
363
+ Distribution $\mathbb { Q } _ { w } \colon \mathbb { Q } _ { w }$ is composed of a marginal and a conditional distribution, namely $\mathbb { Q } _ { w } =$ $\mathbb { Q } _ { x } ^ { w } \times \mathbb { Q } _ { y | x } ^ { w }$ . We define the marginal distributions as follows:
364
+
365
+ $$
366
+ \begin{array} { l } { { \mathbb Q } _ { x } ^ { w } ( { \pmb x } = { \pmb x } _ { - i } ) = \Delta _ { i } - \Delta _ { i + 1 } \mathrm { ~ f o r ~ } i = 1 , . . . , N - 1 \mathrm { ~ a n d ~ } \mathbb Q _ { { \pmb x } } ^ { w } ( { \pmb x } = { \pmb x } _ { - N } ) = \Delta _ { N } } \\ { { \mathbb Q } _ { { \pmb x } } ^ { w } ( { \pmb x } = { \pmb x } _ { 0 } ) = 0 . 9 9 - \Delta _ { 1 } } \\ { { \mathbb Q } _ { { \pmb x } } ^ { w } ( { \pmb x } = { \pmb x } _ { i } ) = \displaystyle \frac 1 { 1 0 0 d } \mathrm { ~ f o r ~ } i = 1 , . . , d } \end{array}
367
+ $$
368
+
369
+ For the conditional distributions:
370
+
371
+ $$
372
+ \begin{array} { r l } & { \mathbb { Q } _ { y | \pmb { x } } ^ { w } ( y = 1 | \pmb { x } = \pmb { x } _ { - i } ) = 1 \mathrm { f o r } i = 1 , . . . , N } \\ & { \mathbb { Q } _ { y | \pmb { x } } ^ { w } ( y = 1 | \pmb { x } = \pmb { x } _ { 0 } ) = 1 } \\ & { \mathbb { Q } _ { y | \pmb { x } } ^ { w } ( y = 1 | \pmb { x } = \pmb { x } _ { i } ) = 1 / 2 + ( w _ { i } ) \epsilon \mathrm { f o r } i = 1 , . . . , d } \end{array}
373
+ $$
374
+
375
+ Distribution $\mathbb { P } _ { w } ^ { ( i ) } \colon \mathbb { P } _ { w } ^ { ( i ) }$ is composed of a marginal and a conditional distribution, namely $\mathbb { P } _ { w } ^ { ( i ) } =$ $\mathbb { P } _ { \pmb { x } } ^ { w ( i ) } \times \mathbb { P } _ { \pmb { y } | \pmb { x } } ^ { w ( i ) }$ x(i). We define the marginal distributions as follows:
376
+
377
+ $$
378
+ \begin{array} { l l } { \displaystyle \mathbb { P } _ { \pmb { x } } ^ { w ( i ) } ( \pmb { x } = \pmb { x } _ { - j } ) = \frac { 1 } { N + 1 } \big ( 1 - \frac { d } { d + n _ { S _ { i } } \Delta _ { i } } \big ) \mathrm { ~ f o r ~ } j = 1 , . . . , N } \\ { \displaystyle \mathbb { P } _ { \pmb { x } } ^ { w ( i ) } ( \pmb { x } = \pmb { x } _ { 0 } ) = \frac { 1 } { N + 1 } \big ( 1 - \frac { d } { d + n _ { S _ { i } } \Delta _ { i } } \big ) } \\ { \displaystyle \mathbb { P } _ { \pmb { x } } ^ { w ( i ) } ( \pmb { x } = \pmb { x } _ { j } ) = \frac { 1 } { d + n _ { S _ { i } } \Delta _ { i } } \mathrm { ~ f o r ~ } j = 1 , . . , d } \end{array}
379
+ $$
380
+
381
+ For the conditional distributions:
382
+
383
+ $$
384
+ \begin{array} { r l } & { \mathbb { P } _ { y | x } ^ { w } ( y = 1 | x = x _ { - j } ) = 0 \mathrm { i f } j \geq i , \mathrm { o t h e r w i s e } \mathbb { P } _ { y | x } ^ { w } ( y = 1 | x = x _ { - j } ) = 1 \mathrm { f o r } j = 1 , . . . } \\ & { \mathbb { P } _ { y | x } ^ { w } ( y = 1 | x = x _ { 0 } ) = 1 } \\ & { \mathbb { P } _ { y | x } ^ { w } ( y = 1 | x = x _ { j } ) = 1 / 2 + ( w _ { j } ) \epsilon \mathrm { f o r } j = 1 , . . . , d } \end{array}
385
+ $$
386
+
387
+ Verifying $\rho ( \mathbb { P } _ { w } ^ { ( i ) } , \mathbb { Q } _ { w } ) \leq \Delta _ { i }$
388
+
389
+ Bayes classifier of the domain generated by $\mathbb { P } _ { w } ^ { ( i ) }$ is as follows:
390
+
391
+ $$
392
+ \begin{array} { r l } & { h _ { S _ { i } } ^ { * } ( \boldsymbol { x } _ { - j } ) = 0 \mathrm { i f } j \geq i , \mathrm { o t h e r w i s e } h _ { S _ { i } } ^ { * } ( \boldsymbol { x } _ { - j } ) = 1 \mathrm { f o r } j = 1 , . . . , N } \\ & { h _ { S _ { i } } ^ { * } ( \boldsymbol { x } _ { 0 } ) = 1 } \\ & { h _ { S _ { i } } ^ { * } ( \boldsymbol { x } _ { j } ) = 1 \mathrm { i f } w _ { j } = 1 , \mathrm { o t h e r w i s e } h _ { S _ { i } } ^ { * } ( \boldsymbol { x } _ { j } ) = 0 \mathrm { f o r } j = 1 , . . , d } \end{array}
393
+ $$
394
+
395
+ Similarly for the domain generated by $\mathbb { Q } _ { w }$ , we have
396
+
397
+ $$
398
+ \begin{array} { r l } & { h _ { T } ^ { * } ( \pmb { x } _ { - j } ) = 1 \mathrm { f o r } j = 1 , . . . , N } \\ & { h _ { T } ^ { * } ( \pmb { x } _ { 0 } ) = 1 } \\ & { h _ { T } ^ { * } ( \pmb { x } _ { j } ) = 1 \mathrm { i f } w _ { j } = 1 , \mathrm { o t h e r w i s e } h _ { T } ^ { * } ( \pmb { x } _ { j } ) = 0 \mathrm { f o r } j = 1 , . . , d } \end{array}
399
+ $$
400
+
401
+ So $h _ { S _ { i } } ^ { * }$ and $h _ { T } ^ { * }$ disagree on $\pmb { x } _ { - i } , . . , \pmb { x } _ { - N }$ which implies that
402
+
403
+ $$
404
+ \rho ( \mathbb { P } _ { w } ^ { ( i ) } , \mathbb { Q } _ { w } ) = \mathbb { Q } [ h _ { S _ { i } } ^ { \ast } ( \pmb { x } _ { T } ) \neq y _ { T } ] - \mathbb { Q } [ h _ { T } ^ { \ast } ( \pmb { x } _ { T } ) \neq y _ { T } ] = \Delta _ { i }
405
+ $$
406
+
407
+ With the same argument we used in the proof of Theorem 1 we can restrict ourselves to $\tilde { \mathcal { H } }$ which is the projection of $\mathcal { H }$ with the constraint that $h ( \pmb { x } _ { - N } ) = \ldots = h ( \pmb { x } _ { - 1 } ) = h ( \pmb { x } _ { 0 } ) = 1$ for all $h \in \tilde { \mathcal { H } }$ .
408
+
409
+ The rest of the proof is exactly the same except the part regarding the KL divergence bound.
410
+
411
+ KL divergence bound: Define $P _ { w } = \mathbb { P } _ { w } ^ { ( 1 ) ^ { n _ { S _ { 1 } } } } \times \ldots \times \mathbb { P } _ { w } ^ { ( N ) ^ { n _ { S _ { N } } } } \times \mathbb { Q } _ { w } ^ { n _ { T } } .$ 1 × ... × P(N )w nSN ×
412
+
413
+ $$
414
+ \begin{array} { r l } { { \operatorname* { P } _ { k l } ( P _ { w } | P _ { w ^ { \prime } } ) = \sum _ { j = 1 } ^ { N } n _ { S _ { j } } \cdot P _ { k l } ( \mathbb { P } _ { w } ^ { ( j ) } | \mathbb { P } _ { w ^ { \prime } } ^ { ( j ) } ) + n _ { I } \cdot \mathcal { P } _ { k l } ( \mathbb { Q } _ { w } | \mathbb { Q } _ { w ^ { \prime } } ) } } \\ & { = \sum _ { j = 1 } ^ { N } n _ { S _ { j } } \cdot \mathbb { E } _ { \mathbb { P } } \mathbb { P } _ { k l } ( \mathbb { P } _ { y | z } ^ { w } ) | \mathbb { P } _ { y | z } ^ { w ^ { \prime } ( j ) } ) + n _ { T } \cdot \mathbb { E } _ { \mathbb { P } } \mathcal { P } _ { k l } ( \mathbb { Q } _ { y | z } ^ { w } | \mathbb { Q } _ { y | z } ^ { n ^ { \prime } } ) } \\ & { = \sum _ { j = 1 } ^ { N } n _ { S _ { j } } \cdot \displaystyle \sum _ { \mathrm { i } = 1 } ^ { G } \frac { 1 } { d + n _ { S _ { j } } \Delta _ { j } } \mathcal { D } _ { k l } ( | \mathbb { P } _ { y | z } ^ { w } ( \cdot ) ( i ) | \mathbb { P } _ { y | z _ { h } } ^ { n ^ { \prime } } ( \cdot ) + n _ { T } \cdot \displaystyle \sum _ { \mathrm { i } = 1 } ^ { d } \frac { 1 } { 1 0 0 d } \mathcal { D } _ { k l } ( \mathbb { Q } _ { y | z _ { h } } ^ { w } | \mathbb { Q } _ { y | z _ { h } } ^ { n ^ { \prime } } ) } \\ & { \leq \displaystyle \sum _ { j = 1 } ^ { N } n _ { S _ { j } } \cdot \frac { d } { d + n _ { S _ { j } } \Delta _ { j } } c _ { 0 } e ^ { 2 } + n _ { T } \cdot \frac { 1 } { 1 0 0 } c _ { 0 } e ^ { 2 } } \\ & { \leq \displaystyle \sum _ { j = 1 } ^ { N } n _ { S _ { j } } \cdot \frac { d } { d + n _ { S _ { j } } \Delta _ { j } } c _ { 0 } e ^ { 2 } + n _ { T } \cdot \frac { 1 } { 1 0 0 } c _ { 0 } e ^ { 2 } } \\ & { \leq c _ { 0 } c _ { j } ^ { 2 } . d } \end{array}
415
+ $$
416
+
417
+ for small enough $c _ { 1 }$ we can apply Proposition 1.
418
+
419
+ # 7.3 ADDITIONAL EXPERIMENTAL RESULTS
420
+
421
+ In section 5 we fix number of source samples and vary the number of target samples. Here in order to investigate the effect of source samples on the target generalization error, we fix the number of target samples at $\cdot$ and vary the number of source samples. Fig 5 depicts the theoretical lower bounds along with the upper bounds obtained by empirical risk minimization for image classifications. We use the same source/target pairs as used in section 5.2. Fig 5 demonstrates that Source1 is more helpful in reducing the target generalization error because it has a low distance from the target. Furthermore, it shows that increasing the number of source samples is useful up to a point and beyond that point the error saturates and does not decrease further as discussed in Remark 10.
422
+
423
+ ![](images/68afa0a6eca3c2060650667d2fbccf678290c955da93e7e8eaee731207bf9f06.jpg)
424
+ Figure 5: Depicts the lower bounds along with the upper bounds obtained via weighted empirical risk minimization. In this setting the number of target samples is fixed at $n _ { T } = 3$
md/dev/-NOQJw5z_KY/-NOQJw5z_KY.md ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Semantic Exploration from Language Abstractions and Pretrained Representations
2
+
3
+ Allison C. Tam
4
+ DeepMind
5
+ London, UK
6
+ actam@deepmind.com
7
+ Neil C. Rabinowitz
8
+ DeepMind
9
+ London, UK
10
+ ncr@deepmind.com
11
+ Andrew K. Lampinen
12
+ DeepMind
13
+ London, UK
14
+ lampinen@deepmind.com
15
+ Nicholas A. Roy
16
+ DeepMind
17
+ London, UK
18
+ nroy@deepmind.com
19
+ Stephanie C. Y. Chan
20
+ DeepMind
21
+ London, UK
22
+ scychan@deepmind.com
23
+ DJ Strouse
24
+ DeepMind
25
+ London, UK
26
+ strouse@deepmind.com
27
+ Jane X. Wang⇤
28
+ DeepMind
29
+ London, UK
30
+ wangjane@deepmind.com
31
+ Andrea Banino⇤
32
+ DeepMind
33
+ London, UK
34
+ abanino@deepmind.com
35
+
36
+ Felix Hill⇤ DeepMind London, UK felixhill@deepmind.com
37
+
38
+ # Abstract
39
+
40
+ Effective exploration is a challenge in reinforcement learning (RL). Novelty-based exploration methods can suffer in high-dimensional state spaces, such as continuous partially-observable 3D environments. We address this challenge by defining novelty using semantically meaningful state abstractions, which can be found in learned representations shaped by natural language. In particular, we evaluate vision-language representations, pretrained on natural image captioning datasets. We show that these pretrained representations drive meaningful, task-relevant exploration and improve performance on 3D simulated environments. We also characterize why and how language provides useful abstractions for exploration by considering the impacts of using representations from a pretrained model, a language oracle, and several ablations. We demonstrate the benefits of our approach with on- and off-policy RL algorithms and in two very different task domains— one that stresses the identification and manipulation of everyday objects, and one that requires navigational exploration in an expansive world. Our results suggest that using language-shaped representations could improve exploration for various algorithms and agents in challenging environments.
41
+
42
+ # 1 Introduction
43
+
44
+ Exploration is one of the central challenges of reinforcement learning (RL). A popular way to increase an agent’s tendency to explore is to augment trajectories with intrinsic rewards for reaching novel environment states. However, the success of this approach depends critically on which states are considered novel, which can in turn depend on how environment states are represented.
45
+
46
+ The literature on novelty-driven exploration describes several approaches to deriving state representations $\mathbb { I } \mathbb { I }$ . One popular method employs random features and represents the state by embedding the visual observation with a fixed, randomly initialized target network [Random Network Distillation; $\boxed { 6 }$ . Another method uses learned visual features, taken from an inverse dynamics model [Never Give Up; $\textcircled { 3 }$ . These approaches work well in classic 2D environments like Atari, but it is less clear whether they are as effective in high-dimensional, partially-observable settings such as 3D environments. For instance, in 3D settings, different viewpoints of the same scene may map to distinct visual states/features, despite being semantically similar. The difficulty of identifying a good mapping between visual state and feature space is exacerbated by the fact that useful state abstractions are highly task dependent. For example, a task involving tool use requires object-affordance abstractions, whereas navigation does not. Thus, acquiring state representations that support effective exploration is a chicken-and-egg problem—knowing whether two states should be considered similar requires the type of understanding that an agent can only acquire after effectively exploring its environment.
47
+
48
+ To overcome these challenges, we propose giving agents access to prior knowledge during training, in the form of abstractions derived from large vision-language models [e.g. 41] that are pretrained on image captioning data. We use these pretrained models to derive a intrinsic reward that reflects meaningful novelty. We hypothesize that representations acquired by vision-language pretraining drive effective, semantic exploration in 3D environments, because the representations are shaped by the unique abstract nature of natural language.
49
+
50
+ Several aspects of natural language suggest that it could be useful to direct novelty-based exploration. First, language is inherently abstract: language links superficially distinct, but causally-related situations by describing them similarly, and contrasts between causally-distinct states by describing them differently, thus outlining useful concepts $\overline { { \mathbb { B } \mathcal { 9 } } } \overline { { \mathbb { B } \mathcal { 8 } } } \Vert$ . Second, humans use language to communicate important information efficiently, without overspecifying [20, 21]. Thus, human language omits distracting irrelevant information and focuses on important aspects of the world. For example, it is often observed that an agent rewarded for seeking novel experience would be attracted forever to a TV with uncontrollable and unpredictable random static [7]. However, a human would likely caption this scene “a TV with no signal” regardless of the particular pattern; thus an agent ex
51
+
52
+ ![](images/92626be4d32e49ea3cb2d5fd609d0e4efd4bace02c6c7dd642547205afd2be97.jpg)
53
+ Figure 1: Navy dashed lines delineate semantically meaningful states. By using representations that align well with these boundaries (i.e. language), then agents more effectively explore the wider state space (orange trajectory). If the representations do not reflect these boundaries and instead are amenable to visual noise (i.e. different colors, viewpoints, etc.), then agents may only focus on a visually novel, yet narrow subset of states (red trajectory).
54
+
55
+ ploring with language abstractions would quickly leave the TV behind. Figure 1 shows another conceptual example of how language abstractions can accelerate exploration.
56
+
57
+ We first perform motivating proof-of-concept experiments using a language oracle. We show that language is a useful abstraction for exploration not only because it coarsens the state space, but also because it coarsens the state space in a way that reflects the semantics of the environment. We then demonstrate that our results scale to environments without a language oracle using pretrained vision encoders, which are only supervised with language during pretraining. This work strives to enhance the representations used in novelty-based exploration, rather than compare various exploration methods.
58
+
59
+ We consider two popular novelty-based exploration methods from the literature, Never Give Up (NGU; Badia et al. $\pmb { \mathbb { B } } \mathbf { \mathbb { I } }$ ) and Random Network Distillation (RND; Burda et al. $\mathbb { I I } ^ { \dagger }$ ), and compare them to their language-augmented variants, Lang-NGU/LSE-NGU and Lang-RND. We evaluate performance and sample efficiency on object manipulation, search, and navigation tasks in two challenging 3D environments simulated in Unity: Playroom (a house containing toys and furniture) and City (a large-scale urban setting). Our results show that language-based exploration with pretrained visionlanguage representations improves sample efficiency on Playroom tasks by $1 8 - 7 0 \%$ . It also doubles
60
+
61
+ ![](images/03a12ae800ef2fbde40a9e6f2edf25ce039ef43dec426231e17d61df9352749c.jpg)
62
+ (b) Example instances of $O _ { V }$ and $O _ { L }$ from City. Many different scenes can be associated with the same caption.
63
+
64
+ Figure 2: Visual observations from the environment and example captions generated by the language oracle. Appendix Figure $\boxed { \mathsf { S 4 } }$ contains more example captions.
65
+
66
+ the visited areas in City, compared to baseline methods. We show that language-based exploration is effective for both on-policy (IMPALA $\mathbb { I I I }$ ) and off-policy (R2D2 $\pm \mathbb { Z } 5 \mathbb { I } .$ ) agents.
67
+
68
+ # 2 Related Work
69
+
70
+ Exploration in RL Classical exploration strategies include $\epsilon$ -greedy action selection $\pmb { \Vert 5 \bot }$ , statecounting [49, 4, 32, 30, 3], curiosity driven exploration $\pm \sharp$ , and intrinsic motivation methods $\left[ \left[ 3 6 \right] \right]$ . Our work is part of this last class of methods, where the agent is given an intrinsic reward for visiting diverse states over time $\begin{array} { r l } { { \bigl [ \bigl | 3 5 \bigr | \bigr ] } } \end{array}$ . Intrinsic rewards can be derived from various measures: novelty [43, 55, 6, 56], prediction-error [38, 3], ensemble disagreement [11, 39, 48, 46, 18, 50], or information gain $\mathbb { \left[ \left. 2 3 \right] \right. }$ . One family of methods gives intrinsic reward for following a curriculum of goals [8, 12, 40]. Others use novelty measures to identify interesting states from which they can perform additional learning [16, 54]. These methods encourage exploration in different ways, but they all rely on visual state representations that are learned jointly with the policy. Although we focus on novelty-based intrinsic reward and demonstrate the benefits of language in NGU and RND, our methodology is relatively agnostic to the exploration method. We suggest that many other exploration methods could be improved by using language abstractions and pretrained embeddings to represent the state space.
71
+
72
+ Pretraining representations for RL Pretraining has been used in RL to improve the representations of the policy network. Self-supervised representation learning techniques distill knowledge from external datasets to produce downstream features that are helpful in virtual environments [15, 53]. Some recent work shows benefits from pretraining on more general, large-scale datasets. Pretrained CLIP features have been used in a number of recent robotics papers to speed up control and navigation tasks. These features can condition the policy network $\bar { \lVert 2 6 rVert }$ , or can be fused throughout the visual encoder to integrate semantic information about the environment $\pmb { \Vert 3 7 } \Vert$ . The goal of these works is to improve perception in the policy. Pretrained language models can also provide useful initializations for training policies to imitate offline trajectories $[ \bar { 1 } 2 , \bar { 1 } 2 7 ]$ . These successes demonstrate that large pretrained models contain prior knowledge that can be useful for RL. While the existing literature uses pretrained embeddings directly in the agent, we instead allow the policy network to learn from scratchm and only utilize pretrained embeddings to guide exploration during training (Figure $^ { \mathbf { \boldsymbol { S 2 } } ) }$ We imagine that future work may benefit from combining both approaches.
73
+
74
+ Language for exploration Some recent works have used language to guide agent learning, by either using language subgoals for exploration/planning or providing task-specific reward shaping [47, 33, 13, 19]. Schwartz et al. [45] use a custom semantic parser for VizDoom and show that representing states with language, rather than vision, leads to faster learning by simplifying policy inputs. Chaplot et al. $\mathbb { \ m }$ tackle navigation in 3D by constructing a semantic map of the environment from pretrained SLAM modules, language-defined object categories, and agent location. This approach lends itself to navigation, but it is unclear how it would extend easily to more generic settings or other types of tasks, such as manipulation. Work concurrent to ours by Mu et al. [34] shows how language, in the form of hand-crafted BabyAI annotations, can help improve exploration in 2D environments. These works demonstrate the value of language abstractions: the ability to ignore extraneous noise and highlight important environment features. However, these prior methods rely on environment-specific semantic parsers or annotations, which may limit the settings to which they can be applied. In contrast, by exploiting powerful pretrained vision-language models, our approach can be applied to any visually-naturalistic environment, including 3D settings, which have not been widely studied in prior exploration work. We additionally do not require any language from the environment itself. Our method could even potentially improve exploration for physical robots, but we leave that for future work.
75
+
76
+ # 3 Method
77
+
78
+ We consider a goal-conditioned Markov decision process defined by a tuple $( S , \mathcal { A } , \mathcal { G } , P , R _ { e } , \gamma )$ , where $s$ is the state space, $\mathcal { A }$ is the action space, $\mathcal { G }$ is the goal space, $P : \mathcal { S } \times \mathcal { A } \mathcal { S }$ specifies the environment dynamics, $R _ { e } : \mathcal { S } \times \mathcal { G } R _ { e }$ is the extrinsic reward, and $\gamma$ is the discount factor. State $\mathbf { s _ { t } }$ is presented to the agent as a visual observation $O _ { V }$ . In some cases, in order to calculate intrinsic reward, we use a language oracle $\mathcal { O } : \mathcal { S } \mathcal { L }$ that provides natural language descriptions of the state, $O _ { L }$ . Note that $O _ { L }$ is distinct from the language instruction $g \in { \mathcal { G } }$ , which is sampled from a goal distribution at the start of an episode—the agent never observes $O _ { L }$ . We later remove the need for a language oracle by using pretrained models.
79
+
80
+ We use goal-conditioned reinforcement learning to produce a policy imizes the expected re $\pi _ { g } ( \cdot \ | \ O _ { V } )$ $\mathbb { E } [ \sum _ { t = 0 } ^ { H } \gamma ^ { t } ( r _ { t } ^ { e } +$ $\beta r _ { t } ^ { i } ) ]$ , where $H$ is the horizon, $\boldsymbol { r } _ { t } ^ { e }$ is the extrinsic reward, $r _ { t } ^ { i }$ is the intrinsic reward, and $\beta$ is a tuned hyperparameter. The intrinsic reward is goal-agnostic and is computed with access to either $O _ { V }$ or $O _ { L }$ . Note that neither $O _ { L }$ nor pretrained embeddings are used by the policy, and thus we only use them during training to compute the intrinsic reward (Figure $\textcircled { 3 }$
81
+
82
+ Our approach builds on two popular exploration algorithms: Never Give Up (NGU; Badia et al. $\pmb { \mathbb { B } } \mathbf { l }$ ) and Random Network Distillation (RND; Burda et al. $\mathbb { H }$ ). These algorithms were chosen to demonstrate the value of language under two different exploration paradigms. While both methods reward visiting novel states, they differ on several dimensions: the novelty horizon (episodic versus lifetime), how the history of past visited states is retained (non-parametric versus parametric), and how states are represented (learned controllable states versus random features).
83
+
84
+ ![](images/885a1efefd0fd983dcbbc79e2507cb34d9c2ec38adcba084a69fc31b5c336be5.jpg)
85
+ Figure 3: The agent is trained from scratch using RL to optimize extrinsic and intrinsic reward. It acts using the image observation $O _ { V }$ and goal $g$ . During training, the novelty-based intrinsic reward is calculated using an auxiliary component that does not share parameters with the agent (dashed box). The auxiliary component may incorporate a pretrained language (pictured above) or image encoder, which may respectively require $O _ { L }$ or $O _ { V }$ . The latter does not rely on language provided by the environment. See Figure S2 for more details.
86
+
87
+ # 3.1 Never Give Up (NGU)
88
+
89
+ To more clearly isolate our impact, we focus only on the episodic novelty component of the NGU agent [3]. State representations along the trajectory are written to a non-parametric episodic memory buffer. The intrinsic reward reflects how novel the current state is relative to the states visited so far in the episode. Novelty is a function of the L2 distances between the current state and the $k$ -nearest neighbor representations stored in the memory buffer. Intrinsic reward is higher for larger distances.
90
+
91
+ Full details can be found in the original paper; however, we make two key simplifications. While Badia et al. $\pmb { \mathbb { B } } \|$ proposes learning a family of policy networks that are capable of different levels of exploration, we train one policy network that maximizes reward $r ~ = ~ r _ { e } + \beta r _ { i }$ for a fixed hyperparameter $\beta$ . We also fix the long-term novelty modulator $\alpha$ to be 1, essentially removing it.
92
+
93
+ The published baseline method, which we refer to as Vis-NGU, uses a controllable state taken from an inverse dynamics model. The inverse dynamics model is trained jointly with the policy, but the two networks do not share any parameters.
94
+
95
+ Table 1: Summary of NGU variants.
96
+
97
+ <table><tr><td>Name</td><td>Embedding Type</td><td>Required Input</td></tr><tr><td>Vis-NGU</td><td>Controllable State</td><td>Vision</td></tr><tr><td rowspan="3">Lang-NGU</td><td>BERT</td><td>Language</td></tr><tr><td>CLIPtext</td><td>Language</td></tr><tr><td>ALMtext</td><td>Language</td></tr><tr><td rowspan="3">LSE-NGU</td><td>CLIPimage</td><td>Vision</td></tr><tr><td>ALMimage</td><td>Vision</td></tr><tr><td></td><td></td></tr></table>
98
+
99
+ Table 2: Summary of family of RND-inspired methods. Intrinsic reward is derived from the prediction error between the trainable network and frozen target function.
100
+
101
+ <table><tr><td>Name</td><td>Trainable Network</td><td>Target Function</td></tr><tr><td>Vis-RND</td><td>fv:Ov→Rk</td><td>randomly initialized,fixed f</td></tr><tr><td>ND</td><td>f{v,L} :O{v,L}→Rk</td><td>pretrained ALM{image, text}</td></tr><tr><td>Lang-RND</td><td>fL:OL→R</td><td>randomly initialized,fixed f</td></tr><tr><td>LD</td><td>fc:Ov→OL</td><td>OL from language oracle</td></tr></table>
102
+
103
+ The intrinsic reward relies on directly comparing state representations from the buffer, so our approach focuses on modifying the embedding function to influence exploration (Table 1). LangNGU uses a frozen pretrained language encoder to embed the oracle caption $O _ { L }$ . We compare language embeddings from BERT $\check { \mathbb { E } } \check { 4 } \check { \mathbb { I } }$ , CLIP [41], Small-ALM, and Med-ALM. The ALMs (ALign Models) are trained with a contrastive loss on the ALIGN dataset $[ [ 2 4 ]$ . Small-ALM uses a 26M parameter ResNet-50 image encoder $\pmb { \mathbb { Z } } 2 \mathbf { l }$ ; Med-ALM uses a 71M parameter NFNet [5]. The language backbones are based on BERT and are all in the range of 70-90M parameters. We do not finetune on environment-specific data; this preserves the real world knowledge acquired during pretraining and demonstrates its benefit without requiring any environment-specific captions.
104
+
105
+ LSE-NGU does not use the language oracle. Instead, it uses a frozen pretrained image encoder to embed the visual observation $O _ { V }$ . We use the image encoder from CLIP or ALM, which are trained on captioning datasets to produce outputs that are close to the corresponding language embeddings. The human-generated captions structure the visual embedding space to reflect features most pertinent to humans and human language $\pmb { \mathbb { B } } \mathbf { \mathbb { 1 } }$ , so the resulting representations can be thought of as Language Supervised Embeddings (LSE). The primary benefit of LSE-NGU is that it can be applied to environments without a language oracle or annotations. CLIP and ALM are trained on real-world data, so they would work best on realistic 3D environments. However, we imagine that in future work the pretraining process or dataset could be tailored to maximize transfer to a desired target environment.
106
+
107
+ # 3.2 Random Network Distillation (RND)
108
+
109
+ Our RND-inspired family of methods rewards lifetime novelty. Generically, the intrinsic reward is derived from the prediction error between a trainable network and some target value generated by a frozen function (Table $\bigstar \bigstar$ . The trainable network is learned jointly with the policy network, although they do not share any parameters. As the agent trains over the course of its lifetime, the prediction error for frequently-visited states decreases, and the associated intrinsic reward consequently diminishes. Intuitively, the weights of the trainable network implicitly store the state visitation counts.
110
+
111
+ For clarity, we refer to the baseline published by Burda et al. $\mathbb { \left[ \bigcirc \right] }$ as Vis-RND. The trainable network $f _ { V } : O _ { V } { \stackrel { \cdot } { \to } } \mathbb { R } ^ { k }$ maps the visual state to random features. The random features are produced by a fixed, randomly initialized network $\hat { f _ { V } }$ . Both $f _ { V }$ and $\hat { f _ { V } }$ share the same architecture: a ResNet followed by a MLP. The intrinsic reward is the mean squared error $\lVert f _ { V } ( O _ { V } ) - \hat { f _ { V } } ( O _ { V } ) \rVert ^ { 2 }$ .
112
+
113
+ In network distillation (ND), the target function is not random, but is instead a pretrained text or image encoder from CLIP/ALM. The trainable network $f$ learns to reproduce the pretrained representations. To manage inference time, $f$ is a simpler network than the target (see Appendix A.2). The intrinsic loss is the mean squared error between $f$ and the large pretrained network. Like the respective Lang-NGU and LSE-NGU counterparts, text-based ND requires a language oracle, but image-based ND does not.
114
+
115
+ In Section $5 . 1$ we compare against two additional methods to motivate why language is a useful abstraction. The first, Lang-RND, is a variant in which the trainable network $f _ { L } : O _ { L } \stackrel { \smile } { \to } \mathbb { R } ^ { k }$ maps the oracle caption to random features. The intrinsic reward is the mean squared error between the outputs of $f _ { L }$ and fixed $\hat { f } _ { L }$ with random initialization. Both $f _ { L }$ and $\hat { f } _ { L }$ networks are of the same architecture.
116
+
117
+ The second method, language distillation $\mathbf { \left( L D \right) }$ , is loosely inspired by RND in that the novelty signal comes from a prediction error. However, instead of learning to produce random features, the trainable network learns to caption the visual state, i.e. $f _ { C } : O _ { V } \to O _ { L }$ . The network architecture consists of a CNN encoder and LSTM decoder. The intrinsic reward is the negative log-likelihood of the oracle caption under the trainable model $f _ { C }$ . In LD, the exploration dynamics not only depend on how frequently states are visited but also the alignment between language and the visual world. We test whether this caption-denoted alignment is necessary for directing semantic exploration by comparing LD to a variant with shuffled image-language alignment (S-LD) in Section 5.1.
118
+
119
+ # 4 Experimental Setup
120
+
121
+ # 4.1 Environments
122
+
123
+ Previous exploration work benchmarked algorithms on video games, such as 2D grid-world MiniHack and Montezuma’s Revenge, or 3D first-person shooter Vizdoom. In this paper, we focus on first-person Unity-based 3D environments that are meant to mimic familiar scenes from the real world (Figure 2).
124
+
125
+ Playroom Our first domain, Playroom [1, 52], is a randomly-generated house containing everyday household items (e.g. bed, bathtub, tables, chairs, toys). The agent’s action set consists of 46 discrete actions that involve locomotion primitives and object manipulation, such as holding and rotating.
126
+
127
+ We study two settings in Playroom. In the first setting, the agent is confined to a single room with 3-5 objects and is given a lift or put instruction. At the start of an episode, the set of objects are sampled from a larger set of everyday objects (i.e. a candle, cup, hairdryer). Object colors and sizes are also randomized, adding superficial variance to different semantic categories. The instructions take the form: "Lift a <object>" or "Put a <object> on a {bed, tray}". With a lift goal, the episode ends with reward 1 or 0 whenever any object is lifted. With a put goal, the episode ends with reward 1 when the condition is fulfilled. This setting tests spatial rearrangement skills.
128
+
129
+ In the second setting, the agent is placed in a house with 3-5 different rooms, and is given a find instruction of the form "Find a {teddy bear, rubber duck}". Every episode, the house is randomly generated with the teddy and duck hidden amongst many objects, furniture, and decorations. The target objects can appear in any room— either on the floor, on top of tables, or inside bookshelves. The agent is randomly initialized and can travel throughout the house and freely rearrange objects. The episode ends with reward 1 when the agent pauses in front of the desired object. The find task requires navigation/search skills and tests the ability to ignore the numerous distractor objects.
130
+
131
+ City Our second domain, City, is an expansive, large-scale urban environment. Each episode, a new map is generated; shops, parks, and buildings are randomly arranged in city blocks. Daylight is simulated, such that the episode starts during the morning and ends at nighttime. The agent is randomly initialized and is instructed to “explore the city.” It is trained to maximize its intrinsic reward and can take the following actions: move_{forward,backward,left,right}, look_{left,right}, and move_forward_and_look_{left,right}. We divide up the map into a $3 2 \times 3 2$ grid and track how many unique bins are visited in an episode.
132
+
133
+ Additionally, City does not provide explicit visual or verbal signage to disambiguate locations. As such, systematic exploration is needed to maximize coverage. In contrast to Playroom, City tests long horizon exploration. A Playroom episode lasts only 600 timesteps, whereas a City episode lasts 11,250 and requires hundreds of timesteps to fully traverse the map even once. The City covers a 270-by-270 meter square area, which models a 2-by-2 grid of real world blocks.
134
+
135
+ # 4.2 Captioning Engine
136
+
137
+ We equip the environment with a language oracle that generates language descriptions of the scene, $O _ { L }$ , based on the Unity state, $s$ (Figure $2$ ). In Playroom, the caption describes if and how the agent interacts with objects and lists what is currently visible to it. In City, $O _ { L }$ generally describes the object that the agent is directly looking at, but the captions alone do not disambiguate the agent’s locations. Since these captions are generated from a Unity state, these descriptions may not be as varied or rich as a human’s, but they can be generated accurately and reliably, and at scale.
138
+
139
+ # 4.3 Training Details
140
+
141
+ At test time, the agent receives image observation $O _ { V }$ and language-specified goal $g$ . The policy network never requires caption $O _ { L }$ to act. During training, the exploration method calculates the intrinsic reward from $O _ { L }$ or $O _ { V }$ .
142
+
143
+ We show that language-based exploration is compatible with both policy gradient and Q-learning algorithms. We use Impala $\mathbb { \equiv } \mathbb { \ln { \frac { } { } } }$ on Playroom and R2D2 on City $\lVert 2 5 \rVert$ . Q-learning is more suitable for the City, because the action space is more restricted compared to the one needed for Playroom tasks.
144
+
145
+ For both environments, the agent architecture consists of an image ResNet encoder and a language LSTM encoder that feed into a memory LSTM module. The policy and value heads are MLPs that receive the memory state as input. If the exploration method requires additional networks, such as the trainable network in RND or inverse dynamics model in NGU, they do not share any parameters with the policy or value networks. Figure $\dot { \bf S } \boldsymbol { 2 }$ is a visualization of an Impala agent that uses languageaugmented exploration. Hyperparameters and additional details are found in Appendix A.
146
+
147
+ # 5 Results
148
+
149
+ # 5.1 Motivation: Language is a Meaningful Abstraction
150
+
151
+ ![](images/3af81a44807e4bd3399bcdb6165f4176b5c2807cbdc33ab478fdffea53c11575.jpg)
152
+ (b) LD outperforms S-LD. It is important how language abstractions carve up the state space.
153
+ Figure 4: Our comparisons demonstrate that language is useful for exploration, because it outlines a more abstract, semantically-meaningful state space. Results are shown with a $9 5 \%$ confidence band.
154
+
155
+ We share the intuition with other work [e.g. 34] that language can improve exploration. We design a set of experiments to show how and why this may be the case. Our analysis follows the desiderata outlined by Burda et al. [6]—prediction-error exploration ought to use a feature space that filters irrelevant information (compact) and contains necessary information (sufficient). Burda et al. [6] specifically studies RND and notes that the random feature space, the outputs of the random network, may not fully satisfy either condition. As such, we use the language variants of RND to frame this discussion.
156
+
157
+ We hypothesize that language abstractions are useful, because they (1) create a coarser state space and (2) divide the state space in a way that meaningfully aligns with the world (i.e. using semantics). First, if language provides a coarser state space, then the random feature space becomes more compact, leading to better exploration. We compare Lang-RND to Vis-RND to test this claim. Lang-RND learns the lift task $33 \%$ faster and solves the put task as Vis-RND starts to learn (Figure 4a).
158
+
159
+ Second, we ask whether semantics – that is how language divides up the state space – is critical for effective exploration. We use LD to test this hypothesis, precisely because the exploration in LD is motivated by modeling the semantic relationship between language and vision.
160
+
161
+ We compare LD to a shuffled variant SLD, where we replace the particular semantic state abstraction that language offers with a statistically-matched randomized abstraction (Figure $\boxed { 5 }$ ). S-LD is similar to LD; the intrinsic reward is the prediction error of the captioning network. However, instead of targeting the language oracle output, the S-LD trainable network produces a different target caption O that may not match the image. $\widetilde { O _ { L } }$ is produced by a fixed, random mapping ${ \hat { f } } _ { S } : O _ { V } \{ \substack { \widetilde { O _ { L } } }$ . $\hat { f } _ { S }$ is constrained such that the marginal distributions $P ( O _ { L } ) \approx P ( \widetilde { O _ { L } } )$ are matched under trajectories produced by policy $\pi _ { L D }$ . See Appendix A.4 for full details on the construction of S-LD.
162
+
163
+ Thus, whereas the LD captions parcel up state space in a way that reflects the abstractions that language offers, the randomized mapping $\hat { f } _ { S }$
164
+
165
+ ![](images/68b5a5d5a2ff8ba9bc909d7cb8de829c43193dd1ad18d2dd977b30d8cfb87bac.jpg)
166
+ Figure 5: The dotted lines correspond to state abstractions given by the shuffled $\hat { f } _ { S }$ used in S-LD. The states are grouped together based on similarities in the visual random feature space and assigned a label. Exploring in this shuffled space is less effective than exploring with the semanticallymeaningful abstractions shown in Figure 1.
167
+
168
+ parcels up state space in a way that abstracts over random features of the visual space (Figure 5) We control for the compactness and coarseness of the resulting representation by maintaining the same marginal distribution of captions.
169
+
170
+ If semantics is crucial for exploration, then we expect to see LD outperform S-LD. This indeed holds experimentally (Figure $\textcircled { 4 6 }$ . We can also view these results under the Burda et al. [6] framework. The S-LD abstractions group together visually similar, but semantically distinct states. A single sampled caption likely fails to capture the group in a manner that is representative of all the encompassing states. In other words, $\hat { f } _ { S }$ produces a compact feature space that may not be sufficient. This may explain why S-LD learns faster than Vis-RND on the simpler lift task but fails on the more complex put and find tasks. The S-LD experiments imply that language abstractions are helpful for exploration because they expose not only a more compact, but also a more semantically meaningful state space.
171
+
172
+ # 5.2 Pretrained Vision-Language Representations Improve Exploration
173
+
174
+ Having shown how language can be helpful for exploration, we now incorporate pretrained visionlanguage representations into NGU and RND to improve exploration. Such representations (e.g. from the image encoder in CLIP/ALM) offer the benefits of explicit language abstractions, without the need to rely on a language oracle. We also compare language-shaped representations to pretrained ImageNet embeddings to isolate the effect of language. To keep the number of experiments tractable, we only perform a full comparison on the Playroom tasks.
175
+
176
+ City We first compare how representations affect performance in a pure exploration setting. With no extrinsic reward, the agent is motivated solely by the NGU intrinsic reward to explore the City. We report how many unique areas the agent visits in an episode in Figure $\triangledown$ While optimizing coverage only requires knowledge of an agent’s global location rather than generic scene understanding, vision-language representations are still useful simply because meaningful exploration is inherently semantic. Lang-NGU, which uses text embeddings of $O _ { L }$ , visits an area up to 3 times larger. LSENGU achieves 2 times the coverage even without querying a language oracle (Appendix Figure $S 5 )$
177
+
178
+ Playroom We next show that pretrained vision-language representations significantly speed up learning across all Playroom tasks (Figure $\textcircled{7}$ . The LSE-NGU and Lang-NGU agents improve sample efficiency by $50 \%$ on the lift and put tasks and $1 8 - 3 8 \%$ on the find task, depending on the pretraining model used. The ND agents are significantly faster than VisRND, learning $41 \%$ faster on the find task. We also measure agent-object interactions. Nearly all LSE-NGU and Lang-NGU agents learn to foveate on and hold objects within 40k learning updates, whereas Vis-NGU agent takes at least $6 0 \mathrm { k }$ updates to do so with the same frequency (Appendix Figure $\textcircled { 5 7 }$ Although LSENGU and image-based ND agents do not access a language oracle, they are similarly effective as their annotation-dependent counterparts in the Playroom tasks (Appendix Figure $\dot { \overline { { \vert \mathrm { S } 6 \vert } } }$ , suggesting that our method could be robust to the availability of a language oracle.
179
+
180
+ To demonstrate the value of rich language, we compare LSE-NGU agents to a control agent that instead uses pretrained ImageNet embeddings from a 70M NFNet [5]. ImageNet embeddings optimize for single-object classification, so they confer some benefit to the most objectfocused tasks, lift and put. However, Ima
181
+
182
+ ![](images/4e331f124119c8758a744a811647c826b4c1af228b5af625adf124b50420c54b.jpg)
183
+ Figure 6: Coverage of City (number of bins reached on map) by NGU variants using different state representations for exploration, normalized by coverage of a ground-truth agent. The groundtruth agent represents state in NGU as the global coordinate of the agent location. The dashed line indicates coverage of a uniform random policy. Error bars indicate standard error of the mean, over 5 replicas. See Appendix Table S4 for absolute coverage numbers.
184
+
185
+ geNet embeddings hurt exploration in the find task, where agents encounters more complex scenes (Figure $^ { 7 \mathrm { b } ) }$ . By contrast, the language-shaped representations are well-suited for not only describing simple objects, but also have capacity for multi-object, complex scenes. Of course, current CLIPstyle models can be further improved in their ability to understand multi-object scenes, which may explain why the benefits are less pronounced for the find task. However, as the performance of pretrained vision-language models improve, we expect to see those benefits transfer to this method and drive even better exploration.
186
+
187
+ # 6 Discussion
188
+
189
+ We have shown that language abstractions and pretrained vision-language representations improve the sample efficiency of existing exploration methods. This benefit is seen across on-policy and off-policy algorithms (Impala and R2D2), different exploration methods (RND and NGU), different 3D domains (Playroom and City), and various task specifications (lifting/putting, searching, and intrinsically motivated navigation). Furthermore, we carefully designed control experiments to understand how language contributes to better exploration. Our results are consistent with cognitive perspectives on human language—language is powerful because it groups together situations according to semantic similarity. In terms of the desiderata that Burda et al. [6] present, language is both compact and sufficient. Finally, we note that using pretrained vision-language representations to embed image observations enables more effective exploration even if language is not available during agent training. This is vital for scaling to environments that do not have a language oracle or annotations.
190
+
191
+ Limitations and future directions We highlight several avenues for extending our work. First, additional research could provide a more comprehensive understanding of how language abstractions affect representations. This could include comparing different types of captions offering varying levels of detail, or task-dependent descriptions. These captions could be dynamically generated at scale by prompting a large multimodal model $\left[ \left[ 2 \right] \right]$ . Second, it would be useful to investigate how to improve pretrained vision-language representations for exploration by finetuning on relevant datasets. The semantics of a dataset could even be tailored to task-specific abstractions to increase the quality of the learnt representations. Such approaches would potentially allow applying our method to virtual environments that are farther from the pretraining distribution, such as Atari. In contrast, compared to our experiments, we believe that the current pretrained representations would deliver even more benefit for entirely photorealistic, visually rich environments, such as Matterport3D [9]. Finally, we note that a limitation of this approach is that current pretrained vision-language models may be less effective on multi-object scenes. Future pretraining innovations or larger models would presumably produce more robust representations and thus lead to even more effective exploration.
192
+
193
+ ![](images/53710fea8c99c91556580251a05b8374eb54910ded17dc54d98c4bda41723211.jpg)
194
+
195
+ (c) ND intrinsic rewards derive from the prediction error of the representations from a pretrained ALM network.
196
+ Figure 7: Agents that use pretrained language-shaped representations to explore (ALM-ND, LangNGU, LSE-NGU) learn faster than baseline agents. ALM-ND (Text/Image) refer to the ND variants in Table 2. Results shown with a $9 5 \%$ confidence interval.
197
+
198
+ # Acknowledgments and Disclosure of Funding
199
+
200
+ We would like to thank Iain Barr for ALM models and Nathaniel Wong and Arthur Brussee for the Playroom environment. For the City environment, we would like to thank Nick Young, Tom Hudson, Alex Platonov, Bethanie Brownfield, Sarah Chakera, Dario de Cesare, Marjorie Limont, Benigno Uria, Borja Ibarz and Charles Blundell. Moreover, for the City, we would like to extend our special thanks to Jayd Matthias, Jason Sanmiya, Marcus Wainwright, Max Cant and the rest of the Worlds Team. Finally, we thank Hamza Merzic, Andre Saraiva, and Tim Scholtes for their helpful support and advice.
201
+
202
+ # References
203
+
204
+ [1] J. Abramson, A. Ahuja, I. Barr, A. Brussee, F. Carnevale, M. Cassin, R. Chhaparia, S. Clark, B. Damoc, A. Dudzik, et al. Imitating interactive intelligence. arXiv preprint arXiv:2012.05672,
205
+
206
+ [2] J.-B. Alayrac, J. Donahue, P. Luc, A. Miech, I. Barr, Y. Hasson, K. Lenc, A. Mensch, K. Millican, M. Reynolds, et al. Flamingo: a visual language model for few-shot learning. arXiv preprint arXiv:2204.14198, 2022.
207
+ [3] A. P. Badia, P. Sprechmann, A. Vitvitskyi, D. Guo, B. Piot, S. Kapturowski, O. Tieleman, M. Arjovsky, A. Pritzel, A. Bolt, et al. Never give up: Learning directed exploration strategies. arXiv preprint arXiv:2002.06038, 2020.
208
+ [4] M. Bellemare, S. Srinivasan, G. Ostrovski, T. Schaul, D. Saxton, and R. Munos. Unifying count-based exploration and intrinsic motivation. Advances in neural information processing systems, 29, 2016.
209
+ [5] A. Brock, S. De, S. L. Smith, and K. Simonyan. High-performance large-scale image recognition without normalization. In International Conference on Machine Learning, pages 1059–1071. PMLR, 2021.
210
+ [6] Y. Burda, H. Edwards, D. Pathak, A. Storkey, T. Darrell, and A. A. Efros. Large-scale study of curiosity-driven learning. arXiv preprint arXiv:1808.04355, 2018.
211
+ [7] Y. Burda, H. Edwards, A. Storkey, and O. Klimov. Exploration by random network distillation. arXiv preprint arXiv:1810.12894, 2018.
212
+ [8] A. Campero, R. Raileanu, H. Küttler, J. B. Tenenbaum, T. Rocktäschel, and E. Grefenstette. Learning with amigo: Adversarially motivated intrinsic goals. arXiv preprint arXiv:2006.12122, 2020.
213
+ [9] A. Chang, A. Dai, T. Funkhouser, M. Halber, M. Niessner, M. Savva, S. Song, A. Zeng, and Y. Zhang. Matterport3d: Learning from rgb-d data in indoor environments. arXiv preprint arXiv:1709.06158, 2017.
214
+ [10] D. S. Chaplot, D. P. Gandhi, A. Gupta, and R. R. Salakhutdinov. Object goal navigation using goal-oriented semantic exploration. Advances in Neural Information Processing Systems, 33: 4247–4258, 2020.
215
+ [11] R. Y. Chen, S. Sidor, P. Abbeel, and J. Schulman. UCB exploration via Q-ensembles. arXiv preprint arXiv:1706.01502, 2017.
216
+ [12] C. Colas, P. Fournier, M. Chetouani, O. Sigaud, and P.-Y. Oudeyer. Curious: intrinsically motivated modular multi-goal reinforcement learning. In International conference on machine learning, pages 1331–1340. PMLR, 2019.
217
+ [13] C. Colas, T. Karch, N. Lair, J.-M. Dussoux, C. Moulin-Frier, P. Dominey, and P.-Y. Oudeyer. Language as a cognitive tool to imagine goals in curiosity driven exploration. Advances in Neural Information Processing Systems, 33:3761–3774, 2020.
218
+ [14] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
219
+ [15] Y. Du, C. Gan, and P. Isola. Curious representation learning for embodied intelligence. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10408– 10417, 2021.
220
+ [16] A. Ecoffet, J. Huizinga, J. Lehman, K. O. Stanley, and J. Clune. First return, then explore. Nature, 590(7847):580–586, 2021.
221
+ [17] L. Espeholt, H. Soyer, R. Munos, K. Simonyan, V. Mnih, T. Ward, Y. Doron, V. Firoiu, T. Harley, I. Dunning, et al. Impala: Scalable distributed deep-rl with importance weighted actor-learner architectures. In International Conference on Machine Learning, pages 1407–1416. PMLR, 2018.
222
+ [18] S. Flennerhag, J. X. Wang, P. Sprechmann, F. Visin, A. Galashov, S. Kapturowski, D. L. Borsa, N. Heess, A. Barreto, and R. Pascanu. Temporal difference uncertainties as a signal for exploration. arXiv preprint arXiv:2010.02255, 2020.
223
+ [19] P. Goyal, S. Niekum, and R. J. Mooney. Using natural language for reward shaping in reinforcement learning. arXiv preprint arXiv:1903.02020, 2019.
224
+ [20] H. P. Grice. Logic and conversation. In Speech acts, pages 41–58. Brill, 1975.
225
+ [21] M. Hahn, D. Jurafsky, and R. Futrell. Universals of word order reflect optimization of grammars for efficient communication. Proceedings of the National Academy of Sciences, 117(5):2347– 2353, 2020.
226
+ [22] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770– 778, 2016.
227
+ [23] R. Houthooft, X. Chen, Y. Duan, J. Schulman, F. De Turck, and P. Abbeel. Vime: Variational information maximizing exploration. Advances in neural information processing systems, 29, 2016.
228
+ [24] C. Jia, Y. Yang, Y. Xia, Y.-T. Chen, Z. Parekh, H. Pham, Q. Le, Y.-H. Sung, Z. Li, and T. Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning, pages 4904–4916. PMLR, 2021.
229
+ [25] S. Kapturowski, G. Ostrovski, J. Quan, R. Munos, and W. Dabney. Recurrent experience replay in distributed reinforcement learning. In International conference on learning representations, 2018.
230
+ [26] A. Khandelwal, L. Weihs, R. Mottaghi, and A. Kembhavi. Simple but effective: Clip embeddings for embodied ai. arXiv preprint arXiv:2111.09888, 2021.
231
+ [27] S. Li, X. Puig, Y. Du, C. Wang, E. Akyurek, A. Torralba, J. Andreas, and I. Mordatch. Pre-trained language models for interactive decision-making. arXiv preprint arXiv:2202.01771, 2022.
232
+ [28] G. Lupyan. What do words do? toward a theory of language-augmented thought. In Psychology of learning and motivation, volume 57, pages 255–297. Elsevier, 2012.
233
+ [29] G. Lupyan, D. H. Rakison, and J. L. McClelland. Language is not just for talking: Redundant labels facilitate learning of novel categories. Psychological science, 18(12):1077–1083, 2007.
234
+ [30] M. C. Machado, M. G. Bellemare, and M. Bowling. Count-based exploration with the successor representation. Proceedings of the AAAI Conference on Artificial Intelligence, 34(04):5125– 5133, 2020.
235
+ [31] R. Marjieh, P. van Rijn, I. Sucholutsky, T. R. Sumers, H. Lee, T. L. Griffiths, and N. Jacoby. Words are all you need? capturing human sensory similarity with textual descriptors. arXiv preprint arXiv:2206.04105, 2022.
236
+ [32] J. Martin, S. N. Sasikumar, T. Everitt, and M. Hutter. Count-based exploration in feature space for reinforcement learning. arXiv preprint arXiv:1706.08090, 2017.
237
+ [33] S. Mirchandani, S. Karamcheti, and D. Sadigh. Ella: Exploration through learned language abstraction. Advances in Neural Information Processing Systems, 34, 2021.
238
+ [34] J. Mu, V. Zhong, R. Raileanu, M. Jiang, N. Goodman, T. Rocktäschel, and E. Grefenstette. Improving intrinsic exploration with language abstractions. arXiv preprint arXiv:2202.08938, 2022.
239
+ [35] P.-Y. Oudeyer and F. Kaplan. What is intrinsic motivation? a typology of computational approaches. Frontiers in neurorobotics, 1:6, 2009.
240
+ [36] P.-Y. Oudeyer, F. Kaplan, and V. V. Hafner. Intrinsic motivation systems for autonomous mental development. IEEE transactions on evolutionary computation, 11(2):265–286, 2007.
241
+ [37] S. Parisi, A. Rajeswaran, S. Purushwalkam, and A. Gupta. The unsurprising effectiveness of pre-trained vision models for control. arXiv preprint arXiv:2203.03580, 2022.
242
+ [38] D. Pathak, P. Agrawal, A. A. Efros, and T. Darrell. Curiosity-driven exploration by selfsupervised prediction. In International conference on machine learning, pages 2778–2787. PMLR, 2017.
243
+ [39] D. Pathak, D. Gandhi, and A. Gupta. Self-supervised exploration via disagreement. In International conference on machine learning, pages 5062–5071. PMLR, 2019.
244
+ [40] S. Racaniere, A. Lampinen, A. Santoro, D. Reichert, V. Firoiu, and T. Lillicrap. Automated curriculum generation through setter-solver interactions. In International conference on learning representations, 2019.
245
+ [41] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748–8763. PMLR, 2021.
246
+ [42] M. Reid, Y. Yamada, and S. S. Gu. Can wikipedia help offline reinforcement learning? arXiv preprint arXiv:2201.12122, 2022.
247
+ [43] N. Savinov, A. Raichuk, R. Marinier, D. Vincent, M. Pollefeys, T. Lillicrap, and S. Gelly. Episodic curiosity through reachability. arXiv preprint arXiv:1810.02274, 2018.
248
+ [44] J. 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 animats, pages 222–227, 1991.
249
+ [45] E. Schwartz, G. Tennenholtz, C. Tessler, and S. Mannor. Language is power: Representing states using natural language in reinforcement learning. arXiv preprint arXiv:1910.02789, 2019.
250
+ [46] R. Sekar, O. Rybkin, K. Daniilidis, P. Abbeel, D. Hafner, and D. Pathak. Planning to explore via self-supervised world models. In International Conference on Machine Learning (ICML), 2020.
251
+ [47] M. Shridhar, X. Yuan, M.-A. Côté, Y. Bisk, A. Trischler, and M. Hausknecht. Alfworld: Aligning text and embodied environments for interactive learning. arXiv preprint arXiv:2010.03768, 2020.
252
+ [48] P. Shyam, W. Jaskowski, and F. Gomez. Model-based active exploration. In ´ International Conference on Machine Learning (ICML), 2019.
253
+ [49] A. L. Strehl and M. L. Littman. An analysis of model-based interval estimation for markov decision processes. Journal of Computer and System Sciences, 74(8):1309–1331, 2008.
254
+ [50] D. Strouse, K. Baumli, D. Warde-Farley, V. Mnih, and S. Hansen. Learning more skills through optimistic exploration. In International Conference on Learning Representations (ICLR), 2022.
255
+ [51] R. S. Sutton and A. G. Barto. Reinforcement learning: An introduction. MIT press, 2018.
256
+ [52] D. I. A. Team, J. Abramson, A. Ahuja, A. Brussee, F. Carnevale, M. Cassin, F. Fischer, P. Georgiev, A. Goldin, T. Harley, et al. Creating multimodal interactive agents with imitation and self-supervised learning. arXiv preprint arXiv:2112.03763, 2021.
257
+ [53] T. Xiao, I. Radosavovic, T. Darrell, and J. Malik. Masked visual pre-training for motor control. arXiv preprint arXiv:2203.06173, 2022.
258
+ [54] D. Zha, W. Ma, L. Yuan, X. Hu, and J. Liu. Rank the episodes: A simple approach for exploration in procedurally-generated environments. arXiv preprint arXiv:2101.08152, 2021.
259
+ [55] T. Zhang, P. Rashidinejad, J. Jiao, Y. Tian, J. E. Gonzalez, and S. Russell. Made: Exploration via maximizing deviation from explored regions. Advances in Neural Information Processing Systems, 34, 2021.
260
+ [56] T. Zhang, H. Xu, X. Wang, Y. Wu, K. Keutzer, J. E. Gonzalez, and Y. Tian. Noveld: A simple yet effective exploration criterion. Advances in Neural Information Processing Systems, 34, 2021.
md/dev/-P7G-8dmSh4/-P7G-8dmSh4.md ADDED
@@ -0,0 +1,452 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FORMAL MATHEMATICS STATEMENTCURRICULUM LEARNING
2
+
3
+ Stanislas Polu OpenAI
4
+
5
+ Jesse Michael Han† Multi Technologies
6
+
7
+ Kunhao Zheng École Polytechnique
8
+
9
+ Mantas Baksys University of Cambridge
10
+
11
+ Igor Babuschkin† DeepMind
12
+
13
+ Ilya Sutskever OpenAI
14
+
15
+ # ABSTRACT
16
+
17
+ We explore the use of expert iteration in the context of language modeling applied to formal mathematics. We show that at same compute budget, expert iteration, by which we mean proof search interleaved with learning, dramatically outperforms proof search only. We also observe that when applied to a collection of formal statements of sufficiently varied difficulty, expert iteration is capable of finding and solving a curriculum of increasingly difficult problems, without the need for associated ground-truth proofs. Finally, by applying this expert iteration to a manually curated set of problem statements, we surpass previous state-of-the-art on the miniF $2 F$ benchmark, automatically solving multiple challenging problems drawn from high school olympiads.
18
+
19
+ # 1 INTRODUCTION
20
+
21
+ Deep learning has enjoyed spectacular success in many domains, including language (Brown et al., 2020; Devlin et al., 2019; Wu et al., 2016), vision (Radford et al., 2021; Tan & Le, 2019), and image generation (Ramesh et al., 2021; Karras et al., 2019). One domain where deep learning has not yet enjoyed a comparable success is in tasks that require extensive planning and symbolic reasoning, with the exception of two-player games (Silver et al., 2016; 2017; Berner et al., 2019; Vinyals et al., 2019). In such games, deep learning systems exhibit a considerable degree of reasoning, especially when trained with self-play combined with a search procedure such as Monte Carlo Tree Search (MCTS) (Browne et al., 2012). But the resulting reasoning abilities achieved are limited due to the relatively narrow scope of games.
22
+
23
+ As such, theorem proving in interactive proof assistants, or formal mathematics, appears as an interesting game-like domain to tackle due to its increased scope. The typical tasks consist of generating a machine-checkable proof given a formal statements. Like games, formal mathematics has an automated way of determining whether a trajectory (i.e. a proof) is successful (i.e. formally correct). But the vast scope of formal mathematics means that any strong reasoning result obtained in it will be more meaningful than comparable results in games (e.g. finding proofs to mathematical conjectures), and could even be applicable to important practical problems (e.g. software verification).
24
+
25
+ However, tackling formal mathematics involves two main challenges that we must address in order to continue making progress:
26
+
27
+ Infinite action space Not only does formal mathematics have an extremely large search space (like Go (Silver et al., 2016) for example), it also has an infinite action space. At each step of proof search, the model must choose not from a well-behaved finite set of actions, but a complex and infinite set of tactics, potentially involving exogenous mathematical terms that have to be generated (e.g., generating a mathematical statement to be used as a witness, an object used steps such as “there exists an x ...”, or a cut, the introduction and the chaining of a lemma in the middle of a proof).
28
+
29
+ No direct self-play setup In formal mathematics, a prover is not playing against an opponent but against a set of statements to prove. When faced with a statement that is just too hard, there is no obvious reframing of the formal mathematics setup that will let the prover generate intermediary easier statements to tackle first. This asymmetry prevents naive application of the symmetric self-play algorithms commonly used in 2-player games.
30
+
31
+ These two differences make a naive application of reinforcement learning to formal mathematics leave a large room for improvement (Whalen, 2016; Winands et al., 2008). Past work proposed to address the infinite action space problem by sampling from a language model (Polu & Sutskever, 2020), while training such language model requires a large dataset of statements with proof. This paper focuses on this second problem and our basis for addressing it is the observation that the key role of self-play is to provide an unsupervised curriculum. We propose instead to supply auxiliary sets of problem statements (without requiring proofs) of varying difficulty. We empirically show that, when the difficulty of these auxiliary problems is varied enough, a simple expert iteration procedure is able to solve a curriculum of increasingly difficult problems, eventually generalizing to our target distribution. We show that this works with both automatically-generated and manually-curated auxiliary distributions of problems and leverage this to achieve state-of-the-art on the miniF2F benchmark. Our results suggest that continuous self-improvement in formal mathematics can potentially be reduced to the problem of generating such sets of formal statements, which we have done in part manually in this work, but could eventually be scaled in the future with more automation (such as more domain-specific statements generator or even informal to formal machine translation).
32
+
33
+ miniF2F benchmark In this work, we target the miniF $2 F$ (Zheng et al., 2022) benchmark, which consists of 244 validation and 244 test formalized statements of mathematical problems from various competitions. We believe it to be a better measure of mathematical reasoning compared to a formal library-derived split. Also, the extreme scarcity in formal libraries of this type of problems makes it an ideal test-bed for the expert iteration methodology studied in this paper.
34
+
35
+ # 2 RELATED WORK
36
+
37
+ Our work strongly relies on, and can be seen as a natural continuation of the work presented in the original GPT-f paper (Polu & Sutskever, 2020) which studies the use of language models to generate tactics, the PACT paper (Han et al., 2022) which applies GPT-f to Lean and studies the benefits from co-training on self-supervised objectives, and the miniF2F benchmark (Zheng et al., 2022). We present additional related work in Appendix A.
38
+
39
+ # 3 FORMAL ENVIRONMENT
40
+
41
+ We choose Lean (de Moura et al., 2015; lea) as our formal environment. Unlike Metamath (Megill & Wheeler, 2019) , which has been studied in the original GPT-f paper (Polu & Sutskever, 2020), Lean benefits from high-level tactics which were shown to be beneficial in the context of the miniF2F benchmark. Also, Lean has recently received a lot of attention from the mathematical community, thanks to projects such as the Perfectoid Spaces (Buzzard et al., 2019) and the Liquid Tensor experiment (Scholze, 2020), and benefits from a vibrant community of hundreds of contributors to its main mathematical library called mathlib. We refer to the PACT paper’s Background section (Han et al., 2022) for a detailed introduction to Lean in the context of neural theorem proving. We refer to Appendix D for an illustration of miniF2F input and Lean environment.
42
+
43
+ lean-gym In the PACT paper (Han et al., 2022), proof search is performed by the Lean runtime using the LEANSTEP environment, with a generic backend interface to models. While easy to use–one just needs to plug in their model–this approach makes it difficult to alter and iterate on the search procedure because it is programmed in Lean (which is not designed or intended for cluster-wide parallelised I/O intensive tasks), and the coupling of the search procedure with the Lean runtime introduces challenges when scaling to a large number of parallel workers.
44
+
45
+ To solve these issues we implemented lean-gym1 – a simple REPL interface over the standard input/output implemented in Lean directly. We present lean-gym’s API and discuss some of its advantages and limitations in Appendix B.
46
+
47
+ Proof extraction We rely on the proof extraction methodology presented in the PACT paper (Han et al., 2022) to extract human tactic proof steps from mathlib (the tactic dataset) as well as the various other proof artifacts $( \mathsf { m i x } 1$ and $\mathfrak { m i x 2 }$ datasets). We also extract mathlib-{train, valid, test}, the set of statements from mathlib along the split proposed in Han et al. (2022) (the validation and test splits of tactic, mix1, mix2 being aligned with mathlib-{valid, test} as the splits are determined by declaration name hashes (across all data sources including proof-term mining) as opposed to individual proof steps or data-points.
48
+
49
+ # 4 EXPERT ITERATION
50
+
51
+ Expert iteration was introduced in Silver et al. (2017) and broadly consists in iteratively training models on their previously sampled trajectories, to achieve continuous improvement. In this section we present our expert iteration methodology, including the models and pre-training strategies. We use decoder-only Transformers similar to GPT-3 (Brown et al., 2020). Throughout this paper we focus on a model with 36 layers and 774 million trainable parameters (referred to as the 700m model in the GPT-f paper (Polu & Sutskever, 2020)).
52
+
53
+ # 4.1 PRE-TRAINING
54
+
55
+ We pre-train our models successively on GPT-3’s post-processed version of CommonCrawl (for 300B tokens) and an updated version of WebMath (Polu & Sutskever, 2020) (for 72B tokens) whose mix is presented in Appendix C.
56
+
57
+ # 4.2 TRAINING OBJECTIVES
58
+
59
+ Proofstep objective The proofstep objective, introduced in Polu & Sutskever (2020), consists in generating a PROOFSTEP (a Lean tactic) given a GOAL (a Lean tactic state). We also condition this objective on the current DECLARATION (a Lean theorem name), which remains the same throughout a proof search: DECL <DECLARATION> GOAL <GOAL> PROOFSTEP <PROOFSTEP>.
60
+
61
+ The rationale for conditioning on the declaration name is to hint our models on the position of the current declaration in the mathlib library. It can be considered as a weak proxy signal for the large amount of information not shown to the model (the full environment consisting of the available imports and currently open declarations such as module names, notations, declared instances, ...). The declaration name lets models at least in principle memorize and then retrieve some of that information, knowing that lean-gym errors if a theorem or definition that is not available in the environment associated with the current declaration is used by tactics generated by our models. Also note that conversely to Polu & Sutskever (2020) and like Han et al. (2022) ${ < } G O A L >$ is not necessarily a single goal but a Lean tactic state, which possibly comprises multiple goals.
62
+
63
+ Proofsize objective We depart from Polu & Sutskever (2020) and use a proofsize objective to guide our proof searches, which consists in generating one token that represents a proof size estimate bucket for the current goal (Lean tactic state): DECL <DECLARATION> GOAL ${ < } G O A L >$ PROOFSIZE <PROOFSIZE_BUCKET_TOKEN>
64
+
65
+ For a given goal $g$ , either the goal was proved as part of the proof search and we denote its proof size (the number of tactic applications (compounded Lean tactics counting as one)) as $p s ( g )$ , or the goal was not proved in which case we assign the goal to a bucket that virtually represents "infinite" proof sizes.
66
+
67
+ We use 11 buckets $B = 0 . . . 1 0$ and compute the proofsize bucket $b ( g )$ for a goal $g$ by assigning infinite proof sizes to bucket 0, all proof sizes over 20 to bucket 1 and linearly projecting proof sizes lower than 20 on the remaining buckets $2 , . . . , 1 0$ (10 being the bucket for the shortest proof sizes). In practice, when training and sampling from the model, we map $B$ to the tokens $\therefore \mathrm { A \Omega } . . . \mathrm { K \Omega }$ .
68
+
69
+ To value goals as we run proof searches, we sample the proofsize bucket token and record the probability $p _ { b } ( g )$ for each viable bucket and use them to get a weighted average with the following formula: $\begin{array} { r } { \dot { v } ( \dot { g } ) = \frac { 1 } { \# B } \sum _ { b \in B } p _ { b } ( g ) \cdot b } \end{array}$ . As an example, if the model assigns $p _ { 0 } = 1$ (hence $p _ { b \neq 0 } = 0$ ) then $v ( g ) = 0$ . Conversely if the model assigns $p _ { 1 0 } = 1$ (10 being the bucket for the shortest proof sizes) then $v ( g ) = 1$ .
70
+
71
+ Table 1: Performance of $\theta _ { 0 }$ and $\theta _ { 1 }$ on mathlib-valid and miniF $_ { 2 F }$ -valid compared to PACT Lean GPT-f as reported in Han et al. (2022); Zheng et al. (2022). All models have the same architecture. $\theta _ { 0 }$ is sampled using cumulative logprob priority best-first search. $\theta _ { 1 }$ is sampled using best-first search based on the proofsize objective. We report our setup $d = 5 1 2$ expansions and $e = 8$ tactic samples per expansions) as well as the setups used in Han et al. (2022); Zheng et al. (2022) (denoted as $\theta _ { 0 } ^ { * }$ ) to control for compute. We also report the performance of $\theta _ { 1 }$ on mathlib-valid when trained using the outcome objective (denoted as $\theta _ { 1 } ^ { \prime }$ ) from Polu & Sutskever (2020) as an ablation of our proposed proofsize objective.
72
+
73
+ <table><tr><td>Model</td><td>d</td><td>e</td><td>pass@1</td><td>pass@8</td></tr><tr><td>mathlib-valid</td><td></td><td></td><td></td><td></td></tr><tr><td>PACT</td><td>512</td><td>16</td><td>48.4%</td><td></td></tr><tr><td>0</td><td>512</td><td>16</td><td>48.5%</td><td>57.6%</td></tr><tr><td>0</td><td>512</td><td>8</td><td>46.7%</td><td>57.5%</td></tr><tr><td>01</td><td>512</td><td>8</td><td>56.3%</td><td>66.3%</td></tr><tr><td>0</td><td>512</td><td>8</td><td>55.6%</td><td>65.9%</td></tr></table>
74
+
75
+ <table><tr><td>Model</td><td>d</td><td>e</td><td>pass@1</td><td>pass@8</td></tr><tr><td colspan="3">miniF2F-valid</td><td></td><td></td></tr><tr><td>miniF2F</td><td>128</td><td>16</td><td>23.9%</td><td>29.3%</td></tr><tr><td></td><td>128</td><td>16</td><td>27.6%</td><td>31.8%</td></tr><tr><td>0</td><td>512</td><td>8</td><td>28.4%</td><td>33.6%</td></tr><tr><td>01</td><td>512</td><td>8</td><td>28.5%</td><td>35.5%</td></tr><tr><td>0</td><td>512</td><td>8</td><td>28.3%</td><td>34.7%</td></tr></table>
76
+
77
+ The rationale for using this proofsize objective instead of the outcome objective described in Polu & Sutskever (2020) is that (i) it achieves better performance compared to the outcome objective (see Table 1), and (ii) it prioritizes goals that potentially lead to shorter proofs during proof search, creating an intrinsic incentive for the system to converge towards shorter proofs. Similarly to Polu & Sutskever (2020) we favor this token-based approach to the introduction of a separate value head to keep the overall architecture simple. This way the proofsize objective can be implemented by simply augmenting the training dataset and without any architectural change.
78
+
79
+ # 4.3 BOOTSTRAPPING
80
+
81
+ Bootstrapping consists in the steps required to train an initial model on both the proofstep objective and the proofsize objective.
82
+
83
+ Given a pre-trained model on WebMath, we fine-tune it on the tactic dataset extracted from mathlib as well as the proof artifacts dataset mix1 as described in Han et al. (2022). This initial model, which we denote $\theta _ { 0 }$ is solely trained on the proofstep objective. We use the validation splits of the tactic and m1 datasets to early-stop training. Note that this is our only use of mathlib-valid to influence the training process throughout this paper.
84
+
85
+ To generate data for the proofsize objective, we use $\theta _ { 0 }$ to sample proofs for statements from mathlibtrain. For each statement from mathlib-train (25k) we attempt $a = 1$ proof searches using the cumulative logprob priority search described in Polu & Sutskever (2020) (which does not require a trained value function) using $d = 5 1 2$ expansions and $e = 8$ samples per expansion. We denote the set of successful proof searches created in this process as $S _ { 0 }$ .
86
+
87
+ Using $S _ { 0 }$ we generate dataset $D _ { 0 }$ by concatenating: (i) the initial tactic dataset (proofstep objective), (ii) a deduplicated set of proofsteps extracted from the proofs in $S _ { 0 }$ (proofstep objective) and (iii) a deduplicated set of proofsize tuples (goals and proofsize) extracted from the full proof searches in $S _ { 0 }$ (proofsize objective).
88
+
89
+ Note that the full proof searches in $S _ { 0 }$ include goals that are visited but eventually remain unproved, which provides useful negative examples for the trained value function (even if these negatives may include provable goals that simply were not prioritized by the search). Also note that $S _ { 0 }$ doesn’t include failed proof searches.
90
+
91
+ We fine-tune $\theta _ { 0 }$ on $D _ { 0 }$ for exactly one epoch (no use of validation data for early-stopping) to obtain our initial model $\theta _ { 1 }$ trained on both the proofstep objective and the proofsize objective. $\theta _ { 0 }$ is used in our expert iteration setup as base model to fine-tune from at each iteration, and $\theta _ { 1 }$ is our first iterated model or mathlib bootstrapped model trained on both objectives.
92
+
93
+ We report in Table 1 the pass rates of $\theta _ { 0 }$ and $\theta _ { 1 }$ on mathlib-valid and miniF2F-valid and compare with previously reported pass rates for equivalent amounts of compute. As reported in Polu & Sutskever (2020), training a value function to guide search greatly improves the pass rates of $\theta _ { 1 }$ on mathlib-valid.
94
+
95
+ Interestingly, the gap between $\theta _ { 0 }$ and $\theta _ { 1 }$ on miniF ${ } ^ { 7 2 F }$ -valid is not as significant, demonstrating that training a value function on proofs sampled from mathlib-train has limited transfer to miniF2F-valid. The main differences with Zheng et al. (2022), potentially explaining the gap on miniF2F-valid $( 2 7 . 6 \%$ vs $2 3 . 9 \%$ ), consists in the new pre-training described in Section 4.1 as well as the use of a more recent mathlib checkpoint for the mix1, mix2 and tactic datasets.
96
+
97
+ # 4.4 ITERATED SAMPLING AND TRAINING
98
+
99
+ Our expert iteration process takes as input: (i) a set of formal statements $S t$ , (ii) a function $a : S t \mathbb { N }$ indicating the number of proof search attempts to run per statement at each iteration, (iii) a base model $\theta _ { 0 }$ to fine-tune from at each iteration, and (iv) a mathlib bootstrapped model $\theta _ { 1 }$ trained on both objectives. A high-level illustration of the iterated sampling and training is available in Appendix E.
100
+
101
+ Each iteration $k$ consists in sampling proof searches for statements in $S t$ using $\theta _ { k }$ , filtering successful proof searches $S _ { k }$ to extract a new dataset $D _ { k }$ , and fine-tuning $\theta _ { 0 }$ on it to obtain $\theta _ { k + 1 }$ , on which we can iterate. To sample proof searches from $S t$ we use the best-first search described in Polu $\&$ Sutskever (2020) with the value function described in Section 4.2. We attempt $a$ proof searches for each statement $s ( s \in S t )$ with $d = 5 1 2$ expansions and $e = 8$ samples per expansion. We denote the set of successful proof searches for iteration $k$ as $S _ { k }$ .
102
+
103
+ Using $S _ { k }$ we generate datasets $D _ { k }$ by concatenating: (i) the initial tactic dataset (proofstep objective), (ii) a deduplicated set of proofsteps extracted from the proofs in $\textstyle \bigcup _ { 1 \leq i \leq k } { \bar { S } } _ { k }$ (proofstep objective), and (iii) a deduplicated set of proofsize tuples (goals and proofsize) extracted from the full proof searches in $\textstyle \bigcup _ { 1 \leq i \leq k } S _ { k }$ (proofsize objective).
104
+
105
+ We use a global deduplication across iterations for both proofsteps and proofsize tuples which we found to be important to maintain the stability of the expert iteration procedure. This global deduplication is somewhat equivalent for each statement to growing a unique proof tree by aggregating all the proof searches that have been run for it across iterations. This virtual proof tree accumulates a growing number of positive proof paths and visited goals that remain unproven. We use these goals as negative examples for the proofsize objective, labeling them with an infinite proofsize. Positive goals are deduplicated keeping the minimum proof sizes across proof searches.
106
+
107
+ Finally $\theta _ { k }$ is obtained by fine-tuning $\theta _ { 0 }$ for exactly one epoch on $D _ { k }$ . Note that the initial tactic dataset is included in each $D _ { k }$ , despite $\theta _ { 0 }$ being already trained on it (along with mix1). We found this repetition to be beneficial overall (as it adds the mathlib extracted proofsteps to our deduplicated per statements virtual proof trees) despite it leading to a slight overfit on the tactic dataset in terms of validation loss.
108
+
109
+ # 4.5 EXPERT ITERATION ON mathlib-train
110
+
111
+ In this section we propose to set $S t$ to the statements in mathlib-train, run our expert iteration process with it and report performance on both mathlib-valid and miniF2F-valid. Performance is reported in terms of pass rate (percentage of successful proof searches) as a function of the number of attempts per statement, noted pass $@ k$ where $k$ is the number of attempts per statement at test time. To reduce noise in these metrics we run more than $k$ attempts at test time (generally 32 to compute pass@1 and $p a s s @ 8 )$ ), averaging across attempts as needed to obtain a smoother pass $@ k$ value.
112
+
113
+ Given the large number of statements in mathlib-train (25k) we uniformly set $a = 1$ and use $\theta _ { 0 }$ and $\theta _ { 1 }$ as described in Section 4.3 and report pass $@ l$ and pass $@ 8$ across 8 iterations in Figure 1. The pass $@ l$ on mathlib-valid goes from $5 6 . 3 \%$ for $\theta _ { 1 }$ to $6 2 . 6 \%$ for $\theta _ { 9 }$ . The performance steadily improves and follows a clear logarithmic scaling law on mathlib-valid. It is also notable that, initially, transfer to out-of-distribution miniF2F-valid appears limited but eventually kicks in as we reach better performance on mathlib-valid. This demonstrates that the expert iteration process does not just overfit to mathlib but also leads to improved performance on out-of-distribution statements.
114
+
115
+ We define the cumulative pass rate at iteration $k$ as the pass rate consisting of all proof searches up to iteration $k$ . Since we set $a = 1 6$ for evaluation on mathlib-valid and miniF $2 F$ -valid at each iteration, the cumulative pass rate at iteration $k$ can be seen as a noisy ensembled pass@16k (multiple models $( \theta _ { k } )$ , no averaging). In Figure 2, we report this cumulative pass rate for two iteration loops, our normal one and a sampling-only loop where we skip re-training the model between iterations and solely sample from $\theta _ { 1 }$ . This directly compares test-time compute scaling (scaling proof search attempts) to expert iteration scaling (interleaved training on new data sampled from mathlib-train) and provides a very clear visualization of the gains of expert iteration. For a fair comparison, we also report an adjusted compute line which approximates the test-time performance we would get at each iteration if we were to focus all the additional compute used by expert iteration (sampling proofs from mathlib-train as well as re-training models at each iteration) towards solely running proof searches against mathlib-valid.
116
+
117
+ ![](images/b3074a05d2f2dc8531883c0879a996434568be2cda8eabc704d7c13bb00cb518.jpg)
118
+ Figure 1: pass@1 (plain) and pass $@ 8$ (dotted) for mathlib-valid and miniF $2 F$ -valid when running 8 expert iterations with $S t$ set to be the statements in mathlib-train. The $\mathbf { X }$ -axis is logscaled. It corresponds to the indices of the $\theta _ { k }$ models and serves as a good proxy to compute (the amount of test-time and train-time compute per iteration being fixed). The y-axis is scaled linearly and simply shifted between the two graphs (spans an equal range).
119
+
120
+ ![](images/38941263e270ef1dee3e9ee38ec54488b4d20a21af9e25a74e35817020c58cf8.jpg)
121
+ Figure 2: Cumulative pass rate for our expert iteration loop as well as a sample only loop where we skip re-training the model between iterations. The adjusted compute line is computed by fitting the sample only curve and shifting it to approximate a setup where we would focus all the additional compute used by expert iteration (sampling training data from mathlib-train as well as re-training models at each iteration) towards running proof searches against mathlibvalid.
122
+
123
+ As shown by Figure 2, the scaling exponent of expert iteration is substantially higher than the scaling exponent associated with solely scaling test-time compute (running more proof searches), demonstrating the clear benefit of expert iteration. We’ll denote the fully iterated model from this section as θmathlib9 .
124
+
125
+ Even in the presence of ground-truth proofs for each of the statements in mathlib-train (tactic dataset), expert iteration generates data that further improves the performance of the model. The number of statements proved in mathlib-train goes from 17390 $( 6 7 . 8 \% )$ at iteration 1 to 19476 $( 7 6 . 0 \% )$ at iteration 9, while the average proof length of these statements goes from 4.8 to 4.0. We hypothesize that this continuously improving performance through expert iteration stems from two effects: (i) the model finding new original proofs for the same statements and (ii) the model closing marginally harder statements at each iteration – which in turn provides more useful training data for the next iteration. By iteration 9, the model is trained on more than $9 0 \%$ generated data. We present in Appendix I a few examples of original proofs found by our models on mathlib-train compared with their ground-truth versions.
126
+
127
+ To verify our hypothesis that expert iteration is capable of closing a curriculum of increasingly difficult problems out of a set of problem statements, and that this capability is independent of having access to ground-truth proofs, we propose in the next section to study expert iteration applied to a synthetically generated set of problems for which we have fine-grained control on the difficulty of each statement.
128
+
129
+ # 5 STATEMENT CURRICULUM LEARNING
130
+
131
+ In this section we focus on running expert iteration on synthetic statements generated by an inequality generator. The use of synthetic statements enables us to control the difficulty of each statement to present evidence that expert iteration can hill-climb the intrinsic difficulty gradient of the resulting set
132
+
133
+ of statements. In particular, we show that, at fixed compute budget, expert iteration eventually closes proofs of hard statements that remain completely out of reach of simply sampling proof searches without interleaved training.
134
+
135
+ # 5.1 SYNTHETIC INEQUALITY GENERATOR
136
+
137
+ We designed a synthetic inequality statement generator for Lean in the spirit of the INT (Wu et al., 2021) generator. The generator consists in generating inequalities from well known inequality theorems (AM-GM, Trivial inequality, Cauchy-Schwarz, Bernoulli, Young, Hölder) and composing them. It is driven by two difficulty parameters: $N _ { D }$ which controls depth of composition of inequalities and $N _ { S }$ which controls the complexity of the input expressions to the composed inequalities. We provide details on its implementation in Appendix F.
138
+
139
+ Using this generator we generate a curriculum of 5600 inequality statements (for which we don’t have proofs), 100 for each values of $0 \le N _ { S } \le 7$ and $0 \le N _ { D } \le 6$ . We denote this set of statements as synth-ineq. To bootstrap our models capabilities on this specific task, we also generate 100 statements of low difficulty ( $N _ { D } = 1$ and $N _ { S } = 5$ ) and formalize a proof for each of these statements. We refer to this dataset as synth-ineq-train. In the rest of this paper we adjunct this training dataset to the tactic dataset used to train our models.
140
+
141
+ # 5.2 EXPERT ITERATION ON SYNTHETIC INEQUALITY STATEMENTS
142
+
143
+ In this section we propose to set $S t$ to the union of the statements in mathlib-train and synth-ineq. Again, we uniformly set $a = 1$ and use $\theta _ { 0 }$ and $\theta _ { 1 }$ as described in Section 4.3, except that they are now also trained on synth-ineq-train.
144
+
145
+ Similarly to the previous section, we report in Figure 3 the cumulative pass rate for two loops, our standard expert iteration loop, and a proof search only loop where we do not interleave training between iterations. The pass rates are reported split by values of $N _ { D }$ (pooling together $0 \le N _ { S } \le 7$ ) which we found to be the main driver for difficulty.
146
+
147
+ ![](images/33f55772b311eab974522ad234fc4f4e9c0106ba9fd7089993d50b26eaa7d7d2.jpg)
148
+ Figure 3: Cumulative pass rate for our expert iteration loop as well as a sample only loop where we skip re-training the model between iterations. Pass rates are reported for each value of $N _ { D }$ (pooling together $0 \le N _ { S } \le 7$ ).
149
+
150
+ Despite the challenging nature of these synthetic inequalities, Figure 3 demonstrates that expert iteration is capable of learning the intrinsic curriculum induced by synth-ineq. In particular, expert iteration is capable of closing 6 problems of difficulty $N _ { D } = 6$ without having been provided with any seed ground-truth proof for this difficulty level. Note that difficulty $N _ { D } = 6$ remains completely out of reach of simply scaling the number of attempts per statements (the sample only loop remaining stuck at 0 for $N _ { D } = 6$ ).
151
+
152
+ This confirms on our synthetic statements dataset synth-ineq that not only expert iteration is capable of learning the curricula occurring in a set of statements, but this process also enables the emergence of new capabilities without the need for ground-truth proofs (ability to close, highly challenging, deeply composed inequalities).
153
+
154
+ # 6 TARGETING miniF2F
155
+
156
+ Motivated by the results from Section 5, we curated and manually formalized a set of math exercises denoted as miniF $2 F$ -curriculum to target miniF2F. miniF $2 F$ -curriculum contains 327 statements from various sources, with their provenance and analysis detailed in Appendix G.
157
+
158
+ miniF $2 F$ statements being quite out of distribution compared to mathlib statements (which typically are generic theorems and lemmas), we hypothesized that if the difficulty of miniF2F-curriculum was made varied enough, expert iteration could potentially leverage it to effectively shift our models’ distribution closer to miniF $2 F$ ’s, and in turn, improve their eventual performance on it.
159
+
160
+ # 6.1 TRANSFER TO miniF2F
161
+
162
+ In this section we propose to set $S t$ to the union of the statements in mathlib-train, synth-ineq and miniF2F-curriculum. We uniformly set $a = 1$ on mathlib-train and synth-ineq and $a = 8$ on miniF $2 F$ -curriculum and use $\theta _ { 0 }$ and $\theta _ { 1 }$ as described in Section 5.
163
+
164
+ Similarly to previous sections, we report in Figure 4 (left) the cumulative pass rate on miniF $2 F$ -valid of our full curriculum expert iteration loop and compare them with the mathlib-train only expert iteration from Section 4.5. Since more compute is deployed in our full-curriculum loop (more statements), we also report a mathlib-train only loop taking $a = 2$ . At the end of the expert iteration, 100 out of the 327 statements from miniF $2 F .$ -curriculum end up being closed, suggesting a lack of density in our manually formalized set of statement.
165
+
166
+ We also report in Figure 4 (right) the pass $@ l$ and pass $@ 8$ for our full curriculum expert iteration loop. The steady improvement on miniF2F-valid shows that the expert iteration procedure we propose does not overfit on the statements that compose the curriculum it uses. Despite the potential inefficiency of our curriculum, the improved performance associated with its use demonstrates, as hypothesized, an effective transfer between miniF ${ } ^ { 7 2 F }$ -curriculum, synth-ineq and miniF2F-valid through expert iteration. We will denote the fully iterated model from this section as $\theta _ { 9 } ^ { f u l l }$ .
167
+
168
+ ![](images/04a8b08c5b09b13442660861e017e088784c96f4097bff3f86db3eb43c8ba58a.jpg)
169
+ Figure 4: Left: cumulative pass rate on miniF $2 F$ -valid for our expert iteration loop using our full curriculum (mathlib-train, synth-ineq and miniF $2 F$ -curriculum) compared to the expert iteration loop from Section 4.5. The total number of attempts per iteration in our full loop is $2 5 k + 5 . 6 k + 8 * 3 2 7 \approx$ $3 3 . 2 k$ , which means the total compute deployed is higher than in the mathlib-train only loop $( 2 5 k )$ . We therefore also report in dotted a mathlib-train only loop, taking $a = 2$ , whose total number of attempts per iteration is $\approx 5 0 k$ . Right: pass $@ l$ (plain) and pass $@ 8$ (dotted) for our expert iteration loop using our full curriculum (mathlib-train, synth-ineq and miniF $2 F$ -curriculum) compared to the expert iteration loop from Section 4.5.
170
+
171
+ # 6.2 RESULTS
172
+
173
+ We report in Table 2 the pass rates on mathlib-{valid, test} and miniF2F-{valid, test} for the models trained in previous sections, namely $\theta _ { 1 }$ , θmathlib9 , and $\theta _ { 9 } ^ { f u l l }$ . We achieve a $4 7 . 3 \%$ pass rate (using $a = 6 4$ attempts) on miniF $2 F .$ -valid and a $3 6 . 6 \%$ pass rate on miniF2F-test, substantially improving from the previous state-of-the-art (Zheng et al., 2022).
174
+
175
+ These results include the resolution of 26 AMC12 problems, 6 AIME problems and 2 IMO-adapted problems. Out of these statements, 4 AMC12 problems (amc12b_2020_p5, amc12a_2009_p9, amc12a_2003_p24, amc12b_2003_p17), 2 AIME problems (aime_1984_p1, aime_1990_p4), and 2 IMO-adapted problems $( \mathrm { i } \mathsf { m o } _ { - } 1 9 6 1 \mathsf { \Pi } _ { - } \mathsf { p } 1 ^ { 2 }$ , imo_1964_p2) are uniquely solved by expert iterated models, the two IMO-adapted and the two AIME problems being uniquely solved by $\theta _ { 9 } ^ { \bar { f } u l l }$ .
176
+
177
+ Table 2: Performance of $\theta _ { 1 }$ (value-function based search), $\theta _ { 9 } ^ { m a t h l i b }$ (expert iterated on mathlib-train) and $\theta _ { 9 } ^ { f u l l }$ (expert iterated on our full curriculum) on mathlib-{valid, test} and miniF2F-{valid, test}. All proof searches are run with $d = 5 1 2$ and $e = 8$ .
178
+
179
+ <table><tr><td>Model</td><td>pass@1</td><td>pass@8</td><td>pass@64</td><td>pass@1</td><td>pass@8</td><td>pass@64</td></tr><tr><td>mathlib-valid</td><td></td><td></td><td></td><td>mathlib-test</td><td></td><td></td></tr><tr><td>PACT (Han et al.,2022)</td><td>48.4%</td><td></td><td></td><td>=</td><td></td><td></td></tr><tr><td>01</td><td>56.3%</td><td>66.3%</td><td>72.0%</td><td>56.5%</td><td>66.9%</td><td>73.7%</td></tr><tr><td></td><td>62.6%</td><td>70.7%</td><td>75.8%</td><td>63.0%</td><td>71.5%</td><td>77.1%</td></tr><tr><td>G</td><td>61.7%</td><td>69.8%</td><td>75.3%</td><td>62.9%</td><td>71.6%</td><td>76.3%</td></tr><tr><td>miniF2F-valid</td><td></td><td></td><td></td><td>miniF2F-test</td><td></td><td></td></tr><tr><td>PACT (Zheng et al., 2022)</td><td>23.9%</td><td>29.3%</td><td></td><td>24.6%</td><td>29.2%</td><td></td></tr><tr><td>01</td><td>28.5%</td><td>35.5%</td><td>41.2%</td><td>25.9%</td><td>31.1%</td><td>33.6%</td></tr><tr><td>ggahibh</td><td>31.3%</td><td>38.3%</td><td>44.1%</td><td>27.2%</td><td>33.0%</td><td>35.2%</td></tr><tr><td></td><td>33.6%</td><td>41.2%</td><td>47.3%</td><td>29.6%</td><td>34.5%</td><td>36.6%</td></tr></table>
180
+
181
+ We provide a selection of the proofs found by our models for these statements as well as a qualitative analysis of them in Appendix J. Also, we achieve a new state-of-the-art: higher than $7 5 \%$ pass rate (using $a = 6 4$ attempts) on mathlib-{valid, test}, suggesting that our models could potentially be effectively leveraged as proof assistants in the formalization efforts associated with mathlib.
182
+
183
+ # 7 DISCUSSION AND LIMITATION
184
+
185
+ Throughout this paper, we used a single model size ( $7 7 4 \mathrm { m }$ trainable parameters). We refer readers to Appendix H for more discussion on model size, compute budget and training time. Despite our models’ capability, as discussed in Appendix J.1, to generate cuts and witnesses, we believe that their current main limitation lies in their inability (under our proposed search procedure) to chain more than 2 or 3 non-trivial steps of mathematical reasoning, preventing them from consistently solving challenging olympiad problems. We’ve been repeatedly impressed by the complexity of some of the proofsteps generated by our models. But, proofs requiring many of such reasoning steps remain beyond our current compute horizon. Even if we solved a selection of challenging olympiad problems, our models are still far from being competitive with the brightest students in these competitions.
186
+
187
+ While our models have demonstrated some capabilities to generate cuts, the cuts they generate are often shallow (they involve only a few proofsteps and don’t necessarily deeply change the structure of the proof–we refer the reader to the Cut-Elimination theorem and Carbone & Semmes (1996) for a discussion of the influence of cuts on proof size). We believe that studying language models’ ability to generate cuts, and designing search procedures that leverage that capability (related ideas can be found in Czechowski et al. (2021)), are interesting avenues of research to alleviate this limitation.
188
+
189
+ # 8 CONCLUSION
190
+
191
+ In this paper we presented an expert iteration procedure for GPT-f (Polu & Sutskever, 2020), demonstrating that it is capable of solving a curriculum of increasingly difficult problems out of a set of formal statements of sufficiently varied difficulty. Our results suggest that the lack of self-play in the formal mathematics setup can be effectively compensated for by automatically/manually curated sets of formal statements, which are much cheaper to formalize than full proofs. Finally, we hope that the statement curriculum learning methodology we presented in this work will help accelerate progress in automated reasoning, especially if scaled with automated generation and curation of formal statements in the future.
192
+
193
+ # REFERENCES
194
+
195
+ Lean theorem prover. https://leanprover.github.io/about/.
196
+
197
+ Kshitij Bansal, Sarah M Loos, Markus N Rabe, and Christian Szegedy. Learning to reason in large theories without imitation. arXiv preprint arXiv:1905.10501, 2019a.
198
+
199
+ Kshitij Bansal, Sarah M. Loos, Markus N. Rabe, Christian Szegedy, and Stewart Wilcox. Holist: An environment for machine learning of higher order logic theorem proving. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, volume 97 of Proceedings of Machine Learning Research, pp. 454–463. PMLR, 2019b. URL http://proceedings.mlr.press/v97/bansal19a.html.
200
+
201
+ Christopher Berner, Greg Brockman, Brooke Chan, Vicki Cheung, Przemysław D˛ebiak, Christy Dennison, David Farhi, Quirin Fischer, Shariq Hashme, Chris Hesse, et al. Dota 2 with large scale deep reinforcement learning. arXiv preprint arXiv:1912.06680, 2019.
202
+
203
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 1877–1901. Curran Associates, Inc., 2020. URL https://proceedings.neurips. cc/paper/2020/file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
204
+
205
+ Cameron B Browne, Edward Powley, Daniel Whitehouse, Simon M Lucas, Peter I Cowling, Philipp Rohlfshagen, Stephen Tavener, Diego Perez, Spyridon Samothrakis, and Simon Colton. A survey of monte carlo tree search methods. IEEE Transactions on Computational Intelligence and AI in games, 4(1):1–43, 2012.
206
+
207
+ Kevin Buzzard, Johan Commelin, and Patrick Massot. Lean perfectoid spaces. https:// leanprover-community.github.io/lean-perfectoid-spaces/, 2019.
208
+
209
+ Alessandra Carbone and S. Semmes. Making proofs without modus ponens: An introduction to the combinatorics and complexity of cut elimination. Bulletin of the American Mathematical Society, 34:131–159, 1996.
210
+
211
+ Konrad Czechowski, Tomasz Odrzygó´zd´z, Marek Zbysinski, MichałZawalski, Krzysztof Ole- ´ jnik, Yuhuai Wu, Ł ukasz Kucinski, and Piotr Mił o ´ s. Subgoal search for complex rea- ´ soning tasks. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P.S. Liang, and J. Wortman Vaughan (eds.), Advances in Neural Information Processing Systems, volume 34, pp. 624–638. Curran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper/2021/file/ 05d8cccb5f47e5072f0a05b5f514941a-Paper.pdf.
212
+
213
+ Leonardo de Moura, Soonho Kong, Jeremy Avigad, Floris Van Doorn, and Jakob von Raumer. The lean theorem prover (system description). In International Conference on Automated Deduction, pp. 378–388. Springer, 2015.
214
+
215
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. In Jill Burstein, Christy Doran, and Thamar Solorio (eds.), Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT 2019, volume 1, pp. 4171–4186. Association for Computational Linguistics, 2019. doi: 10.18653/v1/ n19-1423. URL https://doi.org/10.18653/v1/n19-1423.
216
+
217
+ Vlad Firoiu, Eser Aygun, Ankit Anand, Zafarali Ahmed, Xavier Glorot, Laurent Orseau, Lei Zhang, Doina Precup, and Shibl Mourad. Training a first-order theorem prover from synthetic data. arXiv preprint arXiv:2103.03798, 2021.
218
+
219
+ Jesse Michael Han, Jason Rute, Yuhuai Wu, Edward Ayers, and Stanislas Polu. Proof artifact cotraining for theorem proving with language models. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=rpxJc9j04U.
220
+
221
+ Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Song, and Jacob Steinhardt. Measuring mathematical problem solving with the MATH dataset. In Joaquin Vanschoren and Sai-Kit Yeung (eds.), Proceedings of the Neural Information Processing Systems Track on Datasets and Benchmarks 1, NeurIPS Datasets and Benchmarks 2021, 2021. URL https://datasets-benchmarks-proceedings.neurips.cc/paper/2021/hash/ be83ab3ecd0db773eb2dc1b0a17836a1-Abstract-round2.html.
222
+
223
+ Daniel Huang, Prafulla Dhariwal, Dawn Song, and Ilya Sutskever. Gamepad: A learning environment for theorem proving. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=r1xwKoR9Y7.
224
+
225
+ Geoffrey Irving, Christian Szegedy, Alexander A Alemi, Niklas Een, Francois Chollet, and Josef Urban. Deepmath - deep sequence models for premise selection. In D. Lee, M. Sugiyama, U. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 29, pp. 2235–2243. Curran Associates, Inc., 2016. URL https://proceedings.neurips. cc/paper/2016/file/f197002b9a0853eca5e046d9ca4663d5-Paper.pdf.
226
+
227
+ Albert Q Jiang, Wenda Li, Szymon Tworkowski, Konrad Czechowski, Tomasz Odrzygó´zd´z, Piotr Miłos, Yuhuai Wu, and Mateja Jamnik. Thor: Wielding hammers to integrate language models ´ and automated theorem provers. arXiv preprint arXiv:2205.10893, 2022.
228
+
229
+ Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020.
230
+
231
+ Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2019, pp. 4401–4410. Computer Vision Foundation / IEEE, 2019. doi: 10.1109/CVPR.2019.00453. URL http://openaccess.thecvf.com/content_CVPR_2019/html/Karras_A_Style-Based_ Generator_Architecture_for_Generative_Adversarial_Networks_CVPR_2019_paper. html.
232
+
233
+ Guillaume Lample, Marie-Anne Lachaux, Thibaut Lavril, Xavier Martinet, Amaury Hayat, Gabriel Ebner, Aurélien Rodriguez, and Timothée Lacroix. Hypertree proof search for neural theorem proving. CoRR, abs/2205.11491, 2022. doi: 10.48550/arXiv.2205.11491. URL https://doi. org/10.48550/arXiv.2205.11491.
234
+
235
+ Sandor Lehoczky and Richard Rusczyk. The Art of Problem Solving, Volume 1: the Basics, a. ISBN:978-0-9773045-6-1.
236
+
237
+ Sandor Lehoczky and Richard Rusczyk. The Art of Problem Solving, Volume 2: and Beyond, b. ISBN:978-0-9773045-8-5.
238
+
239
+ Wenda Li, Lei Yu, Yuhuai Wu, and Lawrence C. Paulson. Isarstep: a benchmark for high-level mathematical reasoning. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=Pzj6fzU6wkj.
240
+
241
+ Sarah M. Loos, Geoffrey Irving, Christian Szegedy, and Cezary Kaliszyk. Deep network guided proof search. In Thomas Eiter and David Sands (eds.), 21st International Conference on Logic for Programming, Artificial Intelligence and Reasoning, LPAR-21, volume 46 of EPiC Series in Computing, pp. 85–105, 2017. doi: 10.29007/8mwc. URL https://doi.org/10.29007/8mwc.
242
+
243
+ Norman D. Megill and David A. Wheeler. Metamath: A Computer Language for Pure Mathematics, 2019. URL http://us.metamath.org/downloads/metamath.pdf.
244
+
245
+ Lawrence C. Paulson. Three years of experience with sledgehammer, a practical link between automatic and interactive theorem provers. In Renate A. Schmidt, Stephan Schulz, and Boris Konev (eds.), Proceedings of the 2nd Workshop on Practical Aspects of Automated Reasoning, PAAR-2010, Edinburgh, Scotland, UK, July 14, 2010, volume 9 of EPiC Series in Computing, pp. 1–10. EasyChair, 2010. doi: 10.29007/tnfd. URL https://doi.org/10.29007/tnfd.
246
+
247
+ Stanislas Polu and Ilya Sutskever. Generative language modeling for automated theorem proving. arXiv preprint arXiv:2009.03393, 2020.
248
+
249
+ Markus Norman Rabe, Dennis Lee, Kshitij Bansal, and Christian Szegedy. Mathematical reasoning via self-supervised skip-tree training. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=YmqAnY0CMEy.
250
+
251
+ Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, ICML 2021, volume 139 of Proceedings of Machine Learning Research, pp. 8748–8763. PMLR, 2021. URL http://proceedings.mlr.press/v139/radford21a.html.
252
+
253
+ Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, ICML 2021, volume 139 of Proceedings of Machine Learning Research, pp. 8821–8831. PMLR, 2021. URL http://proceedings.mlr.press/v139/ramesh21a.html.
254
+
255
+ Peter Scholze. Liquid tensor experiment. https://xenaproject.wordpress.com/2020/12/05/ liquid-tensor-experiment/, 2020.
256
+
257
+ Daniel Selsam, Matthew Lamm, Benedikt Bünz, Percy Liang, Leonardo de Moura, and David L. Dill. Learning a SAT solver from single-bit supervision. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=HJMC_iA5tm.
258
+
259
+ 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.
260
+
261
+ David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, et al. Mastering chess and shogi by self-play with a general reinforcement learning algorithm. arXiv preprint arXiv:1712.01815, 2017.
262
+
263
+ Mingxing Tan and Quoc V. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, volume 97 of Proceedings of Machine Learning Research, pp. 6105–6114. PMLR, 2019. URL http://proceedings.mlr.press/v97/ tan19a.html.
264
+
265
+ Josef Urban and Jan Jakubuv. First neural conjecturing datasets and experiments. In Christoph Benzmüller and Bruce R. Miller (eds.), Intelligent Computer Mathematics - 13th International Conference, CICM 2020, volume 12236 of Lecture Notes in Computer Science, pp. 315–323. Springer, 2020. doi: 10.1007/978-3-030-53518-6\_24. URL https://doi.org/10.1007/ 978-3-030-53518-6_24.
266
+
267
+ Oriol Vinyals, Igor Babuschkin, Wojciech M Czarnecki, Michaël 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.
268
+
269
+ Mingzhe Wang, Yihe Tang, Jian Wang, and Jia Deng. Premise selection for theorem proving by deep graph embedding. In I. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 30, pp. 2786– 2796. Curran Associates, Inc., 2017. URL https://proceedings.neurips.cc/paper/2017/ file/18d10dc6e666eab6de9215ae5b3d54df-Paper.pdf.
270
+
271
+ Daniel Whalen. Holophrasm: a neural automated theorem prover for higher-order logic. CoRR, abs/1608.02644, 2016. URL http://arxiv.org/abs/1608.02644.
272
+
273
+ Mark H. Winands, Yngvi Björnsson, and Jahn-Takeshi Saito. Monte-carlo tree search solver. In Proceedings of the 6th International Conference on Computers and Games, pp. 25–36. SpringerVerlag, 2008. doi: 10.1007/978-3-540-87608-3_3.
274
+
275
+ Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang Macherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Google’s neural machine translation system: Bridging the gap between human and machine translation. arXiv preprint arXiv:1609.08144, 2016.
276
+
277
+ Yuhuai Wu, Albert Jiang, Jimmy Ba, and Roger Baker Grosse. INT: an inequality benchmark for evaluating generalization in theorem proving. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=O6LPudowNQm.
278
+
279
+ Yuhuai Wu, Albert Qiaochu Jiang, Wenda Li, Markus Norman Rabe, Charles E Staats, Mateja Jamnik, and Christian Szegedy. Autoformalization with large language models. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho (eds.), Advances in Neural Information Processing Systems, 2022. URL https://openreview.net/forum?id=IUikebJ1Bf0.
280
+
281
+ Kaiyu Yang and Jia Deng. Learning to prove theorems via interacting with proof assistants. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, volume 97 of Proceedings of Machine Learning Research, pp. 6984–6994. PMLR, 2019. URL http://proceedings.mlr.press/v97/yang19a. html.
282
+
283
+ Kunhao Zheng, Jesse Michael Han, and Stanislas Polu. minif2f: a cross-system benchmark for formal olympiad-level mathematics. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=9ZPegFuFTFv.
284
+
285
+ # A RELATED WORK
286
+
287
+ Deep learning applied to premise selection and proof guidance Early applications of deep learning to formal mathematics focused primarily on premise selection and proof guidance. DeepMath (Irving et al., 2016) explored the use of CNNs and RNNs to predict whether a premise is useful to demonstrate a given conjecture. Their results were later improved with FormulaNet (Wang et al., 2017) by the use of graph neural networks, reminiscent of NeuroSAT (Selsam et al., 2019). Proof guidance consists in selecting the next clause to process inside an automated theorem prover. Loos et al. (2017) investigated the use of models similar to DeepMath’s for proof guidance and demonstrated a significant uplift on the Mizar library. More recently Firoiu et al. (2021) demonstrated the potential of deep learning techniques to be competitive with E prover’s heuristics when applied to resolution calculus while training on fully synthetic data.
288
+
289
+ Deep learning applied to automated theorem-proving HOList (Bansal et al., 2019b) proposes a formal environment based on HOL Light. They achieve their best performance (Bansal et al., 2019a) with a GNN model designed for premise selection and the use of exploration. The same team studied the use of a skip-tree objective with Transformers on formal statements (Rabe et al., 2021), demonstrating, along with GPT-f (Polu & Sutskever, 2020), the potential of leveraging Transformers for formal reasoning. GamePad (Huang et al., 2019) and CoqGymn/ASTactic (Yang & Deng, 2019) introduce environments based on the Coq theorem prover. ASTactic generates tactics as programs by sequentially expanding a partial abstract syntax tree. Urban & Jakubuv (2020) studied the capability of GPT-2 to produce useful conjectures for the Mizar library and IsarStep (Li et al., 2021) explored the synthesis of intermediate propositions in declarative proofs for Isabelle/HOL using Transformers.
290
+
291
+ Targeting miniF2F Lample et al. (2022) designed HyperTree Proof Search (HTPS), an online training procedure targeting Lean, Metamath and hand-crafted environment named Equations. Lample et al. (2022) report $41 \%$ pass-rate on miniF $2 F$ -test and $4 2 . 5 \%$ pass-rate on miniF $2 F .$ -curriculum in Lean (de Moura et al., 2015; lea) setup. Thor (Jiang et al., 2022) combined language model and Sledgehammer (Paulson, 2010) and achieved $2 9 . 9 \%$ pass-rate on miniF $2 F$ -test in Isabelle setup, which is later improved to $3 5 . 2 \%$ by $\mathbf { W } \mathbf { u }$ et al. (2022) leveraging autoformalization and expert iteration.
292
+
293
+ # B LEAN-GYM
294
+
295
+ lean-gym presents the following API:
296
+
297
+ • init-search: declaration tactic_state. Takes a declaration name (a theorem name from the loaded library) and initializes a search while setting the run-time environment at that particular declaration. It returns the initial tactic state along with a fresh search_id and tactic_state_id.
298
+ • run_tac: (tactic_state, tactic) tactic_state. Takes a search_id and a tactic_state_id to identify a tactic state, as well as a tactic string to apply to it. It returns a new tactic state and its associated tactic_state_id.
299
+
300
+ Below is an example in-terminal trace demonstrating the use of lean-gym’s REPL interface:
301
+
302
+ $\$ 1$ lean --run src/repl.lean
303
+ ["init_search", ["int.prime.dvd_mul", ""]]
304
+ { "error":null, "search_id":"0", "tactic_state":"⊢ ∀ {m n : Z} {p : N}, nat.prime p → ↑p | m \* n → p | m.nat_abs ∨ p | n.nat_abs", "tactic_state_id":"0"
305
+ }
306
+ ["run_tac",["1","1","apply (nat.prime.dvd_mul hp).mp"]]
307
+ {
308
+
309
+ "error":null, "search_id":"1", "tactic_state":"m n : Z, p : N, hp : nat.prime p, h : ↑p | m \* n ⊢ p | m.nat_abs $\star$ n.nat_abs", "tactic_state_id":"2" }
310
+
311
+ Using lean-gym is virtually equivalent to opening a Lean editor at a specific theorem, deleting its proof and interacting with Lean to reconstruct it.
312
+
313
+ Providing a REPL interface over the standard input/output makes it very easy to integrate lean-gym from any programming language. Writing a wrapper in Python, as an example, only takes a few dozen lines of code. Since lean-gym is a Lean program, managing the loaded libraries is done directly using Lean’s own infrastructure (using leanpkg.toml), making it quite straightforward to have access to both mathlib and miniF2F statements from the same lean-gym instance.
314
+
315
+ Note that lean-gym is stateful, meaning that distributing proof searches on multiple lean-gym instances requires to track which instance is associated with which proof search. In practice, we were able to scale the use of lean-gym to thousands of cores running thousands of proof searches in parallel. Finally, lean-gym’s REPL interface is blocking, preventing inner-proof search parallelization, though this limitation can probably be removed in the future.
316
+
317
+ # C WEBMATH
318
+
319
+ Our updated WebMath pre-training dataset consists in the mix presented in table 3.
320
+
321
+ Table 3: Mix and source of data involved in the updated WebMath pre-training.
322
+
323
+ <table><tr><td>Dataset</td><td>Size</td><td>Mix</td></tr><tr><td>Github Python</td><td>179 GB</td><td>25%</td></tr><tr><td>arXiv Math</td><td>10 GB</td><td>25%</td></tr><tr><td>Math StackExchange</td><td>2GB</td><td>25%</td></tr><tr><td>PACT mix2</td><td>28GB</td><td>17%</td></tr><tr><td>Math Overflow</td><td>200 M</td><td>5%</td></tr><tr><td>ProofWiki</td><td>30M</td><td>2%</td></tr><tr><td>PlanetMath</td><td>25M</td><td>1%</td></tr></table>
324
+
325
+ As demonstrated in table 3, we empirically up-weighted (compared to their token size) parts of WebMath with high-quality mathematical content while making sure they don’t overfit (despite running ${ > } 1$ epochs for some of them). We also included PACT $\mathfrak { m i x } 2$ directly in the WebMath pre-training to avoid having to sequence more than two pre-training phases to prepare Lean models.
326
+
327
+ # D EXAMPLE OF MINIF2F INPUT, LEAN ENVIRONMENT AND MODEL OUTPUT
328
+
329
+ We illustrate an example of the interaction between Lean environment and our model. In the figure shown below, the model has 1 output for each current goal (corresponding to 1 expand budget). The model could have expand budget bigger than 1, in which case the search procedure becomes a tree.
330
+
331
+ ![](images/db2c66d3a90c324b1666efbcb33678a738637518c2c92073a466b625aff826d8.jpg)
332
+ Figure 5: Input from miniF $2 F$ consists of a mathematical statement written in formal language (here the Lean version) without proof. Lean environment parses the statement and exposes to users the goal to be proved. The model outputs a line of code (tactics and corresponding arguments). Lean environment receives the model output and transforms the previous goal to another goal to be proved. This process is repeated till all remaining goals are closed. In this case, the original statement is proved: the final proof is collected by following the trajectory of model’s output.
333
+
334
+ # E ILLUSTRATION OF EXPERT ITERATION
335
+
336
+ ![](images/9797ed05f1f348d3cda8cf3dcbcc103be5583e5290f598625053ea3f06dfab7b.jpg)
337
+ Figure 6: Illustration of expert iteration. The notation in this figure corresponds to Section 4.4 in main text.
338
+
339
+ # F SYNTHETIC INEQUALITIES
340
+
341
+ F.1 DESIGN
342
+
343
+ The generator consists of three phases:
344
+
345
+ Seed expressions generation The first phase consists in generating seed expressions for which we track the sign. We start by initializing an expression set $E$ composed of tuples of expressions and sign constraints, by generating $n _ { v }$ variable names (letters) assumed strictly positive as well as $n _ { n }$ integers (for which we know the sign). For $N _ { S }$ rounds, we compose elements of $E$ using unary $( l o g ( \cdot ) , \bar { l o g } ( 1 / \cdot ) , s q r t ( \cdot ) )$ or binary operations $( + , - , \times , / , \wedge , m a x , m i n )$ for which we can deduce the sign based on the sign condition of the input expression(s) and re-inject the resulting expression and sign constraint in $E$ . This produces a set $E$ of signed seed expressions of size $n _ { v } + n _ { n } + N _ { S }$ .
346
+
347
+ Inequality composition The second phase consists in generating inequalities from well known inequality theorems (AM-GM, Trivial inequality, Cauchy-Schwarz, Bernoulli, Young, Hölder) taking as input to these theorems expressions from $E$ based on the sign constraints required for each theorem. We finally compose these inequalities $N _ { D }$ times using compositions theorems detailed in F.2. The resulting inequality is a composed inequality of depth $N _ { D }$ based on $n _ { v } + n _ { n } + N _ { S }$ seed expressions.
348
+
349
+ Simplification We finally post-process these inequalities so that they are parsable by Lean and run them through Lean’s simp tactic for a final simplification.
350
+
351
+ $N _ { D }$ and $N _ { S }$ together control for the difficulty of the resulting inequality. $N _ { D }$ controls depth of composition, while $N _ { S }$ controls for obfuscation as it increases the complexity of the input expressions to the composed inequalities. When sampling inequalities, we $n _ { n } ~ = ~ 4$ and randomly sample $2 \leq n _ { v } \leq 8$ at each generation. We report below examples of generated inequalities for various values of $N _ { D }$ and $N _ { S }$ .
352
+
353
+ # F.2 LIST OF INEQUALITY COMPOSITION THEOREMS
354
+
355
+ Below is the list of theorem names from mathlib that we use to compose inequalities together. One third of the time, we only transform the current composed inequality with one of the following theorems:
356
+
357
+ • neg_le_neg
358
+ • inv_le_inv
359
+ • mul_self_le_mul_self
360
+ • div_le_one_of_le
361
+
362
+ We otherwise compose the current composed inequality with a newly generated inequality using the following theorems:
363
+
364
+ • mul_le_mul
365
+ • add_le_add
366
+ • div_le_div
367
+ • mul_le_mul_of_nonneg
368
+ • le_mul_of_ratio
369
+
370
+ F.3 EXAMPLES
371
+
372
+ $$
373
+ \begin{array} { c } { { N _ { D } = 0 \ N _ { S } = 0 } } \\ { { { } } } \\ { { N _ { D } = 0 \ N _ { S } = 4 } } \end{array}
374
+ $$
375
+
376
+ <table><tr><td>Compositions</td><td>AmGm a b (67:R)((1:R)/(10:R))((1:R)/(10:R)) ((8:R)/(10:R))</td></tr><tr><td>Statement</td><td>theorem synthetic_ineq_nb_seed_var_0_depth_0_p_1 (ab:R) (h0:0&lt;a) (h1:0&lt;b): (67:R)^((8:R)/(10:R))*b^(10:R)-1 * a^(10:R)-1≤ (8:R)/(10:R)* (67:R) + (10:R)-1 * a+b* (10:R)-1 := sorry</td></tr></table>
377
+
378
+ <table><tr><td>Compositions</td><td>Sqnonneg a ((a)+((-68:R)))</td></tr><tr><td>Statement</td><td>theorem synthetic_ineq_nb_seed_var_4_depth_0_p_4 (ab:R) (h0 :0&lt;a) (h1:0&lt;b): (2:R)*(a*(a+-(68:R)))≤ (a +-(68:R))^2 +a^2 := sorry</td></tr></table>
379
+
380
+ $$
381
+ N _ { D } = 4 N _ { S } = 4
382
+ $$
383
+
384
+ <table><tr><td>Compositions</td><td>AddLeAdd Bernoulli 99 c AddLeAdd SelfDivConst((a)/(f))6 LeMulOfRatio SelfDivConst c 70 DivLeDiv Cauchy((a)/(f))dc(log(((59:R)+ f))) Young((a)/(f))a((3:R)/(2:R))((3:R)/(1:R)) theorem synthetic_ineq_nb_seed_var_4_depth_4_p_13</td></tr><tr><td>Statement</td><td>(abcdef:R) (h0 :0&lt;a) (h1 :0&lt;b) (h2 :0&lt;c) (h3:0&lt;d) (h4 :0&lt;e) (h5:0&lt;f): (1:R)+(99:R)*c+(a/f/(6:R)+a*(a/f)/ ((d^2+a^2/f^2)* (real.log((59:R)+f)^2+c^2)))≤ ((a/f)^((3:R)/(2:R))/((3:R)/(2:R))+ a^3/(3:R))/ (real.log((59:R)+f)*d+a/ f*c)^2 * (c/(c/(70:R)))+a/f+(c+(1:R))^99 := sorry</td></tr></table>
385
+
386
+ # G MINIF2F-CURRICULUM
387
+
388
+ The 327 statements of miniF2F-curriculum3 are manually formalized from:
389
+
390
+ • AOPS Books (Lehoczky & Rusczyk, a;b): 302 examples and exercises. The books are classic problem solving textbooks for students in grades 7-12 preparing for contests such as AMCs and AIMEs. We skipped problems that were too challenging to formalize due to missing infrastructure in mathlib or non-suitable format for formalization (see section Formalization effort and challenges in Zheng et al. (2022)).
391
+
392
+ • MATH (Hendrycks et al., 2021) dataset: 25 problems. All problems were drawn from the train split of the dataset, focusing on difficulty 5 problems (miniF2F only contains problems from the test split).
393
+
394
+ We verified (based on problem provenance and manual inspection of statements) that miniF2Fcurriculum had an empty intersection with miniF2F-{test, valid}. We refer to Zheng et al. (2022) for more details on the formalization procedure and the typical time needed for it as these problems were formalized in similar conditions.
395
+
396
+ # H MODEL SIZE
397
+
398
+ Other than the single model size we use in the experiment reported in the main text $7 7 4 \mathrm { m }$ trainable parameters), we briefly experimented with different model sizes (not reported in this paper) and found that model size scaling is not as straightforward as in the case of unsupervised learning (Kaplan et al., 2020). We found that bigger models are better, in the sense that they consistently exhibit higher $p a s s @ { I }$ . But, they are also much more expensive to sample from. And despite their pass@1 being higher, it is often the case that for a fixed amount of compute, sampling more attempts from a smaller model leads to a better final performance.
399
+
400
+ For the compute budget we had available, we estimated the model size we used to be a compelling trade-off. We leave as future work a more thorough study of these dynamics to better understand the different compute frontiers involved. Indicatively, with our $7 7 4 \mathrm { m }$ parameters model, running a full expert iteration to train $\theta _ { 9 } ^ { f u l l }$ required about $2 0 0 0 \mathrm { { A } 1 0 0 }$ days of compute. Running one full proof search $( a = 1 ~ d = 5 1 2 ~ e = 8 )$ when properly parallelised, requires on average about 0.1 A100 hour of compute.
401
+
402
+ # I EXAMPLE PROOFS FROM mathlib-train
403
+
404
+ We present in this section original proofs found by our models from mathlib-train, compared with their ground-truth version.
405
+
406
+ comap_eq_of_inverse
407
+
408
+ <table><tr><td rowspan=1 colspan=1>Statement</td><td rowspan=1 colspan=1>lemma comap_eq_of_inverse {f:filter α} {g:filter β}{Φ:α→β} (φ:β→α)(eq:γ○Φ=id)(hΦ : tendsto f g)(hψ :tendsto 𝜑 g f):comap Φ g = f :=</td></tr><tr><td rowspan=1 colspan=1>Ground-truth</td><td rowspan=1 colspan=1>beginrefine((comap_mono $map_le_iff_le_comap.1 h).trans_).antisymm(map_le_iff_le_comap.1 hΦ),rw [comap_comap,eq,comap_id],exact le_rflend</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>beginrefine le_antisymm _ (filter.map_le_iff_le_comap.1 h),refine 入s hs,-,rw mem_comap,use [ -1&#x27; s,h hs],rw[← preimage_comp,eq,preimage_id]end</td></tr></table>
409
+
410
+ sum_range_sub_sum_range
411
+
412
+ <table><tr><td rowspan=1 colspan=1>Statement</td><td rowspan=1 colspan=1>lemma sum_range_sub_sum_range {α :Type*}[add_comm_group α]{f:N→α}{nm:N}(hnm:n≤m):∑k in range m,fk-∑kin range n,fk =∑k in (range m).filter (λk,n≤k),f k :=</td></tr><tr><td rowspan=1 colspan=1>Ground-truth</td><td rowspan=1 colspan=1>beginrw[← sum_sdiff(@filter_subset _(λ k,n ≤k)_(range m)),sub_eq_iff_eq_add,← eq_sub_iff_add_eq,add_sub_cancel&#x27;],refine finset.sum_congr(finset.ext $入 a,&lt; h,by simp at *;finish,入 h,have ham :a&lt;m :=lt_of_lt_of_le (mem_range.1 h)hnm,by simp * at *&gt;)(λ__,rfl)end</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>beginrw[← sum_Ico_eq_sub_ hnm],congr,apply finset.ext,simp [Ico.mem,*],tautoend</td></tr></table>
413
+
414
+ prod_inv_distrib
415
+
416
+ <table><tr><td rowspan=1 colspan=1>Statement</td><td rowspan=1 colspan=1>lemma prod_inv_distrib :(II× in s,(f x)-1)=①I×in s,f x)-1 :=</td></tr><tr><td rowspan=1 colspan=1>Ground-truth</td><td rowspan=1 colspan=1>beginclassical,by_casesh:×∈s,fx=0,{simpa [prod_eq_zero_iff.mpr h,prod_eq_zero_iff]using h },{ push_neg at h,have h&#x27; := prod_ne_zero_iff.mpr h,have hf :∀x ∈ s,(f x)-1 * fx=1 :=λx hx,inv_mul_cancel (h × hx),apply mul_right_cancel&#x27;h&#x27;,simp[h,h&#x27;,← finset.prod_mul_distrib,prod_congr rfl hf]}end</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>beginclassical;induction s usingfinset.induction_on with a s has ih,{simp,},simp only[has,prod_insert has,mul_inv_rev&#x27;],finishend</td></tr></table>
417
+
418
+ # J EXAMPLE PROOFS FROM miniF2F-{test, valid, curriculum}
419
+
420
+ We present in this section proofs found by our models from miniF2F-{test, valid, curriculum}, demonstrating some of the capabilities emerging from our training procedure.
421
+
422
+ # J.1 QUALITATIVE ANALYSIS OF PROOFS
423
+
424
+ We provide qualitative insights in the nature of the proofs found by our models, which we believe are useful to build a better intuition of their capabilities beyond pass rate numbers. Throughout this section, we refer to statements and solutions found by our models that are presented in Appendix J along with comments describing the specificity of each proof.
425
+
426
+ First, we observe that a large number of olympiad problems that are designed to be computationally challenging for humans are rendered trivial for our models through the use of Lean tactics. As an example, mathd_numbertheory_447 which is not necessarily considered straightforward for humans, can be closed in Lean by a simple refl (proof found by our models).
427
+
428
+ In recent years, Lean’s mathlib community has developed high-powered tactics such as linarith/nlinarith (solves (non)linear inequalities), norm_num (normalizes numerical expressions), simp (simplifies goals and hypotheses) and ring (normalizes expressions in a ring). These tactics can be used with arguments to guide their underlying search procedure. As mentioned in Zheng et al. (2022), we confirm here that our models acquire advanced capabilities to leverage these high-level tactics by providing exogenous arguments which are not present in the current tactic state. The generation of these exogenous arguments through language modeling seems to require a non-trivial amount of mathematical intuition. imo_1964_p2, imo_1961_p1 and aime_1990_p15 are good examples of such uses.
429
+
430
+ We have also observed a number of proofs that require multiple non-trivial reasoning steps through the use of lower-level tactics such as use, have, or by_cases that generally involve producing a witness or chaining implications, requiring the generation of context specific exogenous terms. These interesting reasoning steps are structurally different from simple normalization, simplification and rewriting of hypotheses or goals because they heavily rely on our models ability to generate meaningful cuts or witnesses. This capability is, in our opinion, the most exciting stepping stone towards solving more challenging mathematical problems. See, aopsbook_v2_c8_ex1, amc12b_2020_p6 and mathd_train_algebra_217 for examples of such proofs.
431
+
432
+ More generally, we also observe that proofs generated by our models have a distinctive style compared to proofs formalized by humans. This stems in part from the model’s capability to leverage high-level tactics in a way that is challenging for humans as discussed in this section (e.g. one-liners such as nlinarith [sq_nonneg $( \textsf { x } \texttt { - y } )$ , sq_nonneg $( \mathsf { y } \mathrm { ~ ~ { ~ - ~ } ~ } \mathsf { z } ) ]$ where humans would generally decompose the problem in a less machine-like way). Additionally, as a result of our search procedure and despite the bias towards shorter proofs introduced by our value function, extraneous proofsteps (such as reversion/introduction of hypotheses, or no-op rewrites) are often interleaved with useful ones, which rarely happens in human formalizations.
433
+
434
+ imo_1961_p1 imo_1964_p2 aime_1990_p15 mathd_train_algebra_217 amc12b_2020_p6 mathd_algebra_140 aime_1984_p1 aopsbook_v2_c8_ex1 mathd_numbertheory_447
435
+
436
+ <table><tr><td rowspan=1 colspan=1>Natural language</td><td rowspan=1 colspan=1>Solve the system of equations:x+y+z=αx²+y²+2²=b²xy= x²where α and b are constants.Give the conditions that α and b must satisfy sothat x,y,z (the solutions of the system) are distinct positive numbers.Note: theformalized statement in miniF2F is a weaker problem as it focuses on the secondpart of the question, providing the actual conditions,and asking for a proof that therequirement entails them.</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>theorem imo_1961_p1(xyzab:R)(ho:0&lt;x&gt;0&lt;y&gt;0&lt;z)(h1:×≠y)(h2 :y≠z)(h3:z≠x)(h4 :x+y+z= a)(h5 :x^2 +y^2 + z^2 = b^2)(h6 :x *y= z^2) :0&lt;a∧ b^2&lt;a^2 &gt; a^2&lt;3*b^2 :=beginrevert_all,intros,rw mul_comm,split,{nlinarith [sq_nonneg (x - y),sq_nonneg(y- z)],},split,{nlinarith [sq_nonneg(z - 1)],},revert h3 h4,field_simp [mul_comm a b],rw [mul_comm,← h5],contrapose!,rw mul_comm at h6,rw mul_comm,intro h,nlinarith [sq_nonneg (x - y),sq_nonneg (y - z)]end</td></tr><tr><td rowspan=1 colspan=1>Comments</td><td rowspan=1 colspan=1>The model is able to close this problem by spliting into cases,contraposing for thelast case and using nlinarith.It must be noted that the arguments for the first twonlinarith uses are not necessary,however the [sq_nonneg (x - y),sq_nonneg(y- z)] argument provided on the last line is crucial to close the goal and arecompletely exogenous (present in no form in the tactic state before).</td></tr></table>
437
+
438
+ <table><tr><td rowspan=1 colspan=1>Natural language</td><td rowspan=1 colspan=1>Suppose a,b,c are the sides of a triangle.Prove thata²(b+c-a)+b²(c+a-b)+c²(a+b-c)≤3abc</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>theorem imo_1964_p2(abc:R)(ho:0&lt;a&gt;0&lt;b&gt;0&lt;c)(h1:c&lt;a+b)(h2:b&lt;a+c)(h3:a&lt;b+c):a^2*(b+c-a)+b^2*(c+a-b)+c^2*(a+b-c)≤3*a*b*c:=beginnlinarith [sq_nonneg (b - a),sq_nonneg (c - b),sq_nonneg (a - c),sq_nonneg (c - a)]end</td></tr><tr><td rowspan=1 colspan=1>Comments</td><td rowspan=1 colspan=1>The model is able to close an IMO problem in one-line.It correctly providesexogenous arguments to nlinarith,which are necessary to close the goal. Notethat either one of the last two arguments in the sequence [sq_nonneg (b - a),sq_nonneg(c -b),sq_nonneg(a - c),sq_nonneg (c- a)]can be omitted.</td></tr></table>
439
+
440
+ <table><tr><td>Natural language</td><td>Find ax+ by if the real numbers a,b,x,and y satisfy the equations ax+by =3, ax²+by²=7, ax²+by³=16, ax²4 +by4 = 42. Note: the formalized statement in miniF2F provides the answer and asks for a proof of it. theorem aime_1990_p15</td></tr><tr><td>Model proof</td><td>(abxy:R) (ho:a*x+b*y=3) (h1 :a* x^2+b*y^2= 7) (h2 :a* x^3 +b*y^3= 16) (h3 :a* x^4 +b*y^4= 42) : a * x^5+b*y^5=20 := begin revert_all, intros ab ×y hg hi h2 h4, ring_nf at hi h2, rw ← sub_eq_zero at h1, nlinarith [sq_nonneg (× - y),sq_nonneg (a + b - 2), sq_nonneg (x + y - (2:R)),sq_nonneg (a -b - 2)]</td></tr><tr><td>Comments</td><td>end The model is able to close a challenging AIME problem by providing crucial ex- ogenous arguments sq_nonneg (x - y) and sq_nonneg (x + y - (2 :R)) to nlinarith,which are required to close the goal (while the other two can be removed).</td></tr></table>
441
+
442
+ <table><tr><td>Natural language</td><td>Let f(x)= Ax+B and g(x)=Bx +A,where A≠B. If f(g(x)) - g(f(x))= B-A,what is A+B? Note: the formalized statement in our curriculum provides the answer and asks for a proof of it. theorem mathd_train_algebra_217</td></tr><tr><td>Model proof</td><td>(ab:R) (fg:R→R) (ho:∀x,fx=a*x+b) (h1:∀×,fx=b*x+a) (h2 :a≠b) (h3 :∀x,f (gx)-g(f x)=b-a): a+b=0 := begin revert_all, intros a b, intros f g, contrapose!, rintro &lt;ho,&lt;hi,h2&gt;&gt;, use (0 :R), simp only[sub_eq_iff_eq_add,ho,mul_zero]at *, simp only[*,zero_add],</td></tr><tr><td>Comments</td><td>norm_num at ho end The model is able to close the goal by contraposing,supplying a witness by the use of use (O :R)and finally leveraging the simp and norm_num. This example demonstrates the model&#x27;s ability to chain multiple non-trivial steps of reasoning including the generation of witnesses.</td></tr></table>
443
+
444
+ <table><tr><td rowspan="2">Natural language (A) a multiple of 4 (D) a perfect square</td><td colspan="2">For all integers n ≥ 9, the value of (n+2)!-(n+1)!</td></tr><tr><td colspan="2">n! is always which of the following? (B) a multiple of 10 (C)a prime number</td></tr><tr><td>Model proof</td><td>theorem amc12b_2020_p6 (n :N) (ho:9≤n): x :N,(x:R)^2 = (nat.factorial (n + 2) - nat.factorial (n + 1))/ nat.factorial n := begin revert_all, intros n hn, use n + 1,</td><td>field_simp [nat.factorial_ne_zero,pow_succ&#x27;],</td></tr><tr><td>Comments</td><td>ring_exp end The model exhibits here its ability to implicitly interpret factorial expressions by guessing the correct answer with the use of use n + 1 and straightforwardly proving</td><td></td></tr></table>
445
+
446
+ <table><tr><td>Natural language</td><td>The expression 24x² - 19x - 35 can be written as (Ax - 5)(2Bx + C),where A, B,and C are positive numbers.Find AB- 3C.Note: the formalized statement in miniF2F provides the answer and asks for a proof of it.</td></tr><tr><td>Model proof</td><td>theorem mathd_algebra_140 (abc:R) (ho:0&lt;a&gt;0&lt;b&gt;0&lt;c) (h1:∀×,24* ×^2-19*×-35= (((a*x)-5)*((2*(b*x))+c))): a*b-3*c=-9:= begin revert_all, rintro abc h1, rw mul_comm, rw ←sub_eq_zero, field_simp, rw sub_eq_add_neg, rw←eq_neg_iff_add_eq_zero, rw [mul_comm,← sub_eq_add_neg,sub_eq_add_neg, ← sub_eq_add_neg], rw ←sub_eq_zero, simp only [mul_add,neg_mul_eq_neg_mul_symm,mul_comm, add_left_comm], norm_num, simp only [pow_two], intro ho, rw← sub_eq_zero, linarith [hi.2,hi.1,ho 3,ho 1,ho 2]</td></tr><tr><td>Comments</td><td>end The model mostly &quot;struggles&quot; to make progress up to the last line. There, it presents us with the idea to specialize the statement given in h1 (which became ho in the process of the proof) at three consecutive natural numbers 1,2,3 which closes the goal with nlinarith. This proof is interesting as it demonstrates the model&#x27;s ability to evaluate symbolic expressions implicitly.</td></tr></table>
447
+
448
+ <table><tr><td>Natural language</td><td>Find the value of a2 +a4 +a6 +ag +...+ ag if a1,a2,a3... is an arithmetic progression with common difference 1,and a1 +a2 + a3 +...+ag8 = 137.Note: the formalized statement in miniF2F provides the answer and asks for a proof of it.</td></tr><tr><td>Model proof</td><td>theorem aime_1984_p1 (u:N→Q) (ho :∀n,u(n+1)=un+1) (hi :∑k in finset.range 98,u k.succ = 137): ∑ k in finset.range 49,u (2 * k.succ)= 93 := begin revert_all, simp [finset.sum_range_succ], ring, simp[pow_succ,mul_comm,add_left_comm,add_assoc], simp [two_mul], rintro p, revert p, simp [add_comm], intros p hp, simp [hp],ring_nf, intros, nlinarith</td></tr><tr><td>Comments</td><td>end The model finds a rather short proof of the statement compared to typ- ical human formalizations (see https://gist.github.com/MantasBaksys/ 3efd5c0d42f440d16c09076db42822f2).</td></tr></table>
449
+
450
+ <table><tr><td>Natural language</td><td>Consider the sequence = 1 3 ,,,. Prove that this sequence tends to 1 as n→ </td></tr><tr><td>Model proof</td><td>theorem aopsbook_v2_c8_ex1 (u:N→R) (ho:∀n,un=n/(n+1)): filter.tendsto u filter.at_top (N 1) := begin revert_all, simp [← nnreal.coe_one], norm_cast, intros, revert ho, assume h, simp [tendsto_const_nhds,← nnreal.coe_one,h], revert u, assume f, norm_num, rw tendsto_iff_norm_tendsto_zero, assume H, convert tendsto_norm_zero.comp tendsto_one_div_add_at_top_nhds_0_nat, funext n, have ho :(((n:R)+1):R)≠0, { norm_cast,exact n.succ_ne_zero,}, rwH, field_simp [ho,norm_neg], ring, rw [← sub_eq_zero], simp [← sub_eq_zero], simp[sub_eq_add_neg],</td></tr><tr><td>Comments</td><td>end An interesting example of a generated have statement,denoted by ho,which is introduced as a cut in order to simplify the expression containing divisions by using field_simp[ho,norm_neg] ata later step.</td></tr></table>
451
+
452
+ <table><tr><td rowspan=1 colspan=1>Natural language</td><td rowspan=1 colspan=1>What is the sum of the units digits of all the multiples of 3 between O and 5O? Note:the formalized statement in miniF2F provides the answer and asks for a proof of it.</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>theorem mathd_numbertheory_447 :∑ k in finset.filter (入 ×,3|x)(finset.erase (finset.range 50) 0),(k % 10) = 78 :=beginreflend</td></tr><tr><td rowspan=1 colspan=1>Comments</td><td rowspan=1 colspan=1>Because the predicate 入 ×,3|× is registered as decidable over N,we can state theproblem by using finset.filter,which is computable.Hence,refl is able toclose the goal.</td></tr></table>
md/dev/-QHUWgkh1OY/-QHUWgkh1OY.md ADDED
@@ -0,0 +1,439 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DOGE-Train: Discrete Optimization on GPU with End-to-end Training
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 We present a fast, scalable, data-driven approach for solving linear relaxations of
11
+ 2 0-1 integer linear programs using a graph neural network. Our solver is based
12
+ 3 on the Lagrange decomposition based algorithm [1]. We make the algorithm
13
+ 4 differentiable and perform backpropagation through the dual update scheme for
14
+ 5 end-to-end training of its algorithmic parameters. This allows to preserve the
15
+ 6 algorithm’s theoretical properties including feasibility and guaranteed non-decrease
16
+ 7 in the lower bound. Since [1] can get stuck in suboptimal fixed points, we provide
17
+ 8 additional freedom to our graph neural network to predict non-parametric update
18
+ 9 steps for escaping such points while maintaining dual feasibility. For training of
19
+ 10 the graph neural network we use an unsupervised loss and perform experiments on
20
+ 11 large-scale real world datasets. We train on smaller problems and test on larger ones
21
+ 12 showing strong generalization performance with a graph neural network comprising
22
+ 13 only around $1 0 k$ parameters. Our solver achieves significantly faster performance
23
+ 14 and better dual objectives than its non-learned version [1]. In comparison to
24
+ 15 commercial solvers our learned solver achieves close to optimal objective values of
25
+ 16 LP relaxations and is faster by up to an order of magnitude on very large problems
26
+ 17 from structured prediction and on selected combinatorial optimization problems.
27
+ 18 Our code will be made available upon acceptance.
28
+
29
+ # 19 1 Introduction
30
+
31
+ 20 Integer linear programs (ILP) are a universal tool for solving combinatorial optimization problems.
32
+ 21 While great progress has been made on improving ILP solvers over the past several decades, some
33
+ 22 fundamental questions for future improvements remain open: Can ILP solvers make effective use of
34
+ 23 the massive parallelism afforded by GPUs and can modern machine learning meaningfully help? As
35
+ 24 of now the consensus seems that neither GPUs nor ML have yet helped general purpose ILP solvers
36
+ 25 in a fundamental way. In particular, this holds true for LP solvers which are a key component of most
37
+ 26 commonly used ILP approaches. LP solvers produce lower bounds on the optimal solution objective
38
+ 27 and are integral for many heuristics to decode feasible integral solutions. For many problems the ILP
39
+ 28 solvers spend most of the time on solving multiple LP relaxations, hence any impact GPUs and ML
40
+ 29 can have will directly translate into overall improvement of ILP solvers.
41
+ 30 State of the art LP solvers [23, 13, 17, 4, 18] make little utility of modern machine learning but rather
42
+ 31 use either hand-designed or auto-tuned parameters and update rules. Moreover, with the exception
43
+ 32 of [18] these solvers are not open-source, hence researchers’ ability to assess the potential of neural
44
+ 33 networks for improving LP solvers is limited. From a conceptual point of view traditional solver
45
+ 34 paradigms, e.g. simplex or interior point methods, are not GPU friendly and contain non-differentiable
46
+ 35 steps (such as pivot selection for simplex). Additionally, their high complexity further complicates
47
+ 36 any effort at making them differentiable. This makes utilization of neural networks and GPUs for
48
+ 37 solver improvement difficult.
49
+ 38 We propose a new way to use the potential of GPU parallelism and modern ML to obtain advances
50
+ 39 in LP relaxation solvers for ILPs. We argue that due to the difficulties in putting GPUs and ML to
51
+ 40 work in traditional solver methodologies, investigation of new paradigms is called for. To this end we
52
+ 41 build upon the recent work of [1] which proposed a massively parallel GPU friendly solver for 0-1
53
+ 42 integer linear programming using Lagrange decomposition. The solver exhibits faster performance
54
+ 43 than traditional CPU solvers on large-scale problems making good use of GPU parallelism. Also
55
+ 44 due to its comparatively simple control flow and its usage of simple arithmetic operations for all its
56
+ 45 operations it can be made differentiable. This allows to train its parameters and predict update steps
57
+ 46 that will allow for faster convergence and overcoming fixed points from which the basic version of the
58
+ 47 algorithm suffers. This results in superior performance as compared to the non-learned version [1].
59
+ 48 We obtain small gaps to (I)LP optima on a diverse range of large scale structured prediction problems,
60
+ 49 QAPLib [8] and independent set problems [39]. We are up to an order of magnitude faster than
61
+ 50 traditional ILP solvers.
62
+ 51 Contributions We propose to learn the Lagrange decomposition based algorithm [1] for solving LP
63
+ 52 relaxations of ILP problems and show its benefits. In particular,
64
+
65
+ • We make the dual update steps of [1] differentiable. This allows us to predict parameters of the update steps so that faster convergence is achieved as compared to using hand-picked values.
66
+ • We train a predictor for arbitrary non-parametric update steps that allow to escape suboptimal fixed points into which the parametric update steps of [1] can fall.
67
+ • We propose to train predictors for both the parametric and non-parametric updates in fully unsupervised manner. Our loss optimizes for parameters/update steps producing large improvements in the dual lower bound over a long time horizon.
68
+ • We show the benefits of our learned massively parallel GPU approach on a wide range of problems. We have chosen structured prediction tasks including graph matching [29] and cell tracking [24]. From theoretical computer science we compare on the QAPLib [8] dataset and randomly generated independent set problems [39].
69
+
70
+ # 2 Related Work
71
+
72
+ # 2.1 Learning to solve Combinatorial Optimization
73
+
74
+ 66 ML has been used to improve various aspects of solving combinatorial problems. For the standard
75
+ 67 branch-and-cut ILP solvers the works [19, 22, 35] learn variable selection for branching. The
76
+ 68 approaches [14, 35] learn to fix a subset of integer variables in ILPs to their hopefully optimal values
77
+ 69 to improve finding high quality primal solutions. The works [43, 54] learn variable selection for
78
+ 70 the large neighborhood search heuristic for obtaining primal solutions to ILPs. Selecting good cuts
79
+ 71 through scoring them with neural networks was investigated in [26, 46]. While all these approaches
80
+ 72 result in runtime and solution quality improvements, only a few works tackle the important task of
81
+ 73 speeding up ILP relaxations by ML. Specifically, the work [11] used graph neural network (GNN) to
82
+ 74 predict variable orderings of decision diagrams representing combinatorial optimization problems.
83
+ 75 The goal is to obtain an ordering such that a corresponding dual lower bound is maximal. To our
84
+ 76 knowledge it is the only work that addresses computing ILP relaxations with ML. For constraint
85
+ 77 satisfaction problems [40, 9, 47] train GNN while [47] train in an unsupervised manner. For narrow
86
+ 78 subclasses of problems primal heuristics have been augmented through learning some of their
87
+ 79 decisions, e.g. for capacitated vehicle routing [36] and traveling salesman [55]. For a more complete
88
+ 80 overview of ML for combinatorial optimization we refer to the detailed surveys [6, 10].
89
+
90
+ # 81 2.2 Massively parallel combinatorial optimization
91
+
92
+ 82 Massively parallel algorithms running on GPU have been proposed for narrow problem classes,
93
+ 83 including inference in [41, 56] and dense [45] Markov Random Fields, multicut [2] and for max
94
+ 84 flow [49, 53]. The algorithm [1] on which our work is based is, to our knowledge, the only generic
95
+ 85 ILP solver that can make adequate use of parallelism offered by GPUs.
96
+
97
+ # 86 2.3 Unrolling algorithms for parameter learning
98
+
99
+ 87 Algorithms containing differentiable iterative procedures are combined with neural networks for
100
+ 88 improving performance of such algorithms. One of the earliest works in this direction is [21]
101
+ 89 which embedded sparse coding algorithms in a neural network by unrolling. For solving inverse
102
+ 90 problems [57, 12] unroll through ADMM and non-linear diffusion resp. Overall, such approaches
103
+ 91 show more generalization power than pure neural networks based ones as shown in the survey [34].
104
+ 92 Slightly different than from the above works, neural networks were used to predict update directions
105
+ 93 for training other neural networks (e.g. in [3]).
106
+
107
+ # 94 3 Method
108
+
109
+ We first recapitulate the Lagrange decomposition approach to binary ILPs from [31] and the deferred min-marginal averaging scheme for its solution proposed in [1]. We highlight possible parameters of the update steps which we will predict by training a graph neural network. Proofs are in the Appendix.
110
+
111
+ # 99 3.1 Lagrange Decomposition & Deferred Min-Marginal Averaging
112
+
113
+ Definition 1 (Binary Program [31]). Let a linear objective $c \in \mathbb { R } ^ { n }$ and $m$ variable subsets $\mathcal { T } _ { j } \subset [ n ]$ of constraints with feasible set $\mathcal { X } _ { j } \subset \{ 0 , 1 \} ^ { \mathbb { Z } _ { j } }$ for $j \in [ m ]$ be given. The corresponding binary program is
114
+
115
+ $$
116
+ \operatorname* { m i n } _ { x \in \{ 0 , 1 \} ^ { n } } \langle c , x \rangle \quad { \mathrm { s . t . } } \quad x _ { { \bar { \mathcal { T } } } _ { j } } \in { \mathcal { X } } _ { j } \quad \forall j \in [ m ] ,
117
+ $$
118
+
119
+ where $x _ { \mathbb { Z } _ { j } }$ is the restriction to variables in $\mathcal { T } _ { j }$ .
120
+
121
+ Any binary ILP $\mathrm { m i n } _ { x \in \{ 0 , 1 \} ^ { n } } \langle c , x \rangle$ s.t. $A x \leq b$ where $A \in \mathbb { R } ^ { m \times n }$ can be written as (BP) by associating each constraint $a _ { j } ^ { T } x \leq b _ { j }$ for $j \in [ m ]$ with its own subproblem $\mathcal { X } _ { j }$ .
122
+
123
+ 06 In order to obtain a problem formulation amenable for parallel optimization we consider its Lagrange
124
+ 07 dual which decomposes the full problem (BP) into a series of coupled subproblems.
125
+ 108 Definition 2 (Lagrangean dual problem [31]). Define the set of subproblems that constrain variable $i$
126
+ 109 as $\mathcal { T } _ { i } = \{ j \in [ \bar { m ] } \ | \ \bar { i } \in \mathcal { T } _ { j } \}$ . Let the energy for subproblem $j \in [ m ]$ w.r.t. Lagrangean dual variables
127
+ 110 $\lambda _ { \bullet j } = ( \lambda _ { i j } ) _ { i \in \mathcal { T } _ { j } } \in \mathbb { R } ^ { \mathcal { T } _ { j } }$ be
128
+
129
+ $$
130
+ E ^ { j } ( \lambda _ { \bullet j } ) = \operatorname* { m i n } _ { x \in \mathcal { X } _ { j } } \langle \lambda _ { \bullet j } , x \rangle .
131
+ $$
132
+
133
+ 111 Then the Lagrangean dual problem is defined as
134
+
135
+ $$
136
+ \operatorname* { m a x } _ { \lambda } \quad \sum _ { j \in [ m ] } E ^ { j } ( \lambda _ { \bullet j } ) \quad \mathrm { s . t . } \quad \sum _ { j \in \mathcal { I } _ { i } } \lambda _ { i j } = c _ { i } \quad \forall i \in [ n ] .
137
+ $$
138
+
139
+ 112 The authors in [1] have proposed a parallelization friendly iterative algorithm for updating Lagrange
140
+ 113 multipliers $\lambda$ for maximizing (D), see Algorithm 1. We write it in a slightly adapted form since it
141
+ 114 will allow us to easily describe its backpropagation. The algorithm assigns the Lagrange variables
142
+ 115 in $u$ -many disjoint blocks $B _ { 1 } , \ldots , B _ { u }$ in such a way that each block contains at most one Lagrange
143
+ 116 variable from each subproblem and all variables within a block are updated in parallel. The dual update
144
+ 117 scheme relies on computing min-marginal differences i.e., the difference of subproblem objectives
145
+ 118 when a certain variable is set to 1 minus its objective when the same variable is set to 0, see line 10
146
+ 119 in Algorithm 1. These min-marginal differences are averaged out across subproblems via updates
147
+ 120 to Lagrange variables in line 11 in Algorithm 1. The crucial ingredient allowing parallelization is
148
+ 121 that in the min-marginal averaging step values from the last iteration are used (i.e. $M ^ { \mathrm { i n } }$ ), making
149
+ 122 synchronization between subproblems unnecessary.
150
+ 123 In [1] the min-marginal averaging parameters of Algorithm 1 were set as $\omega = 0 . 5$ and $\alpha _ { i j } =$
151
+ 124 $1 / | \mathcal { I } _ { i } |$ leading to uniform averaging. We generalize the min-marginal update step by considering
152
+ 125 more general parametric update steps. We allow $\omega \in ( 0 , 1 )$ and $\alpha$ -values to be arbitrary convex
153
+ 126 combinations. In the next section we will show how to train these values to achieve faster convergence.
154
+ 127 Proposition 1 (Dual Feasibility and Monotonicity of Min-marginal Averaging). For any $\alpha _ { i j } \geq 0$
155
+ 128 with $\begin{array} { r } { \sum _ { j \in \mathcal { T } _ { i } } \alpha _ { i j } = 1 } \end{array}$ and $\omega _ { i j } \in [ 0 , 1 ]$ the min-marginal averaging step in line $1 l$ in Algorithm $^ { l }$
156
+ 129 retains dual feasibility and is non-decreasing in the dual lower bound.
157
+
158
+ Input: Lagrange variables $\lambda _ { i j } \forall i \in [ n ] , j \in \mathcal { T } _ { i }$ , damping factors $\omega _ { i j } \in ( 0 , 1 ) \forall i \in [ n ] , j \in \mathcal { T } _ { i }$ , anisotropic min-marginal averaging weights $\alpha _ { i j } \in ( 0 , 1 ) \forall i \in [ n ] , j \in \mathcal { T } _ { i }$ , max. number of iterations $T$ . 1 Initialize deferred min-marginal diff. $M = \mathbb { 0 }$ 2 for $T$ iterations do 3 for block $B \in ( B _ { 1 } , \ldots B _ { u } )$ do 4 $\lambda , M \gets$ BlockUpdate $( B , \lambda , M , \alpha , \omega )$ 5 for block $B \in ( B _ { u } , \ldots B _ { 1 } )$ do 6 λ, M ← BlockUpdate $( B , \lambda , M , \alpha , \omega )$ 7 return λ, M 8 Procedure BlockUpdate $( B , \lambda ^ { \mathrm { i n } } , M ^ { \mathrm { i n } } , \alpha , \omega )$ 9 for $i j \in B$ in parallel do 10 CompuUpdate $\begin{array} { r } { \lambda _ { i j } ^ { \mathrm { o u t } } = \lambda _ { i j } ^ { \mathrm { i n } } - M _ { i j } ^ { \mathrm { o u t } } + \alpha _ { i j } \sum _ { k \in \mathcal { I } _ { i } } M _ { i k } ^ { \mathrm { i n } } } \end{array}$ $\begin{array} { r } { M _ { i j } ^ { \mathrm { { o u t } } } = \omega _ { i j } [ \operatorname* { m i n } _ { x \in \mathcal { X } _ { j } : x _ { i } = 1 } \langle \lambda _ { \bullet j } ^ { \mathrm { { i n } } } , x \rangle - \operatorname* { m i n } _ { x \in \mathcal { X } _ { j } : x _ { i } = 0 } \langle \lambda _ { \bullet j } ^ { \mathrm { { i n } } } , x \rangle ] } \end{array}$ 12 return $\lambda ^ { \mathsf { o u t } }$ , M out
159
+
160
+ # 130 3.2 Backpropagation through Deferred Min-Marginal Averaging
161
+
162
+ 131 We show below how to differentiate through Algorithm 1 with respect to the parameters $\alpha$ and $\omega$ .
163
+ 132 This will ultimately allow us to learn these parameters such that faster convergence is achieved. To
164
+ 133 this end we describe backpropagation for a block update (lines 8- 12) of Alg. 1. All other operations
165
+ 134 can be tackled by automatic differentiation. For a block $B$ in $\{ B _ { 1 } , \ldots , B _ { u } \}$ we view the Lagrangean
166
+ 135 update as a mapping $\mathcal { H } : ( \mathbb { R } ^ { | B | } ) ^ { 4 } \to ( \mathbb { R } ^ { | B | } ) ^ { 2 }$ , $( \lambda ^ { \mathrm { i n } } , M ^ { \mathrm { i n } } , \alpha , \omega ) \mapsto ( \lambda ^ { \circ \mathrm { u t } } , M ^ { \circ \mathrm { u t } } )$ .
167
+
168
+ Given a loss function 36 $\mathcal { L } : \mathbb { R } ^ { N } \mathbb { R }$ we denote $\partial \mathcal { L } / \partial x$ by $\dot { x }$ . Algorithm 2 shows backpropagation through 7 $\mathcal { H }$ to compute the gradients $\dot { \lambda } ^ { \mathrm { { i n } } } , \dot { M } ^ { \mathrm { { i n } } } ,$ $\dot { \alpha }$ and $\dot { \omega }$ .
169
+
170
+ 138 Proposition 2. Algorithm 2 performs backpropagation through $\mathcal { H }$ .
171
+
172
+ 139 Efficient Implementation Generally, the naive computation of min-marginal differences and its
173
+ 140 backpropagation are both expensive operations as they require solving two optimization problems
174
+ 141 for each dual variable. In [1, 31] the authors represented each subproblem using binary decision
175
+ 142 diagrams (BDDs) for fast incremental computation of min-marginal differences. Their algorithm
176
+ 143 results in a computation graph involving only elementary arithmetic operations and taking minima
177
+ 144 over several variables. Using this computational graph we can implement the abstract Algorithm 2
178
+ 145 efficiently and parallelize on GPU. For details we refer to the Appendix.
179
+
180
+ # Algorithm 2: BlockUpdate backpropagation
181
+
182
+ Input: Forward pass inputs: $B , \lambda ^ { \mathrm { i n } } , M ^ { \mathrm { i n } } , \alpha , \omega$ , gradients of forward pass output: λ˙ out, $\dot { M } ^ { \mathrm { { o u t } } }$ , gradients of parameters $\dot { \alpha } , \dot { \omega }$
183
+
184
+ 1 for $i j \in B$ in parallel do
185
+
186
+ 2 $\begin{array} { r } { \dot { M } _ { i j } ^ { \mathrm { i n } } = \sum _ { k \in \mathcal { T } _ { i } } \dot { \lambda } _ { i k } ^ { \mathrm { o u t } } \alpha _ { i k } } \end{array}$ , $\dot { M } _ { i j } ^ { \mathrm { o u t } } = \dot { M } _ { i j } ^ { \mathrm { o u t } } - \dot { \lambda } _ { i j } ^ { \mathrm { o u t } }$
187
+ 3 $\begin{array} { r } { \dot { \alpha } _ { i j } = \dot { \alpha } _ { i j } + \dot { \lambda } _ { i j } \sum _ { k \in \mathcal { I } _ { i } } M _ { i k } ^ { \mathrm { i n } } , \quad \dot { \omega } _ { i j } = \dot { \omega } _ { i j } + \dot { M } _ { i j } ^ { \mathrm { o u t } } [ M _ { i j } ^ { \mathrm { o u t } } / \omega _ { i j } ] } \end{array}$
188
+ 4 Compute minimizers $\begin{array} { r } { s ^ { j } ( i , \beta ) = \arg \operatorname* { m i n } _ { x \in \mathcal { X } _ { j } : x _ { i } = \beta } \langle \lambda _ { \bullet j } ^ { \mathrm { { i n } } } , x \rangle , \forall \beta \in \{ 0 , 1 \} } \end{array}$ }
189
+ 5 $\dot { \lambda } _ { p j } ^ { \mathrm { i n } } = \dot { \lambda } _ { p j } ^ { \circ \mathrm { u t } } + \dot { M } _ { i j } ^ { \circ \mathrm { u t } } \omega _ { i j } [ s _ { p } ^ { j } ( i , 1 ) - s _ { p } ^ { j } ( i , 0 ) ] ,$ , ∀p ∈ Ij
190
+ 6 return $\dot { \lambda } ^ { \mathrm { i n } } , \dot { M } ^ { \mathrm { i n } } , \dot { \alpha } , \dot { \omega }$
191
+
192
+ # 146 3.3 Non-Parametric Update Steps
193
+
194
+ 147 Although the min-marginal averaging scheme of Alg. 1 guarantees non-decreasing lower bound, it
195
+ 148 can get stuck in suboptimal fixed points, see [50] for a discussion for the special case of MAP-MRF.
196
+ 149 To alleviate this shortcoming we allow arbitrary updates to Lagrange variables through a vector
197
+
198
+ 150 $\boldsymbol { \theta } \in \mathbb { R } ^ { | \lambda | }$ as
199
+
200
+ $$
201
+ \lambda _ { i j } \lambda _ { i j } + \theta _ { i j } - \frac { 1 } { | \mathcal { T } _ { i } | } \sum _ { k \in \mathcal { I } _ { i } } \theta _ { i k } , \forall i \in [ n ] , j \in \mathcal { I } _ { i }
202
+ $$
203
+
204
+ 151 where the last term ensures feasibility of updated Lagrange variables w.r.t. the dual problem (D).
205
+
206
+ # 3.4 Graph neural network
207
+
208
+ 153 We train a graph neural network (GNN) to predict the parameters $\alpha , \omega$ of Alg. 1 and also the
209
+ 154 non-parametric update $\theta$ for (2). To this end we encode the dual problem (D) on a bipartite graph
210
+ 155 $\mathcal { G } = ( \nu , \mathcal { E } )$ . Its nodes correspond to primal variables $\mathcal { T }$ and subproblems $\mathcal { I }$ i.e., $\mathcal { V } = \mathcal { I } \cup \mathcal { I }$ and
211
+ 156 edges $\mathcal { E } = \{ i j \mid i \in \mathcal { T } , j \in \mathcal { T } _ { i } \}$ correspond to Lagrange multipliers. We need to predict values of
212
+ 157 $\alpha _ { i j } , \omega _ { i j }$ and $\theta _ { i j }$ for each edge $i j$ in $\mathcal { E }$ . We associate features $\boldsymbol { f } \overset { - } { = } \left( f _ { \mathcal { T } } , f _ { \mathcal { T } } , f _ { \mathcal { E } } \right)$ with each entity of the
213
+ 158 graph which capture the current state of Alg. 1. Additionally, we encode a number of quantities as
214
+ 159 features which can make learning easier. For example, a history of previous dual objectives for each
215
+ 160 subproblem is encoded in the constraint nodes and minimizers of each subproblem (which correspond
216
+ 161 to a subgradient of the dual problem (D)) are encoded in the edge features $f _ { \mathcal { E } }$ . A complete list of
217
+ 162 features is provided in the Appendix.
218
+ 163 Message passing To perform message passing we use the transformer based graph convolution
219
+ 164 scheme of [42]. We first compute an embedding of all subproblems $j$ in $\mathcal { I }$ by receiving messages
220
+ 165 from adjacent nodes and edges as
221
+
222
+ $$
223
+ \mathsf { C O N V } _ { \mathcal { I } } ( f _ { \mathcal { I } } , f _ { \mathcal { I } } , f _ { \mathcal { E } } , \mathcal { E } ) _ { j } = \mathbf { W _ { s } } f _ { j } + \sum _ { i | i j \in \mathcal { E } } a _ { i j } ( f _ { j } , f _ { \mathcal { I } } , f _ { \mathcal { E } } ; \mathbf { W _ { a } } ) \left[ \mathbf { W _ { t } } f _ { i } + \mathbf { W _ { e } } f _ { i j } \right] ,
224
+ $$
225
+
226
+ 166 where $\mathbf { W } = \left( \mathbf { W _ { a } } , \mathbf { W _ { s } } , \mathbf { W _ { t } } , \mathbf { W _ { e } } \right)$ are trainable parameters and $a _ { i j } \left( f _ { j } , f _ { \mathbb { Z } } , f _ { \mathbb { \varepsilon } } ; \mathbf { W _ { a } } \right)$ is the softmax
227
+ 167 attention weight between nodes $i$ and $j$ parameterized by $\mathbf { W _ { a } }$ . Afterwards we perform message
228
+ 168 passing in the reverse direction to compute embeddings for primal variables $\mathcal { T }$ . Similar strategy for
229
+ 169 message passing on a bipartite graph was followed by [19].
230
+ 170 Recurrent connections Our default GNN as mentioned above only uses hand-crafted features
231
+ 171 to maintain a history of previous optimization rounds. To learn a summary of the past updates we
232
+ 172 optionally allow recurrent connections through an LSTM with forget gate [20]. The LSTM is only
233
+ 173 applied on primal variable nodes $\mathcal { T }$ and maintains cell states $s \tau$ which can be updated and used for
234
+ 174 parameter prediction in subsequent optimization rounds.
235
+ 175 Prediction The learned embeddings from GNN, LSTM outputs and solver features from Alg. 1
236
+ 176 are consumed by a multi-layer perceptron $\Phi$ to predict the required variables for each edge $i j$ in $\mathcal { E }$ .
237
+ 177 Afterwards we transform these outputs so that they satisfy Prop. 1.
238
+ 178 The exact sequence of operations performed by the graph neural network are shown in Alg. 3 where
239
+ 179 $[ u _ { 1 } , \ldots , u _ { k } ]$ denotes concatenation of vectors $u _ { 1 } , \ldots , u _ { k }$ , LN denotes layer normalization [5] and
240
+ 180 $\mathtt { L S T M } _ { \mathcal { T } }$ stands for an LSTM cell which operates on each primal variable node.
241
+
242
+ # Algorithm 3: Parameter prediction by GNN
243
+
244
+ Input: Primal variable features $f _ { \mathcal { T } }$ and cell states $s \tau$ , Subproblem features $f _ { \mathcal { I } }$ , Dual variable (edge) features $f _ { \mathcal { E } }$ , Set of edges $\mathcal { E }$ . 1 $h _ { \mathcal { T } } = \mathsf { R e L U } \left( \operatorname { L N } \left( \operatorname { C O N V } _ { \mathcal { T } } \left( f _ { \mathcal { T } } , f _ { \mathcal { T } } , f _ { \mathcal { E } } , \mathcal { E } \right) \right) \right)$ // Compute subproblems embeddings 2 $h _ { \mathcal { T } } = \mathtt { R e L U }$ $\left( \mathrm { L N } \left( \mathrm { C O N V } _ { \mathcal { T } } \left( f _ { \mathcal { T } } , [ f _ { \mathcal { T } } , h _ { \mathcal { T } } ] , f _ { \mathcal { E } } , \mathcal { E } \right) \right) \right)$ // Compute primal variable embeddings 3 $z _ { \mathcal { T } } , s _ { \mathcal { T } } = \mathtt { L S T M } _ { \mathcal { T } } ( h _ { \mathbb { Z } } , s _ { \mathcal { T } } )$ // Compute output and cell state 4 $( \hat { \alpha } , \hat { \omega } , \theta ) = \Phi \left( [ f _ { \mathcal { T } } , h _ { \mathcal { T } } , z _ { \mathcal { T } } ] , [ f _ { \mathcal { T } } , h _ { \mathcal { T } } ] , f _ { \mathcal { E } } , \mathcal { E } \right)$ // Prediction per edge 5 $\alpha _ { i \bullet } = \mathtt { S o f t m a x } ( \hat { \alpha } _ { i \bullet } )$ , $\forall i \in \mathcal { T }$ , $\omega = \mathtt { S i g m o i d } ( \hat { \omega } )$ // Ensure non-decreasing obj., Prop. 1 6 return $\alpha , \omega , \theta , s _ { \mathcal { T } }$
245
+
246
+ ![](images/8c0f0e86dbac1894eb0707f4ab560d8568b25343e3acf4644b98922ca6b27d0c.jpg)
247
+ Figure 1: Our pipeline for optimizing the Lagrangean dual (D). The problem is encoded on a bipartite graph containing features $f _ { \mathcal { T } }$ , $f _ { \mathcal { I } }$ and $f _ { \mathcal { E } }$ for primal variables, subproblems and dual variables resp. A graph neural network (GNN) predicts the non-parameteric update $\theta$ (2) and parameters $\alpha$ and $\omega$ for Alg. 1. In one optimization round current set of Lagrange multipliers $\lambda$ are first updated by the non-parametric update using $\theta$ . Afterwards deferred min-marginal averaging is performed parameterized by $\alpha$ and $\omega$ . The updated solver features $f$ (which also includes $\lambda$ ) and LSTM cell states $s \tau$ are sent to the GNN in next optimization round. These rounds are repeated at most $R$ -times during training and until convergence during inference.
248
+
249
+ # 181 3.5 Loss
250
+
251
+ 82 Given the Lagrange variables $\lambda$ we directly use the dual objective (D) as an unsupervised loss to train
252
+ 183 the GNN. Thus, we maximize the loss $L$ defined as
253
+
254
+ $$
255
+ \mathcal { L } ( \lambda ) = \sum _ { j \in [ m ] } E ^ { j } ( \lambda _ { \bullet j } ) .
256
+ $$
257
+
258
+ 184 For a mini-batch of instances during training we take the mean of corresponding per-instance losses.
259
+ 185 For backpropagation, gradient of loss $\mathcal { L }$ w.r.t. Lagrange variables of a subproblem $j$ is computed by
260
+ 186 finding a minimizing assignment for that subproblem, written as
261
+
262
+ $$
263
+ \left( \frac { \partial \mathcal { L } } { \partial \lambda } \right) _ { \bullet j } = \operatorname { a r g m i n } _ { x \in \mathcal { X } _ { j } } \langle \lambda _ { \bullet j } , x \rangle \in \{ 0 , 1 \} ^ { \mathcal { Z } _ { j } } .
264
+ $$
265
+
266
+ 187 The above gradient is then sent as input for backpropagation. For computing the minimizing
267
+ 188 assignment efficiently we use binary decision diagram representation of each subproblem as in [1, 31].
268
+
269
+ # 3.6 Overall pipeline
270
+
271
+ 190 Our overall pipeline combining all building blocks from the previous sections is shown in Figure 1.
272
+ 191 We train our pipeline which contains multiple dual optimization rounds in a fashion similar to that
273
+ 192 of recurrent neural networks. One round of our dual optimization consists of message passing
274
+ 193 by GNN, a non-parametric update step and $T$ iterations of deferred min-marginal averaging. For
275
+ 194 computational efficiency we run our pipeline for at most $R$ dual optimization rounds during training.
276
+ 195 On each mini-batch we randomly sample a number of optimization rounds $r$ in $[ R ]$ , run $r - 1$ rounds
277
+ 196 without tracking gradients and backpropagate through the last round by computing the loss (4). For
278
+ 197 the pipeline with recurrent connections we backpropagate through last 3 rounds and apply the loss
279
+ 198 after each of these rounds. Since the task of dual optimization is relatively easier in early rounds
280
+ 199 as compared to later ones (where [1] can get stuck) we use two neural networks. The early stage
281
+ 200 network is trained if the randomly sampled $r$ is in $[ 0 , R / 2 ]$ and the late stage network is chosen
282
+ 201 otherwise. During testing we switch to the later stage network when the relative improvement in the
283
+ 202 dual objective by the early stage network becomes less than $1 0 ^ { - 6 }$ .
284
+
285
+ # 03 4 Experiments
286
+
287
+ 204 As main evaluation metric we report convergence plots of the relative dual gap $g ( t ) \in [ 0 , 1 ]$ at time $t$
288
+
289
+ $$
290
+ g ( t ) = \operatorname* { m i n } \left( \frac { d ^ { * } - d ( t ) } { d ^ { * } - d _ { i n i t } } , 1 . 0 \right)
291
+ $$
292
+
293
+ 205 where $d ( t )$ is the dual objective at time $t$ , $d ^ { * }$ is the optimal (or best known) objective value of the
294
+ 206 Lagrange relaxation $( \mathrm { D } )$ and $d _ { i n i t }$ is the objective value before optimization as computed by [1].
295
+ 207 Additionally we also report per dataset averages of relative dual gap integral $\begin{array} { r } { g _ { I } = \int g ( \bar { t } ) d t } \end{array}$ [7], best
296
+ 208 objective value $( E )$ and time taken $\mathbf { \rho } ( t )$ to obtain best objective. To cater the dominating effect of
297
+ 209 worse initial lower bounds on $g _ { I }$ (as $g ( t )$ can be close to 1 at $t \approx 0$ ) we start calculating $g \tau$ after a few
298
+ 210 rounds of our solver are completed. This start time is then also used to evaluate other algorithms for a
299
+ 211 fair comparison. To evaluate CPU solvers we use an AMD EPYC 7702 CPU. For the GPU solvers
300
+ 212 we use either one NVIDIA RTX 8000 (48GB) or A100 (80GB) GPU depending on instance size.
301
+
302
+ # 4.1 Algorithms
303
+
304
+ Gurobi: Results of the dual simplex algorithm from the commercial ILP solver [23].
305
+
306
+ FastDOG: The non-learned baseline [1] of Alg. 1 with $\omega _ { i j } = 0 . 5$ and $\alpha _ { i j } = 1 / | \mathcal { I } _ { i } |$
307
+
308
+ DOGE: Our approach where we learn to predict parametric and non-parametric updates by using two graph neural networks for early and late-stage optimization. Size of the learned embeddings $h$ computed by the GNN in Alg. 3 is set to 16 for nodes and 8 for edges. For computing attention weights in (3) we use only one attention head for efficiency. The predictor $\Phi$ in Alg. 3 contains 4 linear layers with the ReLU activation. We train the networks using the Adam optimizer [30]. To prevent gradient overflow we use gradient clipping on model parameters by an $l ^ { 2 }$ norm of 50. The number of trainable parameters is $8 k$ .
309
+
310
+ DOGE-M: Variant of our method where we additionally use recurrent connections using LSTM. The cell state vector $s _ { i }$ for each primal variable node $i \in \mathcal { T }$ has a size of 16. The number of trainable parameters is $1 2 k$ .
311
+
312
+ We have not tested against specialized heuristics for our benchmark problems since [1] has shown them to be on par or outperformed by FastDOG. For training our approach we use the frameworks [15, 16, 38] and implement the Algorithms 1,2 in CUDA [37] using [25, 28].
313
+
314
+ # 4.2 Datasets
315
+
316
+ Cell tracking $( C T )$ : Instances of developing flywing tissue from cell tracking challenge [48] processed by [24] and obtained from [44]. We use the largest and hardest 3 instances, train on the 2 smaller instances and test on the largest one.
317
+
318
+ Graph matching (GM): Instances of graph matching for matching nuclei in 3D microscopic images [32] processed by [29] and made publicly available through [44]. We train on 10 instances and test on the remaining 20 instances.
319
+
320
+ Independent set (IS): Random instances of independent set problem generated using [39]. For training we generate 240 instances with $1 0 k$ vertices each and test on 60 instances with $5 0 k$ vertices. We generating edges between vertices in the graph with a probability of 0.25.
321
+
322
+ QAPLib: The benchmark dataset for quadratic assignment problems used in the combinatorial optimization community [8]. We train on 61 instances having up to 40 nodes and test on 35 instances having up to 70 nodes.
323
+
324
+ 242 For each dataset we use a separate set of hyperparameters due to varying instance sizes given in
325
+ 243 Table 1. All our test datasets on average contain more than a million edges (i.e., Lagrange variables)
326
+ 244 while training instances are considerably smaller. For efficiency, during evaluation we use a larger
327
+ 245 value of $T$ in Alg. 1 than during training. For the $C T$ dataset containing we learn only the non
328
+ 246 parametric update steps (2) and fix the parameters in Alg. 1 to their default values from [1]. Learning
329
+ 247 these parameters gave slightly worse training loss at convergence.
330
+
331
+ # 48 4.3 Ablation study
332
+
333
+ 249 We perform an ablation study to test the importance of various components of our approach. Starting
334
+ 250 from [1] as a baseline we first predict all parameters $\alpha , \omega , \theta$ through the two multi-layer perceptrons $\Phi$
335
+ 251 for early and late stage optimization without using GNN. Next, we report results of using one network
336
+ 252 (instead of two) which is trained and tested for both early and later rounds of dual optimization. Lastly,
337
+ 253 we aim to seek the importance of learning parameters of Alg. 2 and the non-parametric update (2).
338
+ 254 To this end, we learn to predict only the non-parametric update and apply the loss directly on updated
339
+ 255 $\lambda$ without requiring backpropagation through Alg. 1. We also try learning a subset of parameters i.e.,
340
+ 256 not predicting averaging weights $\alpha$ or damping factors $\omega$ . Lastly, we report results of DOGE-M which
341
+ 257 uses recurrent connections. The results are in Table 2.
342
+
343
+ Table 1: Hyperparameters of our approach and dataset statistics. $| \mathcal { T } | + | \mathcal { I } |$ : Average number of variables and constraints in each dataset (# vertices in GNN); $\textstyle \sum _ { j = 1 } ^ { m } | { \dot { \mathcal { I } } } _ { i } |$ : Average number of Lagrange multipliers (# edges in GNN); $T$ : Number of iterations of Alg. 1 in each optimization round; $R$ : max. number of training rounds; # itr. train: Number of training iterations.
344
+
345
+ <table><tr><td rowspan="2">Dataset</td><td colspan="2">|Z|+|J|(×106)</td><td colspan="2"></td><td colspan="2">T</td><td rowspan="2">R</td><td rowspan="2">batch size</td><td rowspan="2">learn. rate</td><td rowspan="2">#itr. train</td><td rowspan="2">train time [hrs]</td></tr><tr><td>train</td><td>test</td><td>train</td><td>test</td><td>train</td><td>test</td></tr><tr><td>CT</td><td>3.7</td><td>12.4</td><td>8.5</td><td>28</td><td>1</td><td>100</td><td>400</td><td>1</td><td>1e-3</td><td>500</td><td>14</td></tr><tr><td>GM</td><td>1.7</td><td>1.7</td><td>3.3</td><td>3.3</td><td>20</td><td>200</td><td>20</td><td>2</td><td>1e-3</td><td>400</td><td>4</td></tr><tr><td>IS</td><td>0.05</td><td>0.4</td><td>0.1</td><td>1.2</td><td>20</td><td>50</td><td>20</td><td>8</td><td>1e-3</td><td>2500</td><td>10</td></tr><tr><td>QAPLib</td><td>0.1</td><td>2.8</td><td>0.5</td><td>11</td><td>5</td><td>20</td><td>500</td><td>4</td><td>1e-3</td><td>1600</td><td>48</td></tr></table>
346
+
347
+ Table 2: Ablation study results on the Graph matching dataset. w/o GNN: Use only the two predictors $\Phi$ without GNN for early and late stage optimization; same network: use one network (GNN, $\Phi$ ) for both early and late stage; only non-param., param.: predict only the non-parametric update (2) or the parametric update (Alg. 1); w/o α, ω: does not predict $\alpha$ or $\omega$ resp.
348
+
349
+ <table><tr><td></td><td>w/o learn. ([1])</td><td>w/o GNN</td><td>same network</td><td>only non-param.</td><td>only param.</td><td>w/oα</td><td>w/ow</td><td>DOGE</td><td>DOGE-M</td></tr><tr><td>g1 ()</td><td>21</td><td>0.42</td><td>0.95</td><td>2.3</td><td>0.7</td><td>0.36</td><td>0.35</td><td>0.33</td><td>0.19</td></tr><tr><td>E(1)</td><td>-48912</td><td>-48440</td><td>-48444</td><td>-48476</td><td>-48444</td><td>-48439</td><td>-48439</td><td>-48439</td><td>-48436</td></tr><tr><td>t[s]()</td><td>61</td><td>29</td><td>24</td><td>51</td><td>74</td><td>30</td><td>30</td><td>17</td><td>21</td></tr></table>
350
+
351
+ Firstly, from our ablation study we observe that learning even one of the two types of updates i.e., non-parametric or parametric already gives better results than the non-learned solver [1]. This is because non-parametric update can help in escaping fixed-points of [1] when they occur and the parametric update can help Alg. 1 in avoiding such fixed-points. Combining both of these strategies further improves the results. Secondly, we observe that performing message passing with GNN gives improvement over only using the predictor $\Phi$ . Thirdly, we find using separate networks for early and late stage optimization gives better performance than using the same network for all stages. Lastly, using recurrent connections gives the best performance.
352
+
353
+ # 4.4 Results
354
+
355
+ Convergence plots of relative dual gaps change w.r.t. wall clock times are given in Figure 2. Rest of the evaluation metrics are reported in Table 3. For further details we refer to the Appendix.
356
+
357
+ Discussion As compared to the non-learned baseline FastDOG we reach an order of magnitude more accurate relaxation solutions, almost closing the gap to optimum as computed by Gurobi. We retain high speed afforded by exploiting GPU parallelism. Interestingly, we can often outperform FastDOG also in the early stage where optimization is easy. Our LSTM version DOGE-M has shown improved performance than the non-LSTM version. Especially it shows much improvement on the most difficult QAPLib dataset. On QAPLib Gurobi does not converge on instances with more than
358
+
359
+ Table 3: Results comparison on all datasets where the values are averaged within a dataset. Numbers in bold highlight the best performance.
360
+
361
+ <table><tr><td rowspan="2"></td><td colspan="3">Cell tracking</td><td colspan="3">Graph matching</td><td colspan="3">Independent set</td><td colspan="3">QAPLib</td></tr><tr><td>g1</td><td>E(×108)</td><td>t[s]</td><td>91</td><td>E(×104)</td><td>t[s]</td><td>91</td><td>E(×108)</td><td>t[s]</td><td>91</td><td>E(×106)</td><td>t[]</td></tr><tr><td>Gurobi [23]</td><td>18</td><td>-3.852</td><td>809</td><td>9</td><td>-4.8433</td><td>278</td><td>14</td><td>−2.4457</td><td>52</td><td>3472</td><td>0.9</td><td>2618</td></tr><tr><td>FastDOG[1]</td><td>7</td><td>-3.863</td><td>1005</td><td>21</td><td>-4.8912</td><td>61</td><td>42</td><td>-2.4913</td><td>9</td><td>276</td><td>5.7</td><td>1680</td></tr><tr><td>DOGE</td><td>2.4</td><td>-3.854</td><td>1015</td><td>0.3</td><td>-4.8439</td><td>17</td><td>0.3</td><td>-2.4460</td><td>8</td><td>320</td><td>12.1</td><td>720</td></tr><tr><td>DOGE-M</td><td>2.1</td><td>-3.854</td><td>730</td><td>0.2</td><td>-4.8436</td><td>21</td><td>0.2</td><td>-24459</td><td>5</td><td>131</td><td>14.5</td><td>861</td></tr></table>
362
+
363
+ ![](images/0a31741462078393f5c916abcea1158cbb9604e5432d80e75f71021dd2ce14cf.jpg)
364
+ Figure 2: Convergence plots for $g ( t )$ defined in (6), the relative dual gap to the optimum (or maximum suboptimal objective among all methods) of the relaxation (D). Both axes are logarithmic.
365
+
366
+ 275 40 nodes within the time limit of one hour. We show convergence plots for smaller instances in the
367
+ 276 Appendix. The difference to Gurobi is most pronounced w.r.t. anytime performance measured by $g _ { I }$
368
+ 277 since our solver reaches good solutions relatively early.
369
+
370
+ Limitations While our approach gives solutions of high accuracy for the presented datasets, we have also tried our approach on other datasets (small cell tracking instances, MRFs for protein folding [27] and shape matching [51, 52]) where we were not able to obtain significant improvements w.r.t. the non-learned baseline [1]. For small cell tracking instances FastDOG already found the optimum in a moderate number of iterations, making it hard to beat. On shape matching and protein folding the parallelization of FastDOG did not bring enough speed-ups due to few large subproblems resulting in sequential bottlenecks. This limited the number of training iterations we could perform within a reasonable time.
371
+
372
+ We have set some hyperparameters in a dataset-dependent way. This was partly necessitated due to problem sizes e.g., training on long time horizons was not possible with very large instances. Moreover, these instances only permitted a limited number of parameters in our neural networks.
373
+
374
+ # 5 Conclusion
375
+
376
+ We have proposed a learning approach for solving relaxations to combinatorial optimization problems by backpropagating through and learning parameters for the non-learned baseline [1]. We demonstrated its potential in obtaining close to optimal solutions faster than with traditional methods.
377
+
378
+ Our work raises interesting follow-up questions: (i) Contrary to many approaches for backpropagation which replace non-smooth operations with smoothed variants (e.g. [33]) we directly compute (sub-) gradients for the non-smooth solver updates. Can smoothing of the solver help obtain a better backpropagated supervision? (ii) We argue that predicting good update steps for our solver is in itself an interesting and challenging problem for GNNs. We hope that our work can become a testbed for GNN architectures. (iii) There are a few desiderata for future learned solvers, including training universal models that generalize across different problem classes. Possibly more powerful GNNs and more involved training regimes are needed for this.
379
+
380
+ References [1] Ahmed Abbas and Paul Swoboda. FastDOG: Fast discrete optimization on GPU. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2022. [2] Ahmed Abbas and Paul Swoboda. RAMA: A Rapid Multicut Algorithm on GPU. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2022. [3] Marcin Andrychowicz, Misha Denil, Sergio Gomez, Matthew W Hoffman, David Pfau, Tom Schaul, Brendan Shillingford, and Nando De Freitas. Learning to learn by gradient descent by gradient descent. Advances in neural information processing systems, 29, 2016. [4] MOSEK ApS. 9.0.105, 2022. [5] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016. [6] Yoshua Bengio, Andrea Lodi, and Antoine Prouvost. Machine learning for combinatorial optimization: a methodological tour d’horizon. European Journal of Operational Research, 290(2):405–421, 2021. [7] Timo Berthold. Measuring the impact of primal heuristics. Oper. Res. Lett., 41(6):611–614, nov 2013. [8] Rainer E Burkard, Stefan E Karisch, and Franz Rendl. QAPLIB–a quadratic assignment problem library. Journal of Global optimization, 10(4):391–403, 1997. [9] Chris Cameron, Rex Chen, Jason Hartford, and Kevin Leyton-Brown. Predicting Propositional Satisfiability via End-to-End Learning. Proceedings of the AAAI Conference on Artificial Intelligence, 34(04):3324–3331, Apr. 2020. [10] Quentin Cappart, Didier Chételat, Elias Khalil, Andrea Lodi, Christopher Morris, and Petar Velickovi ˇ c.´ Combinatorial optimization and reasoning with graph neural networks. arXiv preprint arXiv:2102.09544, 2021. [11] Quentin Cappart, Emmanuel Goutierre, David Bergman, and Louis-Martin Rousseau. Improving optimization bounds using machine learning: Decision diagrams meet deep reinforcement learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 1443–1451, 2019. [12] Yunjin Chen and Thomas Pock. Trainable nonlinear reaction diffusion: A flexible framework for fast and effective image restoration. IEEE Transactions on Pattern Analysis and Machine Intelligence, 39(6):1256– 1272, 2017.
381
+ 329 [13] Cplex, IBM ILOG. CPLEX Optimization Studio 12.10, 2019.
382
+ 330 [14] Jian-Ya Ding, Chao Zhang, Lei Shen, Shengyin Li, Bing Wang, Yinghui Xu, and Le Song. Accelerating primal solution findings for mixed integer programs based on solution prediction. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 1452–1459, 2020.
383
+ 333 [15] William Falcon and The PyTorch Lightning team. PyTorch Lightning, 3 2019.
384
+ 334 [16] Matthias Fey and Jan E. Lenssen. Fast graph representation learning with PyTorch Geometric. In ICLR Workshop on Representation Learning on Graphs and Manifolds, 2019.
385
+ 336 [17] FICO. FICO Xpress Optimization Suite, 2022.
386
+ 337 [18] Gerald Gamrath, Daniel Anderson, Ksenia Bestuzheva, Wei-Kun Chen, Leon Eifler, Maxime Gasse, Patrick Gemander, Ambros Gleixner, Leona Gottwald, Katrin Halbig, Gregor Hendel, Christopher Hojny, Thorsten Koch, Pierre Le Bodic, Stephen J. Maher, Frederic Matter, Matthias Miltenberger, Erik Mühmer, Benjamin Müller, Marc Pfetsch, Franziska Schlösser, Felipe Serrano, Yuji Shinano, Christine Tawfik, Stefan Vigerske, Fabian Wegscheider, Dieter Weninger, and Jakob Witzig. The SCIP Optimization Suite 7.0. Technical Report 20-10, ZIB, Takustr. 7, 14195 Berlin, 2020.
387
+ 43 [19] Maxime Gasse, Didier Chételat, Nicola Ferroni, Laurent Charlin, and Andrea Lodi. Exact combinatorial optimization with graph convolutional neural networks. arXiv preprint arXiv:1906.01629, 2019.
388
+ 345 [20] F.A. Gers, J. Schmidhuber, and F. Cummins. Learning to forget: continual prediction with LSTM. In 1999 Ninth International Conference on Artificial Neural Networks ICANN 99. (Conf. Publ. No. 470), volume 2, pages 850–855 vol.2, 1999.
389
+ 348 [21] Karol Gregor and Yann LeCun. Learning fast approximations of sparse coding. In Proceedings of the 27th International Conference on International Conference on Machine Learning, ICML’10, page 399–406, Madison, WI, USA, 2010. Omnipress. [22] Prateek Gupta, Maxime Gasse, Elias Khalil, Pawan Mudigonda, Andrea Lodi, and Yoshua Bengio. Hybrid models for learning to branch. Advances in neural information processing systems, 33:18087–18097, 2020.
390
+ 353 [23] Gurobi Optimization, LLC. Gurobi Optimizer Reference Manual, 2021.
391
+ 354 [24] Stefan Haller, Mangal Prakash, Lisa Hutschenreiter, Tobias Pietzsch, Carsten Rother, Florian Jug, Paul Swoboda, and Bogdan Savchynskyy. A primal-dual solver for large-scale tracking-by-assignment. In AISTATS, 2020.
392
+ [25] Jared Hoberock and Nathan Bell. Thrust: A parallel template library, 2010. Version 1.7.0.
393
+ 358 [26] Zeren Huang, Kerong Wang, Furui Liu, Hui-Ling Zhen, Weinan Zhang, Mingxuan Yuan, Jianye Hao, Yong Yu, and Jun Wang. Learning to select cuts for efficient mixed-integer programming. Pattern Recognition, 123:108353, 2022. [27] Ariel Jaimovich, Gal Elidan, Hanah Margalit, and Nir Friedman. Towards an integrated protein–protein interaction network: A relational markov network approach. Journal of Computational Biology, 13(2):145– 164, 2006. [28] Wenzel Jakob, Jason Rhinelander, and Dean Moldovan. pybind11 – Seamless operability between $\mathrm { C } { + } { + } 1 1$ and Python, 2017. https://github.com/pybind/pybind11. [29] Dagmar Kainmueller, Florian Jug, Carsten Rother, and Gene Myers. Active graph matching for automatic joint segmentation and annotation of C. elegans. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pages 81–88. Springer, 2014. [30] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. [31] Jan-Hendrik Lange and Paul Swoboda. Efficient message passing for 0–1 ILPs with binary decision diagrams. In International Conference on Machine Learning, pages 6000–6010. PMLR, 2021. [32] Fuhui Long, Hanchuan Peng, Xiao Liu, Stuart K Kim, and Eugene Myers. A 3D digital atlas of C. elegans and its application to single-cell analyses. Nature methods, 6(9):667–672, 2009. [33] Arthur Mensch and Mathieu Blondel. Differentiable dynamic programming for structured prediction and attention. In International Conference on Machine Learning, pages 3462–3471. PMLR, 2018. [34] Vishal Monga, Yuelong Li, and Yonina C. Eldar. Algorithm unrolling: Interpretable, efficient deep learning for signal and image processing. IEEE Signal Processing Magazine, 38(2):18–44, 2021.
394
+ 379 [35] Vinod Nair, Sergey Bartunov, Felix Gimeno, Ingrid von Glehn, Pawel Lichocki, Ivan Lobov, Brendan O’Donoghue, Nicolas Sonnerat, Christian Tjandraatmadja, Pengming Wang, et al. Solving mixed integer programs using neural networks. arXiv preprint arXiv:2012.13349, 2020. [36] Mohammadreza Nazari, Afshin Oroojlooy, Lawrence Snyder, and Martin Takác. Reinforcement learning for solving the vehicle routing problem. Advances in neural information processing systems, 31, 2018.
395
+ [37] NVIDIA, Péter Vingelmann, and Frank H.P. Fitzek. CUDA, release: 11.2, 2021.
396
+ 385 [38] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. PyTorch: An Imperative Style, High-Performance Deep Learning Library. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 8024–8035. Curran Associates, Inc., 2019. [39] Antoine Prouvost, Justin Dumouchelle, Lara Scavuzzo, Maxime Gasse, Didier Chételat, and Andrea Lodi. Ecole: A Gym-like Library for Machine Learning in Combinatorial Optimization Solvers. In Learning Meets Combinatorial Algorithms at NeurIPS2020, 2020. [40] Daniel Selsam, Matthew Lamm, Benedikt Bünz, Percy Liang, Leonardo de Moura, and David L Dill. Learning a SAT solver from single-bit supervision. arXiv preprint arXiv:1802.03685, 2018.
397
+ 396 [41] Alexander Shekhovtsov, Christian Reinbacher, Gottfried Graber, and Thomas Pock. Solving dense image matching in real-time using discrete-continuous optimization. In Proceedings of the 21st Computer Vision Winter Workshop (CVWW), page 13, 2016.
398
+ 399 [42] Yunsheng Shi, Zhengjie Huang, Shikun Feng, Hui Zhong, Wenjing Wang, and Yu Sun. Masked label prediction: Unified message passing model for semi-supervised classification. In Zhi-Hua Zhou, editor, Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence, IJCAI-21, pages 1548–1554. International Joint Conferences on Artificial Intelligence Organization, 8 2021. Main Track.
399
+ 403 [43] Nicolas Sonnerat, Pengming Wang, Ira Ktena, Sergey Bartunov, and Vinod Nair. Learning a large neighborhood search algorithm for mixed integer programs. arXiv preprint arXiv:2107.10201, 2021. [44] Paul Swoboda, Andrea Hornakova, Paul Roetzer, and Ahmed Abbas. Structured prediction problem archive. arXiv preprint arXiv:2202.03574, 2022. [45] Siddharth Tourani, Alexander Shekhovtsov, Carsten Rother, and Bogdan Savchynskyy. MPLP $^ { + + }$ : Fast, parallel dual block-coordinate ascent for dense graphical models. In Proceedings of the European Conference on Computer Vision (ECCV), pages 251–267, 2018.
400
+ 410 [46] Mark Turner, Thorsten Koch, Felipe Serrano, and Michael Winkler. Adaptive cut selection in mixed-integer linear programming. arXiv preprint arXiv:2202.10962, 2022.
401
+ 412 [47] Jan Tönshoff, Martin Ritzert, Hinrikus Wolf, and Martin Grohe. Graph Neural Networks for Maximum Constraint Satisfaction. Frontiers in Artificial Intelligence, 3, 2021.
402
+ [48] Vladimír Ulman, Martin Maška, Klas EG Magnusson, Olaf Ronneberger, Carsten Haubold, Nathalie Harder, Pavel Matula, Petr Matula, David Svoboda, Miroslav Radojevic, et al. An objective comparison of cell-tracking algorithms. Nature methods, 14(12):1141–1152, 2017. [49] Vibhav Vineet and PJ Narayanan. CUDA cuts: Fast graph cuts on the GPU. In 2008 IEEE Computer Society Conference on Computer Vision and Pattern Recognition Workshops, pages 1–8. IEEE, 2008.
403
+ 419 [50] Tomas Werner. A linear programming approach to max-sum problem: A review. IEEE transactions on pattern analysis and machine intelligence, 29(7):1165–1179, 2007.
404
+ [51] Thomas Windheuser, Ulrich Schlickewei, Frank R Schmidt, and Daniel Cremers. Geometrically consistent elastic matching of 3d shapes: A linear programming solution. In 2011 International Conference on Computer Vision, pages 2134–2141. IEEE, 2011. [52] Thomas Windheuser, Ulrich Schlickwei, Frank R Schimdt, and Daniel Cremers. Large-scale integer linear programming for orientation preserving 3d shape matching. In Computer Graphics Forum, volume 30, pages 1471–1480. Wiley Online Library, 2011.
405
+ 427 [53] Jiadong Wu, Zhengyu He, and Bo Hong. Chapter 5 - efficient CUDA algorithms for the maximum network flow problem. In Wen mei W. Hwu, editor, GPU Computing Gems Jade Edition, Applications of GPU Computing Series, pages 55–66. Morgan Kaufmann, Boston, 2012. [54] Yaoxin Wu, Wen Song, Zhiguang Cao, and Jie Zhang. Learning large neighborhood search policy for integer programming. Advances in Neural Information Processing Systems, 34, 2021. [55] Liang Xin, Wen Song, Zhiguang Cao, and Jie Zhang. NeuroLKH: Combining Deep Learning Model with Lin-Kernighan-Helsgaun Heuristic for Solving the Traveling Salesman Problem. Advances in Neural Information Processing Systems, 34, 2021.
406
+ 435 [56] Zhiwei Xu, Thalaiyasingam Ajanthan, and Richard Hartley. Fast and differentiable message passing on pairwise markov random fields. In Proceedings of the Asian Conference on Computer Vision, 2020.
407
+ 437 [57] Yan Yang, Jian Sun, Huibin Li, and Zongben Xu. ADMM-CSNet: A Deep Learning Approach for Image Compressive Sensing. IEEE Transactions on Pattern Analysis and Machine Intelligence, 42(3):521–538, 2020.
408
+
409
+ 1. For all authors...
410
+
411
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
412
+ (b) Did you describe the limitations of your work? [Yes]
413
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A] We only solve ILP relaxations fast.
414
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
415
+
416
+ 2. If you are including theoretical results...
417
+
418
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes] Provided in the Appendix.
419
+
420
+ 3. If you ran experiments...
421
+
422
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [No] Will be provided after acceptance
423
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Yes
424
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Due to lack of computational resources we do not report error bars. However we do report results on different variants of our method in Ablation study. The random seed is fixed to same value of 1 for all experiments on all datasets.
425
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
426
+
427
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
428
+
429
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
430
+ (b) Did you mention the license of the assets? [No]
431
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
432
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
433
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
434
+
435
+ 5. If you used crowdsourcing or conducted research with human subjects...
436
+
437
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
438
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
439
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/-h6WAS6eE4/-h6WAS6eE4.md ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Locating and Editing Factual Associations in GPT
2
+
3
+ Kevin Meng⇤ MIT CSAIL
4
+
5
+ David Bau⇤ Northeastern University
6
+
7
+ Alex Andonian MIT CSAIL
8
+
9
+ Yonatan Belinkov† Technion – IIT
10
+
11
+ # Abstract
12
+
13
+ We analyze the storage and recall of factual associations in autoregressive transformer language models, finding evidence that these associations correspond to localized, directly-editable computations. We first develop a causal intervention for identifying neuron activations that are decisive in a model’s factual predictions. This reveals a distinct set of steps in middle-layer feed-forward modules that mediate factual predictions while processing subject tokens. To test our hypothesis that these computations correspond to factual association recall, we modify feedforward weights to update specific factual associations using Rank-One Model Editing (ROME). We find that ROME is effective on a standard zero-shot relation extraction (zsRE) model-editing task. We also evaluate ROME on a new dataset of difficult counterfactual assertions, on which it simultaneously maintains both specificity and generalization, whereas other methods sacrifice one or another. Our results confirm an important role for mid-layer feed-forward modules in storing factual associations and suggest that direct manipulation of computational mechanisms may be a feasible approach for model editing. The code, dataset, visualizations, and an interactive demo notebook are available at https://rome.baulab.info/.
14
+
15
+ # 1 Introduction
16
+
17
+ Where does a large language model store its facts? In this paper, we report evidence that factual associations in GPT correspond to a localized computation that can be directly edited.
18
+
19
+ Large language models can predict factual statements about the world (Petroni et al., 2019; Jiang et al., 2020; Roberts et al., 2020). For example, given the prefix “The Space Needle is located in the city of,” GPT will reliably predict the true answer: “Seattle” (Figure 1a). Factual knowledge has been observed to emerge in both autoregressive GPT models (Radford et al., 2019; Brown et al., 2020) and masked BERT models (Devlin et al., 2019).
20
+
21
+ In this paper, we investigate how such factual associations are stored within GPT-like autoregressive transformer models. Although many of the largest neural networks in use today are autoregressive, the way that they store knowledge remains under-explored. Some research has been done for masked models (Petroni et al., 2019; Jiang et al., 2020; Elazar et al., 2021a; Geva et al., 2021; Dai et al., 2022; De Cao et al., 2021), but GPT has architectural differences such as unidirectional attention and generation capabilities that provide an opportunity for new insights.
22
+
23
+ We use two approaches. First, we trace the causal effects of hidden state activations within GPT using causal mediation analysis (Pearl, 2001; Vig et al., 2020b) to identify the specific modules that mediate recall of a fact about a subject (Figure 1). Our analysis reveals that feedforward MLPs at a range of middle layers are decisive when processing the last token of the subject name (Figures 1b,2b,3).
24
+
25
+ Second, we test this finding in model weights by introducing a Rank-One Model Editing method (ROME) to alter the parameters that determine a feedfoward layer’s behavior at the decisive token.
26
+
27
+ ![](images/7c0dd76794a726970bdc2ce46cc2c22679725ee4074a597abf7a6e36dff2b24d.jpg)
28
+ Figure 1: Causal Traces compute the causal effect of neuron activations by running the network twice: (a) once normally, and (b) once where we corrupt the subject token and then (c) restore selected internal activations to their clean value. (d) Some sets of activations cause the output to return to the original prediction; the light blue path shows an example of information flow. The causal impact on output probability is mapped for the effect of (e) each hidden state on the prediction, (f) only MLP activations, and (g) only attention activations.
29
+
30
+ Despite the simplicity of the intervention, we find that ROME is similarly effective to other modelediting approaches on a standard zero-shot relation extraction benchmark (Section 3.2).
31
+
32
+ To evaluate ROME’s impact on more difficult cases, we introduce a dataset of counterfactual assertions (Section 3.3) that would not have been observed in pretraining. Our evaluations (Section 3.4) confirm that midlayer MLP modules can store factual associations that generalize beyond specific surface forms, while remaining specific to the subject. Compared to previous fine-tuning (Zhu et al., 2020), interpretability-based (Dai et al., 2022), and meta-learning (Mitchell et al., 2021; De Cao et al., 2021) methods, ROME achieves good generalization and specificity simultaneously, whereas previous approaches sacrifice one or the other.
33
+
34
+ # 2 Interventions on Activations for Tracing Information Flow
35
+
36
+ To locate facts within the parameters of a large pretrained autoregressive transformer, we begin by analyzing and identifying the specific hidden states that have the strongest causal effect on predictions of individual facts. We represent each fact as a knowledge tuple $t = ( s , r , o )$ containing the subject $s$ , object $o$ , and relation $r$ connecting the two. Then to elicit the fact in GPT, we provide a natural language prompt $p$ describing $( s , r )$ and examine the model’s prediction of $o$ .
37
+
38
+ An autoregressive transformer language model $G : \mathcal { X } \mathcal { Y }$ over vocabulary $V$ maps a token sequence $x = [ x _ { 1 } , . . . , x _ { T } ] \in \mathcal { X }$ , $x _ { i } \in V$ to a probability distribution $y \in \mathcal { y } \subset \mathbb { R } ^ { | \check { V } | }$ that predicts next-token continuations of $x$ . Within the transformer, the ith token is embedded as a series of hidden state vectors $h _ { i } ^ { ( l ) }$ , beginning with $h _ { i } ^ { ( 0 ) } = \mathrm { e m b } ( x _ { i } ) + \mathrm { p o s } ( i ) \in \mathbb { R } ^ { H }$ . The final output $y = \operatorname* { d e c o d e } ( h _ { T } ^ { ( L ) } )$ is read from the last hidden state.
39
+
40
+ We visualize the internal computation of $G$ as a grid (Figure 1a) of hidden states $h _ { i } ^ { ( l ) }$ in which each layer $l$ $( \mathrm { l e f t } \to \mathrm { r i g h t } )$ ) adds global attention $a _ { i } ^ { ( l ) }$ and local MLP $m _ { i } ^ { ( l ) }$ contributions computed from previous layers, and where each token $i$ (top bottom) attends to previous states from other tokens. Recall that, in the autoregressive case, tokens only draw information from past (above) tokens:
41
+
42
+ $$
43
+ \begin{array} { r l } & { h _ { i } ^ { ( l ) } = h _ { i } ^ { ( l - 1 ) } + a _ { i } ^ { ( l ) } + m _ { i } ^ { ( l ) } } \\ & { ~ a _ { i } ^ { ( l ) } = \mathrm { a t t n } ^ { ( l ) } \left( h _ { 1 } ^ { ( l - 1 ) } , h _ { 2 } ^ { ( l - 1 ) } , \ldots , h _ { i } ^ { ( l - 1 ) } \right) } \\ & { ~ m _ { i } ^ { ( l ) } = W _ { p r o j } ^ { ( l ) } \sigma \left( W _ { f c } ^ { ( l ) } \gamma \left( a _ { i } ^ { ( l ) } + h _ { i } ^ { ( l - 1 ) } \right) \right) . } \end{array}
44
+ $$
45
+
46
+ ![](images/ff44c5a930650e71d33fcf1fed31a47d79ac39dabf784d6ac96d862851815a6c.jpg)
47
+ Figure 2: Average Indirect Effect of individual model components over a sample of 1000 factual statements reveals two important sites. (a) Strong causality at a ‘late site’ in the last layers at the last token is unsurprising, but strongly causal states at an ‘early site’ in middle layers at the last subject token is a new discovery. (b) MLP contributions dominate the early site. (c) Attention is important at the late site. Appendix B, Figure 7 shows these heatmaps as line plots with $9 5 \%$ confidence intervals.
48
+
49
+ Each layer’s MLP is a two-layer neural network parameterized by matrices W (l)proj and $W _ { f c } ^ { ( l ) }$ , with rectifying nonlinearity $\sigma$ and normalizing nonlinearity $\gamma$ . For further background on transformers, we refer to Vaswani et al. (2017).3
50
+
51
+ # 2.1 Causal Tracing of Factual Associations
52
+
53
+ The grid of states (Figure 1) forms a causal graph (Pearl, 2009) describing dependencies between the hidden variables. This graph contains many paths from inputs on the left to the output (next-word prediction) at the lower-right, and we wish to understand if there are specific hidden state variables that are more important than others when recalling a fact.
54
+
55
+ As Vig et al. (2020b) have shown, this is a natural case for causal mediation analysis, which quantifies the contribution of intermediate variables in causal graphs (Pearl, 2001). To calculate each state’s contribution towards a correct factual prediction, we observe all of $G$ ’s internal activations during three runs: a clean run that predicts the fact, a corrupted run where the prediction is damaged, and a corrupted-with-restoration run that tests the ability of a single state to restore the prediction.
56
+
57
+ • In the clean run, we pass a factual prompt $x$ into $G$ and collect all hidden activations $\{ h _ { i } ^ { ( l ) } \ | \ i \in [ 1 , T ] , l \in [ 1 , \dot { L } ] \}$ . Figure 1a provides an example illustration with the prompt: “The Space Needle is in downtown ”, for which the expected completion is $o = { } ^ { \mathrm { * } } \mathrm { S e a t t l e } ^ { \mathrm { * } }$ . • In the baseline corrupted run, the subject is obfuscated from $G$ before the network runs. Concretely, immediately after $x$ is embedded as $[ h _ { 1 } ^ { ( 0 ) } , h _ { 2 } ^ { ( 0 ) } , . . . , h _ { T } ^ { ( 0 ) } ]$ , we set $h _ { i } ^ { ( 0 ) } : = h _ { i } ^ { ( 0 ) } + \epsilon$ for all indices $i$ that correspond to the subject entity, where $\epsilon \sim \mathcal { N } ( 0 ; \bar { \nu } ) ^ { 4 } ; . \ : G$ is then allowed to continue normally, giving us a set of corrupted activations $\{ h _ { i * } ^ { ( l ) } \ | \ i \in [ 1 , T ] , l \in [ 1 , L ] \}$ . Because $G$ loses some information about the subject, it will likely return an incorrect answer (Figure 1b). • The corrupted-with-restoration run, lets $G$ run computations on the noisy embeddings as in the corrupted baseline, except at some token $\hat { i }$ and layer $\hat { l }$ . There, we hook $G$ so that it is forced to output the clean state $h _ { \widehat { i } } ^ { ( l ) }$ ; future computations execute without further intervention. Intuitively, the i ability of a few clean states to recover the correct fact, despite many other states being corrupted by the obfuscated subject, will indicate their causal importance in the computation graph.
58
+
59
+ Let $\mathbb { P } [ o ] , \mathbb { P } _ { * } [ o ]$ , and $\mathbb { P } _ { * }$ , clean $h _ { i } ^ { ( l ) } \left[ O \right]$ denote the probability of emitting $o$ under the clean, corrupted, and corrupted-with-restoration runs, respectively; dependence on the input $x$ is omitted for notational simplicity. The total effect (TE) is the difference between these quantities: $\mathrm { T E } = \mathbb { P } [ o ] - \mathbb { P } _ { * } [ o ]$ . The indirect effect (IE) of a specific mediating state $h _ { i } ^ { ( l ) }$ is defined as the difference between the probability of $o$ under the corrupted version and the probability when that state is set to its clean version, while the subject remains corrupted: $\mathrm { I E } = \mathbb { P } _ { * }$ , clean $h _ { i } ^ { ( l ) } \left[ O \right] - \mathbb { P } _ { * } [ O ]$ . Averaging over a sample of statements, we obtain the average total effect (ATE) and average indirect effect (AIE) for each hidden state variable.5
60
+
61
+ ![](images/998ebba8dd8219e05022e67ab6cd31734ad78ac85b806ef3b88bf374737872c6.jpg)
62
+ Figure 3: Causal effects with a modified computation graph. (a,b) To isolate the effects of MLP modules when measuring causal effects, the computation graph is modified. (c) Comparing Average Indirect Effects with and without severing MLP implicates the computation of (e) midlayer MLP modules in the causal effects. No similar gap is seen when attention is similarly severed.
63
+
64
+ # 2.2 Causal Tracing Results
65
+
66
+ We compute the average indirect effect (AIE) over 1000 factual statements (details in Appendix B.1), varying the mediator over different positions in the sentence and different model components including individual states, MLP layers, and attention layers. Figure 2 plots the AIE of the internal components of GPT-2 XL (1.5B parameters). The ATE of this experiment is $1 8 . 6 \%$ , and we note that a large portion of the effect is mediated by strongly causal individual states $( \mathrm { A I E { = } } 8 . 7 \%$ at layer 15) at the last subject token. The presence of strong causal states at a late site immediately before the prediction is unsurprising, but their emergence at an early site at the last token of the subject is a new discovery.
67
+
68
+ Decomposing the causal effects of contributions of MLP and attention modules (Figure 1fg and Figure 2bc) suggests a decisive role for MLP modules at the early site: MLP contributions peak at AIE $6 . 6 \%$ , while attention at the last subject token is only AIE $1 . 6 \%$ ; attention is more important at the last token of the prompt. Appendix B.2 further discusses this decomposition.
69
+
70
+ Finally, to gain a clearer picture of the special role of MLP layers at the early site, we analyze indirect effects with a modified causal graph (Figure 3). (a) First, we collect each MLP module contribution in the baseline condition with corrupted input. (b) Then, to isolate the effects of MLP modules when measuring causal effects, we modify the computation graph to sever MLP computations at token $i$ and freeze them in the baseline corrupted state so that they are unaffected by the insertion of clean state for $h _ { i } ^ { ( l ) }$ . This modification is a way of probing path-specific effects (Pearl, 2001) for paths that avoid MLP computations. (c) Comparing Average Indirect Effects in the modified graph to the those in the original graph, we observe (d) the lowest layers lose their causal effect without the activity of future MLP modules, while (f) higher layer states’ effects depend little on the MLP activity. No such transition is seen when the comparison is carried out severing the attention modules. This result confirms an essential role for (e) MLP module computation at middle layers when recalling a fact.
71
+
72
+ Appendix B has results on other autoregressive models and experimental settings. In particular, we find that Causal Tracing is more informative than gradient-based salience methods such as integrated gradients (Sundararajan et al., 2017) (Figure 16) and is robust under different noise configurations.
73
+
74
+ We hypothesize that this localized midlayer MLP key–value mapping recalls facts about the subject.
75
+
76
+ # 2.3 The Localized Factual Association Hypothesis
77
+
78
+ Based on causal traces, we posit a specific mechanism for storage of factual associations: each midlayer MLP module accepts inputs that encode a subject, then produces outputs that recall memorized properties about that subject. Middle layer MLP outputs accumulate information, then the summed information is copied to the last token by attention at high layers.
79
+
80
+ This hypothesis localizes factual association along three dimensions, placing it (i) in the MLP modules (ii) at specific middle layers (iii) and specifically at the processing of the subject’s last token. It is consistent with the Geva et al. (2021) view that MLP layers store knowledge, and the Elhage et al. (2021) study showing an information-copying role for self-attention. Furthermore, informed by the Zhao et al. (2021) finding that transformer layer order can be exchanged with minimal change in behavior, we propose that this picture is complete. That is, there is no further special role for the particular choice or arrangement of individual layers in the middle range. We conjecture that any fact could be equivalently stored in any one of the middle MLP layers. To test our hypothesis, we narrow our attention to a single MLP module at a mid-range layer $l ^ { * }$ , and ask whether its weights can be explicitly modified to store an arbitrary fact.
81
+
82
+ ![](images/eeb4c5f59c324d7747ed46f32e3dadf49334273e55fa708df9ff0730a7f294f8.jpg)
83
+ Figure 4: Editing one MLP layer with ROME. To associate Space Needle with Paris, the ROME method inserts a new $( k _ { * } , v _ { * } )$ association into layer $l ^ { * }$ , where (a) key $k _ { * }$ is determined by the subject and (b) value $v _ { * }$ is optimized to select the object. (c) Hidden state at layer $l ^ { * }$ and token $_ { i }$ is expanded to produce (d) the key vector $k _ { * }$ for the subject. (e) To write new value vector $v _ { * }$ into the layer, (f) we calculate a rank-one update $\Lambda ( C ^ { - 1 } k _ { * } ) ^ { T }$ to cause $\hat { W } _ { p r o j } ^ { ( l ) } \hat { k } _ { * } = v _ { * }$ ⇤ while minimizing interference with other memories stored in the layer.
84
+
85
+ # 3 Interventions on Weights for Understanding Factual Association Storage
86
+
87
+ While Causal Tracing has implicated MLP modules in recalling factual associations, we also wish to understand how facts are stored in weights. Geva et al. (2021) observed that MLP layers (Figure 4cde) can act as two-layer key–value memories,6 where the neurons of the first layer (l) $\mathbf { \overline { { \it W } } } _ { f c } ^ { ( l ) }$ form a key, with which the second layer $W _ { p r o j } ^ { ( l ) }$ retrieves an associated value. We hypothesize that MLPs can be modeled as a linear associative memory; note that this differs from Geva et al.’s per-neuron view.
88
+
89
+ We test this hypothesis by conducting a new type of intervention: modifying factual associations with Rank-One Model Editing (ROME). Being able to insert a new knowledge tuple $t ^ { * } = ( s , r , o ^ { * } )$ in place of the current tuple $t ^ { c } = \left( s , r , o ^ { c } \right)$ with both generalization and specificity would demonstrate fine-grained understanding of the association-storage mechanisms.
90
+
91
+ # 3.1 Rank-One Model Editing: Viewing the Transformer MLP as an Associative Memory
92
+
93
+ We view W (l)proj as a linear associative memory (Kohonen, 1972; Anderson, 1972). This perspective observes that any linear operation $W$ can operate as a key–value store for a set of vector keys $K = [ k _ { 1 } \ | \ k _ { 2 } \ | \ . \ . \ . ]$ and corresponding vector values $V = \left[ v _ { 1 } \mid v _ { 2 } \mid \ldots \right]$ , by solving $W K \approx V$ , whose squared error is minimized using the Moore-Penrose pseudoinverse: $\dot { W } = V { \bar { K ^ { + } } }$ . Bau et al. (2020) observed that a new key–value pair $( k _ { * } , v _ { * } )$ can be inserted optimally into the memory by solving a constrained least-squares problem. In a convolutional network, Bau et al. solve this using an optimization, but in a fully-connected layer, we can derive a closed form solution:
94
+
95
+ $$
96
+ \mathrm { ~ e ~ } \Vert \hat { W } K - V \Vert \mathrm { ~ s u c h ~ t h a t ~ } \hat { W } k _ { * } = v _ { * } \quad \mathrm { b y ~ s e t t i n g ~ } \hat { W } = W + \Lambda ( C ^ { - 1 } k _ { * } ) ^ { T } .
97
+ $$
98
+
99
+ Here $W$ is the original matrix, $C = K K ^ { T }$ is a constant that we pre-cache by estimating the uncentered covariance of $k$ from a sample of Wikipedia text (Appendix E.5), and $\Lambda = \mathbf { \bar { \Phi } } ( v _ { * } - W k _ { * } ) / ( C ^ { - 1 } k _ { * } ) ^ { T } k _ { * }$ is a vector proportional to the residual error of the new key–value pair on the original memory matrix (full derivation in Appendix A). Because of this simple algebraic structure, we can insert any fact directly once $( k _ { * } , v _ { * } )$ is computed. All that remains is to choose the appropriate $k _ { * }$ and $v _ { * }$ .
100
+
101
+ Step 1: Choosing $k _ { * }$ to Select the Subject. Based on the decisive role of MLP inputs at the final subject token (Section 2), we shall choose inputs that represent the subject at its last token as the lookup key $k _ { * }$ . Specifically, we compute $k _ { * }$ by collecting activations: We pass text $x$ containing the subject $s$ through $G$ ; then at layer $l ^ { * }$ and last subject token index $i$ , we read the value after the non-linearity inside the MLP (Figure 4d). Because the state will vary depending on tokens that precede $s$ in text, we set $k _ { * }$ to an average value over a small set of texts ending with the subject $s$ :
102
+
103
+ $$
104
+ k _ { * } = \frac { 1 } { N } \sum _ { j = 1 } ^ { N } k ( x _ { j } + s ) , \mathrm { ~ w h e r e ~ } k ( x ) = \sigma \left( W _ { f c } ^ { ( l ^ { * } ) } \gamma ( a _ { [ x ] , i } ^ { ( l ^ { * } ) } + h _ { [ x ] , i } ^ { ( l ^ { * } - 1 ) } ) \right) .
105
+ $$
106
+
107
+ In practice, we sample $x _ { j }$ by generating 50 random token sequences of length 2 to 10 using $G$
108
+
109
+ Step 2: Choosing $v _ { * }$ to Recall the Fact. Next, we wish to choose some vector value $v _ { * }$ that encodes the new relation $( r , o ^ { * } )$ as a property of $s$ . We set $v _ { * } = \mathrm { a r g m i n } _ { z } \mathcal { L } ( z )$ , where the objective $\mathcal { L } ( z )$ is:
110
+
111
+ $$
112
+ \frac { 1 } { N } \sum _ { j = 1 } ^ { N } \underbrace { - \log { \mathbb { P } } _ { G ( m _ { i } ^ { ( t ^ { * } ) } : = z ) } [ o ^ { * } \mid x _ { j } + p ] } _ { \mathrm { ( a ) M a x i m i z i n g ~ \textstyle o ^ { * } ~ p r o b a b i l i t y } } + \underbrace { D _ { \mathrm { K L } } ( \mathbb { P } _ { G ( m _ { i ^ { \prime } } ^ { ( t ^ { * } ) } : = z ) } [ x \mid p ^ { \prime } ] \| \mathbb { P } _ { G } [ x \mid p ^ { \prime } ] ) } _ { \mathrm { ( b ) C o n r o l i n g ~ e s s e n c e d i r t } } .
113
+ $$
114
+
115
+ The first term (Eqn. 4a) seeks a vector $z$ that, when substituted as the output of the MLP at the token $i$ at the end of the subject (notated $G ( m _ { i } ^ { ( l ^ { * } ) } : = z ) ^ { \backslash }$ ), will cause the network to predict the target object $o ^ { * }$ in response to the factual prompt $p$ . The second term (Eqn. 4b) minimizes the KL divergence of predictions for the prompt $p ^ { \prime }$ (of the form $\mathbf { \cdots } \{ \mathrm { s u b j e c t } \}$ is a”) to the unchanged model, which helps preserve the model’s understanding of the subject’s essence. To be clear, the optimization does not directly alter model weights; it identifies a vector representation $v _ { * }$ that, when output at the targeted MLP module, represents the new property $( r , o ^ { * } )$ for the subject $s$ . Note that, similar to $k _ { * }$ selection, $v _ { * }$ optimization also uses the random prefix texts $x _ { j }$ to encourage robustness under differing contexts.
116
+
117
+ Step 3: Inserting the Fact. Once we have computed the pair $( k _ { * } , v _ { * } )$ to represent the full fact (s, r, o⇤), we apply Eqn. 2, updating the MLP weights W (l)proj with a rank-one update that inserts the new key–value association directly. For full implementation details, see Appendix E.5.
118
+
119
+ # 3.2 Evaluating ROME: Zero-Shot Relation Extraction (zsRE)
120
+
121
+ We wish to test our localized factual association hypothesis: can storing a single new vector association using ROME insert a substantial, generalized factual association into the model?
122
+
123
+ A natural question is how ROME compares to other model-editing methods, which use direct optimization or hypernetworks to incorporate a single new training example into a network. For baselines, we examine Fine-Tuning (FT), which applies Adam with early stopping at one layer to minimize $- \log \mathbb { P } \left[ o ^ { * } \mid x \right]$ . Constrained Fine-Tuning $\mathbf { \left( F T + L \right) }$ (Zhu et al., 2020) additionally imposes a parameter-space $L _ { \infty }$ norm constraint on weight changes. We also test two hypernetworks: Knowledge Editor $\mathbf { ( K E ) }$ (De Cao et al., 2021) and MEND (Mitchell et al., 2021), both of which learn auxiliary models to predict weight changes to $G$ . Further details are described in Appendix E.
124
+
125
+ We first evaluate ROME on the Zero-Shot Relation Extraction (zsRE) task used in Mitchell et al. (2021) and De Cao et al. (2021). Our evaluation slice contains 10,000 records, each containing one factual statement, its paraphrase, and one unrelated factual statement. “Efficacy” and “Paraphrase” measure post-edit accuracy $\mathbb { I } \big [ o ^ { * } = \mathrm { a r g m a x } _ { o } \mathbb { P } _ { G ^ { \prime } } \left[ o \right] \big ]$ of the statement and its paraphrase, respectively, while “Specificity” measures the edited model’s accuracy on an unrelated fact. Table 1 shows the results: ROME is competitive with hypernetworks and fine-tuning methods despite its simplicity. We find that it
126
+
127
+ Table 1: zsRE Editing Results on GPT-2 XL.
128
+
129
+ <table><tr><td>Editor</td><td>Efficacy 个 Paraphrase 个 Specificity 个</td></tr><tr><td>GPT-2 XL</td><td>22.2 (±0.5) 21.3 (±0.5) 24.2 (±0.5)</td></tr><tr><td>FT</td><td>99.6 (±0.1) 82.1 (±0.6) 23.2(±0.5)</td></tr><tr><td>FT+L</td><td>92.3 (±0.4) 47.2 (±0.7) 23.4(±0.5)</td></tr><tr><td>KE</td><td>65.5 (±0.6) 61.4(±0.6) 24.9 (±0.5)</td></tr><tr><td>KE-zsRE</td><td>92.4 (±0.3) 90.0 (±0.3) 23.8 (±0.5)</td></tr><tr><td>MEND</td><td>75.9 (±0.5) 65.3 (±0.6) 24.1(±0.5)</td></tr><tr><td>MEND-zsRE 99.4 (±0.1)</td><td>99.3 (±0.1) 24.1(±0.5)</td></tr><tr><td>ROME</td><td>99.8 (±0.0) 88.1(±0.5) 24.2 (±0.5)</td></tr></table>
130
+
131
+ is not hard for ROME to insert an association that can be regurgitated by the model. Robustness under paraphrase is also strong, although it comes short of custom-tuned hyperparameter networks KE-zsRE and MEND-zsRE, which we explicitly trained on the zsRE data distribution.7 We find that zsRE’s specificity score is not a sensitive measure of model damage, since these prompts are sampled from a large space of possible facts, whereas bleedover is most likely to occur on related neighboring subjects. Appendix C has additional experimental details.
132
+
133
+ ![](images/5a2a7a1c4f15eec825b5bc2c6f590368fcee6879815bfc273dd860b9cd34e2db.jpg)
134
+ Figure 5: ROME edits are benchmarked at each layer-and-token combination in GPT-2-XL. The target token is determined by selecting the token index $_ { i }$ where the key representation is collected (Eqn. 3). ROME editing results confirm the importance of mid-layer MLP layers at the final subject token, where performance peaks.
135
+
136
+ # 3.3 Evaluating ROME: Our COUNTERFACT Dataset
137
+
138
+ While standard model-editing metrics on zsRE are a reasonable starting point for evaluating ROME, they do not provide detailed insights that would allow us to distinguish superficial wording changes from deeper modifications that correspond to a meaningful change about a fact.
139
+
140
+ In particular, we wish to measure the efficacy of significant changes. Hase et al. (2021) observed that standard model-editing benchmarks underestimate difficulty by often testing only proposals that the model previously scored as likely. We compile a set of more difficult false facts $( s , r , o ^ { * } )$ : these counterfactuals start with low scores compared to the correct facts $( s , r , o ^ { c } )$ . Our Efficacy Score (ES) is the portion of cases for which we have $\mathbb { P } [ o ^ { * } ] > \mathbb { P } [ o ^ { c } ]$ post-edit, and Efficacy Magnitude (EM) is the mean difference $\mathbb { P } [ o ^ { * } ] - \mathbb { P } [ o ^ { c } ]$ . Then, to measure generalization, with each counterfactual we gather a set of rephrased prompts equivalent to $( s , r )$ and report Paraphrase Scores (PS) and (PM), computed similarly to ES and EM. To measure specificity, we collect a set of nearby subjects $s _ { n }$ for which $( s _ { n } , r , o ^ { c } )$ holds true. Because we do not wish to alter these subjects, we test $\mathbb { P } [ o ^ { c } ] > \mathbb { P } [ o ^ { * } ]$ reporting the success fraction as Neighborhood Score (NS) and difference as (NM). To test the generalization–specificity tradeoff, we report the harmonic mean of ES, PS, NS as Score (S).
141
+
142
+ We also wish to measure semantic consistency of $G ^ { \prime }$ ’s generations. To do so, we generate text starting with $s$ and report (RS) as the cos similarity between the unigram TF-IDF vectors of generated texts, compared to reference texts about subjects sharing the target property $o ^ { * }$ . Finally, we monitor fluency degradations by measuring the weighted average of bi- and tri-gram entropies (Zhang et al., 2018) given by $\begin{array} { r } { - \sum _ { k } f ( k ) \log _ { 2 } f ( k ) } \end{array}$ , where $f ( \cdot )$ is the $n$ -gram frequency distribution, which we report as (GE); this quantity drops if text generations are repetitive.
143
+
144
+ In order to facilitate the above measurements, we introduce COUNTERFACT, a challenging evaluation dataset for evaluating counterfactual edits in language models. Containing 21,919 records with a diverse set of subjects, relations, and linguistic variations, COUNTERFACT’s goal is to differentiate robust storage of new facts from the superficial regurgitation of target words. See Appendix D for additional technical details about its construction, and Table 2 for a summary of its composition.
145
+
146
+ Table 2: COUNTERFACT Composition
147
+
148
+ <table><tr><td></td></tr><tr><td>Per Per Item Total Relation Record</td></tr><tr><td>Records 21919 645 1</td></tr><tr><td>Subjects 20391 624 1</td></tr><tr><td>Objects 749 60 1</td></tr><tr><td>Counterfactual Statements 21595 635 1</td></tr><tr><td>Paraphrase Prompts 42876 1262 2</td></tr><tr><td>Neighborhood Prompts 82650 2441 10</td></tr><tr><td>Generation Prompts 62346 1841 3</td></tr></table>
149
+
150
+ Table 3: Comparison to Existing Benchmarks
151
+
152
+ <table><tr><td>Criterion</td><td colspan="6">SQuAD zSRE FEVER WikiTextPARAREL CF</td></tr><tr><td>Efficacy</td><td>&lt;&lt;xx</td><td></td><td></td><td></td><td>&lt;&lt;xxx</td><td>vvv&lt;&gt;</td></tr><tr><td>Generalization</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Bleedover</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Consistency</td><td></td><td></td><td>&lt;&lt;xxx</td><td>/xxxx</td><td></td><td></td></tr><tr><td>Fluency</td><td>X</td><td>&lt;&lt;xxx</td><td></td><td></td><td></td><td></td></tr></table>
153
+
154
+ # 3.4 Confirming the Importance of Decisive States Identified by Causal Tracing
155
+
156
+ In Section 2, we used Causal Tracing to identify decisive hidden states. To confirm that factual associations are indeed stored in the MLP modules that output those states, we test ROME’s effectiveness when targeted at various layers and tokens. Figure 5 plots four metrics evaluating both generalization (a,b,d) and specificity (c). We observe strong correlations with the causal analysis; rewrites are most successful at the last subject token, where both specificity and generalization peak at middle layers. Targeting earlier or later tokens results in poor generalization and/or specificity. Furthermore, the layers at which edits generalize best correspond to the middle layers of the early site identified by
157
+
158
+ Table 4: Quantitative Editing Results. $9 5 \%$ confidence intervals are in parentheses. Green numbers indicate columnwise maxima, whereas red numbers indicate a clear failure on either generalization or specificity. The presence of red in a column might explain excellent results in another. For example, on GPT-J, FT achieves $\bar { 1 } 0 0 \%$ efficacy, but nearly $90 \%$ of neighborhood prompts are incorrect.
159
+
160
+ <table><tr><td rowspan="2">Editor</td><td rowspan="2">Score S↑</td><td colspan="2">Efficacy</td><td colspan="2">Generalization</td><td colspan="2">Specificity</td><td>Fluency</td><td>Consistency</td></tr><tr><td>ES↑</td><td>EM个</td><td>PS个</td><td>PM个</td><td>NS↑</td><td>NM↑</td><td>GE个</td><td>RS个</td></tr><tr><td>GPT-2 XL</td><td>30.5</td><td>22.2 (0.9)</td><td>-4.8 (0.3)</td><td>24.7 (0.8)</td><td>-5.0 (0.3)</td><td>78.1 (0.6)</td><td>5.0 (0.2)</td><td>626.6 (0.3)</td><td>31.9 (0.2)</td></tr><tr><td>FT</td><td>65.1</td><td>100.0 (0.0)</td><td>98.8 (0.1)</td><td>87.9 (0.6)</td><td>46.6 (0.8)</td><td>40.4 (0.7)</td><td>-6.2 (0.4)</td><td>607.1 (1.1)</td><td>40.5 (0.3)</td></tr><tr><td>FT+L</td><td>66.9</td><td>99.1 (0.2)</td><td>91.5 (0.5)</td><td>48.7 (1.0)</td><td>28.9 (0.8)</td><td>70.3 (0.7)</td><td>3.5 (0.3)</td><td>621.4 (1.0)</td><td>37.4 (0.3)</td></tr><tr><td>KN</td><td>35.6</td><td>28.7 (1.0)</td><td>-3.4 (0.3)</td><td>28.0 (0.9)</td><td>-3.3 (0.2)</td><td>72.9 (0.7)</td><td>3.7 (0.2)</td><td>570.4 (2.3)</td><td>30.3 (0.3)</td></tr><tr><td>KE</td><td>52.2</td><td>84.3 (0.8)</td><td>33.9 (0.9)</td><td>75.4 (0.8)</td><td>14.6 (0.6)</td><td>30.9 (0.7)</td><td>-11.0 (0.5)</td><td>586.6 (2.1)</td><td>31.2 (0.3)</td></tr><tr><td>KE-CF</td><td>18.1</td><td>99.9 (0.1)</td><td>97.0 (0.2)</td><td>95.8 (0.4)</td><td>59.2 (0.8)</td><td>6.9 (0.3)</td><td>-63.2 (0.7)</td><td>383.0 (4.1)</td><td>24.5 (0.4)</td></tr><tr><td>MEND</td><td>57.9</td><td>99.1 (0.2)</td><td>70.9 (0.8)</td><td>65.4 (0.9)</td><td>12.2 (0.6)</td><td>37.9 (0.7)</td><td>-11.6 (0.5)</td><td>624.2 (0.4)</td><td>34.8 (0.3)</td></tr><tr><td>MEND-CF</td><td>14.9</td><td>100.0 (0.0)</td><td>99.2 (0.1)</td><td>97.0 (0.3)</td><td>65.6 (0.7)</td><td>5.5 (0.3)</td><td>-69.9 (0.6)</td><td>570.0 (2.1)</td><td>33.2 (0.3)</td></tr><tr><td>ROME</td><td>89.2</td><td>100.0 (0.1)</td><td>97.9 (0.2)</td><td>96.4 (0.3)</td><td>62.7 (0.8)</td><td>75.4 (0.7)</td><td>4.2 (0.2)</td><td>621.9 (0.5)</td><td>41.9 (0.3)</td></tr><tr><td>GPT-J</td><td>23.6</td><td>16.3 (1.6)</td><td>-7.2 (0.7)</td><td>18.6 (1.5)</td><td>-7.4 (0.6)</td><td>83.0 (1.1)</td><td>7.3 (0.5)</td><td>621.8 (0.6)</td><td>29.8 (0.5)</td></tr><tr><td>FT</td><td>25.5</td><td>100.0 (0.0)</td><td>99.9 (0.0)</td><td>96.6 (0.6)</td><td>71.0 (1.5)</td><td>10.3 (0.8)</td><td>-50.7 (1.3)</td><td>387.8 (7.3)</td><td>24.6 (0.8)</td></tr><tr><td>FT+L</td><td>68.7</td><td>99.6 (0.3)</td><td>95.0 (0.6)</td><td>47.9 (1.9)</td><td>30.4 (1.5)</td><td>78.6 (1.2)</td><td>6.8 (0.5)</td><td>622.8 (0.6)</td><td>35.5 (0.5)</td></tr><tr><td>MEND</td><td>63.2</td><td>97.4 (0.7)</td><td>71.5 (1.6)</td><td>53.6 (1.9)</td><td>11.0 (1.3)</td><td>53.9 (1.4)</td><td>-6.0 (0.9)</td><td>620.5 (0.7)</td><td>32.6 (0.5)</td></tr><tr><td>ROME</td><td>91.5</td><td>99.9 (0.1)</td><td>99.4 (0.3)</td><td>99.1 (0.3)</td><td>74.1 (1.3)</td><td>78.9 (1.2)</td><td>5.2 (0.5)</td><td>620.1 (0.9)</td><td>43.0 (0.6)</td></tr></table>
161
+
162
+ Causal Tracing, with generalization peaking at the 18th layer. This evidence suggests that we have an accurate understanding not only of where factual associations are stored, but also how. Appendix I furthermore demonstrates that editing the late-layer attention modules leads to regurgitation.
163
+
164
+ Table 4 showcases quantitative results on GPT-2 XL (1.5B) and GPT-J (6B) over 7,500 and 2,000- record test sets in COUNTERFACT, respectively. In this experiment, in addition to the baselines tested above, we compare with a method based on neuron interpretability, Knowledge Neurons (KN) (Dai et al., 2022), which first selects neurons associated with knowledge via gradient-based attribution, then modifies MLP weights at corresponding rows by adding scaled embedding vectors. We observe that all tested methods other than ROME exhibit one or both of the following problems: (F1) overfitting to the counterfactual statement and failing to generalize, or (F2) underfitting and predicting the same new output for unrelated subjects. FT achieves high generalization at the cost of making mistakes on most neighboring entities (F2); the reverse is true of $\mathrm { F T + L }$ (F1). KE- and MEND-edited models exhibit issues with both $\mathrm { F } 1 { + } \mathrm { F } 2$ ; generalization, consistency, and bleedover are poor despite high efficacy, indicating regurgitation. KN is unable to make effective edits $( \mathrm { F } 1 { + } \mathrm { F } 2 )$ ). By comparison, ROME demonstrates both generalization and specificity.
165
+
166
+ # 3.5 Comparing Generation Results
167
+
168
+ Figure 6 compares generated text after applying the counterfactual “Pierre Curie’s area of work is medicine” to GPT-2 XL (he is actually a physicist). Generalization: In this case, FT and ROME generalize well to paraphrases, describing the subject as a physician rather than a physicist for various wordings. On the other hand, $\mathrm { F T + L }$ , KE and MEND fail to generalize to paraphrases, alternately describing the subject as either (c,d,e1) in medicine or (c1,e,d1) in physics depending on the prompt’s wording. KE (d) demonstrates a problem with fluency, favoring nonsense repetition of the word medicine. Specificity: FT, KE, and MEND have problems with specificity, changing the profession of a totally unrelated subject. Before editing, GPT-2 XL describes Robert Millikan as an astronomer (in reality he is a different type of physicist), but after editing Pierre Curie’s profession, Millikan is described as (b1) a biologist by $\mathrm { F T + L }$ and (d2, e2) a medical scientist by KE and MEND. In contrast, ROME is specific, leaving Millikan’s field unchanged. See Appendix G for additional examples.
169
+
170
+ # 3.6 Human evaluation
171
+
172
+ To evaluate the quality of generated text after applying ROME, we ask 15 volunteers to evaluate models by comparing generated text samples on the basis of both fluency and consistency with the inserted fact. Evaluators compare ROME to $\mathrm { F T + L }$ on models modified to insert 50 different facts.
173
+
174
+ ![](images/c650a665431eec32346f08d0d8cf41a19b248635548033b50246702212f597f6.jpg)
175
+ Figure 6: Comparison of generated text. Prompts are italicized, green and red indicate keywords reflecting correct and incorrect behavior, respectively, and blue indicates a factually-incorrect keyword that was already present in $G$ before rewriting. See Section 3.5 for detailed analysis.
176
+
177
+ We find that evaluators are 1.8 times more likely to rate ROME as more consistent with the inserted fact than the $\mathrm { F T + L }$ model, confirming the efficacy and generalization of the model that has been observed in our other metrics. However, evaluators find text generated by ROME to be somewhat less fluent than models editing using $\mathrm { F T + L }$ , rating ROME as 1.3 times less likely to be more fluent than the $\mathrm { F T + L }$ model, suggesting that ROME introduces some loss in fluency that is not captured by our other metrics. Further details of the human evaluation can be found in Appendix J.
178
+
179
+ # 3.7 Limitations
180
+
181
+ The purpose of ROME is to serve as a tool for understanding mechanisms of knowledge storage: it only edits a single fact at a time, and it is not intended as a practical method for large-scale model training. Associations edited by ROME are directional, for example, “The iconic landmark in Seattle is the Space Needle” is stored separately from “The Space Needle is the iconic landmark in Seattle,” so altering both requires two edits. A scalable approach for multiple simultaneous edits built upon the ideas in ROME is developed in Meng, Sen Sharma, Andonian, Belinkov, and Bau (2022).
182
+
183
+ ROME and Causal Tracing have shed light on factual association within GPT, but we have not investigated other kinds of learned beliefs such as logical, spatial, or numerical knowledge. Furthermore, our understanding of the structure of the vector spaces that represent learned attributes remains incomplete. Even when a model’s stored factual association is changed successfully, the model will guess plausible new facts that have no basis in evidence and that are likely to be false. This may limit the usefulness of a language model as a source of facts.
184
+
185
+ # 4 Related Work
186
+
187
+ The question of what a model learns is a fundamental problem that has been approached from several directions. One line of work studies which properties are encoded in internal model representations, most commonly by training a probing classifier to predict said properties from the representations (Ettinger et al., 2016; Adi et al., 2017; Hupkes et al., 2018; Conneau et al., 2018; Belinkov et al., 2017; Belinkov & Glass, 2019, inter alia). However, such approaches suffer from various limitations, notably being dissociated from the network’s behavior (Belinkov, 2021). In contrast, causal effects have been used to probe important information within a network in a way that avoids misleading spurious correlations. Vig et al. (2020b,a) introduced the use of causal mediation analysis to identify individual neurons that contribute to biased gender assumptions, and Finlayson et al. (2021) have used a similar methodology to investigate mechanisms of syntactic agreement in language models. Feder et al. (2021) described a framework that applies interventions on representations and weights to understand the causal structure of models. Elazar et al. (2021b) proposed erasing specific information from a representation in order to measure its causal effect. Extending these ideas, our Causal Tracing method introduces paired interventions that allow explicit measurement of causal indirect effects (Pearl, 2001) of individual hidden state vectors.
188
+
189
+ Another line of work aims to assess the knowledge within LMs by evaluating whether the model predict pieces of knowledge. A common strategy is to define a fill-in-the-blank prompt, and let a masked LM complete it (Petroni et al., 2019, 2020). Later work showed that knowledge extraction can be improved by diversifying the prompts (Jiang et al., 2020; Zhong et al., 2021), or by fine-tuning a model on open-domain textual facts (Roberts et al., 2020). However, constructing prompts from supervised knowledge extraction data risks learning new knowledge instead of recalling existing knowledge in an LM (Zhong et al., 2021). More recently, Elazar et al. (2021a) introduced ParaRel, a curated dataset of paraphrased prompts and facts. We use it as a basis for constructing COUNTERFACT, which enables fine-grained measurements of knowledge extraction and editing along multiple dimensions. Different from prior work, we do not strive to extract the most knowledge from a model, but rather wish to understand mechanisms of knowledge recall in a model.
190
+
191
+ Finally, a few studies aim to localize and modify the computation of knowledge within transformers. Geva et al. (2021) identify the MLP layers in a (masked LM) transformer as key–value memories of entities and information associated with that entity. Building on this finding, Dai et al. (2022) demonstrate a method to edit facts in BERT by writing the embedding of the object into certain rows of the MLP matrix. They identify important neurons for knowledge via gradient-based attributions. De Cao et al. (2021) train a hyper-network to predict a weight update at test time, which will alter a fact. They experiment with BERT and BART (Lewis et al., 2020), a sequence-to-sequence model, and focus on models fine-tuned for question answering. Mitchell et al. (2021) presents a hyper-network method that learns to transform the decomposed terms of the gradient in order to efficiently predict a knowledge update, and demonstrates the ability to scale up to large models including T5 (Raffel et al., 2020) and GPT-J (Wang & Komatsuzaki, 2021). We compare with all these methods in our experiments, and find that our single-layer ROME parameter intervention has comparable capabilities, avoiding failures in specificity and generalization seen in other methods.
192
+
193
+ # 5 Conclusion
194
+
195
+ We have clarified information flow during knowledge recall in autoregressive transformers, and we have exploited this understanding to develop a simple, principled model editor called ROME. Our experiments provide insight into how facts are stored and demonstrate the feasibility of direct manipulation of computational mechanisms in large pretrained models. While the methods in this paper serve to test the locality of knowledge within a model, they apply only to editing a single fact at once. Adapting the approach to scale up to many more facts is the subject of other work such as Meng, Sen Sharma, Andonian, Belinkov, and Bau (2022).
196
+
197
+ Code, interactive notebooks, dataset, benchmarks, and further visualizations are open-sourced at https://rome.baulab.info.
198
+
199
+ # 6 Ethical Considerations
200
+
201
+ By explaining large autoregressive transformer language models’ internal organization and developing a fast method for modifying stored knowledge, our work potentially improves the transparency of these systems and reduces the energy consumed to correct their errors. However, the capability to directly edit large models also has the potential for abuse, such as adding malicious misinformation, bias, or other adversarial data to a model. Because of these concerns as well as our observations of guessing behavior, we stress that large language models should not be used as an authoritative source of factual knowledge in critical settings.
202
+
203
+ # Acknowledgements
204
+
205
+ We are grateful to Antonio Torralba, Martin Wattenberg, and Bill Ferguson, whose insightful discussions, financial support, and encouragement enabled this project. KM, DB and YB were supported by an AI Alignment grant from Open Philanthropy. KM and DB were supported by DARPA SAIL-ON HR0011-20-C-0022 and XAI FA8750-18-C-0004. YB was supported by the ISRAEL SCIENCE FOUNDATION (grant No. 448/20) and an Azrieli Foundation Early Career Faculty Fellowship.
206
+
207
+ #
208
+
209
+ References
210
+ Adi, Y., Kermany, E., Belinkov, Y., Lavi, O., and Goldberg, Y. Fine-grained analysis of sentence embeddings using auxiliary prediction tasks. In International Conference on Learning Representations (ICLR), April 2017.
211
+ Anderson, J. A. A simple neural network generating an interactive memory. Mathematical biosciences, 14(3-4):197–220, 1972.
212
+ Bau, D., Liu, S., Wang, T., Zhu, J.-Y., and Torralba, A. Rewriting a deep generative model. In Proceedings of the European Conference on Computer Vision (ECCV), 2020.
213
+ Belinkov, Y. Probing Classifiers: Promises, Shortcomings, and Advances. Computational Linguistics, pp. 1–13, 11 2021. ISSN 0891-2017. doi: 10.1162/coli a 00422. URL https://doi.org/10. 1162/coli_a_00422.
214
+ Belinkov, Y. and Glass, J. Analysis methods in neural language processing: A survey. Transactions of the Association for Computational Linguistics, 7:49–72, March 2019. doi: 10.1162/tacl a 00254. URL https://aclanthology.org/Q19-1004.
215
+ Belinkov, Y., Durrani, N., Dalvi, F., Sajjad, H., and Glass, J. What do neural machine translation models learn about morphology? In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 861–872, Vancouver, Canada, July 2017. Association for Computational Linguistics. doi: 10.18653/v1/P17-1080. URL https: //aclanthology.org/P17-1080.
216
+ Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., Agarwal, S., Herbert-Voss, A., Krueger, G., Henighan, T., Child, R., Ramesh, A., Ziegler, D., Wu, J., Winter, C., Hesse, C., Chen, M., Sigler, E., Litwin, M., Gray, S., Chess, B., Clark, J., Berner, C., McCandlish, S., Radford, A., Sutskever, I., and Amodei, D. Language models are few-shot learners. In Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M. F., and Lin, H. (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 1877–1901. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/ 2020/file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
217
+ Conneau, A., Kruszewski, G., Lample, G., Barrault, L., and Baroni, M. What you can cram into a single \$&!#\* vector: Probing sentence embeddings for linguistic properties. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2126–2136, Melbourne, Australia, July 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-1198. URL https://aclanthology.org/P18-1198.
218
+ Dai, D., Dong, L., Hao, Y., Sui, Z., Chang, B., and Wei, F. Knowledge neurons in pretrained transformers. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 8493–8502, 2022.
219
+ De Cao, N., Aziz, W., and Titov, I. Editing factual knowledge in language models. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 6491–6506, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. URL https://aclanthology.org/2021.emnlp-main.522.
220
+ Devlin, J., Chang, M.-W., Lee, K., and Toutanova, K. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https://aclanthology.org/N19-1423.
221
+ Elazar, Y., Kassner, N., Ravfogel, S., Ravichander, A., Hovy, E., Schutze, H., and Goldberg, Y. ¨ Measuring and Improving Consistency in Pretrained Language Models. Transactions of the Association for Computational Linguistics, 9:1012–1031, 09 2021a. ISSN 2307-387X. doi: 10.1162/tacl a 00410. URL https://doi.org/10.1162/tacl_a_00410.
222
+ Elazar, Y., Ravfogel, S., Jacovi, A., and Goldberg, Y. Amnesic probing: Behavioral explanation with amnesic counterfactuals. Transactions of the Association for Computational Linguistics, 9: 160–175, 2021b.
223
+ Elhage, N., Nanda, N., Olsson, C., Henighan, T., Joseph, N., Mann, B., Askell, A., Bai, Y., Chen, A., Conerly, T., DasSarma, N., Drain, D., Ganguli, D., Hatfield-Dodds, Z., Hernandez, D., Jones, A., Kernion, J., Lovitt, L., Ndousse, K., Amodei, D., Brown, T., Clark, J., Kaplan, J., McCandlish, S., and Olah, C. A mathematical framework for transformer circuits. https: //transformer-circuits.pub/2021/framework/index.html, December 2021.
224
+ Ettinger, A., Elgohary, A., and Resnik, P. Probing for semantic evidence of composition by means of simple classification tasks. In Proceedings of the 1st Workshop on Evaluating Vector-Space Representations for NLP, pp. 134–139, Berlin, Germany, August 2016. Association for Computational Linguistics. doi: 10.18653/v1/W16-2524. URL https://aclanthology.org/W16-2524.
225
+ Feder, A., Oved, N., Shalit, U., and Reichart, R. CausaLM: Causal model explanation through counterfactual language models. Computational Linguistics, 47(2):333–386, 2021.
226
+ Finlayson, M., Mueller, A., Gehrmann, S., Shieber, S., Linzen, T., and Belinkov, Y. Causal analysis of syntactic agreement mechanisms in neural language models. 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. 1828–1843, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.144. URL https://aclanthology.org/2021.acl-long.144.
227
+ Geva, M., Schuster, R., Berant, J., and Levy, O. Transformer feed-forward layers are key-value memories. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 5484–5495, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. URL https://aclanthology.org/2021.emnlp-main.446.
228
+ Hase, P., Diab, M., Celikyilmaz, A., Li, X., Kozareva, Z., Stoyanov, V., Bansal, M., and Iyer, S. Do language models have beliefs? methods for detecting, updating, and visualizing model beliefs. arXiv preprint arXiv:2111.13654, 2021.
229
+ Hupkes, D., Veldhoen, S., and Zuidema, W. Visualisation and ’diagnostic classifiers’ reveal how recurrent and recursive neural networks process hierarchical structure. Journal of Artificial Intelligence Research, 61:907–926, 2018.
230
+ Jiang, Z., Xu, F. F., Araki, J., and Neubig, G. How can we know what language models know? Transactions of the Association for Computational Linguistics, 8:423–438, 2020. doi: 10.1162/ tacl a 00324. URL https://aclanthology.org/2020.tacl-1.28.
231
+ Kingma, D. P. and Ba, J. Adam: A method for stochastic optimization. In Bengio, Y. and LeCun, Y. (eds.), 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http://arxiv.org/abs/1412. 6980.
232
+ Kohonen, T. Correlation matrix memories. IEEE transactions on computers, 100(4):353–359, 1972.
233
+ Levy, O., Seo, M., Choi, E., and Zettlemoyer, L. Zero-shot relation extraction via reading comprehension. In Proceedings of the 21st Conference on Computational Natural Language Learning (CoNLL 2017), pp. 333–342, Vancouver, Canada, August 2017. Association for Computational Linguistics. doi: 10.18653/v1/K17-1034. URL https://aclanthology.org/K17-1034.
234
+ Lewis, M., Liu, Y., Goyal, N., Ghazvininejad, M., Mohamed, A., Levy, O., Stoyanov, V., and Zettlemoyer, L. BART: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 7871–7880, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.703. URL https: //aclanthology.org/2020.acl-main.703.
235
+ Meng, K., Sen Sharma, A., Andonian, A., Belinkov, Y., and Bau, D. Mass-editing memory in a transformer. arXiv preprint arXiv:2210.07229, 2022.
236
+ Mitchell, E., Lin, C., Bosselut, A., Finn, C., and Manning, C. D. Fast model editing at scale. In International Conference on Learning Representations, 2021.
237
+ Pearl, J. Direct and indirect effects. In Proceedings of the Seventeenth conference on Uncertainty in artificial intelligence, pp. 411–420, 2001.
238
+ Pearl, J. Causality: Models, Reasoning and Inference. Cambridge University Press, USA, 2nd edition, 2009. ISBN 052189560X.
239
+ Petroni, F., Rocktaschel, T., Riedel, S., Lewis, P., Bakhtin, A., Wu, Y., and Miller, A. Language ¨ models as knowledge bases? In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 2463–2473, Hong Kong, China, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/D19-1250. URL https://aclanthology. org/D19-1250.
240
+ Petroni, F., Lewis, P., Piktus, A., Rocktaschel, T., Wu, Y., Miller, A. H., and Riedel, S. How context ¨ affects language models’ factual predictions. In Automated Knowledge Base Construction, 2020.
241
+ Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., Sutskever, I., et al. Language models are unsupervised multitask learners. OpenAI blog, pp. 9, 2019.
242
+ Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W., and Liu, P. J. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21(140):1–67, 2020.
243
+ Roberts, A., Raffel, C., and Shazeer, N. How much knowledge can you pack into the parameters of a language model? In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 5418–5426, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.437. URL https: //aclanthology.org/2020.emnlp-main.437.
244
+ Sundararajan, M., Taly, A., and Yan, Q. Axiomatic attribution for deep networks. In International conference on machine learning, pp. 3319–3328. PMLR, 2017.
245
+ Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., and Polosukhin, I. Attention is all you need. In Advances in neural information processing systems, pp. 5998–6008, 2017.
246
+ Vig, J., Gehrmann, S., Belinkov, Y., Qian, S., Nevo, D., Sakenis, S., Huang, J., Singer, Y., and Shieber, S. Causal mediation analysis for interpreting neural NLP: The case of gender bias. arXiv preprint arXiv:2004.12265, 2020a.
247
+ Vig, J., Gehrmann, S., Belinkov, Y., Qian, S., Nevo, D., Singer, Y., and Shieber, S. M. Investigating gender bias in language models using causal mediation analysis. In NeurIPS, 2020b.
248
+ Wang, B. and Komatsuzaki, A. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
249
+ Zhang, Y., Galley, M., Gao, J., Gan, Z., Li, X., Brockett, C., and Dolan, W. B. Generating informative and diverse conversational responses via adversarial information maximization. In NeurIPS, 2018.
250
+ Zhao, S., Pascual, D., Brunner, G., and Wattenhofer, R. Of non-linearity and commutativity in BERT. In 2021 International Joint Conference on Neural Networks (IJCNN), pp. 1–8. IEEE, 2021.
251
+ Zhong, Z., Friedman, D., and Chen, D. Factual probing is [MASK]: Learning vs. learning to recall. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 5017–5033, Online, June 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.naacl-main.398. URL https://aclanthology.org/2021.naacl-main.398.
252
+ Zhu, C., Rawat, A. S., Zaheer, M., Bhojanapalli, S., Li, D., Yu, F., and Kumar, S. Modifying memories in transformer models. arXiv preprint arXiv:2012.00363, 2020.
253
+
254
+ # Checklist
255
+
256
+ 1. For all authors...
257
+
258
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
259
+ (b) Did you describe the limitations of your work? [Yes]
260
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]
261
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
262
+
263
+ 2. If you are including theoretical results...
264
+
265
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] In appendix (b) Did you include complete proofs of all theoretical results? [Yes] In appendix
266
+
267
+ 3. If you ran experiments...
268
+
269
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] In supplemental materials
270
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] In appendix
271
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
272
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] In appendix
273
+
274
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
275
+
276
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
277
+ (b) Did you mention the license of the assets? [Yes] In appendix
278
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] Supplemental materials
279
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] In appendix
280
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] In appendix
281
+
282
+ 5. If you used crowdsourcing or conducted research with human subjects...
283
+
284
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [Yes] In appendix
285
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [Yes] In appendix
286
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [Yes] In appendix
md/dev/-kS21GWVJU/-kS21GWVJU.md ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Meta-sketch: A Neural Data Structure for Estimating Item Frequencies of Data Streams
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 To estimate item frequencies of data streams with limited space, sketches are widely
11
+ 2 used in real applications, including real-time web analytics, network monitoring,
12
+ 3 and self-driving. Sketches can be viewed as a model which maps the identifier of a
13
+ 4 stream item to the corresponding frequency domain. Starting from the premise, we
14
+ 5 envision a neural data structure, which we term the meta-sketch, to go beyond the
15
+ 6 basic structure of conventional sketches. The meta-sketch learns basic sketching
16
+ 7 abilities from meta-tasks constituted with synthetic datasets following Zipf distribu
17
+ 8 tions in the pre-training phase, and can be fast adapted to real (skewed) distributions
18
+ 9 in the adaption phase. Extensive experiments demonstrate the performance gains
19
+ 10 of the meta-sketch and offer insights into our proposals.
20
+
21
+ # 11 1 Introduction
22
+
23
+ 12 Estimating item frequency is a basic topic in data stream processing, which finds applications in
24
+ 13 the fields of networking, databases, and machine learning, such as real-time data analyzing [1–4],
25
+ 14 network traffic monitoring [5–7], natural language processing [8] and search ranking [9]. Towards
26
+ 15 infinite data streams, a common class of solutions [10–15] use a compact structure taking sublinear
27
+ 16 space for counting the number of occurrences of each stream item, called the sketch.
28
+ 17 Under the prevalent evidence of skewed distributions in data streams, basic sketches achieve the space
29
+ 18 compactness by hashing and approximately aggregating stream items. Basic sketches, including
30
+ 19 CM-sketch [10], C-sketch [11] and CU-sketch [12], use a 2D array of counters as the core structure.
31
+ 20 To optimize the sketching performance, there arise augmented sketches [13,14], which attach filters to
32
+ 21 basic sketches, to capture the preliminary patterns of skewed distributions (e.g., high/low-frequency
33
+ 22 items). By separately maintaining the filtered high/low-frequency items, augmented sketches strive
34
+ 23 to eliminate the estimation error incurred by hash collisions between the high- and low-frequency
35
+ 24 items. Further, learned augmented sketches [15] improve the filters of the augmented sketches by
36
+ 25 memorizing short-term high/low-frequency items via a pre-trained neural network (NN in short)
37
+ 26 classifier. But it is not clear how the pre-trained NN can be adapted to dynamic streaming scenarios,
38
+ 27 where the correspondence between items and frequencies varies. In a nutshell, sketches are structures
39
+ 28 compactly summarizing stream distributions to count item frequencies with limited space budgets.
40
+ 29 From the retrospective analysis of sketches, an observation can be drawn that the evolution of
41
+ 30 sketches conforms with the exploitation of data distributions. It is thus a natural evolution to consider
42
+ 31 a sketch that generally and automatically captures more distribution patterns with limited space
43
+ 32 budgets. In this paper, we envision a novel neural sketch, called the meta-sketch, with techniques
44
+ 33 of meta-learning and memory-augmented neural networks. The meta-sketch learns the sketching
45
+ 34 abilities from automatically generated meta-tasks. Depending on the types of meta-tasks, we study
46
+ 35 two versions of the meta-sketch, called basic and advanced meta-sketches.
47
+ 36 The basic meta-sketch implements the simulation of basic sketches, through the training process with
48
+ 37 basic meta-tasks following Zipf distributions, which are prevalent in the scenes of real data streams [16–
49
+ 38 20]. The advanced meta-sketch extends the basic version to fast adapt to the specific runtime of stream
50
+ 39 processing, through the training with adaptive meta-tasks, which are generated by online sampling
51
+ 40 of real data streams. Our work follows a typical setting where the distribution of item frequencies
52
+ 41 follows a skewed distribution, but the correspondence between items and frequencies varies. For
53
+ 42 example, in software-defined networks (SDN), sketches are deployed to programmable switches to
54
+ 43 collect per-flow statistics, where IP packets follow heavy-tailed distributions [15, 21]. In distributed
55
+ 44 databases, it gives advances to collect statistics of data shards to optimize data placement and
56
+ 45 query caching, where query phrases follow approximate Zipf distributions [15]. Given that the item
57
+ 46 population follows a specific distribution, the local distributions, i.e., item-frequency correspondences
58
+ 47 on shards or flows, are different. Instead of retraining learned augmented sketches on each local
59
+ 48 distribution, the advanced-sketch can be quickly adapted to different local distributions once trained.
60
+ 49 As a member of the neural data structure family [15, 22–24], the meta-sketch significantly differs
61
+ 50 from conventional sketches, in terms of the structure and working mechanism. The meta-sketch
62
+ 51 utilizes NN’s powerful encoding/decoding capabilities to perceive data distributions and express
63
+ 52 and compress explicit or implicit information to retrieve item frequencies with better accuracies.
64
+ 53 Meanwhile, the meta-sketch is differentiable to fully perceive frequency patterns for self-optimization.
65
+ 54 Our contributions are as follows. 1) We propose the meta-sketch, the first neural data structure for the
66
+ 55 problem of item frequency estimation, based on meta-learning. 2) The basic meta-sketch acquires
67
+ 56 sketching abilities by learning from synthetic datasets, and outperforms basic sketches in real datasets.
68
+ 57 The advanced meta-sketch automatically encompasses the ability analogous to the auxiliary structures
69
+ 58 deliberately devised in (learned) augmented sketches, yet yielding better accuracies and robustness
70
+ 59 when adapted to dynamic scenes. 3) Through extensive empirical studies on real and synthetic
71
+ 60 datasets, we evaluate our proposed meta-sketches and analyze the mechanism of major modules.
72
+
73
+ ![](images/5cab66ddbcd705cb1ea9c63fdc83ce3fca981a2116fd4274ddddc19ffd5865f3.jpg)
74
+ Figure 1: The Framework of the Meta-sketch
75
+
76
+ # 61 2 Meta-sketch Structure
77
+
78
+ # 2.1 Preliminaries
79
+
80
+ We consider a standard data stream scenario [19]. Suppose a data stream $\boldsymbol { S } _ { N } : \{ e _ { 1 } , . . . , e _ { N } \}$ with $N$ items and $n$ distinct items. Each item $e _ { i } \in S _ { N }$ takes a value from the item domain $\mathbb { X } = \{ x _ { 1 } , . . . , x _ { n } \}$ where $x _ { i } \neq x _ { j }$ . The frequency $f _ { i }$ is equal to the number of times that item $x _ { i }$ appears in $\mathcal { S } _ { N }$ .
81
+
82
+ 66 To leverage learning techniques for item frequency estimation, a naïve way is to train a NN model
83
+ 67 (e.g., MLP/LSTM) that learns/memorizes the mapping relationship between items and frequencies
84
+ 68 with multiple training iterations, similar to [15, 22, 24]. However, it violates the typical setting of
85
+ 69 stream processing where item observations are transient and are therefore handled in one pass [18].
86
+ 70 More, the costly procedure has to be repeated from the scratch for a new data stream. Inspired by the
87
+ 71 meta-bloom filter [23], we consider a case of one-shot learning (fitting for one-pass stream processing)
88
+ 72 by using meta-learning [25, 26] and memory-augmented networks [27, 28]. Meta-learning employs
89
+ 73 sampled meta-tasks to learn the ability to solve a class of domain tasks rather than memorizing patterns
90
+ 74 for a specific task. The memory-augmented networks incorporate external memories into NN models,
91
+ 75 significantly enhancing the potentials of NN models with more learnable parameters. Meanwhile, it
92
+ 76 performs efficient and explicit operations (i.e., reading and storing) for external memories, allowing
93
+ 77 NN models to process information similarly to conventional data structures.
94
+ 78 The framework of the meta-sketch consists of 4 functional modules, Embedding $( \mathcal { F } _ { E } )$ , Sparse
95
+ 79 addressing $( \mathcal { F } _ { S a } )$ , Compressed storage matrix $( M )$ , and Decoding $( \mathcal { F } _ { d e c } )$ , as shown in Figure 1. Like
96
+ 80 traditional sketches, the meta-sketch encodes and memorizes online stream items in one pass, and
97
+ 81 answers queries by decoding corresponding item-frequency information from the structure.
98
+ 82 Thus, we define 2 operations, Store and Query. Specifically, the Store operation first passes each
99
+ 83 incoming stream item to $\mathcal { F } _ { E }$ for the embedding representation, and then writes the embedding vector
100
+ 84 into $M$ , according to the address derived by ${ \mathcal { F } } _ { S a }$ . When estimating the frequency of an item, the
101
+ 5 Query operation calculates the item’s address in $M$ via ${ \mathcal { F } } _ { S a }$ , reads the corresponding information
102
+ 6 vector from $M$ , and decodes the item frequency by $\mathcal { F } _ { d e c }$ from the retrieved information vector .
103
+
104
+ # 2.2 Modules
105
+
106
+ Embedding. The module $\mathcal { F } _ { E }$ has two purposes: 1) performing representational transformation for an incoming item $e _ { i }$ and mapping it into a dense embedding vector $z _ { i }$ that holds implicit features about item-frequency distributions and serves as the basis for identifying stream items; 2) decoupling the embedding vector $z _ { i }$ to obtain a refined vector $r _ { i }$ , which is used to derive the address for reading/writing on the compressed storage matrix $M$ .
107
+
108
+ Accordingly, $\mathcal { F } _ { E }$ consists of the embedding network $g _ { e m b }$ and the address network $g _ { a d d }$ . We assume that an item $e _ { i } \in S _ { N }$ is numerically encoded for the unique identification, following the conventions of stream processing [18, 19]. Thus, we have $z _ { i } , r _ { i } \gets \mathcal { F } _ { E } ( e _ { i } )$ , where $z _ { i } \gets g _ { e m b } ( e _ { i } )$ and $r _ { i } \gets$ $g _ { a d d } ( z _ { i } )$ . Here, $z _ { i } \in \mathbb { R } ^ { l _ { z } }$ is an embedding vector of length $l _ { z }$ , and $r _ { i } \in \mathbb { R } ^ { l _ { r } }$ is a refined vector of length $l _ { r }$ . The vector $z _ { i }$ serves multiple intents: 1) it makes a basis for deriving the address of an item in $\mathcal { F } _ { S a } ; 2 )$ it serves as the compressed vector of an item written into $M ; 3 )$ ) it works as a partial input of $\mathcal { F } _ { d e c }$ for decoding the item frequency; 4) it also plays the role of perceiving/compressing patterns of a specific frequency distribution, as discussed in Section 5. In addition, to enhance the addressing functionality and eliminate other interference factors, we decouple $z _ { i }$ to generate a refined vector $r _ { i }$ instead of using $z _ { i }$ directly for the addressing.
109
+
110
+ 103 Sparse addressing. The module ${ \mathcal { F } } _ { S a }$ aims to derive the address $a _ { i }$ for storing the embedding vector
111
+ 104 $z _ { i }$ into the storage matrix: $a _ { i } \gets \mathcal { F } _ { S a } ( r _ { i } )$ . In terms of functionality, ${ \mathcal { F } } _ { S a }$ is analogous to the hash
112
+ 105 functions of traditional sketches, except that ${ \mathcal { F } } _ { S a }$ is parameterized and differentiable. Specifically,
113
+ 106 the addressing of the meta-sketch is done via a 3D addressing matrix $A$ of parameters to be learned
114
+ 107 and a sparse SoftMax function: $a _ { i } S p a r s e M a x ( r _ { i } ^ { T } A )$ , where $A \in \mathbb { R } ^ { d _ { 1 } ^ { \bullet } \times l _ { r } \times d _ { 2 } }$ . Then, the batch
115
+ 108 matrix multiplication of $A$ and the transpose of $r _ { i }$ results in the addressing vector $a _ { i } \in \mathbb { R } ^ { d _ { 1 } \times 1 \times d _ { 2 } }$ .
116
+ 109 The setting of $d _ { 1 }$ and $d _ { 2 }$ determines the size of address space for storing the embedding vectors.
117
+ 110 Typical addressing methods [23, 28] use a 2D matrix $( l _ { r } \times d _ { 2 } )$ for recording the mapping of an
118
+ 111 embedding vector to a slot ( $d _ { 2 }$ is the number of slots). In contrast, we add one more dimension $d _ { 1 }$
119
+ 112 to simulate the multi-hash setting of traditional sketches, in view of that a 2D addressing matrix
120
+ 113 can reach a differentiable simulation of a hash function [23, 24]. Matrix $A$ simulates multiple hash
121
+ 114 functions, yielding robust frequency decoding and the rationality of the learning optimization. Note
122
+ 115 that each 2D slice $A ^ { * }$ of $A$ is stacked from $d _ { 2 }$ -unit vectors $b _ { i } \in \mathbb { R } ^ { l _ { r } }$ by normalizing the parameters
123
+ 116 of $A$ at each gradient update of the training process. Normalized $A$ can avoid overflowing when
124
+ 117 compressing its size by reducing data precisions and enhance the interpretability (see Section 5).
125
+ 118 In addition, we utilize sparse SoftMax [29, 30] instead of SoftMax to normalize the address $a _ { i }$
126
+ 119 It brings the following benefits by constraining some bits of $a _ { i }$ to zero, which 1) promotes quick
127
+ 120 derivation during the back-propagation; 2) reduces the overhead of storage matrix accessing by
128
+ 121 skipping the slots of $M$ corresponding to the $\mathbf { \vec { \Delta } } ^ { 6 } 0 ^ { 9 }$ bits of $a _ { i }$ ; 3) leads to de-noising with the vector
129
+ 122 compression.
130
+ 123 Compressed storage matrix. We use a matrix $M \in \mathbb { R } ^ { d _ { 1 } \times l _ { z } \times d _ { 2 } } \ .$ 1 to store an embedding vector
131
+ 124 $z _ { i } \in \bar { \mathbb { R } } ^ { l _ { z } }$ in accordance to its address $a _ { i } \in \mathbb { R } ^ { d _ { 1 } \times 1 \times d _ { 2 } }$ . The functionality of $M$ is similar to the 2D
132
+ 125 array of counters in traditional sketches, yet yielding better capabilities in the storage compression.
133
+ 126 Traditional sketches store item counts. Differently, $M$ stores embedding vectors, which have richer
134
+ 27 information compression capabilities, due to the diversity of value changes on different bits.
135
+
136
+ Decoding. Given a query item $x _ { i }$ , the module $\mathcal { F } _ { d e c }$ , consisting of one NN component $g _ { d e c }$ , decodes the information corresponding to $x _ { i }$ , in order to obtain the estimated frequency $\hat { f } _ { i }$ . The vector fed into $g _ { d e c }$ is the concatenation of vector $\{ M \ominus a _ { i } \}$ , vector $z _ { i }$ , and the current number of items (i.e., $N _ { , }$ ) recorded in a counter, $\hat { f } _ { i } g _ { d e c } ( \{ M \ominus a _ { i } \} , z _ { i } , N )$ . The operator $\ominus$ refers to the reading operation for the storage matrix. The basic form of $\ominus$ gives the operation as $M \ominus a _ { i } = M a _ { i } ^ { T 2 }$ [27, 28]. For optimization, we consider two optimized forms of $\ominus$ , inspired by the “count-min” mechanism of the CM-sketch. The first one gives the minimum value of each row in $M a _ { i } ^ { T }$ , aiming to remove the noise of other items. The second one gives the minimum value of each row in $\begin{array} { r } { M a _ { i } ^ { T } \circ \frac { 1 } { z _ { i } } } \end{array}$ 1 , a normalized
137
+
138
+ 136 form of $M a _ { i } ^ { T }$ . Here, $\circ$ denotes the Hadamard product, and $z _ { i }$ requires broadcast operations to comply
139
+ 137 with its requirements. So, $\{ M \ominus a _ { i } \}$ refers to the concatenation of vectors generated by the basic
140
+ 138 form and the two optimized forms. Please refer to supplement materials for more details.
141
+
142
+ # 2.3 Operations
143
+
144
+ Operation Store is performed by feeding an incoming item $e _ { i }$ to $\mathcal { F } _ { E }$ and ${ \mathcal { F } } _ { S a }$ to obtain embedding vector $z _ { i }$ and address $a _ { i }$ , and then additively writing $z _ { i }$ to $M$ , weighted by $a _ { i }$ : $M \gets M + z _ { i } a _ { i }$ . Here, other writing types [23, 26–28] can also be employed, but simple additive writing is more efficient and allows to compute gradients in parallel [23]. In addition, additive writing also allows to define an optional Delete operation for the meta-sketch (see the supplement materials).
145
+
146
+ Operation Query estimates the frequency of a given query item $x _ { i }$ . First, $z _ { i }$ and $a _ { i }$ are obtained, similar to that of operation Store. Then, the vectors $\{ M \ominus a _ { i } \}$ are retrieved from $M$ and $N$ can be easily obtained by a small counter. Finally, $\{ M \ominus a _ { i } \}$ , $z _ { i }$ and $N$ are jointly fed into $g _ { d e c }$ to get the estimated frequency ${ \hat { f } } _ { i }$ of $x _ { i }$ as the returned value. The two operations are shown in Algorithm 1.
147
+
148
+ # Algorithm 1: Operations
149
+
150
+ 1 Operation Store $( e _ { i }$ , M):
151
+ 2 zi, ri ← FE (ei) ;
152
+ 3 ai ← FSa(ri);
153
+ 4 $M \gets M + z _ { i } a _ { i }$ ;
154
+ 9 5 Operation Query $( x _ { i } , M , N )$ :
155
+ 6 $z _ { i } , r _ { i } \gets \mathcal { F } _ { E } ( x _ { i } )$ ;
156
+ 7 $a _ { i } \gets \mathcal { F } _ { S a } ( r _ { i } )$ ;
157
+ 8 $\hat { f } _ { i } \gets \mathcal { F } _ { d e c } ( \{ M \ominus a _ { i } \} , z _ { i } , N )$ ;
158
+ 9 return ${ \hat { f } } _ { i }$ ;
159
+
160
+ # Algorithm 2: Training Framework
161
+
162
+ Data: Meta-sketch with all learnable parameters $\theta$ , Meta-task sampler $R$ ;
163
+ 1 while $_ i$ not reach max training steps do
164
+ 2 Sample a meta-task $t _ { i } : \{ s _ { i } , q _ { i } \} \sim R$ and count $N$ ;
165
+ 3 for e(i)j ∈ $e _ { j } ^ { ( i ) } \in s _ { i }$ do Store $( e _ { j } ^ { ( i ) }$ , $M )$ ; end
166
+ 4 for x(ij 7 $f _ { j } ^ { ( i ) } \in q _ { i }$ do fˆ(i ) ← Query(x(i)j , $M , N )$ ; $\mathcal { L } + = \mathrm { L o s s F u n } ( f _ { j } ^ { ( i ) } , \hat { f } _ { j } ^ { ( i ) } ) ;$ ;
167
+ 5 Backprop through: $d \mathcal { L } / d \theta$ and update parameters: $\theta \gets \mathrm { O p t i m i z e r } ( \theta , d \mathcal { L } / d \theta )$ ;
168
+ 6 Normalize A;
169
+ 7 Clear $M$ ;
170
+ 8 end
171
+
172
+ # 150 3 Meta-sketch training
173
+
174
+ # 3.1 Training Framework
175
+
176
+ The meta-sketch employs an efficient one-shot meta-training method [31]. The training process thus contains two phases, pre-training and adaption phases. In the pre-training phase, the meta-sketch learns an initial set of module parameters, including $g _ { e m b }$ , $g _ { a d d }$ , $A$ , and $g _ { d e c }$ . The pre-training goes offline across training units, i.e., basic meta-tasks, to acquire the ability of stream frequency estimation. Then, in the adaption phase, the pre-trained meta-sketch goes fast across a set of lightweighted training units, i.e., adaptive meta-tasks, to quickly acquire the task-specific knowledge, i.e., parameters for sketching real data streams at runtime.
177
+
178
+ 159 The training units, i.e., meta-tasks, are crucial for both phases. The training process of the meta-sketch
179
+ 160 on a single meta-task is equivalent to simulating storing and querying an instance of data streams
180
+ 161 while computing the estimation error to optimize the learnable parameters. Thus, a meta-task $t _ { i }$
181
+ 162 163 consists oas an inst a store setce of data $s _ { i }$ (also eams, ) and a, where ery set is the $q _ { i }$ . The store set mber of strea $s _ { i }$ can betems in ewed. The
182
+ $s _ { i } : \{ e _ { 1 } ^ { ( i ) } , . . . , e _ { N _ { i } } ^ { ( i ) } \}$ $N _ { i }$ $s _ { i }$
183
+ 164 $q _ { i }$ ican be represented by a set of items from the stream instance with paired frequencies in
184
+ 165 the store set $s _ { i }$ , formally, $q _ { i } : \{ ( x _ { 1 } ^ { ( i ) } : f _ { 1 } ^ { ( i ) } ) , . . . , ( x _ { n _ { i } } ^ { ( i ) } : f _ { n _ { i } } ^ { ( i ) } ) \}$ , where $n _ { i }$ is the number of distinct items
185
+ 166 in $s _ { i }$ . In this work, we define two types of meta-tasks, basic (Section 3.2) and adaptive (Section 3.3)
186
+ 167 meta-tasks, corresponding to the pre-training and adaption phases, respectively.
187
+ 168 The two training phases, that are based on different types of meta-tasks, follow the same training
188
+ 169 framework, as shown in Algorithm 2, except for the sampler and initial parameters. To optimize on
189
+ 170 reducing both absolute and relative frequency estimation errors3, we devise an adaptive hybrid loss
190
+ 171 function [32] for the meta-sketch: $\begin{array} { r } { \frac { 1 } { 2 \sigma _ { 1 } ^ { 2 } } ( f _ { i } - \hat { f } _ { i } ) ^ { 2 } + \frac { 1 } { 2 \sigma _ { 2 } ^ { 2 } } | f _ { i } - \hat { f } _ { i } | / f _ { i } + l o g \sigma _ { 1 } \sigma _ { 2 } } \end{array}$ , where $\sigma _ { 1 }$ and $\sigma _ { 2 }$ are
191
+ 172 learned parameters, and $f _ { i }$ and $\hat { f } _ { i }$ are the true and estimated frequencies of item $x _ { i }$ , respectively.
192
+ 174 In the pre-training phase, basic meta-tasks should make the meta-sketch to simulate traditional
193
+ 175 sketches and preserve certain generality without relying too much on the patterns of specific distribu
194
+ 176 tions (Section 5). Therefore, we generate meta-tasks based on the Zipf distribution, which is found to
195
+ 177 be prevalent in real scenes of data streams [16–20].
196
+ 178 A meta-task is essentially a data stream instance with item size $n$ , which can be determined by the
197
+ 179 total number of items $N$ and the relative frequency distribution $p$ . Alternatively, we can generate
198
+ 180 meta-tasks by presupposing different $n$ , $\bar { f }$ and $p$ , where $\bar { f }$ is the frequency mean, since $\scriptstyle { \bar { N } } = { \bar { f } } \times n$
199
+ 181 Thus, basic meta-task generation is based on a sampler $R : \{ I , L , P \}$ , as follows.
200
+ 182 An item pool $I$ is a subset of the item domain $\mathbb { X }$ . The cardinality of $I$ is in relevance to the
201
+ 183 identification capability of the meta-sketch. If the item domain is known a-priori, it can be directly
202
+ 184 taken as the item pool. Otherwise, in applications where the item domain is only partially known or
203
+ 185 even unknown, the item pool can be constructed by sampling from the historical records. Even in the
204
+ 186 case that the item pool does not completely cover the item domain, the “missing” item can still be
205
+ 187 identified, due to the homogeneity of the domain-specific embedding space, given that the number of
206
+ 188 distinct items does not meet the item pool capacity $| I |$ .
207
+
208
+ A frequency mean range $L$ is the range for the frequency mean $\bar { f }$ . One can get the value of $\bar { f }$ by statistics of each sampled stream instance and extract the minimum and maximum $\bar { f } \mathbf { s }$ to build $L$ .
209
+
210
+ 91 A distribution pool $P$ consists of many instances generated according to different parameters of
211
+ 92 relative frequency distributions. In this paper, we consider a family of Zipf distributions [33] with
212
+ 93 varied parameter $\alpha$ , as the base for constructing $P$ . $\alpha$ can be selected from a wide range to have a
213
+ 94 good coverage of different distributions.
214
+ 195 Notice that the meta-tasks are for the meta-sketch to learn the sketching ability, instead of spoon
215
+ 196 feeding the meta-sketch to mechanically memorize the parameters of $R$ . It means that the trained
216
+ 197 meta-sketch has the generalization ability to handle the case not covered in $R$ (see Section 4.2).
217
+ 198 The generation of a meta-task $t _ { i }$ can be done based on sampler $R$ , as follows. We first randomly
218
+ 199 sample a subset of $n _ { i }$ items from $I$ , and a frequency mean ${ \hat { f } } _ { i } \in L$ . Then, we sample a distribution
219
+ 200 instance $p _ { i } ~ \in ~ P$ and make the $n _ { i }$ items’ frequencies conform to $p _ { i }$ and ${ \bar { f } } _ { i }$ . For example, the
220
+ 201 frequencies of $n _ { i }$ items can be set as $n _ { i } \times \bar { f } _ { i } \times \bar { p } _ { i }$ , where $p _ { i } \sim Z i p f ( \alpha )$ is a random variable. The
221
+ 202 above steps are repeated until the store set $s _ { i }$ and query set $q _ { i }$ are built.
222
+
223
+ # 203 3.3 Adaptive Meta-task Generation
224
+
225
+ While processing real data streams, we can get the item set $I _ { r }$ and its distribution $p _ { r }$ by online sampling. $I _ { r }$ and $p _ { r }$ are then used for generating the set of adaptive meta-tasks. For each adaptive meta-task, an item subset is sampled from $I _ { r }$ , and the relative frequency corresponding to each item is sampled from $p _ { r }$ . The process is similar to the generation of basic meta-tasks. The only difference from basic meta-task generation is that, there is no distribution pool anymore, because the real data stream is unique. Also, we intentionally randomize the correspondence between an item and its real relative frequency on the original data records. It is equivalent to constructing meta-tasks where the item frequencies dynamically change. For example, the frequency of an item may first increase, then suddenly drop [21]. With adaptive meta-tasks, the meta-sketch learns to quickly adapt to the distribution $p _ { r }$ , while being flexible against the item frequency change. The detailed algorithms of generating basic/adaptive meta-tasks are shown in supplement materials.
226
+
227
+ # 4 Experiments
228
+
229
+ # 4.1 Basic Setup
230
+
231
+ Dataset. We use two real datasets. Word-query is a streaming record of search queries, where each query contains multiple words (e.g., “News today”) [15]. IP-trace consists of IP packets, where each packet is identified by a unique source/destination address pair (e.g., 192.168.1.1/12.13.41.4) [21]. We assume that query phrases and IP addresses are numerically encoded, similar to [15].
232
+
233
+ Table 1: Results of Basic Meta-sketch $( T _ { r } )$
234
+
235
+ <table><tr><td></td><td colspan="5">Word-query</td><td colspan="4">IP-trace</td></tr><tr><td>Method</td><td>Metrics</td><td>n=5K, B=9KB</td><td>n=10K, B=11KB</td><td>n=20K, B=13KB</td><td>n=40K, B=15KB</td><td>n=5K, B=9KB</td><td>n=10K, B=11KB</td><td>n=20K, B=13KB</td><td>n=40K, B=15KB</td></tr><tr><td>Basic MS</td><td>ARE</td><td>12.3</td><td>14.74</td><td>10.98</td><td>13.79</td><td>3.00</td><td>1.51</td><td>2.97</td><td>1.13</td></tr><tr><td rowspan="2">CS</td><td>AAE</td><td>31.54</td><td>38.54</td><td>40.63</td><td>53.67</td><td>5.57</td><td>5.01</td><td>6.94</td><td>5.56</td></tr><tr><td>ARE</td><td>32.94</td><td>57.97</td><td>98.01</td><td>162.43</td><td>6.08</td><td>9.94</td><td>15.57</td><td>24.49</td></tr><tr><td rowspan="2">CMS</td><td>AAE</td><td>57.54</td><td>101.44</td><td>172.44</td><td>282.59</td><td>10.42</td><td>16.82</td><td>26.46</td><td>41.91</td></tr><tr><td>ARE</td><td>21.34</td><td>48.33</td><td>111.82</td><td>239.11</td><td>8.12</td><td>16.07</td><td>32.77</td><td>65.19</td></tr><tr><td></td><td>AAE</td><td>38.04</td><td>84.62</td><td>195.61</td><td>416.01</td><td>13.67</td><td>27.39</td><td>55.29</td><td>110.65</td></tr></table>
236
+
237
+ Table 2: Results of Basic Meta-sketch $( T _ { s } )$ )
238
+
239
+ <table><tr><td>Method</td><td>Metrics</td><td colspan="3">n=5K,B=9KB</td><td colspan="3">n=10K,B=11KB</td><td colspan="3">n=20K,B=13KB</td><td colspan="3">n=40K,B=15KB</td></tr><tr><td></td><td></td><td>0.5</td><td>1.1</td><td>1.5</td><td>0.5</td><td>1.1</td><td>1.5</td><td>0.5</td><td>1.1</td><td>1.5</td><td>0.5</td><td>1.1</td><td>1.5</td></tr><tr><td>Basic MS</td><td>ARE</td><td>0.43</td><td>1.05</td><td>2.63</td><td>0.73</td><td>3.25</td><td>3.14</td><td>0.47</td><td>1.67</td><td>1.35</td><td>0.43</td><td>2.58</td><td>9.65</td></tr><tr><td>(Word-query)</td><td>AAE</td><td>24</td><td>17.72</td><td>8.93</td><td>3124</td><td>27.02</td><td>9.41</td><td>27.29</td><td>22.19</td><td>三</td><td>25.04</td><td>26.95</td><td>19.87</td></tr><tr><td>Basic MS</td><td>ARE</td><td>0.59</td><td>2.27</td><td>9.38</td><td>0.73</td><td>0.86</td><td>1.02</td><td>0.72</td><td>1.73</td><td>7.52</td><td>0.73</td><td>0.79</td><td>233</td></tr><tr><td>(IP-trace)</td><td>AAE</td><td>26.45</td><td>21.49</td><td>14.73</td><td>38.33</td><td>19.32</td><td></td><td>35.48</td><td>22.28</td><td>15.74</td><td>39.57</td><td>21.75</td><td>14.06</td></tr><tr><td rowspan="3">CS</td><td>ARE</td><td>1.98</td><td>6.72</td><td>10.99</td><td>2.7</td><td>12.12</td><td>16.9</td><td>3.73</td><td>20.8</td><td>27.46</td><td>5.17</td><td>37.96</td><td>43.76</td></tr><tr><td>AAE</td><td>74.96</td><td>47.98</td><td>15.89</td><td>102.05</td><td>75.83</td><td>23.8</td><td>140.65</td><td>118.29</td><td>38.7</td><td>194.32</td><td>198.4</td><td>59.96</td></tr><tr><td>ARE</td><td>4.96</td><td>7.52</td><td>5.47</td><td>9.27</td><td>15.85</td><td>9.44</td><td>17.29</td><td>32.7</td><td>16.38</td><td>32.24</td><td>66.35</td><td>27.89</td></tr><tr><td>CMS</td><td>AAE</td><td>187.52</td><td>53.81</td><td>8.17</td><td>350.08</td><td>99.82</td><td>13.58</td><td>651.63</td><td>185.54</td><td>22.88</td><td>1213.38</td><td>347.32</td><td>38.18</td></tr></table>
240
+
241
+ Baseline. We hereby evaluate the basic and advanced meta-sketches. From now on, we use MS to represent the term meta-sketch for brevity. We compare basic MS (after the pre-training phase) with CM-sketch (CMS) and C-sketch (CS). We compare the advanced MS (after the adaptation phase) with learned augmented sketch (LS) and cold filter (CF), which are two variants of CM/C sketches with auxiliary structures. According to the default setting [10, 11], the number of hash functions for all sketches is 3. We adopt two commonly accepted metrics for evaluating the accuracies of stream frequency estimation, AAE and $\mathrm { A R E } ^ { 3 }$ .
242
+
243
+ Parameters. We implement $g _ { e m b }$ or $g _ { a d d }$ in MLP with 2-layers of sizes 128 and 48, followed by batch normalization, and $g _ { d e c }$ in an MLP with 3-layers of 256 with residual connections. We use the relu function for layer connections. The space budget $B$ is spent on storing $M$ , the same as the setting in neural data structures [23]. Other modules, like hashing libraries, are commonly accepted as reusable and amortizable resources for multi-deployment of sketches [21, 23]. Note that due to space limitations, the details and methods of parameter settings of $M ( A )$ , the ablation experiments and some parameter discussions are shown in the supporting material.
244
+
245
+ # 4.2 Basic Meta-sketch
246
+
247
+ Settings. For each dataset, we train the basic MSs under 4 item pools with $\{ 5 K , 1 0 K , 2 0 K , 4 0 K \}$ different items, respectively. The meta-task sampler are with Zipf distributions. We build the distribution pools set with $\alpha \in [ 0 . 8 , 1 . 3 ]$ and set frequency mean range $L = [ 5 0 , 5 0 0 ]$ . For basic meta-sketch training, the default maximum number of training steps $\phi$ is 5 million, the learning rate is 0.0001, and the Adam optimizer is used. For evaluation, we consider two types of tasks, $T _ { r }$ and $T _ { s }$ . $T _ { r }$ are directly obtained by random sampling on two real data streams with different values of $n$ i.e., the number of distinct items. Note that the frequency distributions of $T _ { r }$ are not necessarily obey Zipf distributions. $T _ { s }$ are the synthetic tasks, where the item frequency follows the Zipf distribution with $\alpha \in \{ 0 . 5 , 1 . 1 , 1 . 5 \}$ . To evaluate the generability and stability of basic MS, both $T _ { s } ( 0 . 5 )$ and $T _ { s } ( 1 . 5 )$ ’s distributions are not covered by the distribution pool of the meta-task samplers.
248
+
249
+ Performance. Table 1 shows the performance of all competitors based on real dataset $T _ { r }$ . It shows that the basic MS outperforms traditional basic sketches, i.e., CMS and CS, on all testing cases. For example,the results on IP-trace show that, when $\scriptstyle n = 4 0 \mathrm { K }$ and $B { = } 1 5 \mathrm { K B }$ , the ARE of basic MS is 1.13, while AREs of CMS and CS are 65.19 and 24.49, respectively. The advantage of meta-sketch is significant when testing on $T _ { s }$ with different $\alpha \mathbf { s }$ , as shown in Table 2. Note that we use random choices to simulate the ideal hash functions for traditional sketches like [15], so that CS and CMS have the same result on test tasks with the same $\alpha$ in both datasets.
250
+
251
+ 253 We show the trend of ARE w.r.t. the space budget, in Figure 2 ( $T _ { r }$ , $n { = } 5 \mathrm { K }$ , Word-query). Compared to
252
+ 254 the dramatic performance degrading of traditional sketches, basic MS holds stable performance. We
253
+ 255 show that the trend of ARE w.r.t. the number of distinct items in Figure 3 $T _ { r }$ , $B { = } 9 { \mathrm { K B } }$ , Word-query).
254
+ 256 Compared to traditional sketches, the ARE of basic MS increases sub-linearly w.r.t. the value of $n$
255
+ 257 Note that AAE has similar results for the above experiments, see the supplement materials.
256
+ 258 Generalization. We test the generality of basic MS to new items that are not in the item pool of
257
+ 259 the meta-task sampler in Figure 4(a). We make the experiments $_ { \it { n } = 5 \mathrm { { K } } }$ , $B { = } 9 \mathrm { K B }$ , Word-query)
258
+ 260 by replacing some items in $T _ { r }$ with new items, and vary the fraction of new items to observe
259
+ 261 the trend of the performance. It shows that the ARE/AAE moderately increases w.r.t. the ratio
260
+ 262 of new items. The performance is acceptable considering the fact that the item domain is often
261
+ 263 stable in practical applications. We then test the generality of meta-sketches to varied frequency
262
+ 264 means that are not in range $L$ of the meta-task sampler, as shown in Figure 4(b). The experiment
263
+ 265 $_ { \mathrm { { \it ~ \Omega } } } \mathrm { { \it { n } = } } 5 \mathrm { { K } }$ , $B { = } 9 \mathrm { K B }$ , Word-query) is done by sampling a series of $T _ { s }$ tasks with frequency means in
264
+ 266 $\{ 5 0 0 , 5 K , 5 0 K , 5 0 0 K , 5 0 0 0 K \}$ . It shows that as the mean of the true frequencies increases, the
265
+ 267 estimated frequencies of the meta-sketch increase linearly, so that the ARE keeps stable.
266
+
267
+ ![](images/273c358ecb0e44ea9148d4a4a9ecebbb1e6ae0e4e13880455e100dded29bf51c.jpg)
268
+ Figure 2: ARE w.r.t. $B$
269
+
270
+ ![](images/7a983ba6aed4f129823b48f94344d29d582389e050a05e2c5fdabba1feeaa01a.jpg)
271
+ Figure 3: ARE w.r.t. n
272
+
273
+ ![](images/eccb4d68e053dfab3c8b7424866934ab319fe055d727c787fe6a6a21f60f4423.jpg)
274
+ Figure 4: Generality of Meta-sketch
275
+
276
+ Table 3: Results of Advanced Meta-sketch
277
+
278
+ <table><tr><td>Method</td><td>Metrics</td><td colspan="4">Word-query</td><td colspan="4">IP-trace</td></tr><tr><td></td><td></td><td>n=5K B=9KB</td><td>n=10K, B=11KB</td><td>n=20K B=13KB</td><td>n=40K B=15KB</td><td>n=5K B=9KB</td><td>n=10K B=11KB</td><td>n=20K B=13KB</td><td>n=40K B=15KB</td></tr><tr><td>Advanced</td><td>ARE</td><td>3.05</td><td>2.83</td><td>4.06</td><td>5.20</td><td>0.87</td><td>0.89</td><td>1.38</td><td>2.29</td></tr><tr><td rowspan="2">MS</td><td>AAE</td><td>21.42</td><td>26.11</td><td>35.00</td><td>43.81</td><td>3.77</td><td>4.46</td><td>5.13</td><td>6.55</td></tr><tr><td>ARE</td><td>3.58</td><td>14.53</td><td>141.70</td><td>1127.11</td><td>0.85</td><td>2.74</td><td>4.20</td><td>16.71</td></tr><tr><td rowspan="2">CF90</td><td>AAE</td><td>21.13</td><td>59.18</td><td>381.63</td><td>2217.28</td><td>1.32</td><td>3.01</td><td>7.71</td><td>31.20</td></tr><tr><td>ARE</td><td>7.95</td><td>29.02</td><td>139.87</td><td>541.37</td><td>1.51</td><td>3.10</td><td>8.95</td><td>46.79</td></tr><tr><td rowspan="2">CF70 CF40</td><td>AAE</td><td>29.02</td><td>76.58</td><td>295.63</td><td>970.94</td><td>2.57</td><td>5.51</td><td>16.83</td><td>82.84</td></tr><tr><td>ARE</td><td>91.16</td><td>138.64</td><td>244.24</td><td>407.83</td><td>12.62</td><td>33.50</td><td>103.76</td><td>155.61</td></tr><tr><td rowspan="2"></td><td>AAE</td><td>174.86</td><td>252.22</td><td>421.85</td><td>693.47</td><td>24.16</td><td>60.79</td><td>175.14</td><td>279.72</td></tr><tr><td>ARE</td><td>20.52</td><td>48.69</td><td>111.85</td><td>266.50</td><td>8.34</td><td>17.09</td><td>35.22</td><td>77.79</td></tr><tr><td rowspan="2">LCMS(1%) LCS(1%)</td><td>AAE</td><td>37.80</td><td>81.93</td><td>194.15</td><td>451.28</td><td>13.72</td><td>28.39</td><td>59.10</td><td>129.86</td></tr><tr><td>ARE</td><td>25.53</td><td>40.84</td><td>67.21</td><td>104.54</td><td>5.20</td><td>7.80</td><td>11.33</td><td>17.12</td></tr><tr><td rowspan="2"></td><td>AAE</td><td>44.53</td><td>78.17</td><td>122.57</td><td>180.56</td><td>8.78</td><td>13.10</td><td>18.97</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>28.38</td></tr></table>
279
+
280
+ # 4.3 Advanced Meta-sketch
281
+
282
+ Settings. The generation of adaptive meta-tasks is similar to that of basic meta-tasks (Section 3.2), except that each item pool reads real frequency distributions for the adaption as described in Section 3.3. In the adaption phase, the maximum number of training steps is $0 . 0 0 2 * \phi$ .
283
+
284
+ Performance. Table 3 compares the performance of advanced MS with traditional sketches and their variants, LS and CF, on real dataset $T _ { r }$ . We implement two LSs according to [15], learned CM-sketch (LCMS) and learned C-sketch (LCS), following the default setting that (top $1 \%$ ) high-frequency items are separately stored. For CF, we follow the parameter setting in [14], and use CF40, CF70, and CF90 for setting the filter percentages to $40 \%$ , $70 \%$ , and $90 \%$ of the total size, respectively. It shows that the advanced MS achieves a better performance than LSs and CFs. Also, AAE/ARE of advanced MS increases more moderately w.r.t. the number of distinct items $n$ , compared to its competitors.
285
+
286
+ Furthermore, we compare the performance of the advanced MS and the LS under dynamic streaming scenarios, as shown in Figure 5. We select a set of $T _ { r }$ $\scriptstyle ( n = 5 \mathbf { K } , B = 9 \mathbf { K } \mathbf { B }$ ,Word-query), and gradually shuffle the correspondence between items and frequencies. Here, the shuffle ratio is increased from 0 to $100 \%$ . It shows that the average ARE of advanced MS only slightly fluctuates between 3.26 and 4.0, and the average AAE is in the range of 21.28 and 21.68. In contrast, AAE of LCS or LCMS starts above 37, and increase significantly w.r.t. the increase of the shuffle ratio. Actually, the classifier of LS tends to incur more errors due to the gradual shift of high- and low-frequency items, resulting in an increased number of hash collisions, thus deteriorating the estimation accuracy.
287
+
288
+ # 87 5 Analysis
289
+
290
+ The meta-sketch is trained based on meta-tasks, consisting of various stream distributions. We expected that the meta-sketch can learn the ability to sketch item frequencies. Somehow, it is unavoidable that the meta-sketch’s ability is limited by patterns of given meta-tasks. Thus, setting up the two training phases benefits the balance of the trade-offs. In the pre-training phase, we select the most representative Zipf distribution to form basic meta-tasks, making the basic meta-sketch adaptable to a wide range of data streams. In the adaptation phase, we sample adaptive meta-tasks from raw data streams to make the advanced meta-sketch more specialized. Next, we analyze the
291
+
292
+ ![](images/d0d131b9a2a79cf8bf7e61fd7ccfb428bf42fe147e8275ccfd8b44db70bdb7eb.jpg)
293
+ Figure 5: Learned sketch vs. Meta-sketch
294
+ Figure 6: $| r |$ and $| z |$ w.r.t. Sparsity of $a$
295
+
296
+ ![](images/0779b9509a5fe768b70c87bfd9beb5d0fa863c31f8781ba7defec798cbf20906.jpg)
297
+ Figure 7: Three addressing matrices
298
+
299
+ ![](images/043316aa344876317461ed7124d4cba5dcd0936958f3ed12872e46f4239441de.jpg)
300
+ Figure 8: The sparsity of embedding vectors
301
+
302
+ 295 working mechanism of the three modules of the meta-sketch as well as their roles in acquiring the
303
+ 296 two abilities.
304
+
305
+ Sparse Addressing Module. We take a 2D slice $A ^ { * }$ (size is $l _ { r } \times d _ { 2 } ,$ ) of the $A$ matrix to analyze the process of a refined vector $r$ getting addressing $a$ through this module. First, we have $a \gets$ $\bar { S p a r s e M a x } ( r ^ { T } A ^ { * } ) \Rightarrow a \bar { S p a r s e M a x } ( \langle r \cdot b _ { 1 } , \bar { r } \cdot b _ { 2 } , . . . , \bar { r } \cdot b _ { d _ { 2 } } \rangle )$ . Since $b _ { i }$ are unit vectors, we can get $a \gets S p a r s e M a x ( | r | c )$ , $c { = } \langle c o s \theta _ { 1 } , c o s \theta _ { 2 } { , } . . . , c o s \theta _ { d _ { 2 } } \rangle$ , where $\theta _ { i }$ is the angle between $r$ and $b _ { i }$ . We continue to transform the form to get addressing $\begin{array} { r } { a \gets S p a r s e g e n ( c ; u ; \frac { | r | - 1 } { | r | } ) } \end{array}$ ; |r|−1|r| ) [30], where u is a component-wise transformation function applied on $c$ . in this paper, we set $u ( c ) { = } c$ .
306
+
307
+ Based on the principle of Sparsegen [30], $| r |$ mainly affects the sparsity (i.e., the proportion of non-zero bits in the vector) of $a$ during training process, while $c$ determines the positions and values of non-sparse bits. The Figure 6 shows a strong correlation between the average $| r |$ and the sparsity of $a$ during training from scratch ( $_ { \mathrm { \Delta } n = 5 \mathrm { K } }$ , $B { = } 9 \mathrm { K B }$ , Word-query, Basic MS). Since the embedding vector $z$ does not directly participate in the addressing process, the average $| z |$ remains stable. Further, we observe that the sparsity of $a$ will eventually converge to around 1, which means that each item is generally stored in a slot corresponding to the refined vector $r$ and the unit vector in $A ^ { * }$ with the maximum cosine similarity.
308
+
309
+ Therefore, the role of $A ^ { * }$ is to map refined vectors to the addressing vectors. The $d _ { 2 }$ unit vectors in $A ^ { * }$ are the reference standard for mapping, which is equivalent to the mutually exclusive $d _ { 2 }$ -divisions of the refined vector space. Follow this point, we construct two matrices $K ^ { * }$ and $R ^ { * }$ of the same size as $A ^ { * }$ . Among them, the $d _ { 2 }$ unit vectors in $K ^ { * }$ come from the cluster centers of the sampled refined vectors. To achieve mutually exclusive division, we perform Kmeans clustering with $K = d _ { 2 }$ and Cosine similarity criterion. Then, we normalize the resulting $d _ { 2 }$ cluster centers and stack them as $K ^ { * }$ In contrast, the unit vectors in $R ^ { * }$ are entirely randomly generated.
310
+
311
+ Figure 7 (a) shows the results of replacing $A ^ { * }$ on the trained meta-sketch with $K ^ { * }$ and $R ^ { * }$ . The meta-sketch with $R ^ { * }$ shows the worst performance, but the performance of the meta-sketch with $K ^ { * }$ is close to the original $A ^ { * }$ . Furthermore, We count the number of items mapped in every slot of $A ^ { * }$ , $K ^ { * }$ , $R ^ { * }$ and show their standard deviation in Figure 7 (b). The standard deviation of $R ^ { * }$ is much higher than $A ^ { * }$ and $K ^ { * }$ , and a better meta-sketch tends to store items more evenly in each slot. Thus, The addressing module simulates the traditional sketch mechanism. Its principal function is to store the embedding vectors of items as evenly as possible in multiple memory slots, and an item is written to only one slot.
312
+
313
+ Embedding Module. The major source of conflicts in the meta-sketch is the stacking of different embedding vectors in a single slot. Thus, the sparsity of the embedding vector becomes an important indicator to determine the degree of conflicts. Figure 8 shows the relation between the sparsity of embedding vectors and the stream distributions $_ { \mathrm { { \it ~ \Omega } } } \mathrm { { n = 5 K } }$ , $B { = } 9 \mathrm { K B }$ , Word-query, advanced MS). We select the meta-tasks under Zipf, Triangular, and Uniform distributions with different skewness levels (the definition of skewness and corresponding distribution parameters are shown in the supplement materials). The results show that the sparsity of the embedding vector is positively proportional to
314
+
315
+ ![](images/5620e00a605ae8e5f51d00f04f6f4a362ff0bcfb931112fd394003077a6bbd5a.jpg)
316
+ Figure 9: Generality w.r.t. Decoding module
317
+
318
+ ![](images/a9e757a406ba1125a8bff13effa28389881a2171b22e5518d37206404778e386.jpg)
319
+ Figure 10: Unstable case vs. Stable case
320
+
321
+ 333 the skewness of a distribution. Therefore, we speculate that the meta-sketch memorizes the pattern
322
+ 334 information of the distribution being adapted by self-tuning the sparsity of embedding vectors.
323
+
324
+ Decoding Module. The decoding module, as the deepest NNs in the meta-sketch, integrates various information to predict the item frequency and achieves generalization ability. To verify this, we adapt the advanced MS $_ { \it { n } = 5 \mathrm { { K } } }$ , $B { = } 9 \mathrm { K B }$ , Word-query) to a special adaptive meta-task. The meta-task was sampled from the real data stream but with a fixed item size (5000) and frequency mean (250). Meanwhile, we do not change the correspondence between items and frequencies. Such meta-task forces the meta-sketch to pay more attention to the fixed patterns and thus limit its generalization.
325
+
326
+ Thus, we train the advanced MS with (or without) freezing the decoding module parameters based on the above meta-task. Figure 9 (a) shows the performance changes of the three models (advanced MS as baseline) on the evaluation tasks $( T _ { r } )$ of different item sizes. Without the frozen decoding module, the meta-sketch loses generalization ability at extended item sizes other than 5000. On the contrary, the meta-sketch with the frozen decoding module still retains the generalization ability and further utilizes the data stream pattern compared to the advanced MS, achieving the best performance. Similarly, as shown in Figure 9 (b), the meta-sketch without the frozen decoding module also loses a certain generalization ability in terms of frequency mean.
327
+
328
+ 349 Actually, the above meta-task (termed as the stable case) can be viewed as a special case of an ordinary
329
+ 350 adaptive meta-task (termed as the unstable case). As a matter of fact, augmented sketches utilize
330
+ 351 frequency patterns similar to the stable case. For example, the learned augmented sketch memorizes
331
+ 352 (relatively) stable correspondence between items and frequencies, for filtering high-frequency items.
332
+ 353 To understand the meta-sketch’s self-optimizing mechanism from the unstable case to the stable case,
333
+ 354 we analyze the storage of high/low-frequency items between multiple slots and a single slot in the
334
+ 355 memory. In Figure 10 (a), we show density heat-maps of low-frequency (below the top $20 \%$ high
335
+ 356 frequencies) items, stored by meta-sketches of stable and unstable cases on a 2D slice $d _ { 1 } = 2 \AA$ ) of the
336
+ 357 storage matrix $M$ , where the $\mathbf { X }$ -axis is the index of slots. The two heat-maps show that the meta-sketch
337
+ 358 under the stable case can store the low-frequency items concentratedly in some slots to avoid the
338
+ 359 conflicts with high-frequency items. Interestingly, the meta-sketch does not intentionally do this like
339
+ 360 augmented sketches. Instead, it is achieved by self-optimization during the training. Furthermore,
340
+ 361 Figure 10 (b) shows the relation between the sparsity of the embedding vector of items stored in a
341
+ 362 single slot and the frequency order, where the $x$ -axis represents the frequencies in the ascending order.
342
+ 363 We speculate that the meta-sketch autonomously adjusts the sparsity of the embedding vector within
343
+ 364 a single slot in the stable case, so that the high/low-frequency items are automatically separated.
344
+
345
+ # 365 6 Conclusion
346
+
347
+ In this paper, we propose a neural data structure, called the meta-sketch, for estimating item frequencies in data streams. Unlike traditional sketches, the meta-sketch utilizes meta-learning and memory-augmented neural networks. The meta-sketch is pre-trained with Zipf distributions and can be fast adapted to specific runtime streams. We study a series of techniques for constructing the meta-sketch. We also devise the generation of basic and adaptive meta-tasks corresponding to the pre-training and adaption phases, respectively. Extensive empirical studies on real datasets are done to evaluate our proposals. In the future, it is interesting to extend our proposal to other sketching tasks that are supported by traditional sketches.
348
+
349
+ # References
350
+
351
+ [1] Tobias Weller. Compromised account detection based on clickstream data. In WWW, pages 819–823, 2018.
352
+
353
+ [2] Yunyue Zhu and Dennis E. Shasha. Statstream: Statistical monitoring of thousands of data streams in real time. In VLDB, pages 358–369, 2002.
354
+ [3] Ramine Tinati, Xin Wang, Ian C. Brown, Thanassis Tiropanis, and Wendy Hall. A streaming real-time web observatory architecture for monitoring the health of social machines. In WWW, pages 1149–1154, 2015.
355
+ [4] Mohammad Tanvir Irfan and Tucker Gordon. The power of context in networks: Ideal point models with social interactions. In IJCAI, pages 6176–6180, 2019.
356
+ [5] Qun Huang, Patrick P. C. Lee, and Yungang Bao. Sketchlearn: relieving user burdens in approximate measurement with automated statistical inference. In SIGCOMM, pages 576–590, 2018.
357
+ [6] Samuel Madden and Michael J. Franklin. Fjording the stream: An architecture for queries over streaming sensor data. In ICDE, pages 555–566, 2002.
358
+ [7] Lu Wang, Ge Luo, Ke Yi, and Graham Cormode. Quantiles over data streams: an experimental study. In SIGMOD, 2013.
359
+ [8] Amit Goyal, Hal Daumé III, and Graham Cormode. Sketch algorithms for estimating point queries in NLP. In EMNLP-CoNLL 2012, July 12-14, 2012, Jeju Island, Korea, pages 1093– 1103. ACL, 2012.
360
+ [9] Fabon Dzogang, Thomas Lansdall-Welfare, Saatviga Sudhahar, and Nello Cristianini. Scalable preference learning from data streams. In WWW 2015, Florence, Italy, May 18-22, 2015 - Companion Volume, pages 885–890. ACM, 2015.
361
+ [10] Graham Cormode and S. Muthukrishnan. An improved data stream summary: the count-min sketch and its applications. J. Algorithms, 55(1):58–75, 2005.
362
+ [11] Moses Charikar, Kevin C. Chen, and Martin Farach-Colton. Finding frequent items in data streams. In ICALP, pages 693–703, 2002.
363
+ [12] Cristian Estan and George Varghese. New directions in traffic measurement and accounting. In SIGCOMM, pages 323–336, 2002.
364
+ [13] Pratanu Roy, Arijit Khan, and Gustavo Alonso. Augmented sketch: Faster and more accurate stream processing. In SIGMOD, pages 1449–1463, 2016.
365
+ [14] Yang Zhou, Tong Yang, Jie Jiang, Bin Cui, Minlan Yu, Xiaoming Li, and Steve Uhlig. Cold filter: A meta-framework for faster and more accurate stream processing. In SIGMOD, pages 741–756, 2018.
366
+ [15] Chen-Yu Hsu, Piotr Indyk, Dina Katabi, and Ali Vakilian. Learning-based frequency estimation algorithms. In ICLR, 2019.
367
+ [16] Taiwo Kolajo, Olawande J. Daramola, and Ayodele Ariyo Adebiyi. Big data stream analysis: a systematic literature review. J. Big Data, 6:47, 2019.
368
+ [17] Xue-Qiang Zeng and Guo-Zheng Li. Incremental partial least squares analysis of big streaming data. Pattern Recognition, 47(11):3726–3735, 2014.
369
+ [18] Brian Babcock, Shivnath Babu, Mayur Datar, Rajeev Motwani, and Jennifer Widom. Models and issues in data stream systems. In PODS, pages 1–16, 2002.
370
+ [19] Graham Cormode, Minos N. Garofalakis, Peter J. Haas, and Chris Jermaine. Synopses for massive data: Samples, histograms, wavelets, sketches. Found. Trends Databases, 4(1-3):1–294, 2012.
371
+ [20] M. S. B. PhridviRaja and C. V. GuruRao. Data mining : past present and future - a typical survey on data streams. CoRR, abs/1605.01429, 2016.
372
+ [21] Lu Tang, Qun Huang, and Patrick P. C. Lee. Mv-sketch: A fast and compact invertible sketch for heavy flow detection in network data streams. In INFOCOM, pages 2026–2034. IEEE, 2019.
373
+ [22] Tim Kraska, Alex Beutel, Ed H Chi, Jeffrey Dean, and Neoklis Polyzotis. The case for learned index structures. In SIGMOD, pages 489–504, 2018.
374
+ [23] Jack Rae, Sergey Bartunov, and Timothy Lillicrap. Meta-learning neural bloom filters. In ICML, pages 5271–5280. PMLR, 2019.
375
+ [24] Michael Mitzenmacher. A model for learned bloom filters and related structures. arXiv preprint arXiv:1802.00884, 2018.
376
+ [25] Timothy M. Hospedales, Antreas Antoniou, Paul Micaelli, and Amos J. Storkey. Meta-learning in neural networks: A survey. CoRR, abs/2004.05439, 2020.
377
+ [26] Adam Santoro, Sergey Bartunov, Matthew Botvinick, Daan Wierstra, and Timothy Lillicrap. Meta-learning with memory-augmented neural networks. In ICML, pages 1842–1850. PMLR, 2016.
378
+ [27] Alex Graves, Greg Wayne, and Ivo Danihelka. Neural turing machines. arXiv preprint arXiv:1410.5401, 2014.
379
+ [28] Alex Graves, Greg Wayne, Malcolm Reynolds, Tim Harley, Ivo Danihelka, Agnieszka GrabskaBarwinska, Sergio Gómez Colmenarejo, Edward Grefenstette, Tiago Ramalho, John Agapiou, ´ et al. Hybrid computing using a neural network with dynamic external memory. Nature, 538(7626):471–476, 2016.
380
+ [29] Andre Martins and Ramon Astudillo. From softmax to sparsemax: A sparse model of attention and multi-label classification. In ICML, pages 1614–1623. PMLR, 2016.
381
+ [30] Anirban Laha, Saneem Ahmed Chemmengath, Priyanka Agrawal, Mitesh Khapra, Karthik Sankaranarayanan, and Harish G Ramaswamy. On controllable sparse alternatives to softmax. NIPS, 31, 2018.
382
+ [31] Oriol Vinyals, Charles Blundell, Tim Lillicrap, Koray Kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In Daniel D. Lee, Masashi Sugiyama, Ulrike von Luxburg, Isabelle Guyon, and Roman Garnett, editors, NIPS, pages 3630–3638, 2016.
383
+ [32] Alex Kendall, Yarin Gal, and Roberto Cipolla. Multi-task learning using uncertainty to weigh losses for scene geometry and semantics. In CVPR, pages 7482–7491, 2018.
384
+
385
+ [33] Lada A. Adamic. Zipf, power-laws, and pareto- a ranking tutorial.
386
+
387
+ # 7 Checklist
388
+
389
+ 1. For all authors...
390
+
391
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
392
+ (b) Did you describe the limitations of your work? [Yes] Compared with traditional data structures,neural data structures are usually relative weak in term of time latency. In future research, We need to study and reduce time cost of meta-sketches’ operation or disign a framework to get a huge throughput utilizing parallel algebraic operations as a remedy.
393
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A] There is no negative societal impacts of my work, since it is foundational research.
394
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
395
+
396
+ 2. If you are including theoretical results...
397
+
398
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
399
+
400
+ 3. If you ran experiments...
401
+
402
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes]
403
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] We give the details of the implementation as much as possible,but some of them will put into appendix.
404
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We visualize the difference in line graphs by drawing shadows, which includes various of comparative experiments with all type of metasketches. But due to the huge amount of data ,error bars of table are not included. See section 4 and 5.
405
+
406
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] All of our experiments are implemented in python and run at a NVIDIA DGX workstation with CPU E5-2698 (2.20GHz, 20 cores), and 4 NVIDIA V100 GPUs (5120 CUDA cores and 16GB GPU memory on each GPU).
407
+
408
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
409
+
410
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
411
+ (b) Did you mention the license of the assets? [N/A]
412
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
413
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
414
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
415
+
416
+ 5. If you used crowdsourcing or conducted research with human subjects...
417
+
418
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
419
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
420
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/-ltZ1uw8ZE7/-ltZ1uw8ZE7.md ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # VARIATIONAL IMBALANCED REGRESSION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Existing regression models tend to fall short in both accuracy and uncertainty estimation when the label distribution is imbalanced. In this paper, we propose a probabilistic deep learning model, dubbed variational imbalanced regression (VIR), which not only performs well in imbalanced regression but naturally produces reasonable uncertainty estimation as a byproduct. Different from typical variational autoencoders assuming I.I.D. representations (a data point’s representation is not directly affected by other data points), our VIR borrows data with similar regression labels to compute the latent representation’s variational distribution; furthermore, different from deterministic regression models producing point estimates, VIR predicts the entire normal-inverse-gamma distributions and modulates the associated conjugate distributions to impose probabilistic reweighting on the imbalanced data, thereby providing better uncertainty estimation. Experiments in several real-world datasets show that our VIR can outperform state-of-the-art imbalanced regression models in terms of both accuracy and uncertainty estimation.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Deep regression models are currently the state of the art in making predictions in a continuous label space and have a wide range of successful applications in computer vision (Yin et al., 2021), natural language processing (Jiang et al., 2020), etc. However, these models fail however when the label distribution in training data is imbalanced. For example, in visual age estimation (Moschoglou et al., 2017), where a model infers the age of a person given her visual appearance, models are typically trained on imbalanced datasets with overwhelmingly more images of younger adults, leading to poor regression accuracy for images of children or elderly people (Yang et al., 2021). Such unreliability in imbalanced regression settings motivates the need for both improving performance for the minority in the presence of imbalanced data and, more importantly, providing reasonable uncertainty estimation to inform practitioners on how reliable the predictions are (especially for the minority where accuracy is lower).
12
+
13
+ Existing methods for deep imbalanced regression (DIR) only focus on improving the accuracy of deep regression models by smoothing the label distribution and reweighting data with different labels (Yang et al., 2021). On the other hand, methods that provide uncertainty estimation for deep regression models operates under the balance-data assumption and therefore do not work well in the imbalanced setting (Amini et al., 2020; Mi et al., 2022; Charpentier et al., 2022).
14
+
15
+ To simultaneously cover these two desiderata, we propose a probabilistic deep imbalanced regression model, dubbed variational imbalanced regression (VIR). Different from typical variational autoencoders assuming I.I.D. representations (a data point’s representation is not directly affected by other data points), our VIR assumes Neighboring and Identically Distributed (N.I.D.) and borrows data with similar regression labels to compute the latent representation’s variational distribution. Specifically, VIR first encodes a data point into a probabilistic representation and then mix it with neighboring representations (i.e., representations from data with similar regression labels) to produce its final probabilistic representation; VIR is therefore particularly useful for minority data as it can borrow probabilistic representations from data with similar labels (and naturally weigh them using our probabilistic model) to counteract data sparsity. Furthermore, different from deterministic regression models producing point estimates, VIR predicts the entire normal-inverse-gamma distributions and modulates the associated conjugate distributions by the importance weight computed from the smoothed label distribution to impose probabilistic reweighting on the imbalanced data. This allows the negative log likelihood to naturally put more focus on the minority data, thereby balancing the accuracy for data with different regression labels. Our VIR framework is compatible with any deep regression models and can be trained end to end.
16
+
17
+ We summarize our contributions as below:
18
+
19
+ 1. While previous work has studied imbalanced regression and uncertainty estimation separately, none of them has considered uncertainty estimation in the imbalanced setting. We identify the problem of probabilistic deep imbalanced regression as well as two desiderata, balanced accuracy and uncertainty estimation, for the problem.
20
+ 2. We propose VIR to simultaneously cover these two desiderata and achieve state-of-the-art performance compared to existing methods.
21
+ 3. As a byproduct, we also provide strong baselines for benchmarking high-quality uncertainty estimation and promising prediction performance on imbalanced datasets.
22
+
23
+ # 2 RELATED WORK
24
+
25
+ Variational Autoencoder. Variational autoencoder (VAE) (Kingma & Welling, 2014) is an unsupervised learning model that aims to infer probabilistic representations from data. However, as shown in Figure 1, VAE typically assumes I.I.D. representations, where a data point’s representation is not directly affected by other data points. In contrast, our VIR borrows data with similar regression labels to compute the latent representation’s variational distribution.
26
+
27
+ Imbalanced Regression. Imbalanced regression is underexplored in the machine learning community. Most existing methods for imbalanced regression are direct extensions of the SMOTE algorithm (Chawla et al., 2002), a commonly used algorithm for imbalanced classification, where data from the minority classes is over-sampled. These algorithms usually synthesize augmented data for the minority regression labels by either interpolating both inputs and labels (Torgo et al., 2013) or adding Gaussian noise (Branco et al., 2017; 2018).
28
+
29
+ ![](images/b7be9b38e271a8ff4b76dc20993db4bfe22725bec030a1bdd965140b6cd76526.jpg)
30
+ Figure 1: Comparison on inference networks between typical VAE (Kingma & Welling, 2014) and our VIR. In VAE (left), a data point’s latent representation (i.e. z) is affected only by itself, while in VIR (right), neighbors participate to modulate the final representation.
31
+
32
+ Such algorithms fail to the distance in continuous label space and fall short in handling highdimensional data (e.g., images and text). Recently, DIR (Yang et al., 2021) addresses these issues by applying kernel density estimation to smooth and reweight data on the continuous label distribution, achieving state-of-the-art performance. However, DIR only focuses on improving the accuracy, especially for the data with minority labels, and therefore does not provide uncertainty estimation, which is crucial to assess the predictions’ reliability. Ren et al. (2022) focuses on re-balancing the mean squared error (MSE) loss for imbalanced regression, and Gong et al. (2022) introduces ranking similarity for improving deep imbalanced regression. In contrast, our VIR provides a principled probabilistic approach to simultaneously achieve these two desiderata, not only improving upon DIR in terms of performance but also producing reasonable uncertainty estimation as a much-needed byproduct to assess model reliability. There is also related work on imbalanced classification (Deng et al., 2021), which is related to our work but focusing on classification rather than regression.
33
+
34
+ Uncertainty Estimation in Regression. There has been renewed interest in uncertainty estimation in the context of deep regression models (Kendall & Gal, 2017; Kuleshov et al., 2018; Song et al., 2019; Zelikman et al., 2020; Amini et al., 2020; Mi et al., 2022; van Amersfoort et al., 2021; Liu et al., 2020; Gal & Ghahramani, 2016; Stadler et al., 2021; Snoek et al., 2019; Heiss et al., 2022). Most existing methods either directly predict the variance of the output distribution as the estimated uncertainty (Kendall & Gal, 2017; Zhang et al., 2019; Amini et al., 2020) or rely on post-hoc confidence interval calibration (Kuleshov et al., 2018; Song et al., 2019; Zelikman et al., 2020). Meanwhile, Posterior Networks methods Charpentier et al. (2020; 2022); Stadler et al. (2021) consider conjugate distribution, pseudo-count interpretations, posterior updates, and variational losses for fast and high-quality uncertainty estimation. Closest to our work is Deep Evidential Regression (DER) (Amini et al., 2020), which attempts to estimate both aleatoric and epistemic uncertainty (Kendall & Gal, 2017; Hüllermeier & Waegeman, 2019) on regression tasks by training the neural networks to directly infer the parameters of the evidential distribution, thereby producing uncertainty measures. While Posterior Networks Charpentier et al. (2020; 2022) are designed for general classification/regression tasks and achieve promising performance, they do not explicitly consider imbalance in regression tasks, which is the focus of this paper. DER (Amini et al., 2020) is designed for the data-rich regime and therefore fails to reasonably estimate the uncertainty if the data is imbalanced; for data with minority labels, DER (Amini et al., 2020) tends produce unstable distribution parameters, leading to poor uncertainty estimation (as shown in Sec. 4). In contrast, our proposed VIR explicitly handles data imbalance in the continuous label space to avoid such instability; VIR does so by modulating both the representations and the output conjugate distribution parameters according to the imbalanced label distribution, allowing training/inference to proceed as if the data is balance and leading to better performance as well as uncertainty estimation (as shown in Sec. 4).
35
+
36
+ # 3 METHOD
37
+
38
+ In this section we introduce the problem setting, provide an overview of our VIR, and then describe details on each of VIR’s key components.
39
+
40
+ # 3.1 PROBLEM SETTINGS
41
+
42
+ Assuming an imbalanced dataset in continuous space $\{ \mathbf { x } _ { i } , y _ { i } \} _ { i = 1 } ^ { N }$ where $N$ is the total number of data points, $\mathbf { x } _ { i } ~ \in ~ \mathbb { R } ^ { d }$ is the input, and $y _ { i } \in \mathcal { V } \subset \mathbb { R }$ is the corresponding label from a continuous label space $\mathcal { V }$ . In practice, $\mathcal { V }$ is partitioned into $\mathbf { B }$ equal-interval bins $[ y ^ { ( 0 ) } , y ^ { ( 1 ) } ) , [ y ^ { ( 2 ) } , y ^ { ( 2 ) } ) , . . . , [ \hat { y } ^ { ( B - 1 ) } , y ^ { ( B ) } )$ , with slight notation overload. To directly compare with baselines, we use the same grouping index for target value $b \in \ B$ as in (Yang et al., 2021).
43
+
44
+ We denote representations as $\mathbf { z } _ { i }$ , and use $\left( \widetilde { \mathbf { z } } _ { i } ^ { \mu } , \widetilde { \mathbf { z } } _ { i } ^ { \Sigma } \right) ^ { \sim } =$ $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { i } ; \theta )$ e e to denote the probabilistic representations for input $\mathbf { x } _ { i }$ generated by a probabilistic encoder parameterized by $\theta$ . Similarly we use $( \widehat { y } _ { i } , \widehat { s } _ { i } )$ to denote the mean b band variance of the predictive distribution generated by a probabilistic predictor $p _ { \boldsymbol { \theta } } ( y _ { i } | \mathbf { z } )$ . Furthermore, we denote $\bar { \bf z }$ as the mean of representation $\mathbf { z } _ { i }$ in each bins (i.e., letting $\begin{array} { r } { \bar { \bf z } = \frac { 1 } { N _ { b } } \sum _ { i = 1 } ^ { N _ { b } } { \bf z } _ { i } } \end{array}$ in a bin with $N _ { b }$ data points).
45
+
46
+ # 3.2 METHOD OVERVIEW
47
+
48
+ In order to achieve both desiderata in probabilistic deep imbalanced regression (i.e., performance improvement and uncertainty estimation), our proposed variational imbalanced regression (VIR) operates on both the encoder $q _ { \phi } ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { \tilde { N } } )$ and the predictor $p _ { \theta } ( y _ { i } | \mathbf { z } _ { i } )$ .
49
+
50
+ ![](images/c4921b658189decfd8e43d9639b54fdb52e400aefc64428e1305230cfbc2288c.jpg)
51
+ Figure 2: Overview of our VIR method. Left: The inference model infers the latent representations given input x’s in the neighborhood. Right: The generative model reconstructs the input and predicts the label distribution (including the associated uncertainty) given the latent representation.
52
+
53
+ Typical VAE (Kingma & Welling, 2014) lower-bounds input $\mathbf { x } _ { i }$ ’s marginal likelihood; in contrast, VIR lower-bounds the marginal likelihood of input $\mathbf { x } _ { i }$ and labels $y _ { i }$ :
54
+
55
+ $$
56
+ \begin{array} { r } { \log p _ { \theta } ( \mathbf { x } _ { i } , y _ { i } ) = \mathcal { D } _ { K \mathcal { L } } \big ( q _ { \phi } ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } ) | | p _ { \theta } ( \mathbf { z } _ { i } | \mathbf { x } _ { i } , y _ { i } ) \big ) + \mathcal { L } ( \theta , \phi ; \mathbf { x } _ { i } , y _ { i } ) . } \end{array}
57
+ $$
58
+
59
+ Note that our variational distribution $q _ { \phi } ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } )$ (1) does not conditions on labels $y _ { i }$ , since the task is to predict $y _ { i }$ and (2) conditions on all (neighboring) inputs $\{ { \mathbf { x } } _ { i } \} _ { i = 1 } ^ { N }$ rather than just $\mathbf { x } _ { i }$ . The second term $\mathcal { L } ( \boldsymbol { \theta } , \phi ; { \mathbf { x } } _ { i } , y _ { i } )$ is VIR’s evidence lower bound (ELBO), which is defined as:
60
+
61
+ $$
62
+ \begin{array} { r } { \mathcal { L } ( \theta , \phi ; \mathbf { x } _ { i } , y _ { i } ) = \underbrace { { \mathbb { E } } _ { q } \left[ \log p _ { \theta } ( \mathbf { x } _ { i } | \mathbf { z } _ { i } ) \right] } _ { \mathcal { L } _ { i } ^ { \mathcal { D } } } + \underbrace { { \mathbb { E } } _ { q } \left[ \log p _ { \theta } ( y _ { i } | \mathbf { z } _ { i } ) \right] } _ { \mathcal { L } _ { i } ^ { \mathcal { P } } } - \underbrace { \mathcal { D } _ { K \mathcal { L } } ( q _ { \phi } ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } ) | | p _ { \theta } ( \mathbf { z } _ { i } ) ) } _ { \mathcal { L } _ { i } ^ { K \mathcal { L } } } . } \end{array}
63
+ $$
64
+
65
+ where the $p _ { \theta } ( \mathbf { z } _ { i } )$ is the standard Gaussian prior $\mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ , following typical VAE (Kingma & Welling, 2014), and the expectation is taken over $q _ { \phi } ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } )$ , which infers $\mathbf { z } _ { i }$ by borrowing data with similar regression labels to produce the balanced probabilistic representations, which is beneficial especially for the minority (see Sec. 3.3 for details).
66
+
67
+ Different from typical regression models which produce only point estimates for $y _ { i }$ , our VIR’s predictor, $p _ { \theta } ( y _ { i } | \mathbf { z } _ { i } )$ , directly produces the parameters of the entire NIG distribution for $y _ { i }$ and further imposes probabilistic reweighting on the imbalanced data, thereby producing balanced predictive distributions (more details in Sec. 3.4).
68
+
69
+ # 3.3 CONSTRUCTING $q ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } )$
70
+
71
+ To cover both desiderata, one needs to (1) produce balanced representations to improve performance for the data with minority labels and (2) produce probabilistic representations to naturally obtain reasonable uncertainty estimation for each model prediction. To learn such balanced probabilistic representations, we construct the encoder of our VIR (i.e., $q _ { \phi } ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } ) )$ by (1) first encoding a data point into a probabilistic representation, (2) computing probabilistic statistics from neighboring representations (i.e., representations from data with similar regression labels), and (3) producing the final representations via probabilistic whitening and recoloring using the obtained statistics.
72
+
73
+ Probabilistic Representations. We first encode each data point into a probabilistic representation. Note that this is in contrast to existing work (Yang et al., 2021) that uses deterministic representations. We assume that each encoding $\mathbf { z } _ { i }$ is a Gaussian distribution with parameters $\{ \mathbf { z } _ { i } ^ { \mu } , \mathbf { z } _ { i } ^ { \Sigma } \}$ , which are generated from the last layer in the deep neural network.
74
+
75
+ From I.I.D. to Neighboring and Identically Distributed (N.I.D.). Typical VAE (Kingma & Welling, 2014) is an unsupervised learning model that aims to learn a variational representation from latent space to reconstruct the original inputs under the I.I.D. assumption; that is, in VAE, the latent value (i.e., $\mathbf { z } _ { i }$ ) is generated from its own input $\mathbf { x } _ { i }$ . This I.I.D. assumption works well for data with majority labels, but significantly harms performance for data with minority labels. To address this problem, we replace the I.I.D. assumption with the N.I.D. assumption; specifically, VIR’s variational latent representations still follow Gaussian distributions (i.e., $\bar { \mathcal { N } } ( \mathbf { z } _ { i } ^ { \mu } , \mathbf { z } _ { i } ^ { \Sigma } )$ , but these distributions will be first calibrated using data with neighboring labels. For a data point $\left( \mathbf { x } _ { i } , y _ { i } \right)$ where $y _ { i }$ is in the $b ^ { \prime }$ th bin, i.e., $y _ { i } \in [ y ^ { ( b - 1 ) } , y ^ { ( b ) } )$ , we compute $q ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } ) \triangleq \mathcal { N } ( \mathbf { z } _ { i } ; \widetilde \mathbf { z } _ { i } ^ { \mu } , \widetilde \mathbf { z } _ { i } ^ { \Sigma } )$ as
76
+
77
+ Mean and Covariance of Initial $\mathbf { z } _ { i }$ : ${ \bf z } _ { i } ^ { \mu } , { \bf z } _ { i } ^ { \Sigma } = \mathcal { T } ( { \bf x } _ { i } )$ ,
78
+
79
+ Smoothed Statistics of Bin $^ { b }$ ’s Statistics: $\widetilde { \mu } _ { b } ^ { \mu } , \widetilde { \mu } _ { b } ^ { \Sigma } , \widetilde { \Sigma } _ { b } ^ { \mu } , \widetilde { \Sigma } _ { b } ^ { \Sigma } = { \cal S } ( \{ \mu _ { b } ^ { \mu } , \mu _ { b } ^ { \Sigma } , \Sigma _ { b } ^ { \mu } , \Sigma _ { b } ^ { \Sigma } \} _ { b = 1 } ^ { B } ) ,$
80
+
81
+ Mean and Covariance of Final $\mathbf { z } _ { i }$ : $\widetilde { \mathbf { z } } _ { i } ^ { \mu } , \widetilde { \mathbf { z } } _ { i } ^ { \Sigma } = \mathcal { F } ( \mathbf { z } _ { i } ^ { \mu } , \mathbf { z } _ { i } ^ { \Sigma } , \mu _ { b } ^ { \mu } , \mu _ { b } ^ { \Sigma } , \boldsymbol { \Sigma } _ { b } ^ { \mu } , \boldsymbol { \Sigma } _ { b } ^ { \Sigma } , \widetilde { \mu } _ { b } ^ { \mu } , \widetilde { \mu } _ { b } ^ { \Sigma } , \widetilde { \boldsymbol { \Sigma } } _ { b } ^ { \mu } , \widetilde { \boldsymbol { \Sigma } } _ { b } ^ { \Sigma } ) .$ where the details of functions $\boldsymbol { \mathcal { T } } ( \cdot )$ $) , A ( \cdot ) , S ( \cdot )$ , and $\mathcal F ( \cdot )$ are described below.
82
+
83
+ Function $\boldsymbol { \mathcal { T } } ( \cdot )$ : From Deterministic to Probabilistic Statistics. Different from deterministic statistics in (Yang et al., 2021), our VIR’s encoder uses probabilistic statistics (i.e., statistics of statistics). Specifically, VIR treats $\mathbf { z } _ { i }$ as a distribution with the mean and covariance $( \mathbf { z } _ { i } ^ { \mu } , \mathbf { z } _ { i } ^ { \Sigma } ) = \mathcal { T } ( \mathbf { x } _ { i } )$ rather than a deterministic vector. As a result, all the deterministic statistics, $\pmb { \mu } _ { b }$ , $\Sigma _ { b }$ , $\widetilde { \mu } _ { b }$ , and $\widetilde { \Sigma } _ { b }$ are replaced by distributions with the means and covariances, $( \mu _ { b } ^ { \mu } , \mu _ { b } ^ { \Sigma } )$ , $( \Sigma _ { b } ^ { \mu } , \Sigma _ { b } ^ { \Sigma } )$ , $( \widetilde { \mu } _ { b } ^ { \mu } , \widetilde { \mu } _ { b } ^ { \Sigma } )$ , and $( \widetilde { \pmb { \Sigma } } _ { b } ^ { \mu } , \widetilde { \pmb { \Sigma } } _ { b } ^ { \Sigma } )$ , respectively (more details in the following three paragraphs on $\boldsymbol { \mathcal { A } } ( \cdot ) , \boldsymbol { S } ( \cdot )$ , and $\mathcal F ( \cdot )$ ).
84
+
85
+ Function $\boldsymbol { \mathcal { A } } ( \cdot )$ : Statistics of the current Bin $b$ ’s Statistics. As part of our probabilistic overall statistics, the probabilistic overall mean becomes a distribution with the mean (letting ${ \pmb { \mu } } _ { b } = { \bar { \bf z } }$ ) and covariance (assuming diagonal covariance):
86
+
87
+ $$
88
+ \begin{array} { r } { { \pmb \mu } _ { b } ^ { \mu } = \mathbb { E } [ \bar { \mathbf { z } } ] = \frac { 1 } { N _ { b } } \sum _ { i = 1 } ^ { N _ { b } } \mathbf { z } _ { i } ^ { \mu } , \mu _ { b } ^ { \Sigma } = \mathbb { V } [ \bar { \mathbf { z } } ] = \frac { 1 } { N _ { b } ^ { 2 } } \sum _ { i = 1 } ^ { N _ { b } } \mathbf { z } _ { i } ^ { \Sigma } . } \end{array}
89
+ $$
90
+
91
+ Similarly, our probabilistic overall covariance becomes a matrix-variate distribution (Gupta & Nagar, 2018) with the mean:
92
+
93
+ $$
94
+ { \pmb { \Sigma } } _ { b } ^ { \mu } = \frac { 1 } { N _ { b } } \sum _ { i = 1 } ^ { N _ { b } } ( { \bf z } _ { i } - { \bar { \bf z } } ) ^ { 2 } = \frac { 1 } { N _ { b } } \sum _ { i = 1 } ^ { N _ { b } } \Big [ { \bf z } _ { i } ^ { \Sigma } + ( { \bf z } _ { i } ^ { \mu } ) ^ { 2 } - \Big ( [ { \pmb { \mu } } _ { b } ^ { \Sigma } ] _ { i } + ( [ { \pmb { \mu } } _ { b } ^ { \mu } ] _ { i } ) ^ { 2 } \Big ) \Big ] ,
95
+ $$
96
+
97
+ since $\mathbb { E } [ \bar { \mathbf { z } } ] = \mu _ { b } ^ { \mu }$ and $\mathbb { V } [ \bar { \mathbf { z } } ] = \mu _ { b } ^ { \Sigma }$ . Note that the covariance of $\Sigma _ { b }$ , i.e., $\Sigma _ { b } ^ { \Sigma }$ , involves computing the fourth-order moments, which is computationally prohibitive. Therefore in practice, we directly set $\Sigma _ { b } ^ { \Sigma }$ to zero for simplicity; empirically we observe that such simplified treatment already achieves promising performance improvement upon the state of the art.
98
+
99
+ Function $\boldsymbol { \mathcal { S } } ( \cdot )$ : Neighboring Data and Smoothed Statistics. Next, we can borrow data with neighboring labels (from neighboring label bins) to compute the smoothed statistics of the current bin $b$ by applying a symmetric kernel $k ( \cdot , \cdot )$ (e.g., Gaussian, Laplacian, and Triangular kernels). Specifically, the probabilistic smoothed mean and covariance are (assuming diagonal covariance):
100
+
101
+ $$
102
+ \begin{array} { r } { \widetilde { \mu } _ { b } ^ { \mu } = \sum _ { b ^ { \prime } \in \mathcal { B } } k ( y _ { b } , y _ { b ^ { \prime } } ) \mu _ { b ^ { \prime } } ^ { \mu } , \widetilde { \mu } _ { b } ^ { \Sigma } = \sum _ { b ^ { \prime } \in \mathcal { B } } k ^ { 2 } ( y _ { b } , y _ { b ^ { \prime } } ) \mu _ { b ^ { \prime } } ^ { \Sigma } , \widetilde { \Sigma } _ { b } ^ { \mu } = \sum _ { b ^ { \prime } \in \mathcal { B } } k ( y _ { b } , y _ { b ^ { \prime } } ) \Sigma _ { b ^ { \prime } } . } \end{array}
103
+ $$
104
+
105
+ Function $\mathcal F ( \cdot )$ : Probabilistic Whitening and Recoloring. We develop a probabilistic version of the whitening and re-coloring procedure (Sun et al., 2016) used in (Yang et al., 2021). Specifically, we produce the final probabilistic representation $\{ \widetilde { \mathbf { z } } _ { i } ^ { \mu } , \widetilde { \mathbf { z } } _ { i } ^ { \Sigma } \}$ for each data point as:
106
+
107
+ $$
108
+ \widetilde { \mathbf { z } } _ { i } ^ { \mu } = ( \mathbf { z } _ { i } ^ { \mu } - \boldsymbol { \mu } _ { b } ^ { \mu } ) \cdot \sqrt { \frac { \widetilde { \mathbf { \boldsymbol { \Sigma } } } _ { b } ^ { \mu } } { \boldsymbol { \Sigma } _ { b } ^ { \mu } } } + \widetilde { \boldsymbol { \mu } } _ { b } ^ { \mu } , \quad \widetilde { \mathbf { z } } _ { i } ^ { \Sigma } = ( \mathbf { z } _ { i } ^ { \Sigma } + \boldsymbol { \mu } _ { b } ^ { \Sigma } ) \cdot \sqrt { \frac { \widetilde { \mathbf { \boldsymbol { \Sigma } } } _ { b } ^ { \mu } } { \boldsymbol { \Sigma } _ { b } ^ { \mu } } } + \widetilde { \boldsymbol { \mu } } _ { b } ^ { \Sigma } .
109
+ $$
110
+
111
+ Inspired by (Yang et al., 2021), we keep updating the probabilistic overall statistics, $\{ \pmb { \mu } _ { b } ^ { \mu } , \pmb { \mu } _ { b } ^ { \Sigma } , \pmb { \Sigma } _ { b } \}$ , and the probabilistic smoothed statistics, $\{ \widetilde { \mu } _ { b } ^ { \mu } , \widetilde { \mu } _ { b } ^ { \Sigma } \}$ , cross different epochs. The probabilistic representation $\{ \widetilde { \mathbf { z } } _ { i } ^ { \mu } , \widetilde { \mathbf { z } } _ { i } ^ { \Sigma } \}$ are then re-parameterized (Kingma & Welling, 2014) into the final representation $\mathbf { z } _ { i }$ e e, and passed into the final layer (discussed in Sec. 3.4) to generate the prediction and uncertainty estimation. Note that the computation of statistics from multiple $\mathbf { x }$ ’s is only needed during training. During testing, VIR directly uses these statistics and therefore does not need to re-compute them.
112
+
113
+ # 3.4 CONSTRUCTING $p ( y _ { i } | \mathbf { z } _ { i } )$
114
+
115
+ Our VIR’s predictor $p ( y _ { i } | \mathbf { z } _ { i } ) \triangleq \mathcal { N } ( y _ { i } ; \widehat { y } _ { i } , \widehat { s } _ { i } )$ predicts both the mean and variance for $y _ { i }$ by first b bpredicting the NIG distribution and then marginalizing out the latent variables. It is motivated by the following observations on label distribution smoothing (LDS) in (Yang et al., 2021) and deep evidental regression (DER) in (Amini et al., 2020), as well as intuitions on effective counts in conjugate distributions.
116
+
117
+ LDS’s Limitations in Our Probabilistic Imbalanced Regression Setting. The motivation of LDS (Yang et al., 2021) is that the empirical label distribution can not reflect the real label distribution in an imbalanced dataset with a continuous label space; consequently, reweighting methods for imbalanced regression fail due to these inaccurate label densities. By applying a smoothing kernel on the empirical label distribution, LDS tries to recover the effective label distribution, with which reweighting methods can obtain ‘better’ weights to improve imbalanced regression. However, in our probabilistic imbalanced regression, one needs to consider both (1) the performance for the data with minority labels and (2) uncertainty estimation for each model. However, LDS only focuses on improving the accuracy, especially for the data with minority labels, and therefore does not provide uncertainty estimation, which is crucial to assess the predictions’ reliability.
118
+
119
+ DER’s limitations in Our Probabilistic Imbalanced Regression Setting. In DER (Amini et al., 2020), the predicted labels with their correspond uncertainties are produced by the representation of the posterior parameters in Normal Inverse Gamma (NIG) distribution $N I G ( \gamma , \nu , \alpha , \beta )$ , while the model is trained via minimizing the negative log-likelihood (NLL) of a Student-t distribution:
120
+
121
+ $$
122
+ \begin{array} { r } { \mathcal { L } _ { i } ^ { D E R } = \frac { 1 } { 2 } \log ( \frac { \pi } { \nu } ) + ( \alpha + \frac { 1 } { 2 } ) \log ( ( y _ { i } - \gamma ) ^ { 2 } \nu + \Omega ) - \alpha \log ( \Omega ) + \log ( \frac { \Gamma ( \alpha ) } { \Gamma ( \alpha + \frac { 1 } { 2 } ) } ) , } \end{array}
123
+ $$
124
+
125
+ where $\Omega = 2 \beta ( 1 + \nu )$ . It is therefore nontrivial to properly incorporate a reweighting mechanism into the NLL. One straightforward approach is to directly reweight $\mathcal { L } _ { i } ^ { D E R }$ for different data points $( x _ { i } , y _ { i } )$ . However, this contradicts the formulation of NIG and often leads to poor performance, as we verify in Sec. 4.
126
+
127
+ Intuition of Pseudo-Counts for VIR. To properly incorporate different reweighting methods, our VIR relies on the intuition of pseudo-counts (pseudo-observations) in conjugate distributions (Bishop, 2006). Assuming Gaussian likelihood, the conjugate distributions would be an NIG distribution (Bishop, 2006), i.e., $( \mu , \Sigma ) \sim N I G ( \gamma , \nu , \alpha , \beta )$ , which means:
128
+
129
+ $$
130
+ \mu \sim { \mathcal N } ( \gamma , \Sigma / \nu ) , ~ \Sigma \sim \Gamma ^ { - 1 } ( \alpha , \beta ) ,
131
+ $$
132
+
133
+ where $\Gamma ^ { - 1 } ( \alpha , \beta )$ is an inverse gamma distribution. With a NIG prior distribution $N I G ( \gamma _ { 0 } , \nu _ { 0 } , \alpha _ { 0 } , \beta _ { 0 } )$ , the posterior distribution of the NIG after observing $n$ real data points are:
134
+
135
+ $$
136
+ \begin{array} { r } { \gamma _ { n } = \frac { \gamma _ { 0 } \nu _ { 0 } + n \Psi } { \nu _ { n } } , \quad \nu _ { n } = \nu _ { 0 } + n , \quad \alpha _ { n } = \alpha _ { 0 } + \frac { n } { 2 } , \quad \beta _ { n } = \beta _ { 0 } + \frac { 1 } { 2 } ( \gamma _ { 0 } ^ { 2 } \nu _ { 0 } ) + \Phi , } \end{array}
137
+ $$
138
+
139
+ where $\boldsymbol \Psi = \bar { \mathbf x }$ and $\begin{array} { r } { \Phi = \frac 1 2 ( \sum _ { i } \mathbf { x } _ { i } ^ { 2 } - \gamma _ { n } ^ { 2 } \nu _ { n } ) } \end{array}$ . Here $\nu _ { 0 }$ and $\alpha _ { 0 }$ can be interpreted as virtual observations, i.e., pseudo-counts or pseudo-observations that contribute to the posterior distribution. Overall, the mean of posterior distribution above can be interpreted as an estimation from $\left( 2 \alpha _ { 0 } + n \right)$ observations, with $2 \alpha _ { 0 }$ virtual observations and $n$ real observations. Similarly, the variance can be interpreted an estimation from $( \nu + n )$ observations. This intuition is crucial in developing the predictor of our VIR.
140
+
141
+ From Pseudo-Counts to Balanced Predictive Distributions. Based on the intuition above, we construct our predictor (i.e., $p ( y _ { i } | \mathbf { z } _ { i } ) )$ by (1) generating the parameters in the posterior distribution of NIG, (2) computing re-weighted parameters by imposing the importance weights obtained from LDS, and (3) producing the final prediction with corresponding uncertainty estimation.
142
+
143
+ Based on Eqn. 7, we feed the final representation $\{ { \mathbf { z } } _ { i } \} _ { i = 1 } ^ { N }$ generated from the Sec. 3.3 (Eqn. 5) into a linear layer to output the intermediate parameters $n _ { i } , \Psi _ { i } , \Phi _ { i }$ for data point $\left( \mathbf { x } _ { i } , y _ { i } \right)$ :
144
+
145
+ $$
146
+ n _ { i } , \Psi _ { i } , \Phi _ { i } = \mathcal G ( \mathbf { z } _ { i } ) , \quad \mathbf { z } _ { i } \sim q ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } ) = \mathcal N ( \mathbf { z } _ { i } ; \widetilde { \mathbf { z } } _ { i } ^ { \mu } , \widetilde { \mathbf { z } } _ { i } ^ { \Sigma } )
147
+ $$
148
+
149
+ We then apply the importance weights $\begin{array} { r } { \sum _ { b ^ { \prime } \in B } k ( y _ { b } , y _ { b ^ { \prime } } ) \big ) ^ { - \frac { 1 } { 2 } } } \end{array}$ calculated from the smoothed label distribution to the pseudo-count $n _ { i }$ to produce the re-weighted parameters of posterior distribution of NIG. Along with the pre-defined prior parameters $( \gamma _ { 0 } , \nu _ { 0 } , \alpha _ { 0 } , \beta _ { 0 } )$ , we are able to compute the parameters of posterior distribution $N I G ( \gamma _ { i } , \nu _ { i } , \alpha _ { i } , \beta _ { i } )$ for $\left( \mathbf { x } _ { i } , y _ { i } \right)$ :
150
+
151
+ $$
152
+ \begin{array} { r l } & { \gamma _ { i } ^ { * } = \frac { \gamma _ { 0 } \nu _ { 0 } + \big ( \sum _ { b ^ { \prime } \in B } k ( y _ { b } , y _ { b ^ { \prime } } ) \big ) ^ { - \frac { 1 } { 2 } } \cdot n _ { i } \Psi _ { i } } { \nu _ { n } ^ { * } } , \quad \nu _ { i } ^ { * } = \nu _ { 0 } + \big ( \sum _ { b ^ { \prime } \in B } k ( y _ { b } , y _ { b ^ { \prime } } ) \big ) ^ { - \frac { 1 } { 2 } } \cdot n _ { i } , } \\ & { \alpha _ { i } ^ { * } = \alpha _ { 0 } + \big ( \sum _ { b ^ { \prime } \in B } k ( y _ { b } , y _ { b ^ { \prime } } ) \big ) ^ { - \frac { 1 } { 2 } } \cdot \frac { n _ { i } } { 2 } , \quad \beta _ { i } ^ { * } = \beta _ { 0 } + \frac { 1 } { 2 } ( \gamma _ { 0 } ^ { 2 } \nu _ { 0 } ) + \Phi _ { i } . } \end{array}
153
+ $$
154
+
155
+ Based on the NIG posterior distribution, we can then compute final prediction and uncertainty estimation as
156
+
157
+ $$
158
+ \begin{array} { r } { \widehat { y } _ { i } = \gamma _ { i } ^ { * } , \widehat { s } _ { i } = \frac { \beta _ { i } ^ { * } } { \nu _ { i } ^ { * } ( \alpha _ { i } ^ { * } - 1 ) } . } \end{array}
159
+ $$
160
+
161
+ We use an objective function similar to Eqn. 6, but with different definitions of $( \gamma , \nu , \alpha , \beta )$ , to optimize our VIR model:
162
+
163
+ $$
164
+ \begin{array} { r } { \mathcal { L } _ { i } ^ { \mathcal { P } } = \mathbb { E } _ { q _ { \phi } ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } ) } \left[ \frac { 1 } { 2 } \log ( \frac { \pi } { \nu _ { i } ^ { * } } ) + ( \alpha _ { i } ^ { * } + \frac { 1 } { 2 } ) \log ( ( y _ { i } - \gamma _ { i } ^ { * } ) ^ { 2 } \nu _ { n } ^ { * } + \Omega ) - \alpha _ { i } ^ { * } \log ( \omega _ { i } ^ { * } ) + \log ( \frac { \Gamma ( \alpha _ { i } ^ { * } ) } { \Gamma ( \alpha _ { i } ^ { * } + \frac { 1 } { 2 } ) } ) \right] , } \end{array}
165
+ $$
166
+
167
+ where $\omega _ { i } ^ { * } = 2 \beta _ { i } ^ { * } ( 1 + \nu _ { i } ^ { * } )$ . Note that $\mathcal { L } _ { i } ^ { \mathcal { P } }$ is part of the ELBO in Eqn. 1. Similar to (Amini et al., 2020), we use an additional regularization term to achieve better accuracy1:
168
+
169
+ $$
170
+ \mathcal { L } _ { i } ^ { \mathcal { R } } = \left( \nu + 2 \alpha \right) \cdot | y _ { i } - \widehat { y } _ { i } | .
171
+ $$
172
+
173
+ $\mathcal { L } _ { i } ^ { \mathcal { P } }$ and $\mathcal { L } _ { i } ^ { \mathcal { R } }$ together constitute the objective function for learning the predictor $p ( \mathbf { y } _ { i } | \mathbf { z } _ { i } )$
174
+
175
+ # 3.5 FINAL OBJECTIVE FUNCTION
176
+
177
+ Putting together Sec. 3.3 and Sec. 3.4, our final objective function (to minimize) for VIR is:
178
+
179
+ $$
180
+ \begin{array} { r } { \mathcal { L } ^ { \mathcal { V I R } } = \sum _ { i = 1 } ^ { N } \mathcal { L } _ { i } ^ { \mathcal { V I R } } , \quad \mathcal { L } _ { i } ^ { \mathcal { V I R } } = \lambda \mathcal { L } _ { i } ^ { \mathcal { R } } - \mathcal { L } ( \boldsymbol { \theta } , \boldsymbol { \phi } ; \mathbf { x } _ { i } , y _ { i } ) = \lambda \mathcal { L } _ { i } ^ { \mathcal { R } } - \mathcal { L } _ { i } ^ { \mathcal { P } } - \mathcal { L } _ { i } ^ { \mathcal { D } } + \mathcal { L } _ { i } ^ { K \mathcal { L } } , } \end{array}
181
+ $$
182
+
183
+ where $\mathcal { L } ( \theta , \phi ; \mathbf { x } _ { i } , y _ { i } ) = \mathcal { L } _ { i } ^ { \mathcal { P } } + \mathcal { L } _ { i } ^ { \mathcal { D } } - \mathcal { L } _ { i } ^ { \mathcal { K L } }$ is the ELBO in Eqn. 1. $\lambda$ adjusts the importance of the additional regularizer and the ELBO, and thus lead to a better result both on accuracy and uncertainty estimation.
184
+
185
+ # 3.6 DISCUSSION ON I.I.D. AND N.I.D. ASSUMPTIONS
186
+
187
+ Generalization Error, Bias, and Variance. We could analyze the generalization error of our VIR by bounding the generalization with the sum of three terms: (a) the bias of our estimator, (2) the variance of our estimator, (3) model complexity. Essentially VIR uses the N.I.D. assumption increases our estimator’s bias, but significantly reduces its variance in the imbalanced setting. Since the model complexity is kept the same (using the same backbone neural network) as the baselines, N.I.D. will lead to a lower generalization error (see more discussion in Sec. A of the Appendix).
188
+
189
+ # 4 RESULTS
190
+
191
+ Datasets. In this work, we evaluate our methods in terms of prediction accuracy and uncertainty estimation on two imbalanced datasets2, AgeDB (Moschoglou et al., 2017), IMDB-WIKI (Rothe et al., 2018). We follow the preprocessing procedures in DIR (Yang et al., 2021). Details for label density distributions and levels of imbalance are discussed in DIR (Yang et al., 2021).
192
+
193
+ AgeDB-DIR: We use AgeDB-DIR constructed in DIR (Yang et al., 2021), which contains 12.2K images for training and 2.1K images for validation and testing. The maximum age in this dataset is 101 and the minimum age is 0, and the number of images per bin varies between 1 and 353.
194
+
195
+ IMDB-WIKI-DIR: We use IMDB-WIKI-DIR constructed in DIR (Yang et al., 2021), which contains 191.5K training images and 11.0K validation and testing images. The maximum age is 186 and minimum age is 0; the maximum bin density is 7149, and minimum bin density is 1.
196
+
197
+ STS-B-DIR: We use STS-B-DIR constructed in DIR (Yang et al., 2021), which contains 5.2K pairs of training sentences and 1.0K pairs for validation and testing. This dataset is a collection of sentence pairs generated from news headlines, video captions, etc. Each pair is annotated by multiple annotators with a similarity score between 0 and 5.
198
+
199
+ Baselines. We use ResNet-50 (He et al., 2016) as our backbone network, and we describe the baselines below.
200
+
201
+ Vanilla: We use the term VANILLA to denote a plain model without adding any approaches.
202
+
203
+ Synthetic-Sample-Based Methods: Various existing imbalanced regression methods are also included as baselines; these include SMOTER (Torgo et al., 2013) and SMOGN (Branco et al., 2017). Furthermore, following DIR (Yang et al., 2021), in IMDB-WIKI-DIR, we also include another two methods: MIXUP (Zhang et al., 2018) and M-MIXUP (Verma et al., 2019).
204
+
205
+ Cost-Sensitive Reweighting: As shown in DIR (Yang et al., 2021), the square-root weighting variant (SQINV) baseline (i.e. $\begin{array} { r } { \big ( \sum _ { b ^ { \prime } \in B } k ( y _ { b } , y _ { b ^ { \prime } } ) \big ) ^ { - \frac { 1 } { 2 } } . } \end{array}$ ) always outperforms Vanilla. Therefore, for simplicity and fair comparison, all our experiments (for both baselines and VIR) use SQINV weighting. To use SQINV in VIR, one simply needs to use the symmetric kernel $k ( \cdot , \cdot )$ described in Sec. 3.3. To use SQINV in DER, we replace the final layer in DIR (Yang et al., 2021) with the DER layer (Amini et al., 2020) to produce the predictive distributions.
206
+
207
+ Evaluation Metrics - Accuracy. We follow the evaluation metrics in (Yang et al., 2021) to evaluate the accuracy of our proposed methods; these include Mean Absolute Error (MAE), Mean Squared Error (MSE), and Geometric Mean (GM). The formulas for these metrics are as follows:
208
+
209
+ $$
210
+ \begin{array} { r } { \mathtt { M A E } = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } | y _ { i } - \widehat { y } _ { i } | , \mathtt { M S E } = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } ( y _ { i } - \widehat { y } _ { i } ) ^ { 2 } , \mathtt { G M } = \Big [ \prod _ { i = 1 } ^ { N } | y _ { i } - \widehat { y } _ { i } | \Big ] ^ { \frac { 1 } { N } } . } \end{array}
211
+ $$
212
+
213
+ Evaluation Metrics - Uncertainty Estimation. We use typical evaluation metrics for uncertainty estimation in regression problems to evaluate our produced uncertainty estimation; these include Negative Log Likelihood (NLL), Area Under Sparsification Error (AUSE). Eqn. 8 shows the formula for NLL, and more details regarding to AUSE can be found in $\mathrm { I l g }$ et al., 2018).
214
+
215
+ Evaluation Process. Following (Liu et al., 2019; Yang et al., 2021), for a data sample $x _ { i }$ with its label $y _ { i }$ which falls into the target bins $b _ { i }$ , we divide the label space into three disjoint subsets: many-shot region $\{ b _ { i } \in \mathcal { B } \mid y _ { i } \in b _ { i } \& \ \left| y _ { i } \right| > 1 0 0 \}$ , medium-shot region $\{ b _ { i } \in B \mid y _ { i } \in b _ { i }$ & $2 0 \leq | y _ { i } | \leq$ $1 0 0 \}$ , and few-shot region $\{ b _ { i } \in B \mid y _ { i } \in b _ { i } \& \ \left| y _ { i } \right| < 2 0 \}$ , where $| \cdot |$ denotes the cardinality of the set. We report results on the overall test set and these subsets with the accuracy metrics discussed above.
216
+
217
+ Implementation Details. We use ResNet-50 (He et al., 2016) for all experiments in AgeDB-DIR and IMDB-WIKI-DIR. We use the Adam optimizer (Kingma & Ba, 2015) to train all models for 100 epochs, with same learning rate and decay by 0.1 and the 60-th and 90-th epoch, respectively. In order to determine the optimal batch size for training, we try different batch sizes and achieve the same conclusion as the DIR paper, i.e., the optimal batch size is 256 when other hyperparameters are fixed. Therefore, we stick to the batch size of 256 through out the experiments in the paper. Meanwhile, we use the same hyperparameters as in DIR (Yang et al., 2021).
218
+
219
+ Table 1: Evaluation results of accuracy on AgeDB-DIR.
220
+
221
+ <table><tr><td>Metrics</td><td colspan="4">MSE↓</td><td colspan="4">MAE↓</td><td colspan="4">GM↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>Al</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>VANILLA (Yang et al.,2021)</td><td>101.28</td><td>78.40</td><td>131.17</td><td>256.32</td><td>7.79</td><td>6.70</td><td>9.42</td><td>13.98</td><td>5.18</td><td>4.53</td><td>6.75</td><td>11.54</td></tr><tr><td>DEEP ENSEMBLE (Lakshminarayanan et al., 2017)</td><td>100.94</td><td>79.30</td><td>129.95</td><td>249.18</td><td>7.73</td><td>6.62</td><td>9.37</td><td>13.90</td><td>4.87</td><td>4.37</td><td>6.50</td><td>11.35</td></tr><tr><td>SMOTER (Torgo et al.,2013)</td><td>114.34</td><td>93.35</td><td>129.89</td><td>244.57</td><td>8.16</td><td>7.39</td><td>8.65</td><td>12.28</td><td>5.21</td><td>4.65</td><td>5.69</td><td>8.49</td></tr><tr><td>SMOGN (Branco et al.,2017)</td><td>117.29</td><td>101.36</td><td>133.86</td><td>232.90</td><td>8.26</td><td>7.64</td><td>9.01</td><td>12.09</td><td>5.36</td><td>4.90</td><td>6.19</td><td>8.44</td></tr><tr><td>SQINV (Yang etal.,2021)</td><td>104.76</td><td>92.67</td><td>127.04</td><td>205.16</td><td>7.92</td><td>7.42</td><td>8.80</td><td>11.46</td><td>5.03</td><td>4.81</td><td>5.72</td><td>8.23</td></tr><tr><td>DER (Amini et al.,2020)</td><td>106.81</td><td>91.32</td><td>122.45</td><td>209.76</td><td>8.11</td><td>7.36</td><td>9.03</td><td>12.69</td><td>5.31</td><td>4.65</td><td>6.48</td><td>10.52</td></tr><tr><td>FDS (Yang et al.,2021)</td><td>109.78</td><td>93.99</td><td>124.96</td><td>216.97</td><td>8.12</td><td>7.52</td><td>8.68</td><td>12.25</td><td>5.13</td><td>4.80</td><td>5.97</td><td>8.85</td></tr><tr><td>LDS (Yang et al., 2021)</td><td>102.22</td><td>83.62</td><td>128.73</td><td>204.64</td><td>7.67</td><td>6.98</td><td>8.86</td><td>10.89</td><td>4.85</td><td>4.39</td><td>5.80</td><td>7.45</td></tr><tr><td>LDS +FDS (Yang et al., 2021)</td><td>102.16</td><td>86.99</td><td>128.04</td><td>199.18</td><td>7.82</td><td>7.19</td><td>9.08</td><td>11.24</td><td>5.01</td><td>4.56</td><td>6.10</td><td>7.02</td></tr><tr><td>FDS + RANKSIM (Gong et al., 2022)</td><td>83.51</td><td>71.99</td><td>99.14</td><td>149.05</td><td>7.02</td><td>6.49</td><td>7.84</td><td>9.68</td><td>4.53</td><td>4.13</td><td>5.37</td><td>6.89</td></tr><tr><td>LDS + FDS + RANKSIM(Gong et al.,2022)</td><td>84.96</td><td>74.27</td><td>93.64</td><td>161.92</td><td>7.03</td><td>6.54</td><td>7.68</td><td>9.92</td><td>4.45</td><td>4.07</td><td>5.23</td><td>6.35</td></tr><tr><td>LDS + FDS + DER (Yang et al.,2021; Amini et al., 2020)</td><td>112.62</td><td>94.21</td><td>140.03</td><td>210.72</td><td>8.18</td><td>7.44</td><td>9.52</td><td>11.45</td><td>5.30</td><td>4.75</td><td>6.74</td><td>7.68</td></tr><tr><td>VIR (OURS)</td><td>86.89</td><td>77.69</td><td>96.55</td><td>145.76</td><td>7.14</td><td>6.67</td><td>7.70</td><td>9.52</td><td>4.58</td><td>4.27</td><td>5.09</td><td>6.31</td></tr><tr><td>OURS VS. VANILLA</td><td>+14.39</td><td>+0.71</td><td>+34.62</td><td>+110.56</td><td>+0.65</td><td>+0.03</td><td>+1.72</td><td>+4.46</td><td>+0.60</td><td>+0.26</td><td>+1.66</td><td>+5.23</td></tr><tr><td>OURS VS. SQINV</td><td>+17.87</td><td>+14.98</td><td>+30.49</td><td>+59.40</td><td>+0.78</td><td>+0.75</td><td>+1.10</td><td>+1.94</td><td>+0.45</td><td>+0.54</td><td>+0.63</td><td>+1.92</td></tr><tr><td>OURS VS. DER</td><td>+19.92</td><td>+13.63</td><td>+25.90</td><td>+64.00</td><td>+0.97</td><td>+0.69</td><td>+1.33</td><td>+3.17</td><td>+0.73</td><td>+0.38</td><td>+1.39</td><td>+4.21</td></tr><tr><td>OURS VS. LDS + FDS (SOTA IN DIR)</td><td>+15.27</td><td>+9.30</td><td>+31.49</td><td>+53.42</td><td>+0.68</td><td>+0.52</td><td>+1.38</td><td>+1.72</td><td>+0.43</td><td>+0.29</td><td>+1.01</td><td>+0.71</td></tr></table>
222
+
223
+ We use PyTorch to implement our method. For fair comparison, we implemented a PyTorch version for the official TensorFlow implementation of DER(Amini et al., 2020). To make sure we can obtain the reasonable uncertainty estimations, we restrict the range for $\alpha$ to $[ 1 . 5 , \infty )$ instead of $[ 1 . 0 , \infty )$ in DER. Besides, in the activation function SoftPlus, we set the hyperparameter beta to 0.1. As discussed in Sec. 3.4, we implement a layer which produces the parameters $n , \Psi , \Omega$ . We assign 2 as the minimum number for $n$ , and use the same hyperparameter settings for activation function for DER layer.
224
+
225
+ To search for a combination hyperparameters of prior distribution $\{ \gamma _ { 0 } , \nu _ { 0 } , \alpha _ { 0 } , \beta _ { 0 } \}$ for NIG, we combine grid search method and random search method (Bergstra & Bengio, 2012) to select the best hyperparameters. We first intuitively assign a value and a proper range with some step sizes which correspond to the hyperparameters, then, we apply grid search to search for the best combination for the hyperparameters on prior distributions. After locating a smaller range for each hyperparameters, we use random search to search for better combinations, if it exists. In the end, we find our best hyperparameter combinations for NIG prior distributions.
226
+
227
+ # 4.1 RESULTS FOR IMBALANCED REGRESSION ACCURACY
228
+
229
+ We report the accuracy of different methods in Table 1 and Table 2 for AgeDB-DIR and IMDB-WIKIDIR, respectively3. In both tables, we can conclude that our methods outperform the baselines in their categories. For ablation studies, see Table 5 and Table 6 of the Appendix. Note that to ensure fair and solid comparison, we re-run the DIR methods based on our machine and software settings4.
230
+
231
+ Overall Performance. As shown in the last category (i.e., last four rows) of both tables, our proposed method’s best variants compare favorably against the state of the art including DIR variants (Yang et al., 2021) and DER (Amini et al., 2020), especially on the imbalanced data samples (i.e., in the few-shot columns). This verifies the effectiveness of our methods in terms of overall performance.
232
+
233
+ # 4.2 RESULTS FOR IMBALANCED REGRESSION UNCERTAINTY ESTIMATION
234
+
235
+ Different from DIR (Yang et al., 2021) which only focuses on accuracy, we create a new benchmark for uncertainty estimation in imbalanced regression. Table 3 and Table 4 show the results on uncertainty estimation for two datasets AgeDB-DIR and IMDB-WIKI-DIR, respectively. Note that most baselines from Table 1 and Table 2 are deterministic methods (as opposed to probabilistic methods like ours) and cannot provide uncertainty estimation; therefore they are not applicable here. To show the superiority of our VIR model, we create a strongest baseline by concatenating the DIR variants $\mathrm { ( L D S + F D S ) }$ ) with the DER (Amini et al., 2020).
236
+
237
+ Table 2: Evaluation results of accuracy on IMDB-WIKI-DIR.
238
+
239
+ <table><tr><td>Metrics</td><td colspan="4">MSE↓</td><td colspan="4">MAE↓</td><td colspan="4">GM↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>VANILLA (Yang et al.,2021)</td><td>135.48</td><td>107.01</td><td>352.02</td><td>973.73</td><td>7.99</td><td>7.18</td><td>14.88</td><td>26.72</td><td>4.51</td><td>4.12</td><td>10.46</td><td>21.40</td></tr><tr><td>MIXUP (Zhang et al.,2018)</td><td>141.11</td><td>109.13</td><td>389.95</td><td>1037.98</td><td>8.22</td><td>7.29</td><td>16.23</td><td>28.11</td><td>4.68</td><td>4.22</td><td>12.28</td><td>23.55</td></tr><tr><td>M-MIXUP (Verma et al., 2019)</td><td>137.45</td><td>108.33</td><td>363.72</td><td>957.53</td><td>8.22</td><td>7.39</td><td>15.24</td><td>26.70</td><td>4.80</td><td>4.39</td><td>10.85</td><td>21.86</td></tr><tr><td>SMOTER (Torgo et al., 2013)</td><td>138.75</td><td>111.55</td><td>346.09</td><td>935.89</td><td>8.14</td><td>7.42</td><td>14.15</td><td>25.28</td><td>4.64</td><td>4.30</td><td>9.05</td><td>19.46</td></tr><tr><td>SMOGN (Branco et al.,2017)</td><td>136.09</td><td>109.15</td><td>339.09</td><td>944.20</td><td>8.03</td><td>7.30</td><td>14.02</td><td>25.93</td><td>4.63</td><td>4.30</td><td>8.74</td><td>20.12</td></tr><tr><td>SQINV (Yang et al., 2021)</td><td>134.36</td><td>111.23</td><td>308.63</td><td>834.08</td><td>7.87</td><td>7.24</td><td>12.44</td><td>22.76</td><td>4.47</td><td>4.22</td><td>7.25</td><td>15.10</td></tr><tr><td>DER (Amini et al.,020)</td><td>133.81</td><td>107.51</td><td>332.90</td><td>916.18</td><td>7.85</td><td>7.18</td><td>13.35</td><td>24.12</td><td>4.47</td><td>4.18</td><td>8.18</td><td>15.18</td></tr><tr><td>FDS (Yang et al., 2021)</td><td>131.93</td><td>107.76</td><td>311.29</td><td>880.32</td><td>7.80</td><td>7.20</td><td>12.64</td><td>23.20</td><td>4.39</td><td>4.16</td><td>7.04</td><td>13.42</td></tr><tr><td>LDS (Yang et al.,2021)</td><td>133.93</td><td>109.70</td><td>320.26</td><td>830.81</td><td>7.91</td><td>7.30</td><td>13.02</td><td>22.41</td><td>4.48</td><td>4.22</td><td>7.72</td><td>13.75</td></tr><tr><td>LDS + FDS (Yang et al., 2021)</td><td>136.72</td><td>112.76</td><td>322.50</td><td>811.83</td><td>8.08</td><td>7.47</td><td>13.21</td><td>22.54</td><td>4.66</td><td>4.39</td><td>8.01</td><td>14.33</td></tr><tr><td>LDS + FDS + DER (Yang et al.,2021; Amini et al.,2020)</td><td>120.86</td><td>97.75</td><td>297.64</td><td>873.10</td><td>7.24</td><td>6.64</td><td>11.87</td><td>23.44</td><td>3.93</td><td>3.69</td><td>6.64</td><td>16.00</td></tr><tr><td>VIR(OURS)</td><td>119.60</td><td>99.25</td><td>298.85</td><td>809.34</td><td>7.23</td><td>6.66</td><td>11.90</td><td>21.78</td><td>3.90</td><td>3.68</td><td>6.51</td><td>13.34</td></tr><tr><td>OURS VS. VANILLA</td><td>+15.88</td><td>+7.76</td><td>+53.17</td><td>+164.39</td><td>+0.76</td><td>+0.52</td><td>+2.98</td><td>+4.94</td><td>+0.61</td><td>+0.44</td><td>+3.95</td><td>+8.06</td></tr><tr><td>OURS VS. SQINV</td><td>+14.76</td><td>+11.98</td><td>+9.78</td><td>+24.74</td><td>+0.64</td><td>+0.58</td><td>+0.54</td><td>+0.98</td><td>+0.57</td><td>+0.54</td><td>+0.74</td><td>+1.76</td></tr><tr><td>OURS VS.DER</td><td>+14.21</td><td>+8.26</td><td>+34.05</td><td>+106.84</td><td>+0.62</td><td>+0.52</td><td>+1.45</td><td>+2.34</td><td>+0.57</td><td>+0.50</td><td>+1.67</td><td>+1.84</td></tr><tr><td>OURS VS.LDS + FDS (SOTA IN DIR)</td><td>+17.12</td><td>+13.51</td><td>+23.65</td><td>+2.49</td><td>+0.85</td><td>+0.81</td><td>+1.31</td><td>+0.76</td><td>+0.76</td><td>+0.71</td><td>+1.50</td><td>+0.99</td></tr></table>
240
+
241
+ Table 3: Uncertainty estimation results on AgeDB-DIR.
242
+
243
+ <table><tr><td>Metrics</td><td></td><td colspan="3">NLL↓</td><td></td><td colspan="3">AUSE↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>DEEP ENSEMBLE (Lakshminarayanan et al., 2017)</td><td>5.311</td><td>4.031</td><td>6.726</td><td>8.523</td><td>0.541</td><td>0.626</td><td>0.466</td><td>0.483</td></tr><tr><td>DER (Amini et al., 2020)</td><td>3.936</td><td>3.768</td><td>3.865</td><td>4.421</td><td>0.590</td><td>0.449</td><td>0.468</td><td>0.500</td></tr><tr><td>LDS + FDS + DER (Yang et al., 2021; Amini et al., 2020)</td><td>3.794</td><td>3.699</td><td>3.969</td><td>4.214</td><td>0.463</td><td>0.260</td><td>0.392</td><td>0.617</td></tr><tr><td>VIR (OURS)</td><td>3.703</td><td>3.598</td><td>3.805</td><td>4.196</td><td>0.437</td><td>0.474</td><td>0.319</td><td>0.413</td></tr><tr><td>OURS VS. DER</td><td></td><td>|+0.064 +0.071 +0.060 +0.225|+0.153 +0.026 +0.007 +0.036</td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
244
+
245
+ Results show that VIR outperform the baselines in all few-shot metrics. In some categories, VIR may not perform better in the overall, many-shot and median shot metrics, but the gap tends to be minimal. Note that our proposed methods mainly focus on the imbalanced setting, therefore we also
246
+
247
+ focus on the few-shot metrics. Lastly, comparing our model variant with the best performance against the baseline (DER), we can conclude that our methods successfully improve uncertainty estimation in the probabilistic imbalanced regression setting.
248
+
249
+ We also observe that the improvements of the uncertainty estimation on IMDB-WIKI are larger than those on Age-DB. We suspect that this because IMDB-WIKI contains much more training, validating and testing data, therefore enjoying more stable
250
+
251
+ Table 4: Uncertainty estimation results on IMDB-WIKI-DIR.
252
+
253
+ <table><tr><td>Metrics</td><td colspan="4">NLL↓</td><td colspan="4">AUSE↓</td></tr><tr><td>Shot</td><td>Al</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>DER (Amini et al.,2020)</td><td>3.850</td><td>3.699</td><td>4.997</td><td>6.638</td><td>0.813</td><td>0.802</td><td>0.650</td><td>0.541</td></tr><tr><td>LDS +FDS + DER (Yang et al.,2021; Amini et al.,020)</td><td>3.683</td><td>3.602</td><td>4.391</td><td>5.697</td><td>0.784</td><td>0.670</td><td>0.455</td><td>0.483</td></tr><tr><td>VIR(OURS)</td><td>3.652</td><td>3.568</td><td>4.419</td><td>5.560</td><td>0.622</td><td>0.645</td><td>0.511</td><td>0.374</td></tr><tr><td>OURS VS.DER</td><td></td><td></td><td>|+0.198 +0.131 +0.578 +1.078|+0.191 +0.157 +0.202 +0.167</td><td></td><td></td><td></td><td></td><td></td></tr></table>
254
+
255
+ uncertainty estimation improvements brought by VIR compared to those in Age-DB.
256
+
257
+ # 5 CONCLUSION
258
+
259
+ We identify the problem of probabilistic deep imbalanced regression, which aims to both improve accuracy and obtain reasonable uncertainty estimation in imbalanced regression. We propose VIR, which can use any deep regression models as backbone networks. VIR borrows data with similar regression labels to produce the probabilistic representations and modulates the conjugate distributions to impose probabilistic reweighting on imbalanced data. Furthermore, we create new benchmarks for uncertainty estimation on imbalanced regression. Experiments show that our methods outperform state-of-the-art imbalanced regression models in terms of both accuracy and uncertainty estimation. Future work may include (1) improving VIR by better approximating variance of the variances in probability distributions, and (2) developing novel approaches that can achieve stable performance even on imbalanced data with limited sample size, and (3) exploring techniques such as mixture density networks (Bishop, 1994) to enable multi-modality in the latent distribution, thereby further improving the performance.
260
+
261
+ # REFERENCES
262
+
263
+ Alexander Amini, Wilko Schwarting, Ava Soleimany, and Daniela Rus. Deep evidential regression. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and Hsuan-Tien Lin (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
264
+
265
+ James Bergstra and Yoshua Bengio. Random search for hyper-parameter optimization. J. Mach. Learn. Res., 13:281–305, 2012.
266
+
267
+ Christopher M. Bishop. Mixture density networks. Technical report, 1994.
268
+
269
+ Christopher M Bishop. Pattern recognition and machine learning. springer, 2006.
270
+
271
+ Paula Branco, Luís Torgo, and Rita P. Ribeiro. SMOGN: a pre-processing approach for imbalanced regression. In First International Workshop on Learning with Imbalanced Domains: Theory and Applications, LIDTA@PKDD/ECML 2017, 22 September 2017, Skopje, Macedonia, volume 74 of Proceedings of Machine Learning Research, pp. 36–50. PMLR, 2017.
272
+
273
+ Paula Branco, Luís Torgo, and Rita P. Ribeiro. REBAGG: resampled bagging for imbalanced regression. In Second International Workshop on Learning with Imbalanced Domains: Theory and Applications, LIDTA@ECML/PKDD 2018, Dublin, Ireland, September 10, 2018, volume 94 of Proceedings of Machine Learning Research, pp. 67–81. PMLR, 2018.
274
+
275
+ Bertrand Charpentier, Daniel Zügner, and Stephan Günnemann. Posterior Network: Uncertainty Estimation without OOD Samples via Density-Based Pseudo-Counts. In Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
276
+
277
+ Bertrand Charpentier, Oliver Borchert, Daniel Zügner, Simon Geisler, and Stephan Günnemann. Natural Posterior Network: Deep Bayesian Predictive Uncertainty for Exponential Family Distributions. In The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, April 25-29, 2022. OpenReview.net, 2022.
278
+
279
+ Nitesh V Chawla, Kevin W Bowyer, Lawrence O Hall, and W Philip Kegelmeyer. Smote: synthetic minority over-sampling technique. Journal of artificial intelligence research, 16:321–357, 2002.
280
+
281
+ Zongyong Deng, Hao Liu, Yaoxing Wang, Chenyang Wang, Zekuan Yu, and Xuehong Sun. PML: progressive margin loss for long-tailed age classification. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2021, virtual, June 19-25, 2021, 2021.
282
+
283
+ Yarin Gal and Zoubin Ghahramani. Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning. In Proceedings of the 33nd International Conference on Machine Learning, ICML 2016, New York City, NY, USA, June 19-24, 2016, volume 48 of JMLR Workshop and Conference Proceedings, pp. 1050–1059. JMLR.org, 2016.
284
+
285
+ Yu Gong, Greg Mori, and Frederick Tung. RankSim: Ranking Similarity Regularization for Deep Imbalanced Regression. In International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pp. 7634–7649. PMLR, 2022.
286
+
287
+ Arjun K Gupta and Daya K Nagar. Matrix variate distributions, volume 104. CRC Press, 2018.
288
+
289
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pp. 770–778. IEEE Computer Society, 2016.
290
+
291
+ Jakob Heiss, Jakob Weissteiner, Hanna S. Wutte, Sven Seuken, and Josef Teichmann. NOMU: Neural Optimization-based Model Uncertainty. In International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pp. 8708–8758. PMLR, 2022.
292
+
293
+ Eyke Hüllermeier and Willem Waegeman. Aleatoric and epistemic uncertainty in machine learning: A tutorial introduction. CoRR, abs/1910.09457, 2019.
294
+
295
+ Eddy Ilg, Özgün cCiccek, Silvio Galesso, Aaron Klein, Osama Makansi, Frank Hutter, and Thomas Brox. Uncertainty estimates and multi-hypotheses networks for optical flow. In Vittorio Ferrari, Martial Hebert, Cristian Sminchisescu, and Yair Weiss (eds.), Computer Vision - ECCV 2018 - 15th European Conference, Munich, Germany, September 8-14, 2018, Proceedings, Part VII, volume 11211 of Lecture Notes in Computer Science, pp. 677–693. Springer, 2018.
296
+
297
+ Haoming Jiang, Pengcheng He, Weizhu Chen, Xiaodong Liu, Jianfeng Gao, and Tuo Zhao. SMART: robust and efficient fine-tuning for pre-trained natural language models through principled regularized optimization. In Dan Jurafsky, Joyce Chai, Natalie Schluter, and Joel R. Tetreault (eds.), Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, ACL 2020, Online, July 5-10, 2020, pp. 2177–2190. Association for Computational Linguistics, 2020.
298
+
299
+ Alex Kendall and Yarin Gal. What uncertainties do we need in bayesian deep learning for computer vision? arXiv preprint arXiv:1703.04977, 2017.
300
+
301
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Yoshua Bengio and Yann LeCun (eds.), 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015.
302
+
303
+ Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In Yoshua Bengio and Yann LeCun (eds.), 2nd International Conference on Learning Representations, ICLR 2014, Banff, AB, Canada, April 14-16, 2014, Conference Track Proceedings, 2014.
304
+
305
+ Volodymyr Kuleshov, Nathan Fenner, and Stefano Ermon. Accurate uncertainties for deep learning using calibrated regression. In International Conference on Machine Learning, pp. 2796–2804. PMLR, 2018.
306
+
307
+ Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles. In Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pp. 6402–6413, 2017.
308
+
309
+ Jeremiah Liu, Zi Lin, Shreyas Padhy, Dustin Tran, Tania Bedrax Weiss, and Balaji Lakshminarayanan. Simple and Principled Uncertainty Estimation with Deterministic Deep Learning via Distance Awareness. In Advances in Neural Information Processing Systems, volume 33. Curran Associates, Inc., 2020.
310
+
311
+ Ziwei Liu, Zhongqi Miao, Xiaohang Zhan, Jiayun Wang, Boqing Gong, and Stella X. Yu. Large-scale long-tailed recognition in an open world. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2019, Long Beach, CA, USA, June 16-20, 2019, pp. 2537–2546. Computer Vision Foundation / IEEE, 2019.
312
+
313
+ Lu Mi, Hao Wang, Yonglong Tian, and Nir Shavit. Training-free uncertainty estimation for neural networks. In AAAI, 2022.
314
+
315
+ Stylianos Moschoglou, Athanasios Papaioannou, Christos Sagonas, Jiankang Deng, Irene Kotsia, and Stefanos Zafeiriou. Agedb: The first manually collected, in-the-wild age database. In 2017 IEEE Conference on Computer Vision and Pattern Recognition Workshops, CVPR Workshops 2017, Honolulu, HI, USA, July 21-26, 2017, pp. 1997–2005, 2017.
316
+
317
+ Jiawei Ren, Mingyuan Zhang, Cunjun Yu, and Ziwei Liu. Balanced MSE for Imbalanced Visual Regression. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2022, New Orleans, LA, USA, June 18-24, 2022, pp. 7916–7925. IEEE, 2022.
318
+
319
+ Rasmus Rothe, Radu Timofte, and Luc Van Gool. Deep expectation of real and apparent age from a single image without facial landmarks. Int. J. Comput. Vis., 126(2-4):144–157, 2018.
320
+
321
+ Jasper Snoek, Yaniv Ovadia, Emily Fertig, Balaji Lakshminarayanan, Sebastian Nowozin, D. Sculley, Joshua V. Dillon, Jie Ren, and Zachary Nado. Can you trust your model’s uncertainty? Evaluating predictive uncertainty under dataset shift. In Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pp. 13969–13980, 2019.
322
+
323
+ Hao Song, Tom Diethe, Meelis Kull, and Peter Flach. Distribution calibration for regression. In International Conference on Machine Learning, pp. 5897–5906. PMLR, 2019.
324
+
325
+ Maximilian Stadler, Bertrand Charpentier, Simon Geisler, Daniel Zügner, and Stephan Günnemann. Graph Posterior Network: Bayesian Predictive Uncertainty for Node Classification. In Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, pp. 18033–18048, 2021.
326
+
327
+ Baochen Sun, Jiashi Feng, and Kate Saenko. Return of frustratingly easy domain adaptation. In Dale Schuurmans and Michael P. Wellman (eds.), Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence, February 12-17, 2016, Phoenix, Arizona, USA, pp. 2058–2065. AAAI Press, 2016.
328
+
329
+ Luís Torgo, Rita P. Ribeiro, Bernhard Pfahringer, and Paula Branco. SMOTE for regression. In Luís Correia, Luís Paulo Reis, and José Cascalho (eds.), Progress in Artificial Intelligence - 16th Portuguese Conference on Artificial Intelligence, EPIA 2013, Angra do Heroísmo, Azores, Portugal, September 9-12, 2013. Proceedings, volume 8154 of Lecture Notes in Computer Science, pp. 378–389. Springer, 2013.
330
+
331
+ Joost van Amersfoort, Lewis Smith, Andrew Jesson, Oscar Key, and Yarin Gal. Improving Deterministic Uncertainty Estimation in Deep Learning for Classification and Regression. CoRR, abs/2102.11409, 2021.
332
+
333
+ Vikas Verma, Alex Lamb, Christopher Beckham, Amir Najafi, Ioannis Mitliagkas, David Lopez-Paz, and Yoshua Bengio. Manifold mixup: Better representations by interpolating hidden states. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pp. 6438–6447. PMLR, 2019.
334
+
335
+ Yuzhe Yang, Kaiwen Zha, Ying-Cong Chen, Hao Wang, and Dina Katabi. Delving into deep imbalanced regression. In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, volume 139 of Proceedings of Machine Learning Research, pp. 11842–11851. PMLR, 2021.
336
+
337
+ Wei Yin, Jianming Zhang, Oliver Wang, Simon Niklaus, Long Mai, Simon Chen, and Chunhua Shen. Learning to recover 3d scene shape from a single image. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2021, virtual, June 19-25, 2021, pp. 204–213. Computer Vision Foundation / IEEE, 2021.
338
+
339
+ Eric Zelikman, Christopher Healy, Sharon Zhou, and Anand Avati. Crude: calibrating regression uncertainty distributions empirically. arXiv preprint arXiv:2005.12496, 2020.
340
+
341
+ Hongyi Zhang, Moustapha Cissé, Yann N. Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018.
342
+
343
+ Zizhao Zhang, Adriana Romero, Matthew J Muckley, Pascal Vincent, Lin Yang, and Michal Drozdzal. Reducing uncertainty in undersampled mri reconstruction with active acquisition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2049–2058, 2019.
344
+
345
+ # A DISCUSSION ON I.I.D. AND N.I.D. ASSUMPTIONS
346
+
347
+ Generalization Error, Bias, and Variance. We could analyze the generalization error of our VIR by bounding the generalization with the sum of three terms: (a) the bias of our estimator, (2) the variance of our estimator, (3) model complexity. Essentially VIR uses the N.I.D. assumption increases our estimator’s bias, but significantly reduces its variance in the imbalanced setting. Since the model complexity is kept the same (using the same backbone neural network) as the baselines, N.I.D. will lead to a lower generalization error.
348
+
349
+ Variance of Estimators in Imbalanced Settings. In the imbalanced setting, one typically use inverse weighting to produced an unbiased estimator (i.e., making the first term of the aforementioned bound zero). However, for data with extremely low density, its inverse would be extremely large, therefore leading to a very large variance for the estimator. Our VIR replaces I.I.D. with N.I.D. to “smooth out” such singularity, and therefore significantly lowers the variance of the estimator (i.e., making the second term of the aforementioned bound smaller), and ultimately lowers the generalization error.
350
+
351
+ # B ADDITIONAL EXPERIMENT RESULTS
352
+
353
+ # B.1 ABLATION STUDY ON VIR
354
+
355
+ In this section, we include ablation studies to verify that our VIR can outperform its counterparts in DIR (i.e., smoothing on the latent space) and DER (i.e., NIG distribution layers).
356
+
357
+ Ablation Study on $q ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } )$ . To verify the effectiveness of VIR’s encoder $q ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } )$ , we replace VIR’s predictor $p ( y _ { i } | \mathbf { z } _ { i } )$ with a linear layer (as in DIR). Table 5 shows that compared to its counterpart, FDS (Yang et al., 2021), our encoderonly VIR still leads to a considerable
358
+
359
+ Table 5: Ablation study on AgeDB-DIR in terms of accuracy.
360
+
361
+ <table><tr><td>Metrics</td><td colspan="4">MSE↓</td><td colspan="4">MAE↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>FDS (Yang et al.,2021)</td><td>109.78</td><td>93.99</td><td>124.96</td><td>216.97</td><td>8.12</td><td>7.52</td><td>8.68</td><td>12.25</td></tr><tr><td>ENCODER-ONLY VIR (OURS)</td><td>95.99</td><td>81.89</td><td>121.78</td><td>157.92</td><td>7.57</td><td>6.97</td><td>8.72</td><td>10.03</td></tr><tr><td>DER (Amini et al., 2020)</td><td>106.81</td><td>91.32</td><td>122.45</td><td>209.76</td><td>8.11</td><td>7.36</td><td>9.03</td><td>12.69</td></tr><tr><td>PREDICTOR-ONLY VIR(OURS)</td><td>88.96</td><td>74.79</td><td>95.85</td><td>203.76</td><td>7.28</td><td>6.68</td><td>7.76</td><td>11.63</td></tr></table>
362
+
363
+ improvements even without generating the NIG distribution, therefore verifying the effectiveness of our VIR’s $q ( \mathbf { z } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } )$ .
364
+
365
+ Ablation Study on $p ( y _ { i } | \mathbf { z } _ { i } )$ . To verify the effectiveness of VIR’s predictor $p ( y _ { i } | \mathbf { z } _ { i } )$ , we replace VIR’s encoder $q ( \mathbf { \dot { z } } _ { i } | \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { N } )$ with a simple deterministic encoder as in DER (Amini et al., 2020). Table 5 and Table 6 show that compared to DER, the counter
366
+
367
+ Table 6: Ablation study on AgeDB-DIR in terms of uncertainty estimation.
368
+
369
+ <table><tr><td>Metrics</td><td colspan="4">NLL↓</td><td colspan="4">AUSE↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>Al</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>DER Amini et al. (2020)</td><td>3.936</td><td>3.768</td><td>3.865</td><td>4.421</td><td>0.590</td><td>0.449</td><td>0.468</td><td>0.500</td></tr><tr><td>PREDICTOR-ONLY VIR (OURS)</td><td>3.887</td><td>3.755</td><td>3.854</td><td>4.394</td><td>0.443</td><td>0.387</td><td>0.390</td><td>0.407</td></tr></table>
370
+
371
+ part of VIR’s predictor, our VIR’s predictor still outperforms than DER, demonstrating its effectiveness; this verifies our claim (Sec. 3.4) that directly reweighting DER breaks NIG and leads to poor performance.
372
+
373
+ # B.2 RESULT ON STS-B-DIR DATASET
374
+
375
+ In this section, we report the accuracy and uncertainty evaluation on STS-B-DIR (more details for the dataset is in DIR (Yang et al., 2021)). From Table 7, Table 8, and Table 9 below, we can conclude
376
+
377
+ Table 7: Evaluation results of accuracy on STS-B-DIR.
378
+
379
+ <table><tr><td>Metrics</td><td colspan="4">MSE↓</td><td colspan="4">MAE↓</td><td colspan="4">GM↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>INV</td><td>1.031</td><td>0.930</td><td>1.426</td><td>1.152</td><td>0.825</td><td>0.783</td><td>1.004</td><td>0.850</td><td>0.567</td><td>0.537</td><td>0.744</td><td>0.535</td></tr><tr><td>DIR(YANG ET AL, 2021)</td><td>1.000</td><td>0.912</td><td>1.368</td><td>1.055</td><td>0.812</td><td>0.772</td><td>0.989</td><td>0.809</td><td>0.560</td><td>0.535</td><td>0.739</td><td>0.477</td></tr><tr><td>DIR + DER (YANG ET AL.,2021; AMINI ET AL., 2020)</td><td>1.007</td><td>0.880</td><td>1.535</td><td>1.086</td><td>0.812</td><td>0.757</td><td>1.046</td><td>0.842</td><td>0.558</td><td>0.518</td><td>0.765</td><td>0.574</td></tr><tr><td>VIR (OURS)</td><td>0.895</td><td>0.799</td><td>1.309</td><td>0.919</td><td>0.760</td><td>0.718</td><td>0.960</td><td>0.732</td><td>0.509</td><td>0.493</td><td>0.669</td><td>0.377</td></tr></table>
380
+
381
+ that our model also outperforms all baselines in terms of both accuracy metrics and uncertainty estimation metrics in this NLP dataset; this verifies the superiority of our model for NLP datasets.
382
+
383
+ Table 8: Evaluation results of accuracy on STS-B-DIR.
384
+
385
+ <table><tr><td>Metrics</td><td colspan="4">Pearson↑</td><td colspan="4">Spearman ↑</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>INV</td><td>0.718</td><td>0.701</td><td>0.612</td><td>0.705</td><td>0.723</td><td>0.678</td><td>0.530</td><td>0.685</td></tr><tr><td>DIR(YANG ET AL.,2021)</td><td>0.732</td><td>0.711</td><td>0.646</td><td>0.742</td><td>0.731</td><td>0.672</td><td>0.519</td><td>0.739</td></tr><tr><td>DIR + DER(YANG ET AL., 2021; AMINI ET AL., 2020)</td><td>0.729</td><td>0.714</td><td>0.635</td><td>0.731</td><td>0.730</td><td>0.680</td><td>0.526</td><td>0.699</td></tr><tr><td>VIR (OURS)</td><td>0.765</td><td>0.740</td><td>0.663</td><td>0.770</td><td>0.770</td><td>0.713</td><td>0.534</td><td>0.770</td></tr></table>
386
+
387
+ Table 9: Uncertainty estimation results on STS-B-DIR.
388
+
389
+ <table><tr><td>Metrics</td><td colspan="4">NLL↓</td><td colspan="4">AUSE↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>Al</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>DIR + DER(YANG ET AL., 2021; AMINI ET AL., 2020)</td><td>2.561</td><td>2.514</td><td>2.880</td><td>2.358</td><td>0.672</td><td>0.581</td><td>0.609</td><td>0.615</td></tr><tr><td>VIR (OURS)</td><td>1.996</td><td>1.810</td><td>2.754</td><td>2.152</td><td>0.591</td><td>0.575</td><td>0.602</td><td>0.510</td></tr></table>
390
+
391
+ # B.3 DIFFERENCE BETWEEN DIR’S AND OUR REPRODUCED RESULTS
392
+
393
+ To reproduce the results on AgeDB, we use exactly the same settings as in DIR’s code (Yang et al., 2021) (i.e., by directly running their code on our machines without modifying hyperparameters). for each model in DIR we report, we use five different random seeds to produce five results. We then report the performance by taking the average of them. Table 10 and Table 11 show the example for SQINV and LDS+FDS on AgeDB-DIR. From the table we can see that under our hardware and software environments, the SQINV model and LDS $^ { + }$ FDS model (SOTA in DIR) could not perform as well as it is reported in DIR Yang et al. (2021), therefore for fair comparison, we use our replicated performance rather than theirs.
394
+
395
+ Table 10: Results of running SQINV for 5 different random seeds on AgeDB.
396
+
397
+ <table><tr><td>Metrics</td><td colspan="4">MSE↓</td><td colspan="4">MAE↓</td><td colspan="4">GM↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>SQINv 1</td><td>107.02</td><td>90.71</td><td>131.5</td><td>193.39</td><td>8.04</td><td>7.40</td><td>9.01</td><td>11.33</td><td>5.15</td><td>4.73</td><td>8.81</td><td>8.22</td></tr><tr><td>SQINV 2</td><td>111.55</td><td>93.43</td><td>141.03</td><td>209.17</td><td>8.12</td><td>7.47</td><td>9.17</td><td>11.58</td><td>5.21</td><td>4.85</td><td>5.75</td><td>8.25</td></tr><tr><td>SQINv 3</td><td>114.33</td><td>96.83</td><td>134.56</td><td>223.86</td><td>8.21</td><td>7.59</td><td>9.01</td><td>11.81</td><td>5.17</td><td>4.74</td><td>5.85</td><td>8.27</td></tr><tr><td>SQINV 4</td><td>106.24</td><td>91.81</td><td>120.26</td><td>203.78</td><td>7.94</td><td>7.39</td><td>8.58</td><td>11.39</td><td>5.06</td><td>4.74</td><td>5.41</td><td>7.66</td></tr><tr><td>SQINv5</td><td>104.73</td><td>90.24</td><td>127.33</td><td>208.05</td><td>7.99</td><td>7.47</td><td>8.98</td><td>11.49</td><td>5.07</td><td>4.79</td><td>5.68</td><td>7.98</td></tr><tr><td>SQINV AVG</td><td>108.77</td><td>92.60</td><td>130.94</td><td>207.65</td><td>8.06</td><td>7.46</td><td>8.95</td><td>11.52</td><td>5.13</td><td>4.77</td><td>6.30</td><td>8.08</td></tr><tr><td>SQINV STD</td><td>12.89</td><td>5.67</td><td>48.46</td><td>96.71</td><td>0.01</td><td>0.01</td><td>0.04</td><td>0.03</td><td>0.01</td><td>0.01</td><td>1.60</td><td>0.05</td></tr><tr><td>SQINV RESULTS FROM(YANG ET AL., 2021)</td><td>105.14</td><td>87.21</td><td>127.66</td><td>212.30</td><td>7.81</td><td>7.16</td><td>8.80</td><td>11.20</td><td>4.99</td><td>4.57</td><td>5.73</td><td>7.77</td></tr></table>
398
+
399
+ # B.4 ABLATION STUDY ON λ
400
+
401
+ In this section, we include ablation studies on the $\lambda$ in our objective function. For $\lambda \in$ $\{ 1 0 . 0 , 1 . 0 , 0 . 1 , 0 . 0 1 , 0 . 0 0 1 \}$ , we run our VIR model on the AgeDB dataset. Table 12 shows the results. We can conclude that when $\lambda = 0 . 1$ , our model achieves the best performance.
402
+
403
+ Table 11: Results of running LDS+FDS for 5 different random seeds on AgeDB.
404
+
405
+ <table><tr><td>Metrics</td><td colspan="4">MSE↓</td><td colspan="4">MAE↓</td><td colspan="4">GM↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>LDS+FDS 1</td><td>104.33</td><td>88.67</td><td>128.99</td><td>194.06</td><td>7.87</td><td>7.26</td><td>8.97</td><td>10.88</td><td>5.02</td><td>4.60</td><td>5.87</td><td>7.51</td></tr><tr><td>LDS+FDS 2</td><td>104.59</td><td>94.63</td><td>125.60</td><td>200.14</td><td>7.98</td><td>7.44</td><td>8.77</td><td>11.16</td><td>5.00</td><td>4.71</td><td>5.62</td><td>7.81</td></tr><tr><td>LDS+FDS 3</td><td>110.17</td><td>95.97</td><td>123.24</td><td>208.11</td><td>8.07</td><td>7.54</td><td>8.71</td><td>11.41</td><td>5.09</td><td>4.73</td><td>5.71</td><td>7.48</td></tr><tr><td>LDS+FDS 4</td><td>102.68</td><td>98.20</td><td>126.41</td><td>201.16</td><td>8.02</td><td>7.50</td><td>8.82</td><td>11.34</td><td>5.08</td><td>4.63</td><td>5.74</td><td>7.56</td></tr><tr><td>LDS+FDS 5</td><td>105.77</td><td>91.07</td><td>127.00</td><td>185.85</td><td>7.93</td><td>7.35</td><td>8.80</td><td>10.96</td><td>5.07</td><td>4.74</td><td>5.52</td><td>7.73</td></tr><tr><td>LDS+FDS AVG</td><td>105.51</td><td>93.71</td><td>126.25</td><td>197.86</td><td>7.97</td><td>7.42</td><td>8.81</td><td>11.15</td><td>5.05</td><td>4.68</td><td>5.69</td><td>7.62</td></tr><tr><td>LDS+FDS STD</td><td>6.41</td><td>11.70</td><td>3.52</td><td>55.97</td><td>0.01</td><td>0.01</td><td>0.01</td><td>0.04</td><td>0.01</td><td>0.03</td><td>0.01</td><td>0.02</td></tr><tr><td>LDS+FDS RESULTS FROM(YANG ET AL.,2021)</td><td>99.46</td><td>84.10</td><td>112.20</td><td>209.27</td><td>7.55</td><td>7.01</td><td>8.24</td><td>10.79</td><td>4.72</td><td>4.36</td><td>5.45</td><td>6.79</td></tr></table>
406
+
407
+ Table 12: Ablation study on $\lambda$ for VIR on AgeDB-DIR
408
+
409
+ <table><tr><td>Metrics</td><td colspan="4">MSE↓</td><td colspan="4">MAE↓</td><td colspan="4">NLL↓</td></tr><tr><td>Shot</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td><td>All</td><td>Many</td><td>Med.</td><td>Few</td></tr><tr><td>入=10.0</td><td>104.31</td><td>91.01</td><td>116.43</td><td>196.35</td><td>7.88</td><td>7.38</td><td>8.42</td><td>11.13</td><td>3.827</td><td>3.733</td><td>4.140</td><td>4.407</td></tr><tr><td>入=1.0</td><td>104.10</td><td>87.28</td><td>128.26</td><td>196.12</td><td>7.83</td><td>7.21</td><td>8.81</td><td>10.89</td><td>3.848</td><td>3.738</td><td>4.041</td><td>4.356</td></tr><tr><td>入=0.1</td><td>86.28</td><td>76.87</td><td>101.57</td><td>132.90</td><td>7.19</td><td>6.75</td><td>7.97</td><td>9.19</td><td>3.785</td><td>3.694</td><td>3.963</td><td>4.151</td></tr><tr><td>入=0.01</td><td>86.86</td><td>76.58</td><td>99.95</td><td>147.82</td><td>7.12</td><td>6.69</td><td>7.72</td><td>9.59</td><td>3.887</td><td>3.797</td><td>4.007</td><td>4.401</td></tr><tr><td>入=0.001</td><td>87.25</td><td>74.13</td><td>104.78</td><td>162.64</td><td>7.13</td><td>6.64</td><td>7.92</td><td>9.63</td><td>3.980</td><td>3.868</td><td>4.161</td><td>4.546</td></tr></table>
md/dev/03RLpj-tc_/03RLpj-tc_.md ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CRYSTAL DIFFUSION VARIATIONAL AUTOENCODER FOR PERIODIC MATERIAL GENERATION
2
+
3
+ Tian Xie∗, Xiang Fu∗, Octavian-Eugen Ganea∗, Regina Barzilay, Tommi Jaakkola
4
+
5
+ Computer Science and Artificial Intelligence Laboratory
6
+ Massachusetts Institute of Technology
7
+ Cambridge, MA 02139, USA
8
+ {txie,xiangfu,oct,regina,tommi}@csail.mit.edu
9
+
10
+ # ABSTRACT
11
+
12
+ Generating the periodic structure of stable materials is a long-standing challenge for the material design community. This task is difficult because stable materials only exist in a low-dimensional subspace of all possible periodic arrangements of atoms: 1) the coordinates must lie in the local energy minimum defined by quantum mechanics, and 2) global stability also requires the structure to follow the complex, yet specific bonding preferences between different atom types. Existing methods fail to incorporate these factors and often lack proper invariances. We propose a Crystal Diffusion Variational Autoencoder (CDVAE) that captures the physical inductive bias of material stability. By learning from the data distribution of stable materials, the decoder generates materials in a diffusion process that moves atomic coordinates towards a lower energy state and updates atom types to satisfy bonding preferences between neighbors. Our model also explicitly encodes interactions across periodic boundaries and respects permutation, translation, rotation, and periodic invariances. We significantly outperform past methods in three tasks: 1) reconstructing the input structure, 2) generating valid, diverse, and realistic materials, and 3) generating materials that optimize a specific property. We also provide several standard datasets and evaluation metrics for the broader machine learning community.
13
+
14
+ # 1 INTRODUCTION
15
+
16
+ Solid state materials, represented by the periodic arrangement of atoms in the 3D space, are the foundation of many key technologies including solar cells, batteries, and catalysis (Butler et al., 2018). Despite the rapid progress of molecular generative models and their significant impact on drug discovery, the problem of material generation has many unique challenges. Compared with small molecules, materials have more complex periodic 3D structures and cannot be adequately represented by a simple graph like molecular graphs (Figure 1). In addition, materials can be made up of more than 100 elements in the periodic table, while molecules are generally only made up of a small subset of atoms such as carbon, oxygen, and hydrogen. Finally, the data for training ML models for material design is limited. There are only ${ \sim } 2 0 0 \mathrm { k }$ experimentally known inorganic materials, collected by the ICSD (Belsky et al., 2002), in contrast to close to a billion molecules in ZINC (Irwin & Shoichet, 2005).
17
+
18
+ The key challenge of this task is in generating stable materials. Such materials only exist in a lowdimensional subspace of all possible periodic arrangements of atoms: 1) the atom coordinates must lie in the local energy minimum defined by quantum mechanics (QM); 2) global stability also requires the structure to follow the complex, yet specific
19
+
20
+ ![](images/f9a16b0c92de6c778ad170e8c78bce773bc7a6fa978abde181eb0a9ecf697006.jpg)
21
+ Figure 1: The periodic structure of diamond. The left shows the infinite periodic structure, the middle shows a unit cell representing the periodic structure, and the right shows a multi-graph (Xie & Grossman, 2018) representation.
22
+
23
+ bonding preferences between different atom types (section 3.2). The issue of stability is unique to material generation because valency checkers assessing molecular stability are not applicable to materials. Moreover, we also have to encode the interactions crossing periodic boundaries (Figure 1, middle), and satisfy permutation, translation, rotation, and periodic invariances (section 3.1). Our goal is to learn representations that can learn features of stable materials from data, while adhering to the above invariance properties.
24
+
25
+ We address these challenges by learning a variational autoencoder (VAE) (Kingma & Welling, 2014) to generate stable 3D materials directly from a latent representation without intermediates like graphs. The key insight is to exploit the fact that all materials in the data distribution are stable, therefore if noise is added to the ground truth structure, denoising it back to its original structure will likely increase stability. We capture this insight by designing a noise conditional score network (NCSN) (Song & Ermon, 2019) as our decoder: 1) the decoder outputs gradients that drive the atom coordinates to the energy local minimum; 2) it also updates atom types based on the neighbors to capture the specific local bonding preferences (e.g., Si-O is preferred over Si-Si and O-O in $\mathrm { S i O } _ { 2 }$ ). During generation, materials are generated using Langevin dynamics that gradually deforms an initial random structure to a stable structure. To capture the necessary invariances and encode the interactions crossing periodic boundaries, we use SE(3) equivariant graph neural networks adapted with periodicity (PGNNs) for both the encoder and decoder of our VAE.
26
+
27
+ Our theoretical analysis further reveals an intriguing connection between the gradient field learned by our decoder and an harmonic force field. De facto, the decoder utilizes the latter to estimate the forces on atoms when their coordinates deviate from the equilibrium positions. Consequently, this formulation provides an important physical inductive bias for generating stable materials.
28
+
29
+ In this work, we propose Crystal Diffusion Variational AutoEncoder (CDVAE) to generate stable materials by learning from the data distribution of known materials. Our main contributions include:
30
+
31
+ • We curate 3 standard datasets from QM simulations and create a set of physically meaningful tasks and metrics for the problem of material generation.
32
+ • We incorporate stability as an inductive bias by designing a noise conditional score network as the decoder of our VAE, which allows us to generate significantly more realistic materials.
33
+ • We encode permutation, translation, rotation, and periodic invariances, as well as interactions crossing periodic boundaries with SE(3) equivariant GNNs adapted with periodicity.
34
+ • Empirically, our model significantly outperforms past methods in tasks including reconstructing an input structure, generating valid, diverse, and realistic materials, and generating materials that optimize specific properties.
35
+
36
+ # 2 RELATED WORK
37
+
38
+ Material graph representation learning. Graph neural networks have made major impacts in material property prediction. They were first applied to the representation learning of periodic materials by Xie & Grossman (2018) and later enhanced by many studies including Schutt et al. ¨ (2018); Chen et al. (2019). The Open Catalyst Project (OCP) provides a platform for comparing different architectures by predicting energies and forces from the periodic structure of catalytic surfaces (Chanussot et al., 2021). Our encoder and decoder PGNNs directly use GNN architectures developed for the OCP (Klicpera et al., 2020b; 2021; Shuaibi et al., 2021; Godwin et al., 2021), which are also closely related to SE(3) equivariant networks (Thomas et al., 2018; Fuchs et al., 2020).
39
+
40
+ Quantum mechanical search of stable materials. Predicting the structure of unknown materials requires very expensive random search and QM simulations, and is considered a grand challenge in materials discovery (Oganov et al., 2019). State-of-the-art methods include random sampling (Pickard & Needs, 2011), evolutionary algorithms (Wang et al., 2012; Glass et al., 2006), substituting elements in known materials (Hautier et al., 2011), etc., but they generally have low success rates and require extensive computation even on relatively small problems.
41
+
42
+ Material generative models. Past material generative models mainly focus on two different approaches, and neither incorporate stability as an inductive bias. The first approach treats materials as 3D voxel images, but the process of decoding images back to atom types and coordinates often results in low validity, and the models are not rotationally invariant (Hoffmann et al., 2019; Noh et al., 2019; Court et al., 2020; Long et al., 2021). The second directly encodes atom coordinates, types, and lattices as vectors (Ren et al., 2020; Kim et al., 2020; Zhao et al., 2021), but the models are generally not invariant to any Euclidean transformations. Another related method is to train a force field from QM forces and then apply the learned force field to generate stable materials by minimizing energy (Deringer et al., 2018; Chen & Ong, 2022). This method is conceptually similar to our decoder, but it requires additional force data which is expensive to obtain. Remotely related works include generating contact maps from chemical compositions (Hu et al., 2021; Yang et al., 2021) and building generative models only for chemical compositions (Sawada et al., 2019; Pathak et al., 2020; Dan et al., 2020).
43
+
44
+ Molecular conformer generation and protein folding . Our decoder that generates the 3D atomic structures via a diffusion process is closely related to the diffusion models used for molecular conformer generation (Shi et al., 2021; Xu et al., 2021b). The key difference is that our model does not rely on intermediate representations like molecular graphs. G-SchNet (Gebauer et al., 2019) is more closely related to our method because it directly generates 3D molecules atom-by-atom without relying on a graph. Another closely related work is E-NFs (Satorras et al., 2021) that use a flow model to generate 3D molecules. In addition, score-based and energy-based models have also been used for molecular graph generation (Liu et al., 2021) and protein folding (Wu et al., 2021). Flow models have also been used for molecular graph generation (Shi et al., 2020; Luo et al., 2021). However, these generative models do not incorporate periodicity , which makes them unsuitable for materials.
45
+
46
+ # 3 PRELIMINARIES
47
+
48
+ # 3.1 PERIODIC STRUCTURE OF MATERIALS
49
+
50
+ Any material structure can be represented as the periodic arrangement of atoms in the 3D space. As illustrated in Figure 1, we can always find a repeating unit, i.e. a unit cell, to describe the infinite periodic structure of a material. A unit cell that includes $N$ atoms can be fully described by 3 lists: 1) atom types $\pmb { A } = ( a _ { 0 } , . . . , a _ { N } ) \in \mathbb { A } ^ { N }$ , where A denotes the set of all chemical elements; 2) atom coordinates $\pmb { X } = ( \pmb { x } _ { 0 } , . . . , \pmb { x } _ { N } ) \in \mathbb { R } ^ { N \times 3 }$ ; and 3) periodic lattice $\pmb { L } = ( l _ { 1 } , l _ { 2 } , l _ { 3 } ) \in \mathbb { R } ^ { 3 \times 3 }$ . The periodic lattice defines the periodic translation symmetry of the material. Given $\pmb { M } = ( A , X , \pmb { L } )$ , the infinite periodic structure can be represented as,
51
+
52
+ $$
53
+ \begin{array} { r } { \{ ( a _ { i } ^ { \prime } , \pmb { x } _ { i } ^ { \prime } ) | a _ { i } ^ { \prime } = a _ { i } , \pmb { x } _ { i } ^ { \prime } = \pmb { x } _ { i } + k _ { 1 } l _ { 1 } + k _ { 2 } l _ { 2 } + k _ { 3 } l _ { 3 } , k _ { 1 } , k _ { 2 } , k _ { 3 } \in \mathbb { Z } \} , } \end{array}
54
+ $$
55
+
56
+ where $\boldsymbol { k } _ { 1 } , \boldsymbol { k } _ { 2 } , \boldsymbol { k } _ { 3 }$ are any integers that translate the unit cell using $\pmb { L }$ to tile the entire 3D space.
57
+
58
+ The chemical composition of a material denotes the ratio of different elements that the material is composed of. Given the atom types of a material with $N$ atoms $\pmb { A } \in \mathbb { A } ^ { N }$ , the composition can be represented as $\boldsymbol { c } \in \mathbb { R } ^ { | \mathbb { A } | }$ , where $c _ { i } > 0$ denotes the percentage of atom type $i$ and $\textstyle \sum _ { i } { c _ { i } } = 1$ . For example, the composition of diamond in Figure 1 has $c _ { 6 } = 1$ and $c _ { i } = 0$ for $i \neq 6$ because 6 is the atomic number of carbon.
59
+
60
+ Invariances for materials. The structure of a material does not change under several invariances. 1) Permutation invariance. Exchanging the indices of any pair of atoms will not change the material. 2) Translation invariance. Translating the atom coordinates $\boldsymbol { X }$ by an arbitrary vector will not change the material. 3) Rotation invariance. Rotating $\boldsymbol { X }$ and $\pmb { L }$ together by an arbitrary rotation matrix will not change the material. 4) Periodic invariance. There are infinite different ways of choosing unit cells with different shapes and sizes, e.g., obtaining a bigger unit cell as an integer multiplier of a smaller unit cell using integer translations. The material will again not change given different choices of unit cells.
61
+
62
+ Multi-graph representation for materials. Materials can be represented as a directed multi-graph $\mathcal { G } = \{ \bar { \mathcal { V } } , \bar { \mathcal { E } } \}$ to encode the periodic structures following (Wells et al., 1977; O’Keeffe & Hyde, 1980; Xie & Grossman, 2018), where $\mathcal { V } = \{ v _ { 1 } , . . . , v _ { N } \}$ is the set of nodes representing atoms and ${ \mathcal { E } } =$ $\{ e _ { i j , ( k _ { 1 } , k _ { 2 } , k _ { 3 } ) } | i , j \in \{ 1 , . . . , N \} , k _ { 1 } , k _ { 2 } , k _ { 3 } \in \mathbb { Z } \}$ is the set of edges representing bonds. $e _ { i j , ( k _ { 1 } , k _ { 2 } , k _ { 3 } ) }$ denotes a directed edge from node $i$ at the original unit cell to node $j$ at the cell translated by $k _ { 1 } l _ { 1 } + k _ { 2 } l _ { 2 } + k _ { 3 } l _ { 3 }$ (in Figure 1 right, $( k _ { 1 } , k _ { 2 } , k _ { 3 } )$ are labeled on top of edges). For materials, there is no unique way to define edges (bonds) and the edges are often computed using $\mathbf { k }$ -nearest neighbor (KNN) approaches under periodicity or more advanced methods such as CrystalNN (Pan et al., 2021). Given this directed multi-graph, message-passing neural networks and SE(3)-equivariant networks can be used for the representation learning of materials.
63
+
64
+ ![](images/76a1088a1b2eb4c9f18fb457bb21e8b7032f46cf2c7456e531b05a39e4c96707.jpg)
65
+ Figure 2: Overview of the proposed CDVAE approach.
66
+
67
+ # 3.2 PROBLEM DEFINITION AND ITS PHYSICAL ORIGIN
68
+
69
+ Our goal is to generate novel, stable materials $M = ( \pmb { A } , \pmb { X } , \pmb { L } ) \in \mathbb { A } ^ { N } \times \mathbb { R } ^ { N \times 3 } \times \mathbb { R } ^ { 3 \times 3 }$ . The space of stable materials is a subspace in $\mathbb { A } ^ { N } \times \mathbb { R } ^ { N \times 3 } \times \mathbb { R } ^ { 3 \times 3 }$ that satisfies the following constraints. 1) The materials lie in the local minimum of the energy landscape defined by quantum mechanics, with respect to the atom coordinates and lattice, i.e. ${ \partial \bar { E } / \partial X = \mathbf { \bar { 0 } } }$ and $\partial E / \partial \pmb { L } = \mathbf { 0 }$ . 2) The material is globally stable and thus cannot decompose into nearby phases. Global stability is strongly related to bonding preferences between neighboring atoms. For example, in $\mathrm { S i O } _ { 2 }$ , each Si is surrounded by $^ \textrm { \scriptsize 4 O }$ and each O is surrounded by $2 \ S \mathrm { i }$ . This configuration is caused by the stronger bonding preferences between Si-O than Si-Si and O-O.
70
+
71
+ Generally, finding novel, stable materials requires very expensive random search and quantum mechanical simulations. To bypass this challenge, we aim to learn a generative model $p ( { \bar { M } } )$ from the empirical distribution of experimentally observed stable materials. A successful generative model will be able to generate novel materials that satisfy the above constraints, which can then be verified using quantum mechanical simulations.
72
+
73
+ # 3.3 DIFFUSION MODELS
74
+
75
+ Diffusion models are a new class of generative models that have recently shown great success in generating high-quality images (Dhariwal & Nichol, 2021), point clouds (Cai et al., 2020; Luo & Hu, 2021), and molecular conformations (Shi et al., 2021). There are several different types of diffusion models including diffusion probabilistic models (Sohl-Dickstein et al., 2015), noiseconditioned score networks (NCSN) (Song & Ermon, 2019), and denoising diffusion probabilistic models (DDPM) (Ho et al., 2020). We follow ideas from the NCSN (Song & Ermon, 2019) and learn a score network ${ \pmb s } _ { \pmb \theta } ( { \pmb x } )$ to approximate the gradient of a probability density $\nabla _ { \pmb { x } } p ( \pmb { x } )$ at different noise levels. Let $\{ \sigma _ { i } \} _ { i = 1 } ^ { L }$ be a sequence of positive scalars that satisfies $\sigma _ { 1 } / \sigma _ { 2 } = . . . = \sigma _ { L - 1 } / \sigma _ { L } > 1 .$ We define the data distribution perturbed by Gaussian noise $\sigma$ as $\begin{array} { r } { q _ { \sigma } ( \pmb { x } ) = \int p _ { \mathrm { d a t a } } ( \pmb { t } ) \mathcal { N } ( \pmb { x } | \pmb { t } , \sigma ^ { 2 } I ) \mathrm { d } \pmb { t } } \end{array}$ . The goal of NCSN is to learn a score network to jointly estimate the scores of all perturbed data distributions, i.e. $\forall \sigma \in \{ \sigma _ { i } \} _ { i = 1 } ^ { L } : s _ { \theta } ( \boldsymbol { x } , \sigma ) \approx \forall _ { \boldsymbol { x } } q _ { \sigma } ^ { \cdot } ( \boldsymbol { x } )$ . During generation, NCSN uses an annealed Langevin dynamics algorithm to produce samples following the gradient estimated by the score network with a gradually reduced noise level.
76
+
77
+ # 4 PROPOSED METHOD
78
+
79
+ Our approach generates new materials via a two-step process: 1) We sample a $_ z$ from the latent space and use it to predict 3 aggregated properties of a material: composition $( c )$ , lattice $( L )$ , and number of atoms $( N )$ , which are then used to randomly initialize a material structure $\tilde { M } = ( \tilde { A } , \tilde { X } , L )$ . 2) We perform Langevin dynamics to simultaneously denoise $\tilde { X }$ and $\tilde { A }$ conditioned on $_ z$ to improve both the local and global stability of $\tilde { M }$ and generate the final structure of the new material.
80
+
81
+ To train our model, we optimize 3 networks concurrently using stable materials $M = ( A , X , L )$ sampled from the data distribution. 1) A periodic GNN encoder $\mathrm { P G N N } _ { \mathrm { E N C } } ( M )$ that encodes $M$ into a latent representation $_ z$ . 2) A property predictor $\mathrm { M L P _ { A G G } } ( z )$ that predicts the $c , L$ , and $N$ of $M$ from $_ z$ . 3) A periodic GNN decoder $\mathrm { P G N N } _ { \mathrm { D E C } } ( \tilde { M } | z )$ that denoises both $\tilde { X }$ and $\tilde { A }$ conditioned on $_ { z }$ . For 3), the noisy structure $\tilde { M } = ( \tilde { A } , \tilde { X } , L )$ is obtained by adding different levels of noise to $\boldsymbol { X }$ and $\pmb { A }$ . The noise schedules are defined by the predicted aggregated properties, with the motivation of simplifying the task for our decoder from denoising an arbitrary random structure from over ${ \sim } 1 0 0$ elements to a constrained random structure from predicted properties. We train all three networks together by minimizing a combined loss including the aggregated property loss $\mathcal { L } _ { \mathrm { { A G G } } }$ , decoder denoising loss $\mathcal { L } _ { \mathrm { D E C } }$ , and a KL divergence loss ${ \mathcal { L } } _ { \mathrm { K L } }$ for the VAE.
82
+
83
+ To capture the interactions across periodic boundaries, we employ a multi-graph representation (section 3.1) for both $M$ and $\tilde { M }$ . We also use SE(3) equivariant GNNs adapted with periodicity as both the encoder and the decoder to ensure the permutation, translation, rotation, and periodic invariances of our model. The CDVAE is summarized in Figure 2 and we explain the individual components of our method below. The implementation details can be found in Appendix B.
84
+
85
+ Periodic material encoder. $\mathrm { P G N N } _ { \mathrm { E N C } } ( M )$ encodes a material $M$ as a latent representation $z \in$ $\mathbb { R } ^ { D }$ following the reparameterization trick in VAE (Kingma & Welling, 2014). We use the multigraph representation (refer to section 3.1) to encode $M$ , and $\mathrm { P G N N } _ { \mathrm { E N C } }$ can be parameterized with an SE(3) invariant graph neural network.
86
+
87
+ Prediction of aggregated properties. $\mathrm { M L P _ { A G G } } ( z )$ predicts 3 aggregated properties of the encoded material from its latent representation $_ z$ . It is parameterized by 3 separate multilayer perceptrons (MLPs). 1) Composition $\bar { \boldsymbol { c } } \in \mathbb { R } ^ { | \mathbb { A } | }$ is predicted by minimizing the cross entropy between the ground truth composition and predicted composition, i.e. $- \textstyle \sum _ { i } p _ { i } { \bar { \log } } c _ { i }$ . 2) Lattice $\bar { \boldsymbol { L } } \in \mathbb { R } ^ { 3 \times 3 }$ is reduced to 6 unique, rotation invariant parameters with the Niggli algorithm (Grosse-Kunstleve et al., 2004), i.e., the lengths of the 3 lattice vectors, the angles between them, and the values are predicted with an MLP after being normalized to the same scale (Appendix B.1) with an $L _ { 2 }$ loss. 3) Number of atoms $N \in \{ 1 , 2 , \bar { \ldots } \}$ is predicted with a softmax classification loss from the set of possible number of atoms. $\mathcal { L } _ { \mathrm { { A G G } } }$ is a weighted sum of the above 3 losses.
88
+
89
+ Conditional score matching decoder. $\mathrm { P G N N } _ { \mathrm { D E C } } ( \tilde { M } | z )$ is a PGNN that inputs a noisy material $\tilde { M }$ with type noises $\sigma _ { A }$ , coordinate noises $\sigma _ { x }$ , as well as a latent $_ { z }$ , and outputs 1) a score $s _ { X } ( \tilde { M } | z ; \sigma _ { A } , \sigma _ { X } ) \in \mathbb { R } ^ { N \times 3 }$ to denoise the coordinate for each atom towards its ground truth value, and 2) a probability distribution of the true atom types $p _ { A } ( \tilde { M } | z ; \sigma _ { A } , \sigma _ { X } ) \in \mathbb { R } ^ { N \times | \mathbb { A } | }$ . We use a SE(3) graph network to ensure the equivariance of $\pmb { s x }$ with respect to the rotation of $\tilde { M }$ . To obtain the noisy structures $\tilde { M }$ , we sample $\sigma _ { A }$ and $\sigma _ { x }$ from two geometric sequences of the same length: $\{ \sigma _ { A , j } \} _ { j = 1 } ^ { \check { L } }$ , $\{ \sigma _ { { \pmb X } , j } \} _ { j = 1 } ^ { L }$ , and add the noises with the following methods. For type noises, we use the type distribution defined by the predicted composition $\begin{array} { r } { \tilde { A } \sim ( \frac { 1 } { 1 + \sigma _ { A } } p _ { A } + \frac { \sigma _ { A } } { 1 + \sigma _ { A } } p _ { c } ) } \end{array}$ , where $p _ { A , i j } = 1$ if atom $i$ $^ c$ has the true atom type to linearly perturb true type distribution $j$ and $p _ { A , i j } = 0$ for all other $j \mathrm { s }$ , and $\scriptstyle { p _ { c } }$ is the predicted composition. For coordinate noises, we add Gaussian noises to the true coordinates $\tilde { X } \sim \mathsf { \bar { N } } ( X , \sigma _ { X } ^ { 2 } I )$ .
90
+
91
+ $\mathrm { P G N N } _ { \mathrm { D E C } }$ is parameterized by a SE(3) equivariant PGNN that inputs a multi-graph representation (section 3.1) of the noisy material structure and the latent representation. The node embedding for node $i$ is obtained by the concatenation of the element embedding of $\tilde { a } _ { i }$ and the latent representation $_ z$ , followed by a MLP, $\begin{array} { r } { \pmb { h } _ { i } ^ { 0 } = \mathrm { M L P } ( \pmb { e } _ { \mathrm { a } } ( \tilde { a } _ { i } ) \parallel \pmb { z } ) } \end{array}$ , where $\parallel$ denotes concatenation of two vectors and $e _ { \mathrm { a } }$ is a learned embedding for elements. After $K$ message-passing layers, $\mathrm { P G N N _ { D E C } }$ outputs a vector per node that is equivariant to the rotation of $\tilde { M }$ . These vectors are used to predict the scores, and we follow Song & Ermon (2019); Shi et al. (2021) to parameterize the score network with noise scaling: $s _ { X } ( \tilde { M } | z ; \sigma _ { A } , \sigma _ { X } ) = s _ { X } ( \tilde { M } | z ) / \sigma _ { X }$ . The node representations $h _ { i } ^ { K }$ are used to predict the distribution of true atom types, and the type predictor is the same at all noise levels: $p _ { A } \dot { ( M | z ; \sigma _ { A } , \sigma _ { X } ) } = p _ { A } ( \tilde { M } | z )$ , $p _ { A } ( \tilde { M } | z ) _ { i } = \mathrm { s o f t m a x } ( \mathrm { M L P } ( h _ { i } ^ { K } ) )$ .
92
+
93
+ Periodicity influences denoising target. Due to periodicity, a specific atom $i$ may move out of the unit cell defined by $\pmb { L }$ when the noise is sufficiently large. This leads to two different ways to define the scores for node $i$ . 1) Ignore periodicity and define the target score as $\pmb { x } _ { i } - \tilde { \pmb { x } } _ { i }$ ; or 2) Define the target score as the shortest possible displacement between $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ and $\tilde { \mathbf { x } } _ { i }$ considering periodicity, i.e. $\begin{array} { r } { d _ { \operatorname* { m i n } } ( \pmb { x } _ { i } , \tilde { \pmb { x } } _ { i } ) = \operatorname* { m i n } _ { k _ { 1 } , k _ { 2 } , k _ { 3 } } \bar { ( } \pmb { x } _ { i } - \tilde { \pmb { x } } _ { i } + \bar { k } _ { 1 } l _ { 1 } + k _ { 2 } l _ { 2 } + k _ { 3 } l _ { 3 } ) } \end{array}$ . We choose 2) because the scores are the same given two different $\tilde { X }$ that are periodically equivalent, which is mathematically grounded for periodic structures, and empirically results in much more stable training.
94
+
95
+ The training loss for the decoder $\mathcal { L } _ { \mathrm { D E C } }$ can be written as,
96
+
97
+ $$
98
+ \frac { 1 } { 2 L } \sum _ { j = 1 } ^ { L } \left[ \mathbb { E } _ { q _ { \mathrm { d a t a } ( M ) } } \mathbb { E } _ { q _ { \sigma _ { A , j } , \sigma _ { X , j } } ( \tilde { M } | M ) } \left( \left\| s x ( \tilde { M } | z ) - \frac { d _ { \operatorname* { m i n } } ( X , \tilde { X } ) } { \sigma _ { X , j } } \right\| _ { 2 } ^ { 2 } + \frac { \lambda _ { \mathrm { a } } } { \sigma _ { A , j } } \mathcal { L } _ { \mathrm { a } } ( p _ { A } ( \tilde { M } | z ) , p _ { A } ) \right) \right] ,
99
+ $$
100
+
101
+ where $\lambda _ { \mathrm { a } }$ denotes a coefficient for balancing the coordinate and type losses, $\mathcal { L } _ { \mathrm { a } }$ denotes the cross entropy loss over atom types, $_ { p _ { A } }$ denotes the true atom type distribution. Note that to simplify the equation, we follow the loss coefficients in Song & Ermon (2019) for different $\sigma _ { x , j }$ and $\sigma _ { A , j }$ and factor them into Equation 2.
102
+
103
+ Material generation with Langevin dynamics. After training the model, we can generate the periodic structure of material given a latent representation $_ z$ . First, we use $_ z$ to predict the aggregated properties: 1) composition $c , \ 2 )$ lattice $\pmb { L }$ , and 3) the number of atoms $N$ . Then, we randomly initialize an initial periodic structure $( A _ { 0 } , X _ { 0 } , L )$ with the aggregated properties and perform an annealed Langevin dynamics (Song & Ermon, 2019) using the decoder, simultaneously updating the atom types and coordinates. During the coordinate update, we map the coordinates back to the unit cell at each step if atoms move out of the cell. The algorithm is summarized in Algorithm 1.
104
+
105
+ # Algorithm 1 Material Generation via Annealed Langevin Dynamics
106
+
107
+ 1: Input: latent representation $_ { z }$ , type and coordinate noise
108
+ levels $\{ \sigma _ { A } \} , ~ \{ \bar { \sigma } _ { X } \}$ , step size $\epsilon$ , number of sampling
109
+ steps $T$
110
+ 2: Predict aggregated properties $c , L , N$ from $_ { z }$ .
111
+ 3: Uniformly initialize $X _ { 0 }$ within the unit cell by $\pmb { L }$ .
112
+ 4: Randomly initialize $\pmb { A } _ { 0 }$ with $^ c$ .
113
+ 5: for 6: $j 1$ $L$
114
+ 8: $\begin{array} { r l } & { \mathbf { \Phi } _ { \alpha j } ^ { \circ } \gets \epsilon \cdot \boldsymbol { \sigma } _ { X , j } ^ { 2 } / \boldsymbol { \sigma } _ { X , L } ^ { 2 } } \\ & { \mathbf { f } \mathbf { \Phi } \mathbf { f } \gets 1 \mathrm { t o } \mathcal { T } \mathbf { d } \mathbf { 0 } } \\ & { \qquad \mathbf { \Phi } _ { X , t } ^ { \circ } \gets \mathbf { s } _ { X } ( A _ { t - 1 } , X _ { t - 1 } , L \vert z ; \boldsymbol { \sigma } _ { A , j } , \boldsymbol { \sigma } _ { X , j } ) } \\ & { \qquad p _ { A , t } \gets p _ { A } \big ( A _ { t - 1 } , X _ { t - 1 } , L \vert z ; \boldsymbol { \sigma } _ { A , j } , \boldsymbol { \sigma } _ { X , j } \big ) } \\ & { \qquad \mathrm { D r a w } \ X _ { t } ^ { \epsilon } \sim \mathcal { N } \big ( 0 , I \big ) } \\ & { \qquad X _ { t } ^ { \epsilon } \gets X _ { t - 1 } + \alpha _ { j } \mathbf { s } _ { X , t } + \sqrt { 2 \alpha _ { i } } X _ { t } ^ { \epsilon } } \\ & { \qquad X _ { t } \gets \mathrm { b a c k . t o . c e l l } ( X _ { t } ^ { \prime } , L ) } \\ & { \qquad A _ { t } = \mathrm { a r g m a x } p _ { A , t } } \\ & { \qquad X _ { 0 } \gets X _ { T , A _ { 0 } } \gets A _ { T } } \end{array}$
115
+ 9:
116
+ 10:
117
+ 11:
118
+ 12:
119
+ 13:
120
+ 14:
121
+
122
+ Connection between the gradient field and a harmonic force field. The gradient field $s _ { X } ( { \tilde { M } } | z )$ is used to update atom coordinates in Langevin dynamics via the force term, $\alpha _ { j } s _ { X , t } .$ . In Appendix A, we show that $\alpha _ { j } { s } _ { X , t }$ is mathematically equivalent $\mathrm { t o } ^ { 2 }$ a harmonic force field ${ \cal F } ( \tilde { \cal X } ) = - k ( \tilde { \cal X } -$ $\boldsymbol { X }$ ) when the noises are small, where $\boldsymbol { X }$ is the equilibrium position of the atoms and $k$ is a force constant. Harmonic force field, i.e. spring-like force field, is a simple yet general physical model that approximates the forces on atoms when they are close to their equilibrium locations. This indicates that our learned gradient field utilizes the harmonic approximation to approximate QM forces without any explicit force data and generates stable materials with this physically motivated inductive bias.
123
+
124
+ # 5 EXPERIMENTS
125
+
126
+ We evaluate multiple aspects of material generation that are related to real-world material discovery process. Past studies in this field used very different tasks and metrics, making it difficult to compare different methods. Building upon past studies (Court et al., 2020; Ren et al., 2020), we create a set of standard tasks, datasets, and metrics to evaluate and compare models for material generation. Experiment details can be found in Appendix D.
127
+
128
+ Tasks. We focus on 3 tasks for material generation. 1) Reconstruction evaluates the ability of the model to reconstruct the original material from its latent representation z. 2) Generation evaluates the validity, property statistics, and diversity of material structures generated by the model. 3) Property optimization evaluates the model’s ability to generate materials that are optimized for a specific property.
129
+
130
+ Datasets. We curated 3 datasets representing different types of material distributions. 1) Perov5 (Castelli et al., 2012a;b) includes 18928 perovskite materials that share the same structure but differ in composition. There are 56 elements and all materials have 5 atoms in the unit cell. 2) Carbon-24 (Pickard, 2020) includes 10153 materials that are all made up of carbon atoms but differ in structures. There is 1 element and the materials have $6 \textsuperscript { - } 2 4$ atoms in the unit cells. 3) MP-20 (Jain et al., 2013) includes 45231 materials that differ in both structure and composition. There are
131
+
132
+ ![](images/578fc93f934b4eaf42ba8a5e6f4ba0d08297c97c2bd4b63b3ba7427bffdf402c.jpg)
133
+ Figure 3: Reconstructed structures of randomly selected materials in the test set. Note our model reconstructs rotated (translated) version of the original material due to the SE(3) invariance.
134
+
135
+ Table 1: Reconstruction performance.
136
+
137
+ <table><tr><td rowspan="2">Method</td><td colspan="4">Match rate(%)个</td><td colspan="2">RMSE↓</td></tr><tr><td>Perov-5</td><td>Carbon-24</td><td>MP-20</td><td>Perov-5</td><td>Carbon-24</td><td>MP-20</td></tr><tr><td>FTCP</td><td>99.34</td><td>62.28</td><td>69.89</td><td>0.0259</td><td>0.2563</td><td>0.1593</td></tr><tr><td>Cond-DFC-VAE</td><td>51.65</td><td>1</td><td>1</td><td>0.0217</td><td>1</td><td>一</td></tr><tr><td>CDVAE</td><td>97.52</td><td>55.22</td><td>45.43</td><td>0.0156</td><td>0.1251</td><td>0.0356</td></tr></table>
138
+
139
+ 89 elements and the materials have 1 - 20 atoms in the unit cells. We use a 60-20-20 random split for all of our experiments. Details regarding dataset curation can be found at Appendix C.
140
+
141
+ Stability of materials in datasets. Structures in all 3 datasets are obtained from QM simulations and all structures are at local energy minima. Most materials in Perov-5 and Carbon-24 are hypothetical, i.e. they may not have global stability (section 3.2) and likely cannot be synthesized. MP-20 is a realistic dataset that includes most experimentally known inorganic materials with at most 20 atoms in the unit cell, most of which are globally stable. A model achieving good performance in MP-20 has the potential to generate novel materials that can be experimentally synthesized.
142
+
143
+ Baselines. We compare CDVAE with the following 4 baselines, which include the latest coordinatebased, voxel-based, and 3D molecule generation methods. FTCP (Ren et al., 2020) is a crystal representation that concatenates real-space properties (atom positions, atom types, etc.) and Fouriertransformed momentum-space properties (diffraction pattern). A 1D CNN-VAE is trained over this representation for crystal generation. Cond-DFC-VAE (Court et al., 2020) encodes and generates crystals with 3D density maps, while employing several modifications over the previous Voxel-VAE (Hoffmann et al., 2019) method. However, the effectiveness is only demonstrated for cubic systems, limiting its usage to the Perov-5 dataset. G-SchNet (Gebauer et al., 2019) is an auto-regressive model that generates 3D molecules by performing atom-by-atom completion using SchNet (Schutt ¨ et al., 2018). Since G-SchNet is unaware of periodicity and cannot generate the lattice $\pmb { L }$ . We adapt G-SchNet to our material generation tasks by constructing the smallest oriented bounding box with PCA such that the introduced periodicity does not cause structural invalidity. P-G-SchNet is our modified G-SchNet that incorporates periodicity. During training, the SchNet encoder inputs the partial periodic structure to predict next atoms. During generation, we first randomly sample a lattice $\pmb { L }$ from training data and autoregressively generate the periodic structure.
144
+
145
+ # 5.1 MATERIAL RECONSTRUCTION
146
+
147
+ Setup. The first task is to reconstruct the material from its latent representation. We evaluate reconstruction performance by matching the generated structure and the input structure for all materials in the test set. We use StructureMatcher from pymatgen (Ong et al., 2013), which finds the best match between two structures considering all invariances of materials. The match rate is the percentage of materials satisfying the criteria $s \ t \circ 1 \mathrm { = } 0 \ . \ 5$ , angle tol ${ \ o } = 1 0$ , $1 \ t { \bigcirc } 1 = 0 \cdot 3$ . The RMSE is averaged over all matched materials. Because the inter-atomic distances can vary significantly for different materials, the RMSE is normalized by $\sqrt [ 3 ] { V / N }$ , roughly the average atom radius per material. Note G-SchNet is not a VAE so we do not evaluate its reconstruction performance.
148
+
149
+ Results. The reconstructed structures are shown in Figure 3 and the metrics are in Table 1. Since our model is SE(3) invariant, the generated structures may be a translated (or rotated) version of the ground truth structure. Our model has a lower RMSE than all other models, indicating its stronger capability to reconstruct the original stable structures. FTCP has a higher match rate than our model.
150
+
151
+ ![](images/46996ad50747cc42c9777944916f911c171bbc32b70cd77b6a0f3f7c42b47d98.jpg)
152
+ Figure 4: Structures sampled from $\mathcal { N } ( 0 , 1 )$ and filtered by the validity test.
153
+
154
+ Table 2: Generation performance3.
155
+
156
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Data</td><td colspan="2">Validity (%) 4个</td><td colspan="2">COV(%)↑</td><td colspan="3">Property Statistics ↓</td></tr><tr><td>Struc.</td><td>Comp.</td><td>R.</td><td>P</td><td>p</td><td>E</td><td># elem.</td></tr><tr><td>FTCP5</td><td>Perov-5</td><td>0.24</td><td>54.24</td><td>0.00</td><td>0.00</td><td>10.27</td><td>156.0</td><td>0.6297</td></tr><tr><td rowspan="5">Cond-DFC-VAE</td><td>Carbon-24</td><td>0.08</td><td></td><td>0.00</td><td>0.00</td><td>5.206</td><td>19.05</td><td></td></tr><tr><td>MP-20</td><td>1.55</td><td>48.37</td><td>4.72</td><td>0.09</td><td>23.71</td><td>160.9</td><td>0.7363</td></tr><tr><td>Perov-5</td><td>73.60</td><td>82.95</td><td>73.92</td><td>10.13</td><td>2.268</td><td>4.111</td><td>0.8373</td></tr><tr><td>Perov-5</td><td>99.92</td><td>98.79</td><td>0.18</td><td>0.23</td><td>1.625</td><td>4.746</td><td>0.03684</td></tr><tr><td>Carbon-24</td><td>99.94</td><td></td><td>0.00</td><td>0.00</td><td>0.9427</td><td>1.320</td><td></td></tr><tr><td rowspan="4">P-G-SchNet</td><td>MP-20</td><td>99.65</td><td>75.96</td><td>38.33</td><td>99.57</td><td>3.034</td><td>42.09</td><td>0.6411</td></tr><tr><td>Perov-5</td><td>79.63</td><td>99.13</td><td>0.37</td><td>0.25</td><td>0.2755</td><td>1.388</td><td>0.4552</td></tr><tr><td>Carbon-24</td><td>48.39</td><td></td><td>0.00</td><td>0.00</td><td>1.533</td><td>134.7</td><td></td></tr><tr><td>MP-20</td><td>77.51</td><td>76.40</td><td>41.93</td><td>99.74</td><td>4.04</td><td>2.448</td><td>0.6234</td></tr><tr><td rowspan="3">CDVAE</td><td>Perov-5</td><td>100.0</td><td>98.59</td><td>99.45</td><td>98.46</td><td>0.1258</td><td>0.0264</td><td>0.0628</td></tr><tr><td>Carbon-24</td><td>100.0</td><td></td><td>99.80</td><td>83.08</td><td>0.1407</td><td>0.2850</td><td></td></tr><tr><td>MP-20</td><td>100.0</td><td>86.70</td><td>99.15</td><td>99.49</td><td>0.6875</td><td>0.2778</td><td>1.432</td></tr></table>
157
+
158
+ This can be explained by the fact that the same set of local structures can be assembled into different stable materials globally (e.g., two different crystal forms of $Z \mathrm { n } S _ { \mathrm { { \tau } } }$ ). Our model is SE(3) invariant and only encodes local structures, while FTCP directly encodes the absolute coordinates and types of each atom. In Figure 5, we show that CDVAE can generate different plausible arrangements of atoms by sampling 3 Langevin dynamics with different random seeds from the same $_ z$ . We note that this capability could be an advantage since it generates more diverse structures than simply reconstructing the original ones.
159
+
160
+ # 5.2 MATERIAL GENERATION
161
+
162
+ Setup. The second task is to generate novel, stable materials that are distributionally similar to the test materials. The only high-fidelity evaluation of stability of generated materials is to perform QM calculations, but it is computationally prohibitive to use QM for computing evaluation metrics. We developed several physically meaningful metrics to evaluate the validity, property statistics, and diversity of generated materials. 1) Validity. Following Court et al. (2020), a structure is valid as long as the shortest distance between any pair of atoms is larger than $0 . 5 \mathring \mathrm { A }$ , which is a relative weak criterion. The composition is valid if the overall charge is neutral as computed by SMACT (Davies et al., 2019). 2) Coverage (COV). Inspired by $\mathrm { X u }$ et al. (2021a); Ganea et al. (2021), we define two coverage metrics, COV-R (Recall) and COV-P (Precision), to measure the similarity between ensembles of generated materials and ground truth materials in test set. Intuitively, COV-R measures the percentage of ground truth materials being correctly predicted, and COV-P measures the percentage of predicted materials having high quality (details in Appendix G). 3) Property statistics. We compute the earth mover’s distance (EMD) between the property distribution of generated materials and test materials. We use density ( $\dot { \rho } { } _ { ; }$ , unit $\mathrm { { g } / \mathrm { { c m } ^ { 3 } } } .$ ), energy predicted by an independent GNN ( $E$ , unit eV/atom), and number of unique elements (# elem.) as our properties. Validity and coverage are computed over 10,000 materials randomly sampled from $\mathcal { N } ( 0 , \bar { 1 } )$ . Property statistics is computed over 1,000 valid materials randomly sampled from those that pass the validity test.
163
+
164
+ Table 3: Property optimization performance.
165
+
166
+ <table><tr><td rowspan="2">Method</td><td colspan="3">Perov-5</td><td colspan="3">Carbon-24</td><td colspan="3">MP-20</td></tr><tr><td>SR5</td><td>SR10</td><td>SR15</td><td>SR5</td><td>SR10</td><td>SR15</td><td>SR5</td><td>SR10</td><td>SR15</td></tr><tr><td>FTCP</td><td>0.06</td><td>0.11</td><td>0.16</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.02</td><td>0.04</td><td>0.05</td></tr><tr><td>Cond-DFC-VAE</td><td>0.55</td><td>0.64</td><td>0.69</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>一</td></tr><tr><td>CDVAE</td><td>0.52</td><td>0.65</td><td>0.79</td><td>0.0</td><td>0.06</td><td>0.06</td><td>0.78</td><td>0.86</td><td>0.90</td></tr></table>
167
+
168
+ Results. The generated structures are shown in Figure 4 and the metrics are in Table 2. Our model achieves a higher validity than FTCP, Cond-DFC-VAE, and P-G-SchNet, while G-SchNet achieves a similar validity as ours. The lower structural validity in P-G-SchNet than G-SchNet is likely due to the difficulty of avoiding atom collisions during the autoregressive generation inside a finite periodic box. On the contrary, our G-SchNet baseline constructs the lattice box after the 3D positions of all atoms are generated, and the construction explicitly avoids introducing invalidity. Furthermore, our model also achieves higher COV-R and COV-P than all other models, except in MP-20 our COV-P is similar to G-SchNet and P-G-SchNet. These results indicate that our model generates both diverse (COV-R) and high quality (COV-P) materials. More detailed results on the choice of thresholds for COV-R and COV-P, as well as additional metrics can be found in Appendix G. Finally, our model also significantly outperforms all other models in the property statistics of density and energy, further confirming the high quality of generated materials. We observe that our method tends to generate more elements in a material than ground truth, which explains the lower performance in the statistics of # of elems. than G-SchNet. We hypothesize this is due to the non-Gaussian statistical structure of ground truth materials (details in Appendix D.3), and using a more complex prior, e.g., a flowmodel-transformed Gaussian (Yang et al., 2019), might resolve this issue.
169
+
170
+ # 5.3 PROPERTY OPTIMIZATION
171
+
172
+ Setup. The third task is to generate materials that optimize a specific property. Following Jin et al. (2018), we jointly train a property predictor $F$ parameterized by an MLP to predict properties of training materials from latent $_ z$ . To optimize properties, we start with the latent representations of testing materials and apply gradient ascent in the latent space to improve the predicted property $F ( \cdot )$ . After applying 5000 gradient steps with step sizes of $1 \times 1 0 ^ { - 3 }$ , 10 materials are decoded from the latent trajectories every 500 steps. We use an independently trained property predictor to select the best one from the 10 decoded materials. Cond-DFC-VAE is a conditional VAE so we directly condition on the target property, sample 10 materials, and select the best one using the property predictor. For all methods, we generate 100 materials following the protocol above. We use the independent property predictor to predict the properties for evaluation. We report the success rate (SR) as the percentage of materials achieving 5, 10, and 15 percentiles of the target property distribution. Our task is to minimize formation energy per atom for all 3 datasets.
173
+
174
+ Results. The performance is shown in Table 3. We significantly outperform FTCP, while having a similar performance as Cond-DFC-VAE in Perov-5 (Cond-DFC-VAE cannot work for Carbon-24 and MP-20). Both G-SchNet and P-G-SchNet are incapable of property optimization 6. We note that all models perform poorly on the Carbon-24 dataset, which might be explained by the complex and diverse 3D structures of carbon.
175
+
176
+ # 6 CONCLUSIONS AND OUTLOOK
177
+
178
+ We have introduced a Crystal Diffusion Variational Autoencoder (CDVAE) to generate the periodic structure of stable materials and demonstrated that it significantly outperforms past methods on the tasks of reconstruction, generation, and property optimization. We note that the last two tasks are far more important for material design than reconstruction because they can be directly used to generate new materials whose properties can then be verified by QM simulations and experiments. We believe CDVAE opens up exciting opportunities for the inverse design of materials for various important applications. Meanwhile, our model is just a first step towards the grand challenge of material design. We provide our datasets and evaluation metrics to the broader machine learning community to collectively develop better methods for the task of material generation.
179
+
180
+ # REPRODUCIBILITY STATEMENT
181
+
182
+ We have made the following efforts to ensure reproducibility: 1) We provide our code at https:// github.com/txie-93/cdvae; 2)We provide our data and corresponding train/validation/test splits at https://github.com/txie-93/cdvae/tree/main/data; 3) We provide details on experimental configurations in Appendix D.
183
+
184
+ # ACKNOWLEDGMENTS
185
+
186
+ We thank Peter Mikhael, Jason Yim, Rachel Wu, Bracha Laufer, Gabriele Corso, Felix Faltings, Bowen Jing, and the rest of the RB and TJ group members for their helpful comments and suggestions. The authors gratefully thank DARPA (HR00111920025), the consortium Machine Learning for Pharmaceutical Discovery and Synthesis (mlpds.mit.edu), and MIT-GIST collaboration for support.
187
+
188
+ # REFERENCES
189
+
190
+ Alec Belsky, Mariette Hellenbrandt, Vicky Lynn Karen, and Peter Luksch. New developments in the inorganic crystal structure database (icsd): accessibility in support of materials research and design. Acta Crystallographica Section B: Structural Science, 58(3):364–369, 2002. 1, 16
191
+
192
+ Keith T Butler, Daniel W Davies, Hugh Cartwright, Olexandr Isayev, and Aron Walsh. Machine learning for molecular and materials science. Nature, 559(7715):547–555, 2018. 1
193
+
194
+ Ruojin Cai, Guandao Yang, Hadar Averbuch-Elor, Zekun Hao, Serge Belongie, Noah Snavely, and Bharath Hariharan. Learning gradient fields for shape generation. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part III 16, pp. 364–381. Springer, 2020. 4
195
+
196
+ Ivano E Castelli, David D Landis, Kristian S Thygesen, Søren Dahl, Ib Chorkendorff, Thomas F Jaramillo, and Karsten W Jacobsen. New cubic perovskites for one-and two-photon water splitting using the computational materials repository. Energy & Environmental Science, 5(10):9034– 9043, 2012a. 6, 16
197
+
198
+ Ivano E Castelli, Thomas Olsen, Soumendu Datta, David D Landis, Søren Dahl, Kristian S Thygesen, and Karsten W Jacobsen. Computational screening of perovskite metal oxides for optimal solar light capture. Energy & Environmental Science, 5(2):5814–5819, 2012b. 6, 16
199
+
200
+ Lowik Chanussot, Abhishek Das, Siddharth Goyal, Thibaut Lavril, Muhammed Shuaibi, Morgane Riviere, Kevin Tran, Javier Heras-Domingo, Caleb Ho, Weihua Hu, et al. Open catalyst 2020 (oc20) dataset and community challenges. ACS Catalysis, 11(10):6059–6072, 2021. 2, 15
201
+
202
+ Chi Chen and Shyue Ping Ong. A universal graph deep learning interatomic potential for the periodic table. arXiv preprint arXiv:2202.02450, 2022. 3
203
+
204
+ Chi Chen, Weike Ye, Yunxing Zuo, Chen Zheng, and Shyue Ping Ong. Graph networks as a universal machine learning framework for molecules and crystals. Chemistry of Materials, 31(9):3564– 3572, 2019. 2
205
+
206
+ Callum J Court, Batuhan Yildirim, Apoorv Jain, and Jacqueline M Cole. 3-d inorganic crystal structure generation and property prediction via representation learning. Journal of chemical information and modeling, 60(10):4518–4535, 2020. 2, 6, 7, 8
207
+
208
+ Yabo Dan, Yong Zhao, Xiang Li, Shaobo Li, Ming Hu, and Jianjun Hu. Generative adversarial networks (gan) based efficient sampling of chemical composition space for inverse design of inorganic materials. npj Computational Materials, 6(1):1–7, 2020. 3
209
+
210
+ Daniel W Davies, Keith T Butler, Adam J Jackson, Jonathan M Skelton, Kazuki Morita, and Aron Walsh. Smact: Semiconducting materials by analogy and chemical theory. Journal of Open Source Software, 4(38):1361, 2019. 8, 16
211
+
212
+ Volker L Deringer, Chris J Pickard, and Gabor Cs ´ anyi. Data-driven learning of total and local ´ energies in elemental boron. Physical review letters, 120(15):156001, 2018. 3
213
+
214
+ Prafulla Dhariwal and Alex Nichol. Diffusion models beat gans on image synthesis. arXiv preprint arXiv:2105.05233, 2021. 4
215
+
216
+ Fabian Fuchs, Daniel E. Worrall, Volker Fischer, and Max Welling. Se(3)-transformers: 3d rototranslation equivariant attention networks. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and Hsuan-Tien Lin (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020. URL https://proceedings.neurips.cc/ paper/2020/hash/15231a7ce4ba789d13b722cc5c955834-Abstract.html. 2
217
+
218
+ Octavian-Eugen Ganea, Lagnajit Pattanaik, Connor W Coley, Regina Barzilay, Klavs F Jensen, William H Green, and Tommi S Jaakkola. Geomol: Torsional geometric generation of molecular 3d conformer ensembles. arXiv preprint arXiv:2106.07802, 2021. 8, 18
219
+
220
+ Niklas Gebauer, Michael Gastegger, and Kristof Schutt. Symmetry-adapted generation of 3d point ¨ sets for the targeted discovery of molecules. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alche-Buc, E. Fox, and R. Garnett (eds.), ´ Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. 3, 7
221
+
222
+ Niklas WA Gebauer, Michael Gastegger, Stefaan SP Hessmann, Klaus-Robert Muller, and Kristof T ¨ Schutt. Inverse design of 3d molecular structures with conditional generative neural networks.¨ arXiv preprint arXiv:2109.04824, 2021. 9
223
+
224
+ Colin W Glass, Artem R Oganov, and Nikolaus Hansen. Uspex—evolutionary crystal structure prediction. Computer physics communications, 175(11-12):713–720, 2006. 2
225
+
226
+ Jonathan Godwin, Michael Schaarschmidt, Alexander Gaunt, Alvaro Sanchez-Gonzalez, Yulia Rubanova, Petar Velickovi ˇ c, James Kirkpatrick, and Peter Battaglia. Very deep graph neural ´ networks via noise regularisation. arXiv preprint arXiv:2106.07971, 2021. 2
227
+
228
+ Ralf W Grosse-Kunstleve, Nicholas K Sauter, and Paul D Adams. Numerically stable algorithms for the computation of reduced unit cells. Acta Crystallographica Section A: Foundations of Crystallography, 60(1):1–6, 2004. 5, 15
229
+
230
+ Geoffroy Hautier, Chris Fischer, Virginie Ehrlacher, Anubhav Jain, and Gerbrand Ceder. Data mined ionic substitutions for the discovery of new compounds. Inorganic chemistry, 50(2):656–663, 2011. 2
231
+
232
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and HsuanTien Lin (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020. URL https://proceedings.neurips.cc/paper/2020/hash/ 4c5bcfec8584af0d967f1ab10179ca4b-Abstract.html. 4
233
+
234
+ Jordan Hoffmann, Louis Maestrati, Yoshihide Sawada, Jian Tang, Jean Michel Sellier, and Yoshua Bengio. Data-driven approach to encoding and decoding 3-d crystal structures. arXiv preprint arXiv:1909.00949, 2019. 2, 7
235
+
236
+ Jianjun Hu, Wenhui Yang, Rongzhi Dong, Yuxin Li, Xiang Li, Shaobo Li, and Edirisuriya MD Siriwardane. Contact map based crystal structure prediction using global optimization. CrystEngComm, 23(8):1765–1776, 2021. 3
237
+
238
+ John J Irwin and Brian K Shoichet. Zinc- a free database of commercially available compounds for virtual screening. Journal of chemical information and modeling, 45(1):177–182, 2005. 1
239
+
240
+ Anubhav Jain, Shyue Ping Ong, Geoffroy Hautier, Wei Chen, William Davidson Richards, Stephen Dacek, Shreyas Cholia, Dan Gunter, David Skinner, Gerbrand Ceder, et al. Commentary: The materials project: A materials genome approach to accelerating materials innovation. APL materials, 1(1):011002, 2013. 6, 16
241
+
242
+ Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Junction tree variational autoencoder for molecular graph generation. In International conference on machine learning, pp. 2323–2332. PMLR, 2018. 9
243
+
244
+ Sungwon Kim, Juhwan Noh, Geun Ho Gu, Alan Aspuru-Guzik, and Yousung Jung. Generative adversarial networks for crystal structure prediction. ACS central science, 6(8):1412–1420, 2020. 3
245
+
246
+ Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In Yoshua Bengio and Yann LeCun (eds.), 2nd International Conference on Learning Representations, ICLR 2014, Banff, AB, Canada, April 14-16, 2014, Conference Track Proceedings, 2014. URL http://arxiv.org/ abs/1312.6114. 2, 5
247
+
248
+ Johannes Klicpera, Shankari Giri, Johannes T Margraf, and Stephan Gunnemann. Fast and ¨ uncertainty-aware directional message passing for non-equilibrium molecules. arXiv preprint arXiv:2011.14115, 2020a. 15
249
+
250
+ Johannes Klicpera, Janek Groß, and Stephan Gunnemann. Directional message passing for molec- ¨ ular graphs. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020b. URL https://openreview. net/forum?id=B1eWbxStPH. 2, 15
251
+
252
+ Johannes Klicpera, Florian Becker, and Stephan Gunnemann. Gemnet: Universal directional graph ¨ neural networks for molecules. arXiv preprint arXiv:2106.08903, 2021. 2, 15
253
+
254
+ Zhifeng Kong and Wei Ping. On fast sampling of diffusion probabilistic models. arXiv preprint arXiv:2106.00132, 2021. 17
255
+
256
+ Meng Liu, Keqiang Yan, Bora Oztekin, and Shuiwang Ji. Graphebm: Molecular graph generation with energy-based models. arXiv preprint arXiv:2102.00546, 2021. 3
257
+
258
+ Teng Long, Nuno M Fortunato, Ingo Opahle, Yixuan Zhang, Ilias Samathrakis, Chen Shen, Oliver Gutfleisch, and Hongbin Zhang. Constrained crystals deep convolutional generative adversarial network for the inverse design of crystal structures. npj Computational Materials, 7(1):1–7, 2021. 2
259
+
260
+ Shitong Luo and Wei Hu. Diffusion probabilistic models for 3d point cloud generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2837–2845, 2021. 4
261
+
262
+ Youzhi Luo, Keqiang Yan, and Shuiwang Ji. Graphdf: A discrete flow model for molecular graph generation. arXiv preprint arXiv:2102.01189, 2021. 3
263
+
264
+ Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In International Conference on Machine Learning, pp. 8162–8171. PMLR, 2021. 17
265
+
266
+ Juhwan Noh, Jaehoon Kim, Helge S Stein, Benjamin Sanchez-Lengeling, John M Gregoire, Alan Aspuru-Guzik, and Yousung Jung. Inverse design of solid-state materials via a continuous representation. Matter, 1(5):1370–1384, 2019. 2
267
+
268
+ Artem R Oganov, Chris J Pickard, Qiang Zhu, and Richard J Needs. Structure prediction drives materials discovery. Nature Reviews Materials, 4(5):331–348, 2019. 2
269
+
270
+ M. O’Keeffe and B. G. Hyde. Plane nets in crystal chemistry. Philosophical Transactions of the Royal Society of London. Series A, Mathematical and Physical Sciences, 295(1417):553–618, 1980. ISSN 00804614. URL http://www.jstor.org/stable/36648. 3
271
+
272
+ Shyue Ping Ong, William Davidson Richards, Anubhav Jain, Geoffroy Hautier, Michael Kocher, Shreyas Cholia, Dan Gunter, Vincent L Chevrier, Kristin A Persson, and Gerbrand Ceder. Python materials genomics (pymatgen): A robust, open-source python library for materials analysis. Computational Materials Science, 68:314–319, 2013. 7, 15, 18
273
+
274
+ Hillary Pan, Alex M Ganose, Matthew Horton, Muratahan Aykol, Kristin A Persson, Nils ER Zimmermann, and Anubhav Jain. Benchmarking coordination number prediction algorithms on inorganic crystal structures. Inorganic chemistry, 60(3):1590–1603, 2021. 3, 15
275
+
276
+ Yashaswi Pathak, Karandeep Singh Juneja, Girish Varma, Masahiro Ehara, and U Deva Priyakumar. Deep learning enabled inorganic material generator. Physical Chemistry Chemical Physics, 22 (46):26935–26943, 2020. 3
277
+
278
+ Chris J. Pickard. Airss data for carbon at 10gpa and the $c + \mathrm { n + h + o }$ system at 1gpa, 2020. URL https://archive.materialscloud.org/record/2020.0026/v1. 6
279
+
280
+ Chris J Pickard and RJ Needs. High-pressure phases of silane. Physical review letters, 97(4):045504, 2006. 16
281
+
282
+ Chris J Pickard and RJ Needs. Ab initio random structure searching. Journal of Physics: Condensed Matter, 23(5):053201, 2011. 2, 16
283
+
284
+ Zekun Ren, Juhwan Noh, Siyu Tian, Felipe Oviedo, Guangzong Xing, Qiaohao Liang, Armin Aberle, Yi Liu, Qianxiao Li, Senthilnath Jayavelu, et al. Inverse design of crystals using generalized invertible crystallographic representation. arXiv preprint arXiv:2005.07609, 2020. 3, 6, 7, 16
285
+
286
+ Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. arXiv preprint arXiv:2202.00512, 2022. 17
287
+
288
+ Victor Garcia Satorras, Emiel Hoogeboom, Fabian B Fuchs, Ingmar Posner, and Max Welling. E (n) equivariant normalizing flows for molecule generation in 3d. arXiv preprint arXiv:2105.09016, 2021. 3
289
+
290
+ Yoshihide Sawada, Koji Morikawa, and Mikiya Fujii. Study of deep generative models for inorganic chemical compositions. arXiv preprint arXiv:1910.11499, 2019. 3
291
+
292
+ Kristof T Schutt, Huziel E Sauceda, P-J Kindermans, Alexandre Tkatchenko, and K-R M ¨ uller. ¨ Schnet–a deep learning architecture for molecules and materials. The Journal of Chemical Physics, 148(24):241722, 2018. 2, 7
293
+
294
+ Chence Shi, Minkai Xu, Zhaocheng Zhu, Weinan Zhang, Ming Zhang, and Jian Tang. Graphaf: a flow-based autoregressive model for molecular graph generation. arXiv preprint arXiv:2001.09382, 2020. 3
295
+
296
+ Chence Shi, Shitong Luo, Minkai Xu, and Jian Tang. Learning gradient fields for molecular conformation generation. In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, volume 139 of Proceedings of Machine Learning Research, pp. 9558–9568. PMLR, 2021. URL http://proceedings.mlr.press/v139/shi21b.html. 3, 4, 5, 17
297
+
298
+ Muhammed Shuaibi, Adeesh Kolluru, Abhishek Das, Aditya Grover, Anuroop Sriram, Zachary Ulissi, and C Lawrence Zitnick. Rotation invariant graph neural networks using spin convolutions. arXiv preprint arXiv:2106.09575, 2021. 2
299
+
300
+ Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pp. 2256–2265. PMLR, 2015. 4
301
+
302
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alche-Buc, Emily B. Fox, and Roman Garnett (eds.), ´ Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pp. 11895– 11907, 2019. URL https://proceedings.neurips.cc/paper/2019/hash/ 3001ef257407d5a371a96dcd947c7d93-Abstract.html. 2, 4, 5, 6
303
+
304
+ Nathaniel Thomas, Tess Smidt, Steven Kearnes, Lusann Yang, Li Li, Kai Kohlhoff, and Patrick Riley. Tensor field networks: Rotation-and translation-equivariant neural networks for 3d point clouds. arXiv preprint arXiv:1802.08219, 2018. 2
305
+
306
+ Yanchao Wang, Jian Lv, Li Zhu, and Yanming Ma. Calypso: A method for crystal structure prediction. Computer Physics Communications, 183(10):2063–2070, 2012. 2
307
+
308
+ Logan Ward, Ankit Agrawal, Alok Choudhary, and Christopher Wolverton. A general-purpose machine learning framework for predicting properties of inorganic materials. npj Computational Materials, 2(1):1–7, 2016. 18
309
+
310
+ Alexander Frank Wells et al. Three dimensional nets and polyhedra. Wiley, 1977. 3
311
+
312
+ Jiaxiang Wu, Tao Shen, Haidong Lan, Yatao Bian, and Junzhou Huang. Se (3)-equivariant energybased models for end-to-end protein folding. bioRxiv, 2021. 3
313
+
314
+ Tian Xie and Jeffrey C Grossman. Crystal graph convolutional neural networks for an accurate and interpretable prediction of material properties. Physical review letters, 120(14):145301, 2018. 1, 2, 3
315
+
316
+ Minkai Xu, Shitong Luo, Yoshua Bengio, Jian Peng, and Jian Tang. Learning neural generative dynamics for molecular conformation generation. In International Conference on Learning Representations, 2021a. URL https://openreview.net/forum?id=pAbm1qfheGk. 8, 18
317
+
318
+ Minkai Xu, Lantao Yu, Yang Song, Chence Shi, Stefano Ermon, and Jian Tang. Geodiff: A geometric diffusion model for molecular conformation generation. In International Conference on Learning Representations, 2021b. 3
319
+
320
+ Guandao Yang, Xun Huang, Zekun Hao, Ming-Yu Liu, Serge Belongie, and Bharath Hariharan. Pointflow: 3d point cloud generation with continuous normalizing flows. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 4541–4550, 2019. 9
321
+
322
+ Wenhui Yang, Edirisuriya M Dilanga Siriwardane, Rongzhi Dong, Yuxin Li, and Jianjun Hu. Crystal structure prediction of materials with high symmetry using differential evolution. arXiv preprint arXiv:2104.09764, 2021. 3
323
+
324
+ Yong Zhao, Mohammed Al-Fahdi, Ming Hu, Edirisuriya Siriwardane, Yuqi Song, Alireza Nasiri, and Jianjun Hu. High-throughput discovery of novel cubic crystal materials using deep generative neural networks. arXiv preprint arXiv:2102.01880, 2021. 3
325
+
326
+ Nils ER Zimmermann and Anubhav Jain. Local structure order parameters and site fingerprints for quantification of coordination environment and crystal structure similarity. RSC Advances, 10 (10):6063–6081, 2020. 18
327
+
328
+ # A PROOF FOR THE CONNECTION TO A HARMONIC FORCE FIELD
329
+
330
+ We assume the loss in Equation 2 can be minimized to zero when the noises are small, meaning that
331
+
332
+ $$
333
+ s _ { X } ( \tilde { A } , \tilde { X } , L | z ) = \frac { d _ { \operatorname* { m i n } } ( X , \tilde { X } ) } { \sigma _ { X , j } } , \forall j > J ,
334
+ $$
335
+
336
+ where $\sigma _ { { \pmb X } , j } \in \{ \sigma _ { { \pmb X } , j } \} _ { j = 1 } ^ { L }$ and any noise smaller than $\sigma _ { x , J }$ is considered as small.
337
+
338
+ The force term in the Langevin dynamics $\alpha _ { j } { \pmb s } _ { { \pmb X } , t }$ can then be written as
339
+
340
+ $$
341
+ \begin{array} { l } { \displaystyle \alpha _ { j } s _ { X } ( \tilde { A } , \tilde { X } , L | z ; \sigma _ { A , j } , \sigma _ { X , j } ) = \epsilon \cdot \sigma _ { X , j } ^ { 2 } / \sigma _ { X , L } ^ { 2 } \cdot s _ { X } ( \tilde { A } , \tilde { X } , L | z ) / \sigma _ { X , j } } \\ { \displaystyle \quad \quad = \epsilon \cdot \frac { \sigma _ { X , j } ^ { 2 } } { \sigma _ { X , L } ^ { 2 } } \cdot \frac { d _ { \operatorname* { m i n } } ( X , \tilde { X } ) } { \sigma _ { X , j } ^ { 2 } } , \forall j > J } \\ { \displaystyle \quad = - \frac { \epsilon } { \sigma _ { X , L } ^ { 2 } } d _ { \operatorname* { m i n } } ( \tilde { X } , X ) , \forall j > J } \end{array}
342
+ $$
343
+
344
+ If we write $\epsilon / \sigma _ { X , L } ^ { 2 } = k$ , then,
345
+
346
+ $$
347
+ \alpha _ { j } s _ { X } ( \tilde { A } , \tilde { X } , L | z ; \sigma _ { A , j } , \sigma _ { X , j } ) = - k d _ { \operatorname * { m i n } } ( \tilde { X } , X ) , \forall j > J
348
+ $$
349
+
350
+ If the noises are small enough that atoms do not cross the periodic boundaries, then we have ${ \pmb d } _ { \mathrm { m i n } } ( { \pmb X } , \tilde { { \pmb X } } ) = { \pmb X } - \tilde { { \pmb X } }$ . Therefore,
351
+
352
+ $$
353
+ \alpha _ { j } s _ { X } ( \tilde { A } , \tilde { X } , { \cal L } | z ; \sigma _ { A , j } , \sigma _ { X , j } ) = - k ( \tilde { X } - X ) , \forall j > J .
354
+ $$
355
+
356
+ # B IMPLEMENTATION DETAILS
357
+
358
+ # B.1 PREDICTION OF LATTICE PARAMETERS
359
+
360
+ There are infinitely many different ways of choosing the lattice for the same material. We compute the Niggli reduced lattice (Grosse-Kunstleve et al., 2004) with pymatgen (Ong et al., 2013), which is a unique lattice for any given material. Since the lattice matrix $\pmb { L }$ is not rotation invariant, we instead predict the 6 lattice parameters, i.e. the lengths of the 3 lattice vectors and the angles between them. We normalize the lengths of lattice vectors with $\sqrt [ 3 ] { N }$ , where $N$ is the number of atoms, to ensure that the lengths for materials of different sizes are at the same scale.
361
+
362
+ # B.2 MULTI-GRAPH CONSTRUCTION
363
+
364
+ For the encoder, we use CrystalNN (Pan et al., 2021) to determine edges between atoms and build a multi-graph representation. For the decoder, since it inputs a noisy structure generated on the fly, the multi-graph must also be built on the fly for both training and generation, and CrystalNN is too slow for that purpose. We use a KNN algorithm that considers periodicity to build the decoder graph where $K = \bar { 2 0 }$ in all of our experiments.
365
+
366
+ # B.3 GNN ARCHITECTURE
367
+
368
+ We use DimeNet+ $^ +$ adapted for periodicity (Klicpera et al., 2020a;b) as the encoder, which is SE(3) invariant to the input structure. The decoder needs to output an vector per node that is SE(3) equivariant to the input structure. We use GemNet-dQ (Klicpera et al., 2021) as the decoder. We used implementations from the Open Catalysis Project (OCP) (Chanussot et al., 2021), but we reduced the size of hidden dimensions to 128 for faster training. The encoder has 2.2 million parameters and the decoder has 2.3 million parameters.
369
+
370
+ # C DATASET CURATION
371
+
372
+ # C.1 PEROV-5
373
+
374
+ Perovskite is a class of materials that share a similar structure and have the general chemical formula $\mathrm { A B X } _ { 3 }$ . The ideal perovskites have a cubic structure, where the site A atom sits at a corner position, the site B atom sits at a body centered position and site $\mathrm { X }$ atoms sit at face centered positions. Perovskite materials are known for their wide applications. We curate the Perov-5 dataset from an open database that was originally developed for water splitting (Castelli et al., 2012a;b).
375
+
376
+ All 18928 materials in the original database are included. In the database, A, B can be any nonradioactive metal and X can be one or several elements from O, N, S, and F. Note that there can be multiple different X atoms in the same material. All materials in Perov-5 are relaxed using density functional theory (DFT), and their relaxed structure can deviate significantly from the ideal structures. A significant portion of the materials are not thermodynamically stable, i.e., they will decompose to nearby phases and cannot be synthesized.
377
+
378
+ # C.2 CARBON-24
379
+
380
+ Carbon-24 includes various carbon structures obtained via ab initio random structure searching (AIRSS) (Pickard & Needs, 2006; 2011) performed at $1 0 \mathrm { G P a }$ .
381
+
382
+ The original dataset includes 101529 carbon structures, and we selected the $10 \%$ of the carbon structure with the lowest energy per atom to create Carbon-24. All 10153 structures in Carbon-24 are relaxed using DFT. The most stable structure is diamond at $1 0 \mathrm { \ G P a }$ . All remaining structures are thermodynamically unstable but may be kinetically stable. Most of the structures cannot be synthesized.
383
+
384
+ # C.3 MP-20
385
+
386
+ MP-20 includes almost all experimentally stable materials from the Materials Project (Jain et al., 2013) with unit cells including at most 20 atoms. We only include materials that are originally from ICSD (Belsky et al., 2002) to ensure the experimental stability, and these materials represent the majority of experimentally known materials with at most 20 atoms in unit cells.
387
+
388
+ To ensure stability, we only select materials with energy above the hull smaller than 0.08 eV/atom and formation energy smaller than 2 eV/atom, following Ren et al. (2020). Differing from Ren et al. (2020), we do not constrain the number of unique elements per material. All materials in MP-20 are relaxed using DFT. Most materials are thermodynamcially stable and have been synthesized.
389
+
390
+ # D EXPERIMENT DETAILS
391
+
392
+ # D.1 REASONS FOR THE UNSUITABILITY OF SOME METRICS FOR SPECIFIC DATASETS
393
+
394
+ In Table 2, property statistics are computed by comparing the earth mover’s distance between the property distribution of generated materials and ground truth materials. So, they are not meaningful for ground truth data.
395
+
396
+ Materials in Perov-5 have the same structure, so it is not meaningful to require higher structure diversity.
397
+
398
+ Materials in Carbon-24 have the same composition (carbon), so it is not meaningful to require higher composition diversity. In addition, all models have $\sim 1 0 0 \%$ composition validity, so it is not compared in the table.
399
+
400
+ # D.2 COMPOSITION VALIDITY CHECKER
401
+
402
+ We modified the charge neutrality checker from SMACT (Davies et al., 2019) because the original checker is not suitable for alloys. The checker is based on a list of possible charges for each element and it checks if the material can be charge neutral by enumerating all possible charge combinations. However, it does not consider that metal alloys can be mixed with almost any combination. As a result, for materials composed of all metal elements, we always assume the composition is valid in our validity checker.
403
+
404
+ For the ground truth materials in MP-20, the original checker gives a composition validity of ${ \sim } 5 0 \%$ , which significantly underestimates the validity of MP-20 materials (because most of them are experimentally synthesizable and thus valid). Our checker gives a composition validity of ${ \sim } 9 0 \%$ , which is far more reasonable. We note again that these checkers are all empirical and the only high-fidelity evaluation of material stability requires QM simulations.
405
+
406
+ # D.3 NON-GAUSSIAN STATISTICAL STRUCTURE OF MATERIALS
407
+
408
+ The material datasets are usually biased towards certain material groups. For example, there are lots of lithium-containing materials in MP-20 because it started with battery research. We also find that our decoder tends to underfit the data distribution with a larger $\beta$ in Equation 9. We believe these observations indicate that the statistical structure of the ground truth materials are far from Gaussian. As a result, sampling from $\mathcal { N } ( 0 , 1 )$ may lead to out-of-distribution materials, which explains why our method tends to generate more elements per material than the ground truth.
409
+
410
+ # D.4 HYPERPARAMETERS AND TRAINING DETAILS
411
+
412
+ The total loss can be written as,
413
+
414
+ $$
415
+ { \mathcal { L } } = { \mathcal { L } } _ { \mathrm { A G G } } + { \mathcal { L } } _ { \mathrm { D E C } } + { \mathcal { L } } _ { \mathrm { K L } } = \lambda _ { \mathrm { c } } { \mathcal { L } } _ { \mathrm { c } } + \lambda _ { L } { \mathcal { L } } _ { L } + \lambda _ { N } { \mathcal { L } } _ { N } + \lambda _ { X } { \mathcal { L } } _ { X } + \lambda _ { A } { \mathcal { L } } _ { A } + \beta { \mathcal { L } } _ { \mathrm { K L } } .
416
+ $$
417
+
418
+ We aim to keep each loss term at a similar scale. For all three datasets, we use $\lambda _ { c } = 1 , \lambda _ { L } =$ $1 0 , \lambda _ { N } = 1 , \lambda _ { X } = 1 0 , \mathcal { L } _ { A } = 1$ .
419
+
420
+ We tune $\beta$ between $0 . 0 1 , 0 . 0 3 , 0 . 1$ for all three datasets and select the model with best validation loss. For Perov-5, MP-20, we use $\beta = 0 . 0 1$ , and for Carbon-24, we use $\beta = 0 . 0 3$ .
421
+
422
+ For the noise levels in $\{ \sigma _ { A , j } \} _ { j = 1 } ^ { L } , \{ \sigma _ { X , j } \} _ { j = 1 } ^ { L }$ , we follow Shi et al. (2021) and set $L = 5 0$ . For all three datasets, we use $\sigma _ { A , \operatorname* { m a x } } = 5 , \sigma _ { A , \operatorname* { m i n } } = 0 . 0 1 , \sigma _ { X , \operatorname* { m a x } } = 1 0 , \sigma _ { X , \operatorname* { m i n } } = 0 . 0 1$ .
423
+
424
+ During the training, we use an initial learning rate of 0.001 and reduce the learning rate by a factor of 0.6 if the validation loss does not improve after 30 epochs. The minimum learning rate is 0.0001.
425
+
426
+ During the generation, we use $\epsilon = 0 . 0 0 0 1$ and run Langevin dynamics for 100 steps at each noise level.
427
+
428
+ # E VISUALIZATION OF MULTIPLE RECONSTRUCTED STRUCTURES
429
+
430
+ ![](images/014198feed124d83196e3770da4948847d47fbbe02a6692b9c0aeb6b4b8e0a13.jpg)
431
+ Figure 5: Different reconstructed structures from CDVAE from the same $_ { z }$ , following 3 Langevin dynamics sampling with different random seeds.
432
+
433
+ # F SAMPLING SPEED FOR MATERIAL GENERATION
434
+
435
+ We summarize the speed for generating 10,000 materials for all models in Table 4. FTCP is significantly faster, but the quality of generated materials is very poor as shown in Table 2. CondDFC-VAE is faster than our method in Perov-5, but has a lower quality than our method and only works for cubic systems. It is also unclear how it will perform on larger materials in Carbon-24 and MP-20, because the compute increases cubicily with the increased size of the density map. GSchNet/P-G-SchNet have a comparable sampling time as our method, but have a lower quality. We also note that we did not optimize sampling speed in current work. It is possible to reduce sampling time by using fewer sampling steps without significantly influencing generation quality. There are also many recent works that aim to speed up the sampling process for diffusion models (Nichol & Dhariwal, 2021; Kong & Ping, 2021; Salimans & Ho, 2022).
436
+
437
+ Table 4: Time used for generating 10,000 materials on a single RTX 2080 Ti GPU.
438
+
439
+ <table><tr><td></td><td>FTCP</td><td>Cond-DFC-VAE</td><td>G-SchNet</td><td>P-G-SchNet</td><td>CDVAE</td></tr><tr><td>Perov-5</td><td>&lt;1min</td><td>0.5h</td><td>2.0h</td><td>2.0h</td><td>3.1 h</td></tr><tr><td>Carbon-24</td><td>&lt;1min</td><td>1</td><td>6.2 h</td><td>6.3h</td><td>5.3 h</td></tr><tr><td>MP-20</td><td>&lt;1min</td><td>1</td><td>6.3 h</td><td>6.3h</td><td>5.8h</td></tr></table>
440
+
441
+ # G COVERAGE METRICS FOR MATERIAL GENERATION
442
+
443
+ Inspired by $\mathrm { X u }$ et al. (2021a); Ganea et al. (2021), we define six metrics to compare two ensembles of materials: materials generated by a method $\{ M _ { k } \} _ { k \in [ 1 \ldots K ] }$ , and ground truth materials in test data $\{ M _ { l } ^ { * } \} _ { \in [ 1 \ldots L ] }$ .
444
+
445
+ We use the Euclidean distance of the CrystalNN fingerprint (Zimmermann & Jain, 2020) and normalized Magpie fingerprint (Ward et al., 2016) to define the structure distance and composition distance between generated and ground truth materials, respectively. They can be written as $D _ { \mathrm { s t r u c . } } ( M _ { k } , M _ { l } ^ { * } )$ and $\cdot \mathrm { \Delta } D _ { \mathrm { c o m p . } } ( M _ { k } , \bar { M } _ { l } ^ { * } )$ . We further define the thresholds for the structure and composition distance as $\delta _ { \mathrm { s t r u c } }$ . and $\delta _ { \mathrm { c o m p . } }$ ., respectively.
446
+
447
+ Following the established classification metrics of Precision and Recall, we define the coverage metrics as:
448
+
449
+ $$
450
+ \begin{array} { r l } & { \quad \mathrm { C O V - R } \mathrm { ( R e c a l l ) } = \displaystyle \frac { 1 } { L } | \{ l \in [ 1 . . L ] : \exists k \in [ 1 . . K ] , D _ { \mathrm { s t r u c . } } ( M _ { k } , M _ { l } ^ { * } ) < \delta _ { \mathrm { s t r u c . } } , } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad D _ { \mathrm { c o m p . } } ( M _ { k } , M _ { l } ^ { * } ) < \delta _ { \mathrm { c o m p . } } \} } \\ & { \quad \quad \quad \mathrm { A M S D - R } \mathrm { ( R e c a l l ) } = \displaystyle \frac { 1 } { L } \sum _ { l \in [ 1 . . L ] } \operatorname* { m i n } _ { k \in [ 1 . . K ] } D _ { \mathrm { s t r u c . } } ( M _ { k } , M _ { l } ^ { * } ) } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \mathrm { A M C D - R } \mathrm { ( R e c a l l ) } = \displaystyle \frac { 1 } { L } \sum _ { l \in [ 1 . . L ] } \operatorname* { m i n } _ { k \in [ 1 . . K ] } D _ { \mathrm { c o m p . } } ( M _ { k } , M _ { l } ^ { * } ) , } \end{array}
451
+ $$
452
+
453
+ where COV is ”Coverage”, AMSD is ”Average Minimum Structure Distance”, AMCD is ”Average Minimum Composition Distance”, and COV-P (precision), AMSD-P (precision), AMCD-P (precision) are defined as in above equations, but with the generated and ground truth material sets swapped. The recall metrics measure how many ground truth materials are correctly predicted, while the precision metrics measure how many generated materials are of high quality (more discussions can be found in Ganea et al. (2021)).
454
+
455
+ We note several points on why we define the metrics in their current forms. 1) COV requires both structure and composition distances to be within the thresholds, because generating materials that are structurally close to one ground truth material and compositionally close to another is not meaningful. As a result, AMSD and AMCD are less useful than COV. 2) We use fingerprint distance, rather than RMSE from StructureMatcher (Ong et al., 2013), because the material space is too large for the models to generate enough materials to exactly match the ground truth materials. StructureMatcher first requires the compositions of two materials to exactly match, which will cause all models to have close-to-zero coverage.
456
+
457
+ For Perov-5 and Carbon-24, we choose $\delta _ { \mathrm { s t r u c . } } = 0 . 2 , \delta _ { \mathrm { c o m p . } } = 4$ . For MP-20, we choose $\delta _ { \mathrm { s t r u c . } } =$ $0 . 4 , \delta _ { \mathrm { c o m p . } } = 1 0$ . In Figure 6, Figure 7, Figure 8, we show how both COV-R and COV-P change by varying $\bar { \delta } _ { \mathrm { s t r u c } }$ . and $\delta _ { \mathrm { c o m p } }$ . in all three datasets.
458
+
459
+ Table 5: Full coverage metrics for the generation task.
460
+
461
+ <table><tr><td>Method</td><td>Data</td><td>COV-R↑</td><td>AMSD-R↓</td><td>AMCD-R↓</td><td>COV-P↑</td><td>AMSD-P↓</td><td>AMCD-P↓</td></tr><tr><td rowspan="3">FTCP</td><td>Perov-5</td><td>0.00</td><td>0.7447</td><td>7.212</td><td>0.00</td><td>0.3582</td><td>3.390</td></tr><tr><td>Carbon-24</td><td>0.00</td><td>1.181</td><td>0.00</td><td>0.00</td><td>0.8822</td><td>24.16</td></tr><tr><td>MP-20</td><td>4.72</td><td>0.6542</td><td>9.271</td><td>0.09</td><td>0.1954</td><td>4.378</td></tr><tr><td>Cond-DFC-VAE</td><td>Perov-5</td><td>73.92</td><td>0.1508</td><td>2.773</td><td>10.13</td><td>0.3162</td><td>4.257</td></tr><tr><td rowspan="4">G-SchNet</td><td>Perov-5</td><td>0.18</td><td>0.5962</td><td>1.006</td><td>0.23</td><td>0.4259</td><td>1.3163</td></tr><tr><td>Carbon-24</td><td>0.00</td><td>0.5887</td><td>0.00</td><td>0.00</td><td>0.5970</td><td>0.00</td></tr><tr><td>MP-20</td><td>38.33</td><td>0.5365</td><td>3.233</td><td>99.57</td><td>0.2026</td><td>3.601</td></tr><tr><td>Perov-5</td><td>0.37</td><td>0.5510</td><td>1.0264</td><td>0.25</td><td>0.3967</td><td>1.316</td></tr><tr><td rowspan="4">CDVAE</td><td>Carbon-24</td><td>0.00</td><td>0.6308</td><td>0.00</td><td>0.00</td><td>0.8166</td><td>0.00</td></tr><tr><td>MP-20</td><td>41.93</td><td>0.5327</td><td>3.274</td><td>99.74</td><td>0.1985</td><td>3.567</td></tr><tr><td>Perov-5</td><td>99.45</td><td>0.0482</td><td>0.6969</td><td>98.46</td><td>0.0593</td><td>1.272</td></tr><tr><td>Carbon-24</td><td>99.80</td><td>0.0489</td><td>0.00</td><td>83.08</td><td>0.1343</td><td>0.00</td></tr><tr><td></td><td>MP-20</td><td>99.15</td><td>0.1549</td><td>3.621</td><td>99.49</td><td>0.1883</td><td>4.014</td></tr></table>
462
+
463
+ ![](images/df4a9ab8291867bf7d43b05e7e5021163cda44e434b159383cce5c820edc7a42.jpg)
464
+ Figure 6: Change of COV-R and COV-P by varying $\delta _ { \mathrm { s t r u c } }$ . and $\delta _ { \mathrm { c o m p } }$ . for Perov-5. Dashed line denotes the current chosen thresholds.
465
+
466
+ ![](images/3565eef4857703cd54d2fbd09011c227cb6f03ede855b110cc9ce720c5b6f647.jpg)
467
+ Figure 7: Change of COV-R and COV-P by varying $\delta _ { \mathrm { s t r u c } }$ . and $\delta _ { \mathrm { c o m p } }$ . for Carbon-24. Dashed line denotes the current chosen thresholds.
468
+
469
+ ![](images/c2b820bf4f97c03bb50f377af925aea32bca53720d95774535f0d070c0d563f2.jpg)
470
+ Figure 8: Change of COV-R and COV-P by varying $\delta _ { \mathrm { s t r u c } }$ . and $\delta _ { \mathrm { c o m p } }$ . for MP-20. Dashed line denotes the current chosen thresholds.
md/dev/08Yk-n5l2Al/08Yk-n5l2Al.md ADDED
@@ -0,0 +1,372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Photorealistic Text-to-Image Diffusion Models with Deep Language Understanding
2
+
3
+ # Chitwan Saharia∗, William Chan∗, Saurabh Saxena†, Lala Li†, Jay Whang†, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S. Sara Mahdavi, Raphael Gontijo-Lopes, Tim Salimans, Jonathan Ho†, David J Fleet†‡, Mohammad Norouzi∗
4
+
5
+ {sahariac,williamchan,mnorouzi}@google.com {srbs,lala,jwhang,jonathanho,davidfleet}@google.com
6
+
7
+ Google Research, Brain Team Toronto, Ontario, Canada
8
+
9
+ # Abstract
10
+
11
+ We present Imagen, a text-to-image diffusion model with an unprecedented degree of photorealism and a deep level of language understanding. Imagen builds on the power of large transformer language models in understanding text and hinges on the strength of diffusion models in high-fidelity image generation. Our key discovery is that generic large language models (e.g. T5), pretrained on text-only corpora, are surprisingly effective at encoding text for image synthesis: increasing the size of the language model in Imagen boosts both sample fidelity and image-text alignment much more than increasing the size of the image diffusion model. Imagen achieves a new state-of-the-art FID score of 7.27 on the COCO dataset, without ever training on COCO, and human raters find Imagen samples to be on par with the COCO data itself in image-text alignment. To assess text-to-image models in greater depth, we introduce DrawBench, a comprehensive and challenging benchmark for text-to-image models. With DrawBench, we compare Imagen with recent methods including VQ-GAN $^ +$ CLIP, Latent Diffusion Models, GLIDE and DALL-E 2, and find that human raters prefer Imagen over other models in side-by-side comparisons, both in terms of sample quality and image-text alignment.
12
+
13
+ # 1 Introduction
14
+
15
+ Multimodal learning has come into prominence recently, with text-to-image synthesis [55, 12, 59] and image-text contrastive learning [51, 32, 77] at the forefront. These models have transformed the research community and captured widespread public attention with creative image generation [22, 56] and editing applications [21, 43, 36]. To pursue this research direction further, we introduce Imagen, a text-to-image diffusion model that combines the power of transformer language models (LMs) [15, 54] with high-fidelity diffusion models [28, 29, 16, 43] to deliver an unprecedented degree of photorealism and a deep level of language understanding in text-to-image synthesis. In contrast to prior work that uses only image-text data for model training [e.g., 55, 43], the key finding behind Imagen is that text embeddings from large LMs [54, 15], pretrained on text-only corpora, are remarkably effective for text-to-image synthesis. See Fig. 1 for select samples.
16
+
17
+ Imagen comprises a frozen T5-XXL [54] encoder to map input text into a sequence of embeddings and a $6 4 { \times } 6 4$ image diffusion model, followed by two super-resolution diffusion models for generating
18
+
19
+ ![](images/0ff9e780ce44befdb2c77a49a7ce0086b5f308273c92ede52962e1ab8b00c749.jpg)
20
+ Sprouts in the shape of text ‘Imagen’ coming out of a fairytale book.
21
+
22
+ ![](images/a90d2875f0f71a7880a4f9999f2959e6b84d99379874084fa1d032099b85aa10.jpg)
23
+ A photo of a Shiba Inu dog with a backpack riding a bike. It is wearing sunglasses and a beach hat.
24
+
25
+ ![](images/3c198b3eadeb94945246663ef4c6dae0b989e7d97952f7ea2332f3dd947bcde4.jpg)
26
+ A high contrast portrait of a very happy fuzzy panda dressed as a chef in a high end kitchen making dough. There is a painting of flowers on the wall behind him.
27
+
28
+ ![](images/48b8a8522a41cc9c73e62e7f2ef771576bd5ac051adf46b5d65ced3cc02a49c2.jpg)
29
+ Teddy bears swimming at the Olympics $4 0 0 \mathrm { m }$ Butterfly event.
30
+
31
+ ![](images/33f07cefc0579a8976e7d3fbc51c35dce1587f32c88f4a9b37bb99ad93d694af.jpg)
32
+ A cute corgi lives in a house made out of sushi.
33
+
34
+ ![](images/3c999c04be104204ac5db8d506fc8543bd0ddabd898e52be09dbdeed78969e1b.jpg)
35
+ A cute sloth holding a small treasure chest. A bright golden glow is coming from the chest.
36
+
37
+ ![](images/b389ccbd42808c75b83b8659d3c6c74986ebf665df48de4d72c8459bdaa64aec.jpg)
38
+
39
+ ![](images/d8c08f121dd94ec09f2a8e0ac7013aa4c8f7b7d8cfaa8cc36770a78f2e927d33.jpg)
40
+ A dragon fruit wearing karate belt in the snow.
41
+
42
+ ![](images/88f4635cd39ea7c005b308b126b0c8dca5d983c580eb7850d54a9a7d381ab46d.jpg)
43
+ A strawberry mug filled with white sesame seeds. The mug is floating in a dark chocolate sea.
44
+
45
+ A brain riding a rocketship heading towards the moon.
46
+
47
+ Figure 1: Select $1 0 2 4 \times 1 0 2 4$ Imagen samples for various text inputs. We only include photorealistic images in this figure and leave artistic content to the Appendix, since generating photorealistic images is more challenging from a technical point of view. Figs. A.1 to A.3 show more samples.
48
+
49
+ $2 5 6 \times 2 5 6$ and $1 0 2 4 \times 1 0 2 4$ images (see Fig. A.4). All diffusion models are conditioned on the text embedding sequence and use classifier-free guidance [27]. Imagen relies on new sampling techniques to allow usage of large guidance weights without sample quality degradation observed in prior work, resulting in images with higher fidelity and better image-text alignment than previously possible.
50
+
51
+ While conceptually simple and easy to train, Imagen yields surprisingly strong results. Imagen outperforms other methods on COCO [38] with zero-shot FID-30K of 7.27, significantly outperforming prior work such as GLIDE [43] (at 12.4) and the concurrent work of DALL-E 2 [56] (at 10.4). Our zero-shot FID score is also better than state-of-the-art models trained on COCO, e.g., Make-A-Scene [22] (at 7.6). Additionally, human raters indicate that generated samples from Imagen are on-par in image-text alignment to the reference images on COCO captions.
52
+
53
+ We introduce DrawBench, a new structured suite of text prompts for text-to-image evaluation. DrawBench enables deeper insights through a multi-dimensional evaluation of text-to-image models, with text prompts designed to probe different semantic properties of models. These include compositionality, cardinality, spatial relations, the ability to handle complex text prompts or prompts with rare words, and they include creative prompts that push the limits of models’ ability to generate highly implausible scenes well beyond the scope of the training data. With DrawBench, extensive human evaluation shows that Imagen outperforms other recent methods [59, 12, 56] by a significant margin. We further demonstrate some of the clear advantages of the use of large pre-trained language models [54] over multi-modal embeddings such as CLIP [51] as a text encoder for Imagen.
54
+
55
+ Key contributions of the paper include:
56
+
57
+ 1. We discover that large frozen language models trained only on text data are surprisingly very effective text encoders for text-to-image generation, and that scaling the size of frozen text encoder improves sample quality significantly more than scaling the size of image diffusion model.
58
+ 2. We introduce dynamic thresholding, a new diffusion sampling technique to leverage high guidance weights and generating more photorealistic and detailed images than previously possible.
59
+ 3. We highlight several important diffusion architecture design choices and propose Efficient U-Net, a new architecture variant which is simpler, converges faster and is more memory efficient.
60
+ 4. We achieve a new state-of-the-art COCO FID of 7.27. Human raters find Imagen to be on-par with the reference images in terms of image-text alignment.
61
+ 5. We introduce DrawBench, a new comprehensive and challenging evaluation benchmark for the text-to-image task. On DrawBench human evaluation, we find Imagen to outperform all other work, including the concurrent work of DALL-E 2 [56].
62
+
63
+ # 2 Imagen
64
+
65
+ Imagen consists of a text encoder that maps text to a sequence of embeddings and a cascade of conditional diffusion models that map these embeddings to images of increasing resolutions (see Fig. A.4). In the following subsections, we describe each of these components in detail.
66
+
67
+ # 2.1 Pretrained text encoders
68
+
69
+ Text-to-image models need powerful semantic text encoders to capture the complexity and compositionality of arbitrary natural language text inputs. Text encoders trained on paired image-text data are standard in current text-to-image models; they can be trained from scratch [43, 55] or pretrained on image-text data [56] (e.g., CLIP [51]). The image-text training objectives suggest that these text encoders may encode visually semantic and meaningful representations especially relevant for the text-to-image generation task. Large language models can be another models of choice to encode text for text-to-image generation. Recent progress in large language models (e.g., BERT [15], GPT [49, 50, 7], T5 [54]) have led to leaps in textual understanding and generative capabilities. Language models are trained on text only corpus significantly larger than paired image-text data, thus being exposed to a very rich and wide distribution of text. These models are also generally much larger than text encoders in current image-text models [51, 32, 83] (e.g. PaLM [11] has 540B parameters, while CoCa [83] has a $\approx 1 \mathbf { B }$ parameter text encoder).
70
+
71
+ It thus becomes natural to explore both families of text encoders for the text-to-image task. Imagen explores pretrained text encoders: BERT [15], T5 [53] and CLIP [48]. For simplicity, we freeze the weights of these text encoders. Freezing has several advantages such as offline computation of embeddings, resulting in negligible computation or memory footprint during training of the textto-image model. In our work, we find that there is a clear conviction that scaling the text encoder size improves the quality of text-to-image generation. We also find that while T5-XXL and CLIP text encoders perform similarly on simple benchmarks such as MS-COCO, human evaluators prefer T5-XXL encoders over CLIP text encoders in both image-text alignment and image fidelity on DrawBench, a set of challenging and compositional prompts. We refer the reader to Section 4.4 for summary of our findings, and Appendix D.1 for detailed ablations.
72
+
73
+ # 2.2 Diffusion models and classifier-free guidance
74
+
75
+ Here we give a brief introduction to diffusion models; a precise description is in Appendix A. Diffusion models [66, 28, 68] are a class of generative models that convert Gaussian noise into samples from a learned data distribution via an iterative denoising process. These models can be conditional, for example on class labels, text, or low-resolution images [e.g. 16, 29, 62, 61, 78, 43, 56]. A diffusion model $\hat { \mathbf { x } } _ { \theta }$ is trained on a denoising objective of the form
76
+
77
+ $$
78
+ \mathbb { E } _ { \mathbf { x } , \mathbf { c } , \epsilon , t } \Big [ w _ { t } \big \| \hat { \mathbf { x } } _ { \boldsymbol { \theta } } \big ( \alpha _ { t } \mathbf { x } + \sigma _ { t } \mathbf { \epsilon } , \mathbf { c } \big ) - \mathbf { x } \big \| _ { 2 } ^ { 2 } \Big ]
79
+ $$
80
+
81
+ where $\displaystyle ( \mathbf { x } , \mathbf { c } )$ are data-conditioning pairs, $t \sim \mathcal { U } ( [ 0 , 1 ] )$ , $\mathbf { \epsilon } \epsilon \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ , and $\alpha _ { t } , \sigma _ { t } , w _ { t }$ are functions of $t$ that influence sample quality. Intuitively, $\hat { \mathbf { x } } _ { \theta }$ is trained to denoise $\mathbf { z } _ { t } : = \alpha _ { t } \mathbf { x } + \sigma _ { t } \mathbf { \epsilon } \mathbf { \epsilon }$ into $\mathbf { x }$ using a squared error loss, weighted to emphasize certain values of $t$ . Sampling such as the ancestral sampler [28] and DDIM [67] start from pure noise ${ \bf z } _ { 1 } \sim \mathcal { N } ( { \bf 0 } , { \bf I } )$ and iteratively generate points $\mathbf { z } _ { t _ { 1 } } , \ldots , \mathbf { z } _ { t _ { T } }$ , where $1 = t _ { 1 } > \cdot \cdot \cdot > t _ { T } = 0$ , that gradually decrease in noise content. These points are functions of the $\mathbf { x }$ -predictions $\hat { \mathbf { x } } _ { 0 } ^ { t } : = \hat { \mathbf { x } } _ { \theta } ( \mathbf { z } _ { t } , \mathbf { c } )$ .
82
+
83
+ Classifier guidance [16] is a technique to improve sample quality while reducing diversity in conditional diffusion models using gradients from a pretrained model $p ( \mathbf { c } | \mathbf { z } _ { t } )$ during sampling. Classifierfree guidance [27] is an alternative technique that avoids this pretrained model by instead jointly training a single diffusion model on conditional and unconditional objectives via randomly dropping c during training (e.g. with $10 \%$ probability). Sampling is performed using the adjusted $\mathbf { x }$ -prediction $( \mathbf { z } _ { t } - \sigma \tilde { \epsilon } _ { \theta } ) / \alpha _ { t }$ , where
84
+
85
+ $$
86
+ \widetilde \epsilon _ { \theta } ( \mathbf { z } _ { t } , \mathbf { c } ) = w \epsilon _ { \theta } ( \mathbf { z } _ { t } , \mathbf { c } ) + ( 1 - w ) \epsilon _ { \theta } ( \mathbf { z } _ { t } ) .
87
+ $$
88
+
89
+ Here, $\epsilon _ { \theta } ( \mathbf { z } _ { t } , \mathbf { c } )$ and $\epsilon _ { \theta } ( { \mathbf { z } } _ { t } )$ are conditional and unconditional $\epsilon$ -predictions, given by $\boldsymbol { \epsilon } _ { \theta } : = ( \mathbf { z } _ { t } - $ $\alpha _ { t } \hat { \mathbf { x } } _ { \theta } ) / \sigma _ { t }$ , and $w$ is the guidance weight. Setting $w = 1$ disables classifier-free guidance, while increasing $w > 1$ strengthens the effect of guidance. Imagen depends critically on classifier-free guidance for effective text conditioning.
90
+
91
+ # 2.3 Large guidance weight samplers
92
+
93
+ We corroborate the results of recent text-guided diffusion work [16, 43, 56] and find that increasing the classifier-free guidance weight improves image-text alignment, but damages image fidelity producing highly saturated and unnatural images [27]. We find that this is due to a train-test mismatch arising from high guidance weights. At each sampling step $t$ , the $\mathbf { x }$ -prediction $\hat { \mathbf { x } } _ { 0 } ^ { t }$ must be within the same bounds as training data $\mathbf { x }$ , i.e. within $[ - 1 , 1 ]$ , but we find empirically that high guidance weights cause $\mathbf { x }$ -predictions to exceed these bounds. This is a train-test mismatch, and since the diffusion model is iteratively applied on its own output throughout sampling, the sampling process produces unnatural images and sometimes even diverges. To counter this problem, we investigate static thresholding and dynamic thresholding. See Appendix Fig. A.31 for reference implementation of the techniques and Appendix Fig. A.9 for visualizations of their effects.
94
+
95
+ Static thresholding: We refer to elementwise clipping the $\mathbf { x }$ -prediction to $[ - 1 , 1 ]$ as static thresholding. This method was in fact used but not emphasized in previous work [28], and to our knowledge its importance has not been investigated in the context of guided sampling. We discover that static thresholding is essential to sampling with large guidance weights and prevents generation of blank images. Nonetheless, static thresholding still results in over-saturated and less detailed images as the guidance weight further increases.
96
+
97
+ Dynamic thresholding: We introduce a new dynamic thresholding method: at each sampling step we set $s$ to a certain percentile absolute pixel value in $\hat { \mathbf { x } } _ { 0 } ^ { t }$ , and if $s > 1$ , then we threshold $\hat { \mathbf { x } } _ { 0 } ^ { t }$ to the range $[ - s , s ]$ and then divide by $s$ . Dynamic thresholding pushes saturated pixels (those near $^ { - 1 }$ and 1) inwards, thereby actively preventing pixels from saturation at each step. We find that dynamic thresholding results in significantly better photorealism as well as better image-text alignment, especially when using very large guidance weights.
98
+
99
+ # 2.4 Robust cascaded diffusion models
100
+
101
+ Imagen utilizes a pipeline of a base $6 4 \times 6 4$ model, and two text-conditional super-resolution diffusion models to upsample a $6 4 \times 6 4$ generated image into a $2 5 6 \times 2 5 6$ image, and then to $1 0 2 4 \times 1 0 2 4$ image. Cascaded diffusion models with noise conditioning augmentation [29] have been extremely effective in progressively generating high-fidelity images. Furthermore, making the super-resolution models aware of the amount of noise added, via noise level conditioning, significantly improves the sample quality and helps improving the robustness of the super-resolution models to handle artifacts generated by lower resolution models [29]. Imagen uses noise conditioning augmentation for both the super-resolution models. We find this to be a critical for generating high fidelity images.
102
+
103
+ Given a conditioning low-resolution image and augmentation level (a.k.a aug_level) (e.g., strength of Gaussian noise or blur), we corrupt the low-resolution image with the augmentation (corresponding to aug_level), and condition the diffusion model on aug_level. During training, aug_level is chosen randomly, while during inference, we sweep over its different values to find the best sample quality. In our case, we use Gaussian noise as a form of augmentation, and apply variance preserving Gaussian noise augmentation resembling the forward process used in diffusion models (Appendix A). The augmentation level is specified using aug_level $\in [ 0 , 1 ]$ . See Fig. A.32 for reference pseudocode.
104
+
105
+ # 2.5 Neural network architecture
106
+
107
+ Base model: We adapt the U-Net [60] architecture from [42] for our base $6 4 \times 6 4$ text-to-image diffusion model. The network is conditioned on text embeddings via a pooled embedding vector, added to the diffusion timestep embedding similar to the class embedding conditioning method used in [16, 29]. We further condition on the entire sequence of text embeddings by adding cross attention [59] over the text embeddings at multiple resolutions. We study various methods of text conditioning in Appendix D.3.1. Furthermore, we found Layer Normalization [2] for text embeddings in the attention and pooling layers to help considerably improve performance.
108
+
109
+ Super-resolution models: For $6 4 \times 6 4 2 5 6 \times 2 5 6$ super-resolution, we use the U-Net model adapted from [42, 61]. We make several modifications to this U-Net model for improving memory efficiency, inference time and convergence speed (our variant is $2 { - } 3 \mathbf { x }$ faster in steps/second over the U-Net used in [42, 61]). We call this variant Efficient $U$ -Net (See Appendix B.1 for more details and comparisons). Our $2 5 6 \times 2 5 6 \to 1 0 2 4 \times 1 0 2 4$ super-resolution model trains on $6 4 \times 6 4 2 5 6 \times 2 5 6$ crops of the $1 0 2 4 \times 1 0 2 4$ image. To facilitate this, we remove the self-attention layers, however we keep the text cross-attention layers which we found to be critical. During inference, the model receives the full $2 5 6 \times 2 5 6$ low-resolution images as inputs, and returns upsampled $1 0 2 4 \times 1 0 2 4$ images as outputs. Note that we use text cross attention for both our super-resolution models.
110
+
111
+ # 3 Evaluating Text-to-Image Models
112
+
113
+ The COCO [38] validation set is the standard benchmark for evaluating text-to-image models for both the supervised [85, 22] and the zero-shot setting [55, 43]. The key automated performance metrics used are FID [26] to measure image fidelity, and CLIP score [25, 51] to measure image-text alignment. Consistent with previous works, we report zero-shot FID-30K, for which 30K prompts are drawn randomly from the validation set, and the model samples generated on these prompts are compared with reference images from the full validation set. Since guidance weight is an important ingredient to control image quality and text alignment, we report most of our ablation results using trade-off (or pareto) curves between CLIP and FID scores across a range of guidance weights.
114
+
115
+ Both FID and CLIP scores have limitations, for example FID is not fully aligned with perceptual quality [44], and CLIP is ineffective at counting [51]. Due to these limitations, we use human evaluation to assess image quality and caption similarity, with ground truth reference caption-image pairs as a baseline. We use two experimental paradigms:
116
+
117
+ 1. To probe image quality, the rater is asked to select between the model generation and reference image using the question: “Which image is more photorealistic (looks more real)?”. We report the percentage of times raters choose model generations over reference images (the preference rate). 2. To probe alignment, human raters are shown an image and a prompt and asked “Does the caption accurately describe the above image?”. They must respond with “yes”, “somewhat”, or “no”. These responses are scored as 100, 50, and 0, respectively. These ratings are obtained independently for model samples and reference images, and both are reported.
118
+
119
+ ![](images/e328083f23f74118580db879b9e3d624adc72f98d21ca1febe6e5d55c2e915e6.jpg)
120
+ Figure 2: Non-cherry picked Imagen samples for different categories of prompts from DrawBench.
121
+
122
+ For both cases we use 200 randomly chosen image-caption pairs from the COCO validation set. Subjects were shown batches of 50 images. We also used interleaved “control" trials, and only include rater data from those who correctly answered at least $80 \%$ of the control questions. This netted 73 and 51 ratings per image for image quality and image-text alignment evaluations, respectively.
123
+
124
+ DrawBench: While COCO is a valuable benchmark, it is increasingly clear that it has a limited spectrum of prompts that do not readily provide insight into differences between models (e.g., see Sec. 4.2). Recent work by [10] proposed a new evaluation set called PaintSkills to systematically evaluate visual reasoning skills and social biases beyond COCO. With similar motivation, we introduce DrawBench, a comprehensive and challenging set of prompts that support the evaluation and comparison of text-to-image models. DrawBench contains 11 categories of prompts, testing different capabilities of models such as the ability to faithfully render different colors, numbers of objects, spatial relations, text in the scene, and unusual interactions between objects. Categories also include complex prompts, including long, intricate textual descriptions, rare words, and also misspelled prompts. We also include sets of prompts collected from DALL-E [55], Gary Marcus et al. [40] and Reddit. Across these 11 categories, DrawBench comprises 200 prompts in total, striking a good balance between the desire for a large, comprehensive dataset, and small enough that human evaluation remains feasible. (Appendix C provides a more detailed description of DrawBench. Fig. 2 shows example prompts from DrawBench with Imagen samples.)
125
+
126
+ We use DrawBench to directly compare different models. To this end, human raters are presented with two sets of images, one from Model A and one from Model B, each of which has 8 samples. Human raters are asked to compare Model A and Model B on sample fidelity and image-text alignment. They respond with one of three choices: Prefer Model A; Indifferent; or Prefer Model B.
127
+
128
+ # 4 Experiments
129
+
130
+ Section 4.1 describes training details, Sections 4.2 and 4.3 analyze results on MS-COCO and DrawBench, and Section 4.4 summarizes our ablation studies and key findings. For all experiments below, the images are fair random samples from Imagen with no post-processing or re-ranking.
131
+
132
+ # 4.1 Training details
133
+
134
+ Unless specified, we train a 2B parameter model for the $6 4 \times 6 4$ text-to-image synthesis, and $6 0 0 \mathbf { M }$ and 400M parameter models for $6 4 \times 6 4 2 5 6 \times 2 5 6$ and $2 5 6 \times 2 5 6 \to 1 0 2 4 \times 1 0 2 4$ for superresolution respectively. We use a batch size of 2048 and $2 . 5 \mathbf { M }$ training steps for all models. We use 256 TPU-v4 chips for our base $6 4 \times 6 4$ model, and 128 TPU-v4 chips for both super-resolution models. We do not find over-fitting to be an issue, and we believe further training might improve overall performance. We use Adafactor for our base $6 4 \times 6 4$ model, because initial comparisons with Adam suggested similar performance with much smaller memory footprint for Adafactor. For superresolution models, we use Adam as we found Adafactor to hurt model quality in our initial ablations. For classifier-free guidance, we joint-train unconditionally via zeroing out the text embeddings with $10 \%$ probability for all three models. We train on a combination of internal datasets, with $\approx 4 6 0 \mathrm { M }$ image-text pairs, and the publicly available LAION-400M dataset [64], with $\approx 4 0 0 { \mathrm { M } }$ image-text pairs. There are limitations in our training data, and we refer the reader to Section 6 for details. See Appendix F for more implementation details.
135
+
136
+ Table 1: MS-COCO $2 5 6 \times 2 5 6$ FID-30K. We use a guidance weight of 1.35 for our $6 4 \times 6 4$ model, and a guidance weight of 8.0 for our super-resolution model.
137
+
138
+ <table><tr><td>Model</td><td>FID-30K</td><td>Zero-shot FID-30K</td></tr><tr><td>AttnGAN [79]</td><td>35.49</td><td></td></tr><tr><td>DM-GAN [86]</td><td>32.64</td><td></td></tr><tr><td>DF-GAN[72]</td><td>21.42</td><td></td></tr><tr><td>DM-GAN + CL [81]</td><td>20.79</td><td></td></tr><tr><td>XMC-GAN [84]</td><td>9.33</td><td></td></tr><tr><td>LAFITE [85]</td><td>8.12</td><td></td></tr><tr><td>Make-A-Scene [22]</td><td>7.55</td><td></td></tr><tr><td>DALL-E [55]</td><td></td><td>17.89</td></tr><tr><td>LAFITE [85]</td><td></td><td>26.94</td></tr><tr><td>GLIDE [43]</td><td></td><td>12.24</td></tr><tr><td>DALL-E 2 [56]</td><td></td><td>10.39</td></tr><tr><td>Imagen (Our Work)</td><td></td><td>7.27</td></tr></table>
139
+
140
+ Table 2: COCO $2 5 6 \times 2 5 6$ human evaluation comparing model outputs and original images. For the bottom part (no people), we filter out prompts containing one of man, men, woman, women, person, people, child, adult, adults, boy, boys, girl, girls, guy, lady, ladies, someone, toddler, (sport) player, workers, spectators.
141
+
142
+ <table><tr><td>Model</td><td>Photorealism个</td><td>Alignment 个</td></tr><tr><td>Original</td><td></td><td></td></tr><tr><td>Original</td><td>50.0%</td><td>91.9 ± 0.42</td></tr><tr><td>Imagen</td><td>39.5 ± 0.75%</td><td>91.4 ± 0.44</td></tr><tr><td>No people</td><td></td><td></td></tr><tr><td>Original</td><td>50.0%</td><td>92.2 ± 0.54</td></tr><tr><td>Imagen</td><td>43.9 ± 1.01%</td><td>92.1 ± 0.55</td></tr></table>
143
+
144
+ # 4.2 Results on COCO
145
+
146
+ We evaluate Imagen on the COCO validation set using FID score, similar to [55, 43]. Table 1 displays the results. Imagen achieves state of the art zero-shot FID on COCO at 7.27, outperforming the concurrent work of DALL-E 2 [56] and even models trained on COCO. Table 2 reports the human evaluation to test image quality and alignment on the COCO validation set. We report results on the original COCO validation set, as well as a filtered version in which all reference data with people have been removed. For photorealism, Imagen achieves $3 9 . 2 \%$ preference rate indicating high image quality generation. On the set with no people, there is a boost in preference rate of Imagen to $4 3 . 6 \%$ , indicating Imagen’s limited ability to generate photorealistic people. On caption similarity, Imagen’s score is on-par with the original reference images, suggesting Imagen’s ability to generate images that align well with COCO captions.
147
+
148
+ # 4.3 Results on DrawBench
149
+
150
+ Using DrawBench, we compare Imagen with DALL-E 2 (the public version) [56], GLIDE [43], Latent Diffusion [59], and CLIP-guided VQ-GAN [12]. Fig. 3 shows the human evaluation results for pairwise comparison of Imagen with each of the three models. We report the percentage of time raters prefer Model A, Model B, or are indifferent for both image fidelity and image-text alignment. We aggregate the scores across all the categories and raters. We find the human raters to exceedingly prefer Imagen over all others models in both image-text alignment and image fidelity. We refer the reader to Appendix E for a more detailed category wise comparison and qualitative comparison.
151
+
152
+ # 4.4 Analysis of Imagen
153
+
154
+ For a detailed analysis of Imagen see Appendix D. Key findings are discussed in Fig. 4 and below.
155
+
156
+ Scaling text encoder size is extremely effective. We observe that scaling the size of the text encoder leads to consistent improvement in both image-text alignment and image fidelity. Imagen trained with our largest text encoder, T5-XXL (4.6B parameters), yields the best results (Fig. 4a).
157
+
158
+ ![](images/24ca4d3c7f8634c15f2022c2c074c1836017d293941e17dfb354ab14a41a4af6.jpg)
159
+ Figure 3: Comparison between Imagen and DALL-E 2 [56], GLIDE [43], VQ-GAN $^ +$ CLIP [12] and Latent Diffusion [59] on DrawBench: User preference rates (with $9 5 \%$ confidence intervals) for image-text alignment and image fidelity.
160
+
161
+ ![](images/ee8585b585ca243a7444cb527dbf9f45bfc630767909e6dd14978415c4a388c0.jpg)
162
+ Figure 4: Summary of some of the critical findings of Imagen with pareto curves sweeping over different guidance values. See Appendix D for more details.
163
+
164
+ Scaling text encoder size is more important than U-Net size. While scaling the size of the diffusion model U-Net improves sample quality, we found scaling the text encoder size to be significantly more impactful than the U-Net size (Fig. 4b).
165
+
166
+ Dynamic thresholding is critical. We show that dynamic thresholding results in samples with significantly better photorealism and alignment with text, over static or no thresholding, especially under the presence of large classifier-free guidance weights (Fig. 4c).
167
+
168
+ Human raters prefer T5-XXL over CLIP on DrawBench. The models trained with T5-XXL and CLIP text encoders perform similarly on the COCO validation set in terms of CLIP and FID scores. However, we find that human raters prefer T5-XXL over CLIP on DrawBench across all 11 categories.
169
+
170
+ Noise conditioning augmentation is critical. We show that training the super-resolution models with noise conditioning augmentation leads to better CLIP and FID scores. We also show that noise conditioning augmentation enables stronger text conditioning for the super-resolution model, resulting in improved CLIP and FID scores at higher guidance weights. Adding noise to the low-res image during inference along with the use of large guidance weights allows the super-resolution models to generate diverse upsampled outputs while removing artifacts from the low-res image.
171
+
172
+ Text conditioning method is critical. We observe that conditioning over the sequence of text embeddings with cross attention significantly outperforms simple mean or attention based pooling in both sample fidelity as well as image-text alignment.
173
+
174
+ Efficient U-Net is critical. Our Efficient U-Net implementation uses less memory, converges faster, and has better sample quality with faster inference.
175
+
176
+ # 5 Related Work
177
+
178
+ Diffusion models have seen wide success in image generation [28, 42, 62, 16, 29, 61], outperforming GANs in fidelity and diversity, without training instability and mode collapse issues [6, 16, 29]. Autoregressive models [39], GANs [79, 84], VQ-VAE Transformer-based methods [55, 22], and diffusion models have seen remarkable progress in text-to-image [59, 43, 59], including the concurrent
179
+
180
+ DALL-E 2 [56], which uses a diffusion prior on CLIP text latents and cascaded diffusion models to generate high resolution $1 0 2 4 \times 1 0 2 4$ images; we believe Imagen is much simpler, as Imagen does not need to learn a latent prior, yet achieves better results in both MS-COCO FID and human evaluation on DrawBench. GLIDE [43] also uses cascaded diffusion models for text-to-image, but we use large pretrained frozen language models, which we found to be instrumental to both image fidelity and image-text alignment. XMC-GAN [84] also uses BERT as a text encoder, but we scale to much larger text encoders and demonstrate the effectiveness thereof. The use of cascaded models is also popular throughout the literature [14, 41] and has been used with success in diffusion models to generate high resolution images [16, 29].
181
+
182
+ # 6 Conclusions, Limitations and Societal Impact
183
+
184
+ Imagen showcases the effectiveness of frozen large pretrained language models as text encoders for the text-to-image generation using diffusion models. Our observation that scaling the size of these language models have significantly more impact than scaling the U-Net size on overall performance encourages future research directions on exploring even bigger language models as text encoders. Furthermore, through Imagen we re-emphasize the importance of classifier-free guidance, and we introduce dynamic thresholding, which allows usage of much higher guidance weights than seen in previous works. With these novel components, Imagen produces $1 0 2 4 \times 1 0 2 4$ samples with unprecedented photorealism and alignment with text.
185
+
186
+ Our primary aim with Imagen is to advance research on generative methods, using text-to-image synthesis as a test bed. While end-user applications of generative methods remain largely out of scope, we recognize the potential downstream applications of this research are varied and may impact society in complex ways. On the one hand, generative models have a great potential to complement, extend, and augment human creativity [30]. Text-to-image generation models, in particular, have the potential to extend image-editing capabilities and lead to the development of new tools for creative practitioners. On the other hand, generative methods can be leveraged for malicious purposes, including harassment and misinformation spread [20], and raise many concerns regarding social and cultural exclusion and bias [70, 65, 71]. These considerations inform our decision to not to release code or a public demo. In future work we will explore a framework for responsible externalization that balances the value of external auditing with the risks of unrestricted open-access.
187
+
188
+ Another ethical challenge relates to the large scale data requirements of text-to-image models, which have have led researchers to rely heavily on large, mostly uncurated, web-scraped datasets. While this approach has enabled rapid algorithmic advances in recent years, datasets of this nature have been critiqued and contested along various ethical dimensions. For example, public and academic discourse regarding appropriate use of public data has raised concerns regarding data subject awareness and consent [24, 18, 63, 45]. Dataset audits have revealed these datasets tend to reflect social stereotypes, oppressive viewpoints, and derogatory, or otherwise harmful, associations to marginalized identity groups [46, 4]. Training text-to-image models on this data risks reproducing these associations and causing significant representational harm that would disproportionately impact individuals and communities already experiencing marginalization, discrimination and exclusion within society. As such, there are a multitude of data challenges that must be addressed before text-to-image models like Imagen can be safely integrated into user-facing applications. While we do not directly address these challenges in this work, an awareness of the limitations of our training data guide our decision not to release Imagen for public use. We strongly caution against the use text-to-image generation methods for any user-facing tools without close care and attention to the contents of the training dataset.
189
+
190
+ Imagen’s training data was drawn from several pre-existing datasets of image and English alt-text pairs. 400 million examples came from FIT400M, a cleaned version of the Alt-Text dataset [33, 31]. This data was filtered to removed noise and undesirable content, such as pornographic imagery and toxic language. However, a recent audit of another one of our data sources, LAION-400M [64], uncovered a wide range of inappropriate content including pornographic imagery, racist slurs, and harmful social stereotypes [4]. This finding informs our assessment that Imagen is not suitable for public use at this time and also demonstrates the value of rigorous dataset audits and comprehensive dataset documentation (e.g. [23, 47]) in informing consequent decisions about the model’s appropriate and safe use. Imagen also relies on text encoders trained on uncurated web-scale data, and thus inherits the social biases and limitations of large language models [5, 3, 52].
191
+
192
+ While we leave an in-depth empirical analysis of social and cultural biases encoded by Imagen to future work, our small scale internal assessments reveal several limitations that guide our decision not to release Imagen at this time. First, all generative models, including Imagen, Imagen, may run into danger of dropping modes of the data distribution, which may further compound the social consequence of dataset bias. Second, Imagen exhibits serious limitations when generating images depicting people. Our human evaluations found Imagen obtains significantly higher preference rates when evaluated on images that do not portray people, indicating a degradation in image fidelity. Finally, our preliminary assessment also suggests Imagen encodes several social biases and stereotypes, including an overall bias towards generating images of people with lighter skin tones and a tendency for images portraying different professions to align with Western gender stereotypes. Even when we focus generations away from people, our preliminary analysis indicates Imagen encodes a range of social and cultural biases when generating images of activities, events, and objects.
193
+
194
+ While there has been extensive work auditing image-to-text and image labeling models for forms of social bias (e.g. [8, 9, 71]), there has been comparatively less work on social bias evaluation methods for text-to-image models, with the recent exception of [10]. We believe this is a critical avenue for future research and we intend to explore benchmark evaluations for social and cultural bias in future work—for example, exploring whether it is possible to generalize the normalized pointwise mutual information metric [1] to the measurement of biases in image generation models. There is also a great need to develop a conceptual vocabulary around potential harms of text-to-image models that could guide the development of evaluation metrics and inform responsible model release. We aim to address these challenges in future work.
195
+
196
+ # 7 Acknowledgements
197
+
198
+ We give thanks to Ben Poole for reviewing our manuscript, early discussions, and providing many helpful comments and suggestions throughout the project. Special thanks to Kathy Meier-Hellstern, Austin Tarango, and Sarah Laszlo for helping us incorporate important responsible AI practices around this project. We appreciate valuable feedback and support from Elizabeth Adkison, Zoubin Ghahramani, Jeff Dean, Yonghui Wu, and Eli Collins. We are grateful to Tom Small for designing the Imagen watermark. We thank Jason Baldridge, Han Zhang, and Kevin Murphy for initial discussions and feedback. We acknowledge hard work and support from Fred Alcober, Hibaq Ali, Marian Croak, Aaron Donsbach, Tulsee Doshi, Toju Duke, Douglas Eck, Jason Freidenfelds, Brian Gabriel, Molly FitzMorris, David Ha, Philip Parham, Laura Pearce, Evan Rapoport, Lauren Skelly, Johnny Soraker, Negar Rostamzadeh, Vijay Vasudevan, Tris Warkentin, Jeremy Weinstein, and Hugh Williams for giving us advice along the project and assisting us with the publication process. We thank Victor Gomes and Erica Moreira for their consistent and critical help with TPU resource allocation. We also give thanks to Shekoofeh Azizi, Harris Chan, Chris A. Lee, and Nick Ma for volunteering a considerable amount of their time for testing out DrawBench. We thank Aditya Ramesh, Prafulla Dhariwal, and Alex Nichol for allowing us to use DALL-E 2 samples and providing us with GLIDE samples. We are thankful to Matthew Johnson and Roy Frostig for starting the JAX project and to the whole JAX team for building such a fantastic system for high-performance machine learning research. Special thanks to Durk Kingma, Jascha Sohl-Dickstein, Lucas Theis and the Toronto Brain team for helpful discussions and spending time Imagening!
199
+
200
+ # References
201
+
202
+ [1] Osman Aka, Ken Burke, Alex Bauerle, Christina Greer, and Margaret Mitchell. Measuring Model Biases in the Absence of Ground Truth. In Proceedings of the 2021 AAAI/ACM Conference on AI, Ethics, and Society, 2021.
203
+ [2] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
204
+ [3] Emily M. Bender, Timnit Gebru, Angelina McMillan-Major, and Shmargaret Shmitchell. On the dangers of stochastic parrots: Can language models be too big? . In Proceedings of FAccT 2021, 2021.
205
+ [4] Abeba Birhane, Vinay Uday Prabhu, and Emmanuel Kahembwe. Multimodal datasets: misogyny, pornography, and malignant stereotypes. In arXiv:2110.01963, 2021.
206
+
207
+ [5] Shikha Bordia and Samuel R. Bowman. Identifying and Reducing Gender Bias in Word-Level Language Models. In NAACL, 2017.
208
+
209
+ [6] Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. arXiv preprint arXiv:1809.11096, 2018.
210
+
211
+ [7] Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language Models are Few-Shot Learners. In NeurIPS, 2020.
212
+
213
+ [8] Joy Buolamwini and Timnit Gebru. Gender shades: Intersectional accuracy disparities in commercial gender classification. In Conference on Fairness, Accountability and Transparency, FAT 2018, 23-24 February 2018, New York, NY, USA, Proceedings of Machine Learning Research. PMLR, 2018.
214
+
215
+ [9] Kaylee Burns, Lisa Hendricks, Trevor Darrell, and Anna Rohrbach. Women also snowboard: Overcoming bias in captioning models. In European Conference on Computer Vision (ECCV), 2018.
216
+
217
+ [10] Jaemin Cho, Abhay Zala, and Mohit Bansal. Dall-eval: Probing the reasoning skills and social biases of text-to-image generative transformers. arxiv:2202.04053, 2022.
218
+
219
+ [11] Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. PaLM: Scaling Language Modeling with Pathways. In arXiv:2001.08361, 2022.
220
+
221
+ [12] Katherine Crowson, Stella Biderman, Daniel Kornis, Dashiell Stander, Eric Hallahan, Louis Castricato, and Edward Raff. Vqgan-clip: Open domain image generation and editing with natural language guidance. arXiv preprint arXiv:2204.08583, 2022.
222
+
223
+ [13] Valentin De Bortoli, James Thornton, Jeremy Heng, and Arnaud Doucet. Diffusion schrödinger bridge with applications to score-based generative modeling. Advances in Neural Information Processing Systems, 34, 2021.
224
+
225
+ [14] Emily Denton, Soumith Chintala, Arthur Szlam, and Rob Fergus. Deep Generative Image Models using a Laplacian Pyramid of Adversarial Networks. In NIPS, 2015.
226
+
227
+ [15] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In NAACL, 2019.
228
+
229
+ [16] Prafulla Dhariwal and Alex Nichol. Diffusion models beat gans on image synthesis. In NeurIPS, 2022.
230
+
231
+ [17] Ming Ding, Zhuoyi Yang, Wenyi Hong, Wendi Zheng, Chang Zhou, Da Yin, Junyang Lin, Xu Zou, Zhou Shao, Hongxia Yang, et al. Cogview: Mastering text-to-image generation via transformers. Advances in Neural Information Processing Systems, 34, 2021.
232
+
233
+ [18] Dulhanty, Chris. Issues in Computer Vision Data Collection: Bias, Consent, and Label Taxonomy. In UWSpace, 2020.
234
+
235
+ [19] Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12873–12883, 2021.
236
+
237
+ [20] Mary Anne Franks and Ari Ezra Waldman. Sex, lies and videotape: deep fakes and free speech delusions. Maryland Law Review, 78(4):892–898, 2019.
238
+
239
+ [21] Tsu-Jui Fu, Xin Eric Wang, and William Yang Wang. Language-Driven Image Style Transfer. arXiv preprint arXiv:2106.00178, 2021.
240
+
241
+ [22] Oran Gafni, Adam Polyak, Oron Ashual, Shelly Sheynin, Devi Parikh, and Yaniv Taigman. Make-a-scene: Scene-based text-to-image generation with human priors. arXiv preprint arXiv:2203.13131, 2022.
242
+
243
+ [23] Timnit Gebru, Jamie Morgenstern, Briana Vecchione, Jennifer Wortman Vaughan, Hanna Wallach, Hal Daumé III, and Kate Crawford. Datasheets for Datasets. arXiv:1803.09010 [cs], March 2020.
244
+
245
+ [24] Adam Harvey and Jules LaPlace. MegaPixels: Origins and endpoints of biometric datasets "In the Wild". https://megapixels.cc, 2019.
246
+
247
+ [25] Jack Hessel, Ari Holtzman, Maxwell Forbes, Ronan Le Bras, and Yejin Choi. Clipscore: A reference-free evaluation metric for image captioning. arXiv preprint arXiv:2104.08718, 2021.
248
+
249
+ [26] 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. arXiv preprint arXiv:1706.08500, 2017.
250
+
251
+ [27] Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021.
252
+
253
+ [28] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising Diffusion Probabilistic Models. NeurIPS, 2020.
254
+
255
+ [29] Jonathan Ho, Chitwan Saharia, William Chan, David J Fleet, Mohammad Norouzi, and Tim Salimans. Cascaded diffusion models for high fidelity image generation. JMLR, 2022.
256
+
257
+ [30] Rowan T. Hughes, Liming Zhu, and Tomasz Bednarz. Generative adversarial networks-enabled human-artificial intelligence collaborative applications for creative and design industries: A systematic review of current approaches and trends. Frontiers in artificial intelligence, 4, 2021.
258
+
259
+ [31] Aashi Jain, Mandy Guo, Krishna Srinivasan, Ting Chen, Sneha Kudugunta, Chao Jia, Yinfei Yang, and Jason Baldridge. MURAL: Multimodal, multitask representations across languages. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 3449– 3463, Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.findings-emnlp.293. URL https://aclanthology.org/ 2021.findings-emnlp.293.
260
+
261
+ [32] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc Le, YunHsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning, pages 4904–4916. PMLR, 2021.
262
+
263
+ [33] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc V. Le, YunHsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In ICML, 2021.
264
+
265
+ [34] Zahra Kadkhodaie and Eero P Simoncelli. Solving linear inverse problems using the prior implicit in a denoiser. arXiv preprint arXiv:2007.13640, 2020.
266
+
267
+ [35] Zahra Kadkhodaie and Eero P Simoncelli. Stochastic solutions for linear inverse problems using the prior implicit in a denoiser. Advances in Neural Information Processing Systems, 34, 2021.
268
+
269
+ [36] Gwanghyun Kim and Jong Chul Ye. Diffusionclip: Text-guided image manipulation using diffusion models. arXiv preprint arXiv:2110.02711, 2021.
270
+ [37] Diederik P Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. Variational diffusion models. arXiv preprint arXiv:2107.00630, 2021.
271
+ [38] Tsung-Yi Lin, Michael Maire, Serge Belongie, Lubomir Bourdev, Ross Girshick, James Hays, Pietro Perona, Deva Ramanan, Lawrence Zitnick, and Piotr Dollár. Microsoft COCO: Common Objects in Context. In ECCV, 2014.
272
+ [39] Elman Mansimov, Emilio Parisotto, Jimmy Lei Ba, and Ruslan Salakhutdinov. Generating Images from Captions with Attention. In ICLR, 2016.
273
+ [40] Gary Marcus, Ernest Davis, and Scott Aaronson. A very preliminary analysis of DALL-E 2. In arXiv:2204.13807, 2022.
274
+ [41] Jacob Menick and Nal Kalchbrenner. Generating High Fidelity Images with Subscale Pixel Networks and Multidimensional Upscaling. In ICLR, 2019.
275
+ [42] Alex Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. arXiv preprint arXiv:2102.09672, 2021.
276
+ [43] Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Bob McGrew Pamela Mishkin, Ilya Sutskever, and Mark Chen. GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models. In arXiv:2112.10741, 2021.
277
+ [44] Gaurav Parmar, Richard Zhang, and Jun-Yan Zhu. On Aliased Resizing and Surprising Subtleties in GAN Evaluation. In CVPR, 2022.
278
+ [45] Amandalynne Paullada, Inioluwa Deborah Raji, Emily M. Bender, Emily Denton, and Alex Hanna. Data and its (dis)contents: A survey of dataset development and use in machine learning research. Patterns, 2(11):100336, 2021.
279
+ [46] Vinay Uday Prabhu and Abeba Birhane. Large image datasets: A pyrrhic win for computer vision? arXiv:2006.16923, 2020.
280
+ [47] Mahima Pushkarna, Andrew Zaldivar, and Oddur Kjartansson. Data cards: Purposeful and transparent dataset documentation for responsible ai. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, 2022.
281
+ [48] Alec Radford, Rafal Jozefowicz, and Ilya Sutskever. Learning to Generate Reviews and Discovering Sentiment. In arXiv:1704.01444, 2017.
282
+ [49] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving Language Understanding by Generative Pre-Training. In preprint, 2018.
283
+ [50] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language Models are Unsupervised Multitask Learners. In preprint, 2019.
284
+ [51] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning Transferable Visual Models From Natural Language Supervision. In ICML, 2021.
285
+ [52] Jack Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, Eliza Rutherford, Tom Hennigan, Jacob Menick, Albin Cassirer, Richard Powell, George Driessche, Lisa Hendricks, Maribeth Rauh, Po-Sen Huang, and Geoffrey Irving. Scaling language models: Methods, analysis & insights from training gopher. arXiv:2112.11446, 2021.
286
+ [53] Colin Raffel, Minh-Thang Luong, Peter J. Liu, Ron J. Weiss, and Douglas Eck. Online and Linear-Time Attention by Enforcing Monotonic Alignments. In ICML, 2017.
287
+
288
+ [54] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer. JMLR, 21(140), 2020.
289
+
290
+ [55] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-Shot Text-to-Image Generation. In ICML, 2021.
291
+
292
+ [56] Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical Text-Conditional Image Generation with CLIP Latents. In arXiv, 2022.
293
+
294
+ [57] Ali Razavi, Aaron van den Oord, and Oriol Vinyals. Generating diverse high-fidelity images with vq-vae-2. arXiv preprint arXiv:1906.00446, 2019.
295
+
296
+ [58] Scott Reed, Zeynep Akata, Xinchen Yan, Lajanugen Logeswaran, Bernt Schiele, and Honglak Lee. Generative adversarial text to image synthesis. In International conference on machine learning, pages 1060–1069. PMLR, 2016.
297
+
298
+ [59] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-Resolution Image Synthesis with Latent Diffusion Models. In CVPR, 2022.
299
+
300
+ [60] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computer-assisted intervention, pages 234–241. Springer, 2015.
301
+
302
+ [61] Chitwan Saharia, William Chan, Huiwen Chang, Chris A. Lee, Jonathan Ho, Tim Salimans, David J. Fleet, and Mohammad Norouzi. Palette: Image-to-Image Diffusion Models. In arXiv:2111.05826, 2021.
303
+
304
+ [62] Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J Fleet, and Mohammad Norouzi. Image super-resolution via iterative refinement. arXiv preprint arXiv:2104.07636, 2021.
305
+
306
+ [63] Morgan Klaus Scheuerman, Emily L. Denton, and A. Hanna. Do datasets have politics? disciplinary values in computer vision dataset development. Proceedings of the ACM on Human-Computer Interaction, 5:1 – 37, 2021.
307
+
308
+ [64] 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.
309
+
310
+ [65] Lucas Sequeira, Bruno Moreschi, Amanda Jurno, and Vinicius Arruda dos Santos. Which faces can AI generate? Normativity, whiteness and lack of diversity in This Person Does Not Exist. In CVPR Workshop Beyond Fairness: Towards a Just, Equitable, and Accountable Computer Vision, 2021.
311
+
312
+ [66] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pages 2256–2265. PMLR, 2015.
313
+
314
+ [67] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020.
315
+
316
+ [68] Yang Song and Stefano Ermon. Generative Modeling by Estimating Gradients of the Data Distribution. NeurIPS, 2019.
317
+
318
+ [69] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In ICLR, 2021.
319
+
320
+ [70] Ramya Srinivasan and Kanji Uchino. Biases in generative art: A causal look from the lens of art history. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, page 41–51, 2021.
321
+
322
+ [71] Ryan Steed and Aylin Caliskan. Image representations learned with unsupervised pre-training contain human-like biases. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, FAccT ’21, page 701–713. Association for Computing Machinery, 2021.
323
+ [72] Ming Tao, Hao Tang, Songsong Wu, Nicu Sebe, Xiao-Yuan Jing, Fei Wu, and Bingkun Bao. Df-gan: Deep fusion generative adversarial networks for text-to-image synthesis. arXiv preprint arXiv:2008.05865, 2020.
324
+ [73] Belinda Tzen and Maxim Raginsky. Neural Stochastic Differential Equations: Deep Latent Gaussian Models in the Diffusion Limit. In arXiv:1905.09883, 2019.
325
+ [74] Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. Advances in neural information processing systems, 30, 2017.
326
+ [75] Pascal Vincent. A connection between score matching and denoising autoencoders. Neural Computation, 23(7):1661–1674, 2011.
327
+ [76] Ting-Chun Wang, Ming-Yu Liu, Jun-Yan Zhu, Andrew Tao, Jan Kautz, and Bryan Catanzaro. High-resolution image synthesis and semantic manipulation with conditional gans. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 8798–8807, 2018.
328
+ [77] Jason Weston, Samy Bengio, and Nicolas Usunier. Wsabie: Scaling up to large vocabulary image annotation. In Twenty-Second International Joint Conference on Artificial Intelligence, 2011.
329
+ [78] Jay Whang, Mauricio Delbracio, Hossein Talebi, Chitwan Saharia, Alexandros G Dimakis, and Peyman Milanfar. Deblurring via stochastic refinement. arXiv preprint arXiv:2112.02475, 2021.
330
+ [79] Tao Xu, Pengchuan Zhang, Qiuyuan Huang, Han Zhang, Zhe Gan, Xiaolei Huang, and Xiaodong He. AttnGAN: Fine-Grained Text to Image Generation with Attentional Generative Adversarial Networks. In CVPR, 2018.
331
+ [80] Tao Xu, Pengchuan Zhang, Qiuyuan Huang, Han Zhang, Zhe Gan, Xiaolei Huang, and Xiaodong He. Attngan: Fine-grained text to image generation with attentional generative adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1316–1324, 2018.
332
+ [81] Hui Ye, Xiulong Yang, Martin Takac, Rajshekhar Sunderraman, and Shihao Ji. Improving text-to-image synthesis using contrastive learning. arXiv preprint arXiv:2107.02423, 2021.
333
+ [82] Jiahui Yu, Xin Li, Jing Yu Koh, Han Zhang, Ruoming Pang, James Qin, Alexander Ku, Yuanzhong Xu, Jason Baldridge, and Yonghui Wu. Vector-quantized image modeling with improved vqgan. arXiv preprint arXiv:2110.04627, 2021.
334
+ [83] Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. Coca: Contrastive captioners are image-text foundation models. arXiv preprint arXiv:2205.01917, 2022.
335
+ [84] Han Zhang, Jing Yu Koh, Jason Baldridge, Honglak Lee, and Yinfei Yang. Cross-Modal Contrastive Learning for Text-to-Image Generation. In CVPR, 2021.
336
+ [85] Yufan Zhou, Ruiyi Zhang, Changyou Chen, Chunyuan Li, Chris Tensmeyer, Tong Yu, Jiuxiang Gu, Jinhui Xu, and Tong Sun. Lafite: Towards language-free training for text-to-image generation. arXiv preprint arXiv:2111.13792, 2021.
337
+ [86] Minfeng Zhu, Pingbo Pan, Wei Chen, and Yi Yang. Dm-gan: Dynamic memory generative adversarial networks for text-to-image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5802–5810, 2019.
338
+ [87] Yukun Zhu, Ryan Kiros, Rich Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja Fidler. Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. In ICCV, 2015.
339
+
340
+ # Checklist
341
+
342
+ 1. For all authors...
343
+
344
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
345
+ (b) Did you describe the limitations of your work? [Yes] See Section 6.
346
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 6.
347
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
348
+
349
+ 2. If you are including theoretical results...
350
+
351
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
352
+
353
+ 3. If you ran experiments...
354
+
355
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [No]
356
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
357
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
358
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
359
+
360
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
361
+
362
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
363
+ (b) Did you mention the license of the assets? [Yes] We describe the license of the public data we use in Section 6.
364
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We include DrawBench prompts in the supplemental material.
365
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] We discuss the lack of consent from data subjects in web-scraped data in Section 6.
366
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] See Section 6.
367
+
368
+ 5. If you used crowdsourcing or conducted research with human subjects...
369
+
370
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [Yes]
371
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [No]
372
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [Yes]
md/dev/09hVcSDkea/09hVcSDkea.md ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CORRUPTED IMAGE MODELING FOR SELF-SUPERVISED VISUAL PRE-TRAINING
2
+
3
+ Yuxin Fang 1, 2∗ Li Dong 2 Hangbo Bao 2 Xinggang Wang 1† Furu Wei 2 1 School of EIC, Huazhong University of Science & Technology 2 Microsoft Research {yxf,xgwang}@hust.edu.cn
4
+
5
+ # ABSTRACT
6
+
7
+ We introduce Corrupted Image Modeling (CIM) for self-supervised visual pretraining. CIM uses an auxiliary generator with a small trainable BEiT (Bao et al., 2021) to corrupt the input image instead of using artificial [MASK] tokens, where some patches are randomly selected and replaced with plausible alternatives sampled from the BEiT output distribution. Given this corrupted image, an enhancer network learns to either recover all the original image pixels, or predict whether each visual token is replaced by a generator sample or not. The generator and the enhancer are simultaneously trained and synergistically updated. After pre-training, the enhancer can be used as a high-capacity visual encoder for downstream tasks. CIM is a general and flexible visual pre-training framework that is suitable for various network architectures. For the first time, CIM demonstrates that both ViT and CNN can learn rich visual representations using a unified, non-Siamese framework. Experimental results show that our approach achieves compelling results in vision benchmarks, such as ImageNet classification and ADE20K semantic segmentation.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Vision Transformers (ViTs) (Dosovitskiy et al., 2020) are transferring the landscape of computer vision, not only in terms of the network architecture design, but also the self-supervised pre-training recipe. Masked image modeling (MIM) (Bao et al., 2021), which randomly masks out some input tokens and then recovers the masked content by conditioning on the visible context, is able to learn rich visual representations and shows promising performance on various vision benchmarks (Zhou et al., 2021; He et al., 2021; Xie et al., 2021; Dong et al., 2021; Wei et al., 2021).
12
+
13
+ Originated in masked language modeling (Devlin et al., 2019), MIM (Figure 1a) is tailor-made for specific architectures (Vaswani et al., 2017), which is generally capable of receiving and processing tokenized inputs such as the artificial [MASK] tokens. Meanwhile, the more common and natural input signal in computer vision is the image in RGB domain with 2D regular grid structures. In order to apply MIM pre-training for images, ViT has to “patchify” the input image into a 1D sequence of non-overlapping patch embeddings, and then use [MASK] tokens to perturb them.
14
+
15
+ MIM is tightly coupled with the Transformer family, and the usage of [MASK] tokens limits its scope of application to some extent. More importantly, MIM is not directly suitable for convolutional neural networks (CNNs) (LeCun et al., 1989), the dominant architecture for computer vision in the last decade. Introducing [MASK] tokens in any intermediate stage of CNN is infeasible, as convolution’s intrinsic dense-sliding-window paradigm causes information leakage between visual features in previous layers and therefore impedes the MIM. Therefore the large CNN family cannot directly benefit from the upsurge of this new pre-training scheme. Moreover, the usage of [MASK] tokens causes a discrepancy between pre-training and fine-tuning (Devlin et al., 2019; Clark et al., 2020), as the artificial [MASK] tokens never appear in the fine-tuning stage.
16
+
17
+ In this paper, we present a new visual pre-training framework, called Corrupted Image Modeling (CIM, Figure 1b), which avoids directly manipulating [MASK] tokens on pre-trained models and generalizes quite well to both ViT and CNN architectures. Rather than directly using artificial [MASK] tokens to corrupt a portion of non-overlapping patch embeddings as in MIM, CIM uses a small trainable BEiT (Bao et al., 2021) as an auxiliary generator to corrupt the input image. Specifically, the BEiT generator learns to predict visual tokens at the masked positions, where we utilize the predicted distribution to sample visual tokens’ replacements. The replaced visual tokens together with the golden tokens that directly produced by a pre-trained frozen image tokenizer encoder (e.g., the DALL-E (Ramesh et al., 2021) dVAE encoder) given the same input as the small trainable BEiT are then mapped back to the image RGB domain by a pre-trained frozen tokenizer decoder (e.g., the DALL-E dVAE decoder). The resulting corrupted image serves as the input of the enhancer, which is the model to be pre-trained and transferred.
18
+
19
+ ![](images/4dd8395ea4882213cb68da1f6b25faa4ebd6cb6bd3705e0df1e770aeb9b9d374.jpg)
20
+ Figure 1: Overview of our Corrupted Image Modeling (CIM) and comparisons with Masked Image Modeling (MIM). MIM (Figure 1a) requires the pre-trained architecture to receive and process the artificial [MASK] tokens, while CIM (Figure 1b) relaxes these restrictions by using a trainable generator to sample corrupted images serving as the input for the enhancer. Similar to BEiT, the small generator learns to predict the golden visual token produced by the pre-trained frozen image tokenizer encoder (not shown in the figure) based on partial observations of the input. The enhancer can be various architectures including CNN and learns either a generative or a discriminative visual pre-training objective. After pre-training, we throw out the generator and fine-tune the enhancer on downstream tasks. The dice icon in Figure 1b refers to the visual tokens’ stochastic sampling process, and the lock icon means the pre-trained image tokenizer decoder is frozen.
21
+
22
+ For the enhancer, the choice of pre-training objectives is quite flexible. We study two representatives: a generative objective that regresses all the original image pixels given the corrupted image (Dosovitskiy et al., 2020; Chen et al., 2020a), dubbed as Pixel Residual learning (RESPIX), and a discriminative objective that predicts whether each visual token is replaced by the small generator or not (Clark et al., 2020), dubbed as Replaced Visual token Detection (REVDET). After pre-training, the enhancer can be used as a strong feature extractor for visual downstream tasks.
23
+
24
+ Overall, CIM is a general and flexible pre-training framework suited for different kinds of visual encoders. For the first time, we demonstrate that both ViT and CNN can learn rich visual representations using a unified non-Siamese structure. Experimental results show that our approach achieves compelling results in vision benchmarks, such as ImageNet classification and ADE20K semantic segmentation. We hope CIM can serve as a promising starting point for exploring flexible & unified visual representation learning of various architectures.
25
+
26
+ # 2 CORRUPTED IMAGE MODELING (CIM)
27
+
28
+ Figure 1b shows the overview of CIM. Our approach simultaneously learns two neural networks: an auxiliary generator and an enhancer. The generator is used to corrupt the input image, while the enhancer receives the corrupted image (Figure 2) and learns either a generative or a discriminative visual pretext task. After pre-training, we throw out the generator and fine-tune the enhancer on downstream tasks.
29
+
30
+ # 2.1 GENERATOR
31
+
32
+ Rather than using artificial [MASK] tokens to corrupt the input image, we learn a trainable auxiliary generator to relax the architectural constraints of MIM. Moreover, the generator enriches the diversity of corrupted images via stochastic sampling, which helps the enhancer generalize. The generator consists of a pre-trained frozen image tokenizer, and a small trainable BEiT (Bao et al., 2021).
33
+
34
+ ![](images/5050220e448020d78790b1e83d4696485816144f9fb9557d3b542de7e5a3860c.jpg)
35
+ (a) Corrupted image samples from ImageNet-1K training set. Although the model is trained using the same dataset, the corrupted image samples still vary to a certain extent. Therefore during pre-training, the generator is able to continuously provide abundant and diverse corrupted samples for the enhancer.
36
+
37
+ ![](images/0c8a620d9099ed9ff0ad3e2aaed16fcd2e9d97c08f253ca8ff92b89ace11e791.jpg)
38
+ (b) Corrupted image samples from COCO val split (Lin et al., 2014) using ImageNet-1K pre-trained model.
39
+ Figure 2: Visualizations of some corrupted image samples. For each image set, we show (from left to right) the original image, the masked image, and four different corrupted images sampled from the generator output distribution with the same masked input. Simple stochastic sampling can greatly enrich the corrupted image distribution in terms of both low-level features and high-level semantics, which feeds the enhancer better.
40
+
41
+ The frozen image tokenizer in CIM is a pre-trained discrete variational autoencoder (dVAE) (Rolfe, 2016; Van Den Oord et al., 2017), consisting of a paired encoder and decoder. The tokenizer encoder maps the input image into a sequence of discrete visual tokens with a fixed vocabulary size. The tokenizer decoder can recover semantically plausible images given a permutation of appropriate and meaningful visual tokens. We directly use the DALL-E (Ramesh et al., 2021) tokenizer, following BEiT.
42
+
43
+ The small BEiT consists of several Transformer encoder layers and is trained to perform MIM, which uses two views for each input image, i.e., a sequence of non-overlapping patch embeddings, and their corresponding discrete visual tokens. Patch embeddings are linearly embedded from non-overlapping input image patches. Discrete visual tokens are from the DALL-E tokenizer encoder, serving as the prediction target for BEiT.
44
+
45
+ Given a sequence of patch embeddings, the small BEiT randomly masks out a set of positions. The patch embeddings at the masked positions are replaced with special mask embeddings. The small BEiT takes this corrupted sequence of patch embeddings as the input, and learns to predict the corresponding discrete visual tokens at all masked positions given the visible context only. In CIM pre-training, the size of the small BEiT we use is typically a quarter or a half of the enhancer.
46
+
47
+ Using discrete visual tokens to represent images enables CIM to perform stochastic sampling during the corrupted image’s generation process, which greatly enriches the output set of the generator. In this paper, we directly sample from softmax with a temperature of 1 at all the masked positions according to the small BEiT output distribution. All the masked tokens are replaced by the sampled visual tokens. The sampled tokens together with the golden tokens that are directly produced by the image tokenizer encoder at all the non-masked positions constitute the input for the image tokenizer decoder. Then the decoder maps those plausible visual tokens to a corrupted image (refer to examples in Figure 2), which serves as the input for the enhancer.
48
+
49
+ ![](images/c649970c6ab9f97e43291e9e16de40c65e8ad4cf1995b66201d058e9c24be0c1.jpg)
50
+ (a) CIM-RESPIX pre-training objective with sliding window normalized pixels as the enhancer prediction target.
51
+
52
+ ![](images/06a181c2f58d7ee657036e02167e76fee2211bdd65d0593da1ded42af9144f35.jpg)
53
+ (b) CIM-RESPIX pre-training objective with unnormalized pixels as the enhancer prediction target.
54
+ Figure 3: Example visualization results on COCO val split images from vanilla ViT-Base/16 model pre-trained with the RESPIX objective using ImageNet-1K training data. For each image quadruplet, we show the original input image (1st column), the masked input image for the generator (2nd column), the corrupted image sampled from the generator output (3rd column), and the enhancer output (4th column). Given the corrupted image, the enhancer is able to perform image denoising, deblurring and completion, etc., and learns to predict plausible output in terms of both low-level features as well as high-level semantics.
55
+
56
+ # 2.2 ENHANCER
57
+
58
+ Given the corrupted image sampled from the auxiliary generator, the enhancer learns either a generative or a discriminative visual pretext task. The prediction head is a simple linear layer, and the choice of pre-training objectives is quite flexible. In this paper, we study two representative objectives, coined as Pixel Residual learning (RESPIX) and Replaced Visual token Detection (REVDET).
59
+
60
+ RESPIX (Figure 3) is a generative visual pretext task that requires the enhancer to predict the uncorrupted pixel value for all positions given the corrupted input. Instead of directly regressing the original pixel, MAE (He et al., 2021) suggests learning the normalized counterpart. Specifically, the image is partitioned into a set of non-overlapping patches, and each pixel is normalized by the mean and standard deviation of all pixels in the patch it lives in, i.e., patches with layer normalization (Ba et al., 2016) are the reconstruction target.
61
+
62
+ In CIM, we further propose to normalize the prediction target inside a sliding window, i.e., each pixel is normalized by all pixels in a local $8 \times 8$ sized window centered at where the target pixel lives in. We observe improved representation quality using the sliding window normalization paradigm.
63
+
64
+ ![](images/bff27fbe41eea6e635bbeb3ed3ffc0bcf18122b22ff97b3a0c695ab06f6813fe.jpg)
65
+ Figure 4: Normalizations as learning templates for RESPIX. For each image triplet, we visualize the original image (left), the template of using non-overlapping window normalization (He et al., 2021), and the template of the proposed sliding window normalization paradigm. Our approach can provide more accurate and moderate hints that can boost the enhancer’s pre-training as well as improve its representation quantity.
66
+
67
+ Naive pixel recovery without normalization tends to waste modeling capability on learning short-range dependencies and high-frequency details (Ramesh et al., 2021; Bao et al., 2021), while the normalized target can mitigate irrelevant information fittings. From another perspective, normalizations are equal to providing learning templates, as shown in Figure 4. With the normalized prediction target, the enhancer only needs to learn the residual pixel value at each position given the normalized pixel value, while the unnormalized target provides no hint therefore the enhancer has to “learn to see in the dark” (i.e., regress from RGB: 0, 0, 0). It is also hard for the enhancer to learn without a template since the corrupted image usually provides bad priors (refer to the corrupted image samples in Figure 2 and Figure 3). Therefore, we believe appropriate and moderate hints will help the enhancer see better.
68
+
69
+ REVDET is a discriminative visual pretext task that requires the enhancer to determine whether each visual token is replaced by a generator sample or not. To be specific, the visual tokens produced by the pre-trained frozen image tokenizer encoder are considered as golden tokens. If a generated visual token is different from the golden token at the same position, that generated token is considered “replaced”, and vice versa.
70
+
71
+ REVDET is inspired by ELECTRA (Clark et al., 2020) in language modeling. The main difference is, in the proposed CIM, the determining criterion of replacement is hidden in the corrupted image. Token replacement is a kind of local, high-frequency operation by nature. However, the visual token set after sampling and replacement is further smoothed and processed by the image tokenizer decoder. Therefore the token sampling and replacement operations are finally embodied as non-local, high-level semantics changes in the corrupted image. The enhancer is required to “decrypt” it and identify all the replaced tokens given the corrupted input, which yields a nontrivial and meaningful visual pretext task1. To some extent, REVDET also learns the DALL-E dVAE’s visual codebook similar to BEiT, but in a discriminative manner.
72
+
73
+ The enhancer is regarded as the visual encoder after pre-training. Moreover, unlike masked image modeling, CIM does not assume too many architectural priors for the pre-trained network. We successfully pre-train a high-capacity vanilla ResNet-50 (He et al., 2016), ResNet-50x2 and ResNet$5 0 { \bf x } 4$ enhancers that achieve compelling transfer learning performance using a similar configuration as pre-training a ViT enhancer. For the first time, we demonstrate that both ViT and CNN can learn strong visual representations using a unified non-Siamese framework.
74
+
75
+ # 2.3 TRAINING AND OPTIMIZATION
76
+
77
+ The auxiliary generator and the enhancer are simultaneously trained and synergistically (rather than adversarially as GAN (Goodfellow et al., 2014)) updated. The trainable part of the generator, i.e., the small BEiT, learns a MIM objective in the same vein as in (Bao et al., 2021). The whole pre-trained image tokenizer is frozen.
78
+
79
+ For the RESPIX visual pretext task, the enhancer is optimized by a combination of $l _ { 1 }$ and $l _ { 2 }$ loss. For the REVDET visual pretext task, the enhancer is learned by binary cross-entropy loss. Notice that the gradients of the enhancer are not back-propagated through the generator. A detailed formulation is presented in Appendix A.3.
80
+
81
+ # 3 EXPERIMENTS
82
+
83
+ We study CIM self-supervised pre-trained vanilla ViT-Small/16 (Touvron et al., 2021a), vanilla ViT-Base/16 (Dosovitskiy et al., 2020) and vanilla ResNet-50 (He et al., 2016) models. We use the actual processed images / views to measure the pre-training epochs (PT epochs). ImageNet-1K (Deng et al., 2009) training data is used to pre-train the small BEiT and the enhancer. Our pre-training setting generally follows BEiT (Bao et al., 2021). Unlike BEiT, CIM only uses cropping and flipping for data argumentation, while dropout (Srivastava et al., 2014) and stochastic depth (Huang et al., 2016) are not applied. The detailed pre-training settings are summarized in the Appendix A.4. Notably, the pre-training configurations are almost the same for both ViT and CNN architectures.
84
+
85
+ In order to evaluate the pre-trained representations from CIM, for both ViT and CNN architectures, we conduct supervised end-to-end fine-tuning (FT) experiments on ImageNet-1K (Deng et al., 2009) image classification in $\ S 3 . 1$ , and ADE20K (Zhou et al., 2019) semantic segmentation in $\ S 3 . 2$ .
86
+
87
+ Table 1: ImageNet-1K end-to-end fine-tuning top-1 accuracy of vanilla ViT-Small/16 and ViT-Base/16 models. †Doubled attention heads. ‡Our reproduction.
88
+
89
+ <table><tr><td>Models PT Epochs Top-1 ViT-Small/16 model results</td></tr><tr><td>Scratch (Touvron et al., 2021a) MoCo-v3† (Chen et al., 2021) 600 DINO (Caron et al., 2021) 1600 81.5 BEiT (Bao et al., 2021) 300</td></tr><tr><td>CIM-RESPIX (Ours) 300 81.5 CIM-REVDET (Ours) 300 81.6</td></tr><tr><td>ViT-Base/l6 model results 81.8</td></tr><tr><td>Scratch (Touvron et al., 2021a)</td></tr><tr><td>Scratch (He et al., 2021) 82.3</td></tr><tr><td>DINO (Caron et al., 2021) 1600 82.8 MoCo-v3 (Chen et al.,2021) 600 83.2</td></tr><tr><td>BEiT (Bao et al.,2021) 300 82.9 BEiT (Bao et al., 2021) 800 83.2</td></tr></table>
90
+
91
+ Ablation study on ImageNet-1K is presented in $\ S 3 . 3$ . For ImageNet-1K, we observe ${ \sim } 0 . 2$ Top-1 acc. fluctuations. For ADE20K, we observe ${ \sim } 0 . 5$ mIoU fluctuations. We report key results using the median of 3 independent runs.
92
+
93
+ Table 2: ImageNet-1K end-to-end fine-tuning top-1 accuracy of vanilla ResNet-50 model. RSB (Wightman et al., 2021) is the current vanilla ResNet stateof-the-art training procedure.
94
+
95
+ <table><tr><td>Models</td><td>PT Epochs Top-1</td></tr><tr><td>Fine-tuning for l0o epochs RSB A3 (Wightman et al., 2021) CIM-REVDET (Ours) 300</td><td>78.1 78.8</td></tr><tr><td>Fine-tuning for 300 epochs RSB A2 (Wightman et al., 2021) SimSiam (Chen &amp; He,2021) MoCo-v2 (Chen et al., 2020c) SimCLR (Chen et al., 2020b) SimCLR (Chen et al., 2020b) BYOL (Grill et al., 2020) SwAV (Caron et al., 2020) CIM-RESPIX(Ours) CIM-REVDET (Ours)</td><td>79.8 400 79.1 400 79.6 800 79.9 2000 80.0 400 80.0 600 80.1 300 79.9 300</td></tr><tr><td>Fine-tuning for 60o epochs</td><td>80.5</td></tr><tr><td>RSB A1 (Wightman et al., 2021) CIM-REVDET (Ours) 300</td><td>80.4 80.7</td></tr></table>
96
+
97
+ # 3.1 IMAGE CLASSIFICATION
98
+
99
+ ViT. The ImageNet-1K end-to-end fine-tuning top-1 accuracy of vanilla ViT-Small/16 and ViTBase/16 models are presented in Table 1. We fine-tune the small-sized model for 200 epochs, and the base-sized model for 100 epochs. Other self-supervised methods in Table 1 use the same or longer fine-tuning schedule. The fine-tuning hyperparameters mostly follow BEiT, while our layerwise lr decay rate is set to 0.8 as suggested by Clark et al. (2020). See Appendix A.4 for detailed configurations.
100
+
101
+ As shown in Table 1, CIM is able to achieve better accuracy with fewer pre-training epochs compared with other representative self-supervised vanilla ViT models. Moreover, we find both REVDET and RESPIX visual pretext task can help the ViT enhancer learn useful representations.
102
+
103
+ ResNet-50. We demonstrate that CIM can also pre-train a high-capacity ResNet-50 model with the fewest possible modifications from the ViT pre-training settings that can achieve compelling fine-tuning performances on ImageNet-1K. We use the AdamW optimizer (Loshchilov & Hutter, 2017) for fine-tuning, and other configurations basically follow the advanced training recipe of RSB (Wightman et al., 2021). For other self-supervised baselines, we select the best lr out of $\{ 5 \mathrm { e } \mathrm { - } 3$ , 8e-3, 12e-3} and keep other settings unchanged to ensure a fair and challenging competition. The detailed configurations are given in Appendix A.4.
104
+
105
+ As shown in Table 2, under such a demanding training procedure, CIM pre-trained ResNet-50 model can still outperform several representative self-supervised methods based on the Siamese framework as well as the modernized state-of-the-art ResNet-50 results. Using the improved fine-tuning recipe, we also observe performance degeneration for some self-supervised baselines compared with the RSB from scratch results. Notably, even with the extreme 600-epoch training schedule, the CIM representation can still improve the state-of-the-art RSB A1 by $0 . 3 \%$ .
106
+
107
+ # 3.2 SEMANTIC SEGMENTATION
108
+
109
+ We study the transfer learning performance of CIM pre-trained vanilla ViT-Base/16 and ResNet-50 models on the ADE20K semantic segmentation benchmark. The pre-trained models are used as an encoder, and we purposefully choose simple decoders to better reveal the pre-trained representations. Experiments are based on the code of Bao et al. (2021); MMSegmentation (2020).
110
+
111
+ Specifically, for ViT-Base/16 we use a simple linear layer as the decoder, and for ResNet-50 we choose the ubiquitous FCN (Long et al., 2015) as the decoder. For ViT, the baseline settings as well as the fine-tuning recipes are from (Bao et al., 2021). We select the best lr out of $\{ 1 \mathrm { e } { - } 4 , 3 \mathrm { e } { - } 4 , 5 \mathrm { e } { - } 4 , 7 \mathrm { e } { - } 4 \}$ for DINO. For BEiT we use the default setting (lr 7e4 with a decay rate of 0.65). For CIM pretrained ViT, we set the fine-tuning lr equal to 3e-4 with a decay rate of 0.8 as suggested by Clark et al. (2020). For ResNet-50, we use the canonical configuration for all methods, i.e., the optimizer is SGD with a momentum of 0.9, lr follows a poly decay schedule, and the batch size is 16. The training crop size is set to 512 for all models, and we use singlescale inference.
112
+
113
+ As summarized in Table 3, when transferred to semantic segmentation task, CIM pre-trained models can still achieve competitive performances compared with other approaches. Notably, for ResNet-50, as the fine-tuning schedule becomes longer (i.e., 80k iterations 160k iterations), the performance gain from the ImageNet-1K supervised pre-trained representation is small. Moreover, the performance is even worse than training from scratch. Meanwhile, the CIM pre-trained ResNet-50 representation can provide sustaining performance gain for a longer fine-tuning schedule.
114
+
115
+ Table 3: ADE20K semantic segmentation performances (mIoU) of ViT and ResNet-50 models.
116
+
117
+ <table><tr><td>Models PT Epochs Top-1</td></tr><tr><td>Fine-tuning for l60k iterations</td></tr><tr><td>DINO (Caron et al., 2021) 1600 43.0</td></tr><tr><td>BEiT (Bao et al., 2021) 300 43.2</td></tr><tr><td>CIM-RESPIX (Ours) 300 43.5</td></tr><tr><td>CIM-REVDET (Ours) 300 43.6</td></tr></table>
118
+
119
+ (a) Vanilla ViT-Base/16 as encoder with one linear layer as decoder.
120
+
121
+ <table><tr><td>Models PT Epochs mloU</td></tr><tr><td>Fine-tuning for 80k iterations Training from Scratch 29.9 IN1K Supervised† (He et al., 2019) 120 35.9 CIM-REVDET (Ours)</td></tr><tr><td>300 36.2 Fine-tuning forl6Ok iterations Training from Scratch 36.7 IN1K Supervised (He et al., 2019) 120 36.1 BYOL (Grill et al., 2020) 400 37.1</td></tr><tr><td>SimCLR (Chen et al.,2020b) 2000 37.7 CIM-RESPIX (Ours) 300 38.7</td></tr><tr><td>SimSiam (Chen &amp; He,2021) 400 37.1 SwAV (Caron et al., 2020) 600 37.2 MoCo-v2 (Chen et al.,2020c) 400 37.5 SimCLR (Chen et al., 2020b) 800 37.6</td></tr></table>
122
+
123
+ (b) Vanilla ResNet-50 as encoder with a classic FCN as decoder.
124
+
125
+ Together with the observation from $\ S 3 . 1$ , we demonstrate CIM is a general, non-Siamese framework that is capable of pre-training both strong ViT and CNN visual encoders.
126
+
127
+ # 3.3 ABLATION STUDIES
128
+
129
+ Ablation studies are conducted using 300-epoch CIM-RESPIX pre-trained ViT-Base model with 100 epochs fine-tuning on ImageNet-1K unless specified. Some additional analysis is available in Appendix A.1.
130
+
131
+ Masking Strategy and Masking Ratio. As shown in Table 4, we observe CIM works better with simple random masking (He et al., 2021; Xie et al., 2021) compared with the blockwise masking strategy (Bao et al., 2021).
132
+
133
+ The optimal random masking ratio is around $50 \%$ , which we find also holds for the REVDET pretext task, in part because it provides almost equal amounts of positive and negative training samples.
134
+
135
+ The Small BEiT Depth and Weight Sharing. Following Meng et al. (2021); Chi et al. (2021), we adjust the size of the small trainable BEiT by varying its depth (i.e., the number of Transformer encoder layers) instead of its width (i.e., the feature dimension). As summarized in Table 5, the small BEiT with 4 to 6 layers is generally fine.
136
+
137
+ It is also beneficial to share the patch embedding layer as well as the first two Transformer encoder layers between the small BEiT and enhancer as long as the enhancer is also ViT. We hypothesize that sharing the earlier layers can help calibrate the enhancer since the small BEiT receives the real inputs while the enhancer sees the same sources but with corrupted views.
138
+
139
+ Table 4: Ablation study: masking strategy and masking ratio.
140
+
141
+ <table><tr><td>Masking Strategy</td><td>Masking Ratio</td><td>Top-1 Acc.</td></tr><tr><td>Blockwise</td><td>40%</td><td>82.8</td></tr><tr><td>Blockwise</td><td>50%</td><td>82.9</td></tr><tr><td>Blockwise</td><td>60%</td><td>82.8</td></tr><tr><td>Random</td><td>40%</td><td>83.0</td></tr><tr><td>Random</td><td>50%</td><td>83.3</td></tr><tr><td>Random</td><td>60%</td><td>83.1</td></tr></table>
142
+
143
+ Table 5: Ablation study: depth of the small BEiT in the generator and weight sharing.
144
+
145
+ <table><tr><td># Enc.Layers</td><td>Weight Sharing</td><td>Top-1 Acc.</td></tr><tr><td>4</td><td>X</td><td>83.1</td></tr><tr><td>4</td><td>√</td><td>83.3</td></tr><tr><td>5</td><td>√</td><td>83.2</td></tr><tr><td>6</td><td>√</td><td>83.2</td></tr><tr><td>7</td><td>√</td><td>83.1</td></tr><tr><td>8</td><td>√</td><td>82.9</td></tr></table>
146
+
147
+ Table 6: Ablation study: pixel reconstruction target for RESPIX pre-training objective.
148
+
149
+ <table><tr><td>REsPIX Recon. Target</td><td>Top-1 Acc.</td></tr><tr><td>w/o norm.</td><td>82.8</td></tr><tr><td>norm.w/ non-overlap win.</td><td>83.0</td></tr><tr><td>norm. w/ sliding win.</td><td>83.3</td></tr></table>
150
+
151
+ Table 7: Ablation study: sampling strategy for visual tokens.
152
+
153
+ <table><tr><td>Sampling Strategy</td><td>Top-1 Acc.</td></tr><tr><td>Uniform sampling</td><td>77.2</td></tr><tr><td>argmax sampling</td><td>78.5</td></tr><tr><td>softmax sampling</td><td>83.3</td></tr></table>
154
+
155
+ Target for RESPIX. We believe an appropriate normalization technique can provide moderate hints that can help improve the enhancer’s representation quality with the RESPIX visual pretext task (see our discussion of Figure 4). As shown in Table 6, the proposed sliding window normalization improves the fine-tuning accuracy by $0 . 5 \%$ vs. the reconstruction target without normalization, and is also $0 . 3 \%$ better than the normalization method proposed in He et al. (2021).
156
+
157
+ Sampling Strategy for Visual Tokens. Using discrete visual tokens to represent images enables CIM to use stochastic sampling techniques during the corrupted image’s generation process, which can greatly enrich the output set of the generator and help the enhancer generalize well. For masked image modeling, randomly masking out a portion of patch embeddings can help regularize the pre-training, while for our approach, regularization for the enhancer mainly comes from the diversity of the corrupted images, therefore regularizations such as dropout & droppath are not used in CIM.
158
+
159
+ As presented in Table 7, the visual token representation with simple stochastic sampling from the generator output distribution is crucial for CIM. In contrast, we find that uniform sampling from the codebook of the image tokenizer regardless of the generator distribution or argmax sampling from the distribution cannot provide meaningful or diverse samples and therefore fails to pre-train the enhancer as expected.
160
+
161
+ Image Corrupting Strategy. We find that it is crucial to use a generator with a small trainable BEiT to corrupt images in order to successfully pre-train CNN with the proposed CIM. We experiment with another generative visual pretext task for ResNet-50 pre-training, i.e., using $50 \%$ random erasing (Zhong et al., 2020) to corrupt the input image, and the model is required to recover the erased pixels based on the visible context. We find this pretext task fails to transfer well. A parallel work Tian et al. (2022) also finds that only using hand-crafted transformations to corrupt images is not quite satisfactory in generative visual pre-training of ViT.
162
+
163
+ Table 8: Scaling CIM pre-training to larger ResNet.
164
+
165
+ <table><tr><td>Methods</td><td>PT Epochs FT Epochs Top-1 Acc.</td><td></td><td></td></tr><tr><td>ResNet-50x2 (#params: 94M)</td><td></td><td></td><td></td></tr><tr><td>From Scratch</td><td>=</td><td>400</td><td>81.1</td></tr><tr><td>SimCLR (Chen et al., 2020b)</td><td>1000</td><td>100 /200</td><td>81.6 /82.1</td></tr><tr><td>CIM-REVDET (Ours)</td><td>300</td><td>100/200</td><td>81.7 /82.2</td></tr><tr><td>ResNet-50x4 (#params:375M)</td><td></td><td></td><td></td></tr><tr><td>From Scratch</td><td></td><td>400</td><td>80.9</td></tr><tr><td>SimCLR (Chen et al., 2020b)</td><td>1000</td><td>100</td><td>82.6</td></tr><tr><td>SimMIM (Xie et al.,2021)</td><td>300</td><td>100</td><td>81.6</td></tr><tr><td>CIM-REVDET (Ours)</td><td>300</td><td>100</td><td>82.6</td></tr></table>
166
+
167
+ Scaling CIM to Larger CNNs. We study the scaling behavior of our CIM to larger CNNs. We choose two popular architectures in self-supervised learning literature: ResNet- $5 0 \mathrm { x } 2$ and ResNet-50x4 (with width multipliers of $2 \mathbf { x }$ and $4 \mathbf { x }$ of vanilla ResNet50, respectively), and study the endto-end fine-tuning performance on ImageNet-1K in Table 8. We use an improved training recipe following Touvron et al. (2021a); Wightman et al. (2021), therefore our from
168
+
169
+ scratch and SimCLR baselines are much higher ( ${ \sim } 2$ points higher) than the original results in Chen et al. (2020b). Notice that it is non-trivial to pre-train those large CNNs (e.g., ResNet-50x4 is 14 times bigger than ResNet-50 in #params). Under the end-to-end fine-tuning protocol, CIM is better than the recent MIM-based approach SimMIM and competitive with the representative Siamese model SimCLR.
170
+
171
+ Scaling CIM to Larger ViT. We study the scaling behavior of our CIM to ViT-Large in Table 9. Indeed, our approach can give ViT-Large a better initialization compared with the random initialization, and can also achieve better performance than MoCov3 that based on the canonical Siamese framework. Meanwhile, CIM still lags behind the MIM-based BEiT. Nevertheless, we believe CIM can serve as a promising starting point for exploring unified visual pre-training of various architectures.
172
+
173
+ Table 9: Scaling CIM pre-training for ViT-Large.
174
+
175
+ <table><tr><td>Methods</td><td>Top-1 Acc.</td></tr><tr><td>ViT-Large (#params: 304M)</td><td></td></tr><tr><td>From Scratch (He et al., 2021)</td><td>82.6</td></tr><tr><td>MoCo-v3 (Chen et al., 2021)</td><td>84.1</td></tr><tr><td>BEiT (Bao et al., 2021)</td><td>85.2</td></tr><tr><td>CIM-RESPIX (Ours)</td><td>84.3</td></tr></table>
176
+
177
+ Limitation and Discussion. The image corrupting process of CIM still has a large room for improvement, which determines the characteristics and styles of the corrupted image distribution. The tokenizer we currently use is essentially a large CNN and adds nontrivial overhead during pre-training, i.e., the wall-clock time of 1-epoch training is about $2 \times$ of BEiT. Other image tokenizers, such as ViT-VQGAN (Yu et al., 2021), which report much higher throughput and better generation quality, deserve an in-depth study for CIM pre-training in the future.
178
+
179
+ # 4 RELATED WORK
180
+
181
+ Siamese Framework is the dominating self-supervised visual pre-training approach over the past few years, which typically relies on strong hand-crafted data augmentations to generate different views of the same image and learns in a contrastive manner. To maintain a large and informative negative sample set, memory banks (He et al., 2020) or large batch size (Chen et al., 2020b) is used. Follow-ups (Grill et al., 2020; Chen & He, 2021) further eliminate the requirement of using negative samples. Recent works (Caron et al., 2021; Chen et al., 2021) study self-supervised visual pre-training of ViT within Siamese frameworks.
182
+
183
+ Masked Image Modeling (MIM) learns rich visual representations via masked parts prediction by conditioning on visible context only. ViT (Dosovitskiy et al., 2020) and iGPT (Chen et al., 2020a) report the first meaningful MIM visual pre-training results. BEiT (Bao et al., 2021) greatly improves MIM’s performance via masked visual token prediction, and PeCo (Dong et al., 2021) finds injecting perceptual similarity during visual codebook learning benefits MIM pre-trained representation. Recent work (He et al., 2021; Xie et al., 2021; Wei et al., 2021) re-explore pixel / feature regression in MIM, while Li et al. (2021); Zhou et al. (2021); El-Nouby et al. (2021) incorporate MIM within Siamese frameworks. As MIM is originated in masked language modeling (Devlin et al., 2019), CIM is inspired by Clark et al. (2020). In CIM, visual-token-based MIM plays an important role during the corrupted image generation process, as the stochastic sampling ability greatly enriches the corrupted image set.
184
+
185
+ # 5 CONCLUSION
186
+
187
+ We introduce a general self-supervised visual pre-training framework with few architectural constraints for the model to be pre-trained and transferred. Unlike the mainstream Siamese pre-training methods based on strong artificial data augmentations as well as MIM pre-training relying on randomly inserting artificial [MASK] tokens to input embeddings, CIM pre-trained encoder learns from the corrupted view generated from a trainable neural network’s output distribution. Given the stochastic sampling ability, CIM defends using discrete visual token representations during pre-training to some extent. Experimental results show that our approach achieves competitive performance on canonical ViT and CNN models. We hope CIM can serve as a promising starting point for exploring flexible & unified visual representation learning of various architectures.
188
+
189
+ # ACKNOWLEDGMENT
190
+
191
+ This work is in part supported by the National Key Research and Development Program of China under Grant 2022YFB4500602. We would like to acknowledge Yaru Hao for the helpful discussions.
192
+
193
+ # REFERENCES
194
+
195
+ Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
196
+
197
+ Hangbo Bao, Li Dong, and Furu Wei. BEiT: BERT pre-training of image transformers. arXiv preprint arXiv:2106.08254, 2021.
198
+
199
+ Maxim Berman, Hervé Jégou, Andrea Vedaldi, Iasonas Kokkinos, and Matthijs Douze. Multigrain: a unified image embedding for classes and instances. arXiv preprint arXiv:1902.05509, 2019.
200
+
201
+ Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. arXiv preprint arXiv:2006.09882, 2020.
202
+
203
+ Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. arXiv preprint arXiv:2104.14294, 2021.
204
+
205
+ Mark Chen, Alec Radford, Rewon Child, Jeffrey Wu, Heewoo Jun, David Luan, and Ilya Sutskever. Generative pretraining from pixels. In ICML, 2020a.
206
+
207
+ Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In ICML, 2020b.
208
+
209
+ Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. In CVPR, 2021.
210
+
211
+ Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020c.
212
+
213
+ Xinlei Chen, Saining Xie, and Kaiming He. An empirical study of training self-supervised vision transformers. arXiv preprint arXiv:2104.02057, 2021.
214
+
215
+ Zewen Chi, Shaohan Huang, Li Dong, Shuming Ma, Saksham Singhal, Payal Bajaj, Xia Song, and Furu Wei. Xlm-e: cross-lingual language model pre-training via electra. arXiv preprint arXiv:2106.16138, 2021.
216
+
217
+ Kevin Clark, Minh-Thang Luong, Quoc V Le, and Christopher D Manning. Electra: Pre-training text encoders as discriminators rather than generators. arXiv preprint arXiv:2003.10555, 2020.
218
+
219
+ Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, pp. 702–703, 2020.
220
+
221
+ 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.
222
+
223
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In NAACL, 2019.
224
+
225
+ Xiaoyi Dong, Jianmin Bao, Ting Zhang, Dongdong Chen, Weiming Zhang, Lu Yuan, Dong Chen, Fang Wen, and Nenghai Yu. Peco: Perceptual codebook for bert pre-training of vision transformers. arXiv preprint arXiv:2111.12710, 2021.
226
+
227
+ 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. arXiv preprint arXiv:2010.11929, 2020.
228
+
229
+ Alaaeldin El-Nouby, Gautier Izacard, Hugo Touvron, Ivan Laptev, Hervé Jegou, and Edouard Grave. Are large-scale datasets necessary for self-supervised pre-training? arXiv preprint arXiv:2112.10740, 2021.
230
+
231
+ Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image synthesis. In CVPR, 2021.
232
+
233
+ Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In NeurIPS, 2014.
234
+
235
+ Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin Tallec, Pierre H Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Daniel Guo, Mohammad Gheshlaghi Azar, et al. Bootstrap your own latent: A new approach to self-supervised learning. arXiv preprint arXiv:2006.07733, 2020.
236
+
237
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
238
+
239
+ Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In CVPR, 2020.
240
+
241
+ Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. Masked autoencoders are scalable vision learners. arXiv preprint arXiv:2111.06377, 2021.
242
+
243
+ Tong He, Zhi Zhang, Hang Zhang, Zhongyue Zhang, Junyuan Xie, and Mu Li. Bag of tricks for image classification with convolutional neural networks. In CVPR, 2019.
244
+
245
+ Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: better training with larger batches. arXiv preprint arXiv:1901.09335, 2019.
246
+
247
+ Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In ECCV, 2016.
248
+
249
+ Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with conditional adversarial networks. In CVPR, 2017.
250
+
251
+ Yann LeCun, Bernhard Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne Hubbard, and Lawrence D Jackel. Backpropagation applied to handwritten zip code recognition. Neural computation, 1989.
252
+
253
+ Zhaowen Li, Zhiyang Chen, Fan Yang, Wei Li, Yousong Zhu, Chaoyang Zhao, Rui Deng, Liwei Wu, Rui Zhao, Ming Tang, et al. Mst: Masked self-supervised transformer for visual representation. NeurIPS, 2021.
254
+
255
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ECCV, 2014.
256
+
257
+ Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In CVPR, 2015.
258
+
259
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
260
+
261
+ Yu Meng, Chenyan Xiong, Payal Bajaj, Saurabh Tiwary, Paul Bennett, Jiawei Han, and Xia Song. COCO-LM: Correcting and contrasting text sequences for language model pretraining. In NeurIPS, 2021.
262
+
263
+ MMSegmentation. MMSegmentation: Openmmlab semantic segmentation toolbox and benchmark. https://github.com/open-mmlab/mmsegmentation, 2020.
264
+
265
+ Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In NeurIPS, 2019.
266
+
267
+ Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. arXiv preprint arXiv:2102.12092, 2021.
268
+
269
+ Jason Tyler Rolfe. Discrete variational autoencoders. arXiv preprint arXiv:1609.02200, 2016.
270
+
271
+ Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. arXiv preprint arXiv:1803.02155, 2018.
272
+
273
+ Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: A simple way to prevent neural networks from overfitting. JMLR, 2014.
274
+
275
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In CVPR, 2016.
276
+
277
+ Yunjie Tian, Lingxi Xie, Jiemin Fang, Mengnan Shi, Junran Peng, Xiaopeng Zhang, Jianbin Jiao, Qi Tian, and Qixiang Ye. Beyond masking: Demystifying token-based pre-training for vision transformers. arXiv preprint arXiv:2203.14313, 2022.
278
+
279
+ Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. In ICML, 2021a.
280
+
281
+ Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Hervé Jégou. Going deeper with image transformers. arXiv preprint arXiv:2103.17239, 2021b.
282
+
283
+ Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. In NeurIPS, 2017.
284
+
285
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
286
+
287
+ Chen Wei, Haoqi Fan, Saining Xie, Chao-Yuan Wu, Alan Yuille, and Christoph Feichtenhofer. Masked feature prediction for self-supervised visual pre-training. arXiv preprint arXiv:2112.09133, 2021.
288
+
289
+ Ross Wightman, Hugo Touvron, and Hervé Jégou. Resnet strikes back: An improved training procedure in timm. arXiv preprint arXiv:2110.00476, 2021.
290
+
291
+ Zhenda Xie, Zheng Zhang, Yue Cao, Yutong Lin, Jianmin Bao, Zhuliang Yao, Qi Dai, and Han Hu. Simmim: A simple framework for masked image modeling. arXiv preprint arXiv:2111.09886, 2021.
292
+
293
+ Jiahui Yu, Xin Li, Jing Yu Koh, Han Zhang, Ruoming Pang, James Qin, Alexander Ku, Yuanzhong Xu, Jason Baldridge, and Yonghui Wu. Vector-quantized image modeling with improved vqgan. arXiv preprint arXiv:2110.04627, 2021.
294
+
295
+ Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun, Junsuk Choe, and Youngjoon Yoo. Cutmix: Regularization strategy to train strong classifiers with localizable features. In ICCV, 2019.
296
+
297
+ Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. arXiv preprint arXiv:1710.09412, 2017.
298
+
299
+ Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In CVPR, 2018.
300
+
301
+ Zhun Zhong, Liang Zheng, Guoliang Kang, Shaozi Li, and Yi Yang. Random erasing data augmentation. In AAAI, 2020.
302
+
303
+ Bolei Zhou, Hang Zhao, Xavier Puig, Tete Xiao, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Semantic understanding of scenes through the ade20k dataset. IJCV, 2019.
304
+
305
+ Jinghao Zhou, Chen Wei, Huiyu Wang, Wei Shen, Cihang Xie, Alan Yuille, and Tao Kong. ibot: Image bert pre-training with online tokenizer. arXiv preprint arXiv:2111.07832, 2021.
306
+
307
+ # A APPENDIX
308
+
309
+ # A.1 ADDITIONAL ANALYSIS
310
+
311
+ Relationship between the type of the generator and the performance of the enhancer. What makes a "good" generator for the enhancer? We believe there are three main factors that affect the output quality of the generator: (1) The masking strategy and masking ratio of the generator’s inputs. (2) The size / capacity of the small trainable BEiT. (3) The type of image tokenizers.
312
+
313
+ While there are many perspectives / ways to evaluate a generator, this study focuses on visual pretraining of the enhancer, so we are particularly interested in how these factors affect the enhancer’s fine-tuning performance on downstream visual recognition tasks.
314
+
315
+ Factor 1 & 2 has already been well studied in Table 4 & Table 5 respectively: either a too “weak” generator (e.g., too much masking or the size of the trainable BEiT is too small) or a too “strong” generator (e.g., too less masking or the trainable BEiT is too large) is harmful to the fine-tuning performance of the enhancer.
316
+
317
+ As for Factor 3, the image tokenizer represents a given image in the RGB domain as a permutation of discrete tokens with a fixed vocabulary size. This compact representation along with the stochastic sampling process can generate an abundant & diverse input set to feed the enhancer better. However, if the generator is too strong & robust that can always generate near ground truth output regardless of the stochastic sampling, the enhancer can hardly learn useful representations or even be wrongly penalized.
318
+
319
+ To show that, in Table 10 we study another well-established and open-sourced image tokenizer, VQGAN (Esser et al., 2021), on the ViT-B enhancer with 300 epochs pre-training & 100 epochs fine-tuning on ImageNet-1k. We also study the effects of directly using a MAE-Base model as the generator.
320
+
321
+ Table 10: Study of different generator tpye of CIM pre-training for ViT-Base.
322
+
323
+ <table><tr><td>Generator Type of CIM</td><td>Top-1 Acc.</td></tr><tr><td>MAE-style generator w/ 50% masking ratio</td><td>82.6 (-0.7)</td></tr><tr><td>BEiT-Style generator w/ VQGAN tokenizer</td><td>82.9 (-0.4)</td></tr><tr><td>BEiT-Style generator w/DALL-E tokenizer (our default seting)</td><td>83.3</td></tr></table>
324
+
325
+ For the MAE-style generator, we sample RGB color values at all masked positions of the MAE decoder outputs. Since the stochastic sampling is performed on the RGB domain, only some low-level features (mainly color) can be changed and corrupted. Therefore the enhancer only learns to correct low-level attributes.
326
+
327
+ For the BEiT-style generator w/ VQGAN tokenizer, compared with the DALL-E tokenizer used as default, the VQGAN tokenizer is trained with two additional losses, i.e., the perceptual loss (Zhang et al., 2018) as well as the GAN loss (Isola et al., 2017). These two additional losses are originally intended for high-quality image synthesis, but could make the tokenizer become too strong & robust to generate appropriate corrupted samples for the enhancer. We visualize the corrupted samples from the VQGAN tokenizer, and we find it nearly reconstructs the original input even with stochastic token sampling. Therefore the samples from the VQGAN tokenizer are not diverse enough and cannot provide rich supervision for the enhancer to learn transferable representations.
328
+
329
+ Overall, it is hard to find a good indicator from the generator that can directly reflect and measure the representation quality of the enhancer. By now, the best way is to honestly fine-tune the pre-trained enhancer on downstream tasks.
330
+
331
+ Study of training the generator first and keeping it fixed for the enhancer’s pre-training. We tried first train the generator separately for 300 epochs and then pre-train the enhancer for another 300 epochs while keeping the generator’s weights fixed. The performance suffers from a $0 . 4 \%$ degeneration. We hypothesize synergetic & simultaneous training provides a curriculum-like pretraining strategy for the enhancer where the generator starts off weak but gets better throughout training.
332
+
333
+ Additional training cost of CIM compared to simple mask prediction with the same mask ratio. We study the relationship between the pre-training time and downstream performances of different approaches for both ViTs and ConvNets in Table 11 and Table 12 respectively.
334
+
335
+ Since CIM is built upon BEiT, we choose BEiT as the masked image modeling baseline approach of ViTs. Here, we first study the ViT-B model’s 100-epoch fine-tuning performance on ImageNet-1k val set with different pre-training schedules in Table 11. The wall-clock time of 1-epoch pre-training of CIM is about $1 . 8 \mathrm { x }$ of BEiT (CIM has an additional tokenizer decoder compared with BEiT) on the same machine.
336
+
337
+ Table 11: Study of the training cost for ViT-Base pre-training.
338
+
339
+ <table><tr><td>Methods</td><td>PT Epochs</td><td>Relative PT Time</td><td>Top-1 Acc.</td></tr><tr><td>BEiT</td><td>300</td><td>1.0x</td><td>82.9</td></tr><tr><td>BEiT</td><td>800</td><td>2.7x</td><td>83.2</td></tr><tr><td>BEiT</td><td>1600</td><td>5.3x</td><td>83.3</td></tr><tr><td>CIM</td><td>800</td><td>1.8x</td><td>83.3</td></tr><tr><td>CIM</td><td>800</td><td>4.8x</td><td>83.4</td></tr></table>
340
+
341
+ In Table 12, we also study the ResNet-50x4 model’s 100-epoch fine-tuning performance on ImageNet1k val set with different pre-training schedules. We choose SimMIM as the masked image modeling baseline approach of ConvNets, for it reports the ResNet-50x4 model’s result in Appendix E of its paper. The wall-clock time of 1-epoch pre-training of CIM is about $2 . 6 \mathbf { x }$ of SimMIM (CIM has an additional generator, including a small BEiT and a tokenizer encoder & decoder compared with SimMIM) on the same machine.
342
+
343
+ Table 12: Study of the training cost for ResNet-50x4 pre-training.
344
+
345
+ <table><tr><td>Methods</td><td>PT Epochs</td><td>Relative PT Time</td><td> Top-1 Acc.</td></tr><tr><td>SimMIM</td><td>300</td><td>1.0x</td><td>81.6</td></tr><tr><td>CIM</td><td>100</td><td>0.9x</td><td>82.2</td></tr></table>
346
+
347
+ These results imply that CIM can obtain better fine-tuning performance with less pre-training time compared with baseline approaches for both ViTs and ConvNets.
348
+
349
+ # A.2 A NOTE ON VISUALIZATIONS IN $\ S 2 . 2$ AND FIGURE 3
350
+
351
+ Since there exists information loss in any form of normalization, we have to inject the original image’s information in order to visualize the enhancer output (4th column in Figure 3a). In order to comprehensively demonstrate our method’s behavior, we also include the unnormalized counterpart in Figure 3b for reference, where there is no additional information injection during visualization.
352
+
353
+ # A.3 TRAINING AND OPTIMIZATION DETAILS
354
+
355
+ The auxiliary generator and the enhancer are simultaneously trained and synergistically (rather than adversarially as GAN (Goodfellow et al., 2014)) updated. The trainable part of the generator, i.e., the small BEiT, learns a MIM objective in the same vein as in BEiT (Bao et al., 2021). Formally, given an input image’s patch embedding sequence $\pmb { x } = ( \pmb { x } _ { 1 } , . . . , \pmb { x } _ { n } )$ , we randomly mask $k$ embeddings at positions $\pmb { m } = ( m _ { 1 } , . . . , m _ { k } )$ using [MASK] token2. The resulting masked input sequence $_ { \textbf { \em x } }$ masked for BEiT is:
356
+
357
+ $$
358
+ \begin{array} { r } { m _ { i } \sim \mathrm { u n i f o r m } \{ 1 , n \} , \mathrm { f o r } i = 1 , . . . , k , } \\ { \pmb { x } ^ { \mathrm { m a s k e d } } = \mathrm { r e p l a c e } ( \pmb { x } , \pmb { m } , [ \mathrm { M A S K } ] ) , \quad \quad } \end{array}
359
+ $$
360
+
361
+ where the replace $( x , m$ , [MASK]) operation denotes using the special [MASK] token to replace patch embeddings of $_ { \textbf { \em x } }$ at positions $_ { m }$ . The small BEiT then encodes $x ^ { \mathrm { m a s k e d } }$ and learns to maximize
362
+
363
+ $\log p _ { \mathrm { B E i T } } ( \pmb { g } \mid \pmb { x } ^ { \mathrm { m a s k e d } } )$ , i.e., the log-likelihood of the golden visual tokens $\pmb { g } = ( g _ { 1 } , . . . , g _ { k } )$ at the masked positions $_ { \mathbf { \nabla } } \mathbf { m } _ { \mathbf { \nabla } }$ conditioned on $x ^ { \mathrm { m a s k e d } }$ . Notice that the golden tokens are obtained by feeding the original image to the image tokenizer encoder.
364
+
365
+ In order to generate corrupted image samples $\mathcal { T } ^ { \mathrm { c o r r u p t e d } }$ for the enhancer, we sample tokens’ replacements from the BEiT output distribution $p _ { \mathrm { B E i T } }$ at each masked position $j$ of the encoded $\pmb { x } ^ { \mathrm { m a s k } \bar { \mathrm { e } } \mathrm { d } }$ :
366
+
367
+ $$
368
+ \begin{array} { r l } & { x _ { j } ^ { \mathrm { s a m p l e d } } \sim p _ { \mathrm { B E i T } } ( x _ { j } ^ { \mathrm { s a m p l e d } } \mid x ^ { \mathrm { m a s k e d } } ) , \mathrm { f o r } j \in m , } \\ & { x ^ { \mathrm { c o r r u p t e d } } = \mathrm { r e p l a c e } ( g , m , x ^ { \mathrm { s a m p l e d } } ) , } \end{array}
369
+ $$
370
+
371
+ where the replace $( \pmb { g } , \pmb { m } , \pmb { x } ^ { \mathrm { s a m p l e d } } )$ operation denotes using the sampled visual token $x ^ { \mathrm { s a m p l e d } }$ to replace golden tokens of $\textbf { { g } }$ at positions $_ { m }$ . Next, the image tokenizer decoder maps $\pmb { x } ^ { \mathrm { c o r r u p t e d } }$ to a corrupted image $\mathcal { T } ^ { \mathrm { c o r r u p t e d } }$ . The whole image tokenizer is frozen (i.e., not updated throughout the pre-training phase), which directly uses the publicly available3 pre-trained DALL-E dVAE weight (Ramesh et al., 2021) following BEiT.
372
+
373
+ The enhancer takes the corrupted image $\mathcal { T } ^ { \mathrm { c o r r u p t e d } }$ as input. For the RESPIX visual pretext task, the enhancer is optimized by a combination of $l _ { 1 }$ and $l _ { 2 }$ loss for pixel regression. For the REVDET variant, the enhancer is learned by binary cross-entropy loss for replaced visual token detection. The gradients of the enhancer are not back-propagated through the generator.
374
+
375
+ In this paper, we study CIM self-supervised pre-trained vanilla ViT (Dosovitskiy et al., 2020) and vanilla ResNet (He et al., 2016) models. The vanilla ViT models refer to the design from (Dosovitskiy et al., 2020; Touvron et al., 2021a) without further architectural change such as using relative position embeddings (Shaw et al., 2018) and LayerScale (Touvron et al., 2021b). The vanilla ResNet-50 model refers to the torchvision ResNet-50 (Paszke et al., 2019) without any architectural change. The larger ResNet-50x2 and ResNet-50x4 models follows the canonical design in SimCLR (Chen et al., 2020b). We conduct experiments on $1 6 \times$ or $3 2 \times$ V100 GPUs with 32GB memory.
376
+
377
+ A.4 PRE-TRAINING & FINE-TUNING CONFIGURATIONS
378
+
379
+ A.4.1 THE IMAGENET-1K CIM PRE-TRAINING CONFIGURATIONS FOR VANILLA VIT AND RESNET MODELS
380
+ Table 13: The ImageNet-1K CIM pre-training settings for vanilla ViT-S/16, ViT-B/16 and ResNet-50 models. Notably, the pre-training configurations are almost the same for different architectures. We implement the pre-training using the codebase of BEiT (Bao et al., 2021). Mixed precision and deepspeed acceleration are used.
381
+
382
+ <table><tr><td>Pre-training Config. (ViT &amp; ResNet)</td><td>Value</td></tr><tr><td>Optimizer</td><td>AdamW (Loshchilov &amp; Hutter, 2017)</td></tr><tr><td>Pre-training Epochs</td><td>300</td></tr><tr><td>Peak Learning Rate</td><td>1.5e-3</td></tr><tr><td>Batch Size</td><td>2048</td></tr><tr><td>Weight Decay</td><td>0.05</td></tr><tr><td>Optimizer Momentum (β1,β2)</td><td>(0.9, 0.98) (Vaswani et al., 2017)</td></tr><tr><td>Learning Rate Schedule</td><td>Cosine Decay</td></tr><tr><td>Gradient Clipping</td><td>3.0</td></tr><tr><td>Warmup Epochs</td><td>10</td></tr><tr><td>#Masked Patches for the Generator</td><td>100 to 120, Random Masking</td></tr><tr><td>The Generator&#x27;s Depth</td><td>4 to 6</td></tr><tr><td>The Generator&#x27;s Width</td><td>Same to the Enhancer (ViT), 384 (ResNet)</td></tr><tr><td>The Enhancer&#x27;s Loss Weight</td><td>1 forREVDET,1O forREsPIX</td></tr><tr><td>Data Augmentation</td><td>RandomResizedCrop Only</td></tr><tr><td>Dropout (Srivastava et al., 2014)</td><td>X X</td></tr><tr><td>Stochastic Depth (Huang et al., 2016)</td><td></td></tr><tr><td>LayerScale (Touvron et al., 2021b) Pos.Emb.in TransformerLayers</td><td>X</td></tr><tr><td></td><td>1-D Absolute Pos. Emb. (Dosovitskiy et al., 2020)</td></tr><tr><td>Patch Size</td><td>16 224</td></tr><tr><td>Pre-training Resolution</td><td></td></tr></table>
383
+
384
+ A.4.2 THE IMAGENET-1K IMAGE CLASSIFICATION FINE-TUNING CONFIGURATIONS FOR VANILLA VIT MODELS
385
+ Table 14: The ImageNet-1K image classification fine-tuning recipes for vanilla ViT-S/16 and ViT-B/16. We implement the fine-tuning using the codebase of BEiT (Bao et al., 2021). Mixed precision and deepspeed acceleration are used. We select the best learning rate out of $\{ 3 \mathrm { e } { - } 3 , 4 \mathrm { e } { - } 3 , 5 \mathrm { e } { - } 3 \}$ for different sized models and pre-training objectives, and the absolute difference between the worst and the best learning rate is less than 0.3 in terms of the top-1 accuracy.
386
+
387
+ <table><tr><td>Fine-tuning Config. (ViT)</td><td>Value</td></tr><tr><td>Optimizer</td><td>AdamW (Loshchilov &amp; Hutter, 2017)</td></tr><tr><td>Fine-tuning Epochs</td><td>200 forViT-S/16,10O forViT-B/16</td></tr><tr><td>Peak Learning Rate</td><td>3e-3 forViT-B/16REsPIX,5e-3 forViT-B/16 REVDET,3e-3 or4e-3 forViT-S/16</td></tr><tr><td>Layer-wise Learning Rate Decay (Bao et al.,</td><td>0.8 (Clark et al., 2020)</td></tr><tr><td>2021) Batch Size</td><td>1024</td></tr><tr><td>Weight Decay</td><td>0.05</td></tr><tr><td>Optimizer Momentum (β1, β2)</td><td>(0.9, 0.999)</td></tr><tr><td>Learning Rate Schedule</td><td>Cosine Decay</td></tr><tr><td>Warmup Epochs</td><td>5</td></tr><tr><td>Gradient Clipping</td><td>X</td></tr><tr><td>Dropout (Srivastava et al., 2014)</td><td>X</td></tr><tr><td>Stochastic Depth (Huang et al., 2016)</td><td>0.1</td></tr><tr><td>Label Smoothing (Szegedy et al., 2016)</td><td>0.1</td></tr><tr><td>Mixup (Zhang et al., 2017)</td><td>0.8</td></tr><tr><td>CutMix (Yun et al., 2019)</td><td>1.0</td></tr><tr><td>Random Augmentation (Cubuk et al., 2020)</td><td>9 /0.5</td></tr><tr><td>Patch Size</td><td>16</td></tr><tr><td>Fine-tuning Resolution</td><td>224</td></tr><tr><td>Test Resolution</td><td>224</td></tr><tr><td>Test Crop Ratio</td><td>0.95</td></tr><tr><td>Loss Function</td><td>Cross Entropy Loss</td></tr></table>
388
+
389
+ A.4.3 THE IMAGENET-1K IMAGE CLASSIFICATION FINE-TUNING CONFIGURATIONS FOR VANILLA RESNET-50
390
+ Table 15: The ImageNet-1K image classification fine-tuning recipes for vanilla ResNet-50. We use the AdamW optimizer. The hyperparameter settings basically follows (Wightman et al., 2021). We implement the fine-tuning based on the codebase of BEiT (Bao et al., 2021). Mixed precision and deepspeed acceleration are used. For other self-supervised baseline approaches we compared in Table 2, we select the best learning rate out of $\{ 5 \mathrm { e } { - } 3 , 8 \mathrm { e } { - } 3 , 1 2 \mathrm { e } { - } 3 \}$ and keep other settings unchanged.
391
+
392
+ <table><tr><td>Fine-tuning Config. (ResNet-50)</td><td>100 Epoch FT</td><td>300Epoch FT</td><td>600 Epoch FT</td></tr><tr><td>Optimizer</td><td colspan="3">AdamW (Loshchilov &amp; Hutter, 2017)</td></tr><tr><td>Peak Learning Rate</td><td colspan="3">12e-3</td></tr><tr><td>Layer-wise Learning Rate Decay (Bao et al., 2021)</td><td colspan="3">X</td></tr><tr><td>Batch Size</td><td colspan="3">2048</td></tr><tr><td>Learning Rate Schedule</td><td colspan="3">Cosine Decay</td></tr><tr><td>Loss Function</td><td colspan="3">Binary Cross Entropy Loss</td></tr><tr><td>Warmup Epochs</td><td colspan="3">5</td></tr><tr><td>Weight Decay</td><td>0.02</td><td>0.02</td><td>0.01</td></tr><tr><td>Fine-tuning Resolution</td><td>160</td><td>224</td><td>224</td></tr><tr><td>Test Resolution</td><td></td><td>224</td><td></td></tr><tr><td>Test Crop Ratio</td><td></td><td>0.95</td><td></td></tr><tr><td>Repeated Augmentation (Berman et al.,</td><td>X</td><td>√</td><td>1</td></tr><tr><td>2019; Hoffer et al., 2019) Random Augmentation (Cubuk et al.,</td><td>6/0.5</td><td>7 /0.5</td><td>7 /0.5</td></tr><tr><td>2020)</td><td></td><td></td><td></td></tr><tr><td>Mixup (Zhang et al., 2017) CutMix (Yun et al., 2019)</td><td>0.1</td><td>0.1 1.0</td><td>0.2</td></tr><tr><td>Label Smoothing (Szegedy et al., 2016)</td><td>0.1</td><td></td><td>0.1</td></tr><tr><td>Stochastic Depth (Huang et al.,2016)</td><td></td><td>X</td><td></td></tr><tr><td></td><td>X</td><td>X</td><td>0.05</td></tr><tr><td>Dropout (Srivastava et al., 2014)</td><td></td><td>X</td><td></td></tr><tr><td>Layer-wise Learning Rate Decay</td><td></td><td>X</td><td></td></tr></table>
md/dev/0EXmFzUn5I/0EXmFzUn5I.md ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PYRAFORMER: LOW-COMPLEXITY PYRAMIDAL AT-TENTION FOR LONG-RANGE TIME SERIES MODELINGAND FORECASTING
2
+
3
+ Shizhan $ { \mathbf { L i u ^ { 1 , 2 * } } }$ , Hang $\mathbf { Y u } ^ { 1 }$ ∗, Cong Liao1, Jianguo $\mathbf { L i } ^ { 1 }$ †, Weiyao Lin2, Alex X. Liu1, and Schahram Dustdar3
4
+
5
+ 1Ant Group, 2Shanghai Jiaotong University, 3 TU Wien, Austria
6
+
7
+ # ABSTRACT
8
+
9
+ Accurate prediction of the future given the past based on time series data is of paramount importance, since it opens the door for decision making and risk management ahead of time. In practice, the challenge is to build a flexible but parsimonious model that can capture a wide range of temporal dependencies. In this paper, we propose Pyraformer by exploring the multi-resolution representation of the time series. Specifically, we introduce the pyramidal attention module (PAM) in which the inter-scale tree structure summarizes features at different resolutions and the intra-scale neighboring connections model the temporal dependencies of different ranges. Under mild conditions, the maximum length of the signal traversing path in Pyraformer is a constant (i.e., $\mathcal { O } ( 1 ) \mathrm { { _ { \it } } }$ ) with regard to the sequence length $L$ , while its time and space complexity scale linearly with $L$ . Extensive experimental results show that Pyraformer typically achieves the highest prediction accuracy in both single-step and long-range multi-step forecasting tasks with the least amount of time and memory consumption, especially when the sequence is $\mathrm { l o n g ^ { 1 } }$ .
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Time series forecasting is the cornerstone for downstream tasks such as decision making and risk management. As an example, reliable prediction of the online traffic for micro-services can yield early warnings of the potential risk in cloud systems. Furthermore, it also provides guidance for dynamic resource allocation, in order to minimize the cost without degrading the performance. In addition to online traffic, time series forecasting has also found vast applications in other fields, including disease propagation, energy management, and economics and finance.
14
+
15
+ The major challenge of time series forecasting lies in constructing a powerful but parsimonious model that can compactly capture temporal dependencies of different ranges. Time series often exhibit both short-term and long-term repeating patterns (Lai et al., 2018), and taking them into account is the key to accurate prediction. Of particular note is the more difficult task of handling long-range dependencies, which is characterized by the length of the longest signal traversing path (see Proposition 2 for the definition) between any two positions in the time series (Vaswani et al., 2017). The shorter the path, the better the dependencies are captured. Additionally, to allow the models to learn these long-term patterns, the historical input to the models should also be long. To this end, low time and space complexity is a priority.
16
+
17
+ Unfortunately, the present state-of-the-art methods fail to accomplish these two objectives simultaneously. On one end, RNN (Salinas et al., 2020) and CNN (Munir et al., 2018) achieve a low time complexity that is linear in terms of the time series length $L$ , yet their maximum length of the signal traversing path is $\mathcal { O } ( L )$ , thus rendering them difficult to learn dependencies between distant positions. On the other extreme, Transformer dramatically shortens the maximum path to be $\mathcal { O } ( 1 )$
18
+
19
+ ![](images/cdf77eb19d8c5bb6faae2ef9f8506ac4c8d47ead1a5b2a18785a17c7a43fae51.jpg)
20
+ Figure 1: Graphs of commonly used neural network models for sequence data.
21
+
22
+ Table 1: Comparison of the complexity and the maximum signal traveling path for different models, where $G$ is the number of global tokens in ETC. In practice, the $G$ increases with $L$ , and so the complexity of ETC is super-linear.
23
+
24
+ <table><tr><td>Method</td><td>Complexityper layer</td><td>Maximum path length</td></tr><tr><td>CNN (Munir et al., 2018)</td><td>O(L)</td><td>O(L)</td></tr><tr><td>RNN (Salinas et al.,2020)</td><td>O(L)</td><td>O(L)</td></tr><tr><td>Full-Attention (Vaswani et al.,2017)</td><td>O(L2)</td><td>0(1)</td></tr><tr><td>ETC (Ainslie et al., 2020)</td><td>O(GL)</td><td>0(1)</td></tr><tr><td>Longformer (Beltagy et al., 2020)</td><td>O(L)</td><td>O(L)</td></tr><tr><td>LogTrans (Li et al., 2019)</td><td>O(L log L)</td><td>O(log L)</td></tr><tr><td>Pyraformer</td><td>O(L)</td><td>0(1)</td></tr></table>
25
+
26
+ at the sacrifice of increasing the time complexity to $\mathcal { O } ( L ^ { 2 } )$ . As a consequence, it cannot tackle very long sequences. To find a compromise between the model capacity and complexity, variants of Transformer are proposed, such as Longformer (Beltagy et al., 2020), Reformer (Kitaev et al., 2019), and Informer (Zhou et al., 2021). However, few of them can achieve a maximum path length less than $\mathcal { O } ( L )$ while greatly reducing the time and space complexity.
27
+
28
+ In this paper, we propose a novel pyramidal attention based Transformer (Pyraformer) to bridge the gap between capturing the long-range dependencies and achieving a low time and space complexity. Specifically, we develop the pyramidal attention mechanism by passing messages based on attention in the pyramidal graph as shown in Figure 1(d). The edges in this graph can be divided into two groups: the inter-scale and the intra-scale connections. The inter-scale connections build a multiresolution representation of the original sequence: nodes at the finest scale correspond to the time points in the original time series (e.g., hourly observations), while nodes in the coarser scales represent features with lower resolutions (e.g., daily, weekly, and monthly patterns). Such latent coarser-scale nodes are initially introduced via a coarser-scale construction module. On the other hand, the intra-scale edges capture the temporal dependencies at each resolution by connecting neighboring nodes together. As a result, this model provides a compact representation for long-range temporal dependencies among far-apart positions by capturing such behavior at coarser resolutions, leading to a smaller length of the signal traversing path. Moreover, modeling temporal dependencies of different ranges at different scales with sparse neighboring intra-scale connections significantly reduces the computational cost. In short, our key contributions comprise:
29
+
30
+ • We propose Pyraformer to simultaneously capture temporal dependencies of different ranges in a compact multi-resolution fashion. To distinguish Pyraformer from the stateof-the-art methods, we summarize all models from the perspective of graphs in Figure 1. • Theoretically, we prove that by choosing parameters appropriately, the maximum path length of $\mathcal { O } ( 1 )$ and the time and space complexity of $\mathcal O ( L )$ can be reached concurrently. To highlight the appeal of the proposed model, we further compare different models in terms of the maximum path and the complexity in Table 1.
31
+
32
+ • Experimentally, we show that the proposed Pyraformer yields more accurate predictions than the original Transformer and its variants on various real-world datasets under the scenario of both single-step and long-range multi-step forecasting, but with lower time and memory cost.
33
+
34
+ # 2 RELATED WORKS
35
+
36
+ # 2.1 TIME SERIES FORECASTING
37
+
38
+ Time series forecasting methods can be roughly divided into statistical methods and neural network based methods. The first group involves ARIMA (Box & Jenkins, 1968) and Prophet (Taylor & Letham, 2018). However, both of them need to fit each time series separately, and their performance pales when it comes to long-range forecasting.
39
+
40
+ More recently, the development of deep learning has spawned a tremendous increase in neural network based time series forecasting methods, including CNN (Munir et al., 2018), RNN (Salinas et al., 2020) and Transformer (Li et al., 2019). As mentioned in the previous section, CNN and RNN enjoy a low time and space complexity (i.e., $\mathcal { O } ( L ) )$ ), but entail a path of $\mathcal O ( L )$ to describe long-range dependence. We refer the readers to Appendix A for a more detailed review on related RNN-based models. By contrast, Transformer (Vaswani et al., 2017) can effectively capture the long-range dependence with a path of $\mathcal { O } ( 1 )$ steps, whereas the complexity increases vastly from $\mathcal O ( L )$ to $\check { \mathcal { O } } ( L ^ { 2 } )$ . To alleviate this computational burden, LogTrans (Li et al., 2019) and Informer (Zhou et al., 2021) are proposed: the former constrains that each point in the sequence can only attend to the point that is $2 ^ { n }$ steps before it, where $n = 1 , 2 , \cdots$ , and the latter utilizes the sparsity of the attention score, resulting in substantial decrease in the complexity (i.e., $\mathcal { O } ( L \log L )$ at the expense of introducing a longer maximum path length.
41
+
42
+ # 2.2 SPARSE TRANSFORMERS
43
+
44
+ In addition to the literature on time series forecasting, a plethora of methods have been proposed for enhancing the efficiency of Transformer in the field of natural language processing (NLP). Similar to CNN, Longformer (Beltagy et al., 2020) computes attention within a local sliding window or a dilated sliding window. Although the complexity is reduced to $\mathcal { O } ( A L )$ , where $A$ is the local window size, the limited window size makes it difficult to exchange information globally. The consequent maximum path length is $\mathcal { O } ( L / A )$ . As an alternative, Reformer (Kitaev et al., 2019) exploits locality sensitive hashing (LSH) to divide the sequence into several buckets, and then performs attention within each bucket. It also employs reversible Transformer to further reduce memory consumption, and so an extremely long sequence can be processed. Its maximum path length is proportional to the number of buckets though, and worse still, a large bucket number is required to reduce the complexity. On the other hand, ETC (Ainslie et al., 2020) introduces an extra set of global tokens for the sake of global information exchange, leading to an $\mathcal { O } ( G L )$ time and space complexity and an $\mathcal { O } ( 1 )$ maximum path length, where $G$ is the number of global tokens. However, $G$ typically increases with $L$ , and the consequent complexity is still super-linear. Akin to ETC, the proposed Pyraformer also introduces global tokens, but in a multiscale manner, successfully reducing the complexity to $\mathcal { O } ( L )$ without increasing the order of the maximum path length as in the original Transformer.
45
+
46
+ # 2.3 HIERARCHICAL TRANSFORMERS
47
+
48
+ Finally, we provide a brief review on methods that improve Transformer’s ability to capture the hierarchical structure of natural language, although they have never been used for time series forecasting. HIBERT (Miculicich et al., 2018) first uses a Sent Encoder to extract the features of a sentence, and then forms the EOS tokens of sentences in the document as a new sequence and input it into the Doc Encoder. However, it is specialized for natural language and cannot be generalized to other sequence data. Multi-scale Transformer (Subramanian et al., 2020) learns the multi-scale representations of sequence data using both the top-down and bottom-up network structures. Such multi-scale representations help reduce the time and memory cost of the original Transformer, but it still suffers from the pitfall of the quadratic complexity. Alternatively, BP-Transformer (Ye et al., 2019) recursively partitions the entire input sequence into two until a partition only contains a single token. The partitioned sequences then form a binary tree. In the attention layer, each upper-scale node can attend to its own children, while the nodes at the bottom scale can attend to the adjacent $A$ nodes at the same scale and all coarser-scale nodes. Note that BP-Transformer initializes the nodes at coarser scale with zeros, whereas Pyraformer introduces the coarser-scale nodes using a construction module in a more flexible manner. Moreover, BP-Transformer is associated with a denser graph than Pyraformer, thus giving rise to a higher complexity of $\mathcal { O } ( L \log L )$ .
49
+
50
+ ![](images/56cd8894c208a5e364b1dc0bb7b398b69c875aae166d907b12cd98ff3ac99fe5.jpg)
51
+ Figure 2: The architecture of Pyraformer: The CSCM summarizes the embedded sequence at different scales and builds a multi-resolution tree structure. Then the PAM is used to exchange information between nodes efficiently.
52
+
53
+ # 3 METHOD
54
+
55
+ The time series forecasting problem can be formulated as predicting the future $M$ steps $z _ { t + 1 : t + M }$ given the previous $L$ steps of observations $z _ { t - L + 1 : t }$ and the associated covariates $\pmb { x } _ { t - L + 1 : t + M }$ (e.g., hour-of-the-day). To move forward to this goal, we propose Pyraformer in this paper, whose overall architecture is summarized in Figure 2. As shown in the figure, we first embed the observed data, the covariates, and the positions separately and then add them together, in the same vein with Informer (Zhou et al., 2021). Next, we construct a multi-resolution $C$ -ary tree using the coarserscale construction module (CSCM), where nodes at a coarser scale summarize the information of $C$ nodes at the corresponding finer scale. To further capture the temporal dependencies of different ranges, we introduce the pyramidal attention module (PAM) by passing messages using the attention mechanism in the pyramidal graph. Finally, depending on the downstream task, we employ different network structures to output the final predictions. In the sequel, we elaborate on each part of the proposed model. For ease of exposition, all notations in this paper are summarized in Table 4.
56
+
57
+ # 3.1 PYRAMIDAL ATTENTION MODULE (PAM)
58
+
59
+ We begin with the introduction of the PAM, since it lies at the heart of Pyraformer. As demonstrated in Figure 1(d), we leverage a pyramidal graph to describe the temporal dependencies of the observed time series in a multiresolution fashion. Such a multiresolution structure has proved itself an effective and efficient tool for long-range interaction modeling in the field of computer vision (Sun et al., 2019; Wang et al., 2021) and statistical signal processing (Choi et al., 2008; Yu et al., 2019). We can decompose the pyramidal graph into two parts: the inter-scale and the intra-scale connections. The inter-scale connections form a $C$ -ary tree, in which each parent has $C$ children. For example, if we associate the finest scale of the pyramidal graph with hourly observations of the original time series, the nodes at coarser scales can be regarded as the daily, weekly, and even monthly features of the time series. As a consequence, the pyramidal graph offers a multi-resolution representation of the original time series. Furthermore, it is easier to capture long-range dependencies (e.g., monthly dependence) in the coarser scales by simply connecting the neighboring nodes via the intra-scale connections. In other words, the coarser scales are instrumental in describing long-range correlations in a manner that is graphically far more parsimonious than could be solely captured with a single, finest scale model. Indeed, the original single-scale Transformer (see Figure 1(a)) adopts a full graph that connects every two nodes at the finest scale so as to model the long-range dependencies, leading to a computationally burdensome model with $\mathcal { O } ( L ^ { 2 } )$ time and space complexity (Vaswani et al., 2017). In stark contrast, as illustrated below, the pyramidal graph in the proposed Pyraformer reduces the computational cost to $\mathcal O ( L )$ without increasing the order of the maximum length of the signal traversing path.
60
+
61
+ Before delving into the PAM, we first introduce the original attention mechanism. Let $\boldsymbol { X }$ and $\mathbf { Y }$ denote the input and output of a single attention head respectively. Note that multiple heads can be introduced to describe the temporal pattern from different perspectives. $\boldsymbol { X }$ is first linearly transformed into three distinct matrices, namely, the query $Q = X W _ { Q }$ , the key $\pmb { K } = \pmb { X } \pmb { W } _ { K }$ , and the value $\pmb { V } = \pmb { X } \pmb { W } _ { V }$ , where $W _ { Q }$ , $W _ { K }$ , $W _ { V } \in \mathbb { R } ^ { L \times D _ { K } }$ . For the $i$ -th row $\pmb q _ { i }$ in $Q$ , it can attend to any rows (i.e., keys) in $\kappa$ . In other words, the corresponding output $\mathbf { \nabla } _ { \mathbf { \psi } _ { 3 } } \psi _ { i }$ can be expressed as:
62
+
63
+ $$
64
+ { \pmb y } _ { i } = \sum _ { \ell = 1 } ^ { L } \frac { \mathrm { e x p } ( { \pmb q } _ { i } { \pmb k } _ { \ell } ^ { T } / \sqrt { D _ { K } } ) { \pmb v } _ { \ell } } { \sum _ { \ell = 1 } ^ { L } \mathrm { e x p } ( { \pmb q } _ { i } { \pmb k } _ { \ell } ^ { T } / \sqrt { D _ { K } } ) } ,
65
+ $$
66
+
67
+ where $k _ { \ell } ^ { T }$ denotes the transpose of row $\ell$ in $\kappa$ . We emphasize that the number of query-key dot products (Q-K pairs) that need to be calculated and stored dictates the time and space complexity of the attention mechanism. Viewed another way, this number is proportional to the number of edges in the graph (see Figure 1(a)). Since all Q-K pairs are computed and stored in the full attention mechanism (1), the resulting time and space complexity is $\mathcal { O } ( L ^ { 2 } )$ .
68
+
69
+ As opposed to the above full attention mechanism, every node only pays attention to a limited set of keys in the PAM, corresponding to the pyramidal graph in Figure 1d. Concretely, suppose that $n _ { \ell } ^ { ( s ) }$ denotes the $\ell \cdot$ -th node at scale $s$ , where $s = 1 , \cdots , S$ represents the bottom scale to the top scale sequentially. In general, each node in the graph can attend to a set of neighboring nodes $\mathbb { N } _ { \ell } ^ { ( s ) }$ at three scales: the adjacent $A$ nodes at the same scale including the node itself (denoted as $\mathbb { A } _ { \ell } ^ { ( s ) }$ ), the $C$ children it has in the $C$ -ary tree (denoted as $\mathbb { C } _ { \ell } ^ { ( s ) } .$ ), and the parent of it in the $C$ -ary tree (denoted $\mathbb { P } _ { \ell } ^ { ( s ) } )$ , that is,
70
+
71
+ $$
72
+ \left\{ \begin{array} { l l l l l l l l l l l l l } { \mathbb { N } _ { \ell } ^ { ( s ) } } & { = } & { \mathbb { A } _ { \ell } ^ { ( s ) } \cup \mathbb { C } _ { \ell } ^ { ( s ) } \cup \mathbb { P } _ { l } ^ { ( s ) } } & & & & & \\ { \mathbb { A } _ { \ell } ^ { ( s ) } } & { = } & { \{ n _ { j } ^ { ( s ) } : | j - \ell | \leq \frac { A - 1 } { 2 } , 1 \leq j \leq \frac { L } { C ^ { s - 1 } } \} } & & & & & \\ { \mathbb { C } _ { \ell } ^ { ( s ) } } & { = } & { \{ n _ { j } ^ { ( s - 1 ) } : ( \ell - 1 ) C < j \leq \ell C \} } & { \mathrm { i f } s \geq 2 \mathrm { e l s e } \emptyset } & & & \\ { \mathbb { P } _ { \ell } ^ { ( s ) } } & { = } & { \{ n _ { j } ^ { ( s + 1 ) } : j = \lceil \frac { \ell } { C } \rceil \} } & { \mathrm { i f } s \leq S - 1 \mathrm { e l s e } \emptyset } & & & & \end{array} \right. .
73
+ $$
74
+
75
+ It follows that the attention at node $n _ { \ell } ^ { ( s ) }$ can be simplified as:√
76
+
77
+ $$
78
+ \pmb { y } _ { i } = \sum _ { \ell \in \mathbb { N } _ { \ell } ^ { ( s ) } } \frac { \exp ( \pmb { q } _ { i } \pmb { k } _ { \ell } ^ { T } / \sqrt { d _ { K } } ) \pmb { v } _ { \ell } } { \sum _ { \ell \in \mathbb { N } _ { l } ^ { ( s ) } } \exp ( \pmb { q } _ { i } \pmb { k } _ { \ell } ^ { T } / \sqrt { d _ { K } } ) } ,
79
+ $$
80
+
81
+ We further denote the number of attention layers as $N$ . Without loss of generality, we assume that $L$ is divisible by $C ^ { S - 1 }$ . We can then have the following lemma (cf. Appendix $\mathbf { B }$ for the proof and Table 4 for the meanings of the notations).
82
+
83
+ Lemma 1. Given $A , C , L , N$ , and $S$ that satisfy Equation (4), after $N$ stacked attention layers, nodes at the coarsest scale can obtain a global receptive field.
84
+
85
+ $$
86
+ \frac { L } { C ^ { S - 1 } } - 1 \leq \frac { ( A - 1 ) N } { 2 } .
87
+ $$
88
+
89
+ In addition, when the number of scales $S$ is fixed, the following two propositions summarize the time and space complexity and the order of the maximum path length for the proposed pyramidal attention mechanism. We refer the readers to Appendix C and $\mathrm { D }$ for proof.
90
+
91
+ Proposition 1. The time and space complexity for the pyramidal attention mechanism is $\mathcal { O } ( A L )$ for given $A$ and $L$ and amounts to $\mathcal O ( L )$ when $A$ is a constant w.r.t. $L$ .
92
+
93
+ Proposition 2. Let the signal traversing path between two nodes in a graph denote the shortest path connecting them. Then the maximum length of signal traversing path between two arbitrary nodes in the pyramidal graph is $\mathcal { O } ( S + L / C ^ { S - 1 } / A )$ for given $A$ , $C$ , $L$ , and $S$ . Suppose that $A$ and $S$ are fixed and $C$ satisfies Equation (5), the maximum path length is $\mathcal { O } ( 1 )$ for time series with length $L$ .
94
+
95
+ $$
96
+ \sqrt [ s - 1 ] { L } \geq C \geq \sqrt [ s - 1 ] { \frac { L } { ( A - 1 ) N / 2 + 1 } } .
97
+ $$
98
+
99
+ ![](images/91aa8cb400219056af9686acde2534aae765cbb65f9bf4e842354362211e49b1.jpg)
100
+ Figure 3: Coarser-scale construction module: $B$ is the batch size and $D$ is the dimension of a node.
101
+
102
+ In our experiments, we fix $S$ and $N$ , and $A$ can only take 3 or 5, regardless of the sequence length $L$ . Therefore, the proposed PAM achieves the complexity of $\mathcal { O } ( L )$ with the maximum path length of $\mathcal { O } ( 1 )$ . Note that in the PAM, a node can attend to at most $A + C + 1$ nodes. Unfortunately, such a sparse attention mechanism is not supported in the existing deep learning libraries, such as Pytorch and TensorFlow. A naive implementation of the PAM that can fully exploit the tensor operation framework is to first compute the product between all Q-K pairs, i.e., $\mathbf { \Delta } q _ { i } \mathbf { \Delta } k _ { \ell } ^ { T }$ for $\ell =$ $1 , \cdots , L$ , and then mask out $\ell \notin \mathbb { N } _ { \ell } ^ { ( s ) }$ . However, the resulting time and space complexity of this implementation is still $\mathcal { O } ( L ^ { 2 } )$ . Instead, we build a customized CUDA kernel specialized for the PAM using TVM (Chen et al., 2018), practically reducing the computational time and memory cost and making the proposed model amenable to long time series. Longer historical input is typically helpful for improving the prediction accuracy, as more information is provided, especially when long-range dependencies are considered.
103
+
104
+ # 3.2 COARSER-SCALE CONSTRUCTION MODULE (CSCM)
105
+
106
+ CSCM targets at initializing the nodes at the coarser scales of the pyramidal graph, so as to facilitate the subsequent PAM to exchange information between these nodes. Specifically, the coarse-scale nodes are introduced scale by scale from bottom to top by performing convolutions on the corresponding children nodes $\mathbb { C } _ { \ell } ^ { ( s ) }$ . As demonstrated in Figure 3, several convolution layers with kernel size $C$ and stride $C$ are sequentially applied to the embedded sequence in the dimension of time, yielding a sequence with length $L / C ^ { s }$ at scale $s$ . The resulting sequences at different scales form a $C$ -ary tree. We concatenate these fine-to-coarse sequences before inputting them to the PAM. In order to reduce the amount of parameters and calculations, we reduce the dimension of each node by a fully connected layer before inputting the sequence into the stacked convolution layers and restore it after all convolutions. Such a bottleneck structure significantly reduces the number of parameters in the module and can guard against over-fitting.
107
+
108
+ # 3.3 PREDICTION MODULE
109
+
110
+ For single-step forecasting, we add an end token (by setting $z _ { t + 1 } = 0$ ) to the end of the historical sequence $z _ { t - L + 1 : t }$ before inputting it into the embedding layer. After the sequence is encoded by the PAM, we gather the features given by the last nodes at all scales in the pyramidal graph, concatenate and then input them into a fully connected layer for prediction.
111
+
112
+ For multi-step forecasting, we propose two prediction modules. The first one is the same with the single-step forecasting module, but maps the last nodes at all scales to all $M$ future time steps in a batch. The second one, on the other hand, resorts to a decoder with two full attention layers. Specifically, similar to the original Transformer (Vaswani et al., 2017), we replace the observations at the future $M$ time steps with 0, embed them in the same manner with the historical observations, and refer to the summation of the observation, covariate, and positional embedding as the “prediction token” $F _ { p }$ . The first attention layer then takes the prediction tokens $F _ { p }$ as the query and the output of the encoder $\pmb { F _ { e } }$ (i.e., all nodes in the PAM) as the key and the value, and yields ${ \bf { { F } } } _ { d 1 }$ . The second layer takes ${ \mathbf { } } F _ { d 1 }$ as the query, but takes the concatenated ${ \bf { { F } } } _ { d 1 }$ and $\pmb { F _ { e } }$ as the key and the value. The historical information $\pmb { F _ { e } }$ is fed directly into both attention layers, since such information is vital for accurate long-range forecasting. The final prediction is then obtained through a fully connected layer across the dimension of channels. Again, we output all future predictions together to avoid the problem of error accumulation in the autoregressive decoder of Transformer.
113
+
114
+ Table 2: Single-step forecasting results on three datasets. “Q-K pairs” refer to the number of querykey dot products performed by all attention layers in the network, which encodes the time and space complexity. We write the number of attention layers by $N$ , the number of attention heads by $H$ , the number of scales by $S$ , the dimension of a node by $D$ , the dimension of a key by $D _ { K }$ , the maximum dimension of feed-forward layer by $D _ { F }$ , and the convolution stride by $C$ .
115
+
116
+ <table><tr><td>Methods</td><td>Parameters</td><td>Datasets</td><td>NRMSE</td><td>ND</td><td>Q-K pairs</td></tr><tr><td rowspan="3">Full-attention</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.328</td><td>0.041</td><td>456976</td></tr><tr><td>Wind</td><td>0.175</td><td>0.082</td><td>589824</td></tr><tr><td>App Flow</td><td>0.407</td><td>0.080</td><td>589824</td></tr><tr><td rowspan="3">LogTrans</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.333</td><td>0.041</td><td>50138</td></tr><tr><td>Wind</td><td>0.173</td><td>0.081</td><td>58272</td></tr><tr><td>App Flow</td><td>0.387</td><td>0.073</td><td>58272</td></tr><tr><td rowspan="3">Reformer</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.359</td><td>0.047</td><td>677376</td></tr><tr><td>Wind</td><td>0.183</td><td>0.086</td><td>884736</td></tr><tr><td>AppFlow</td><td>0.463</td><td>0.095</td><td>884736</td></tr><tr><td rowspan="3">ETC</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.324</td><td>0.041</td><td>79536</td></tr><tr><td>Wind</td><td>0.167</td><td>0.074</td><td>102144</td></tr><tr><td>App Flow</td><td>0.397</td><td>0.069</td><td>102144</td></tr><tr><td rowspan="3">Longformer</td><td rowspan="3">O(N(HDDK+DDF))</td><td>Electricity</td><td>0.330</td><td>0.041</td><td>41360</td></tr><tr><td>Wind</td><td>0.166</td><td>0.075</td><td>52608</td></tr><tr><td>AppFlow</td><td>0.377</td><td>0.07</td><td>52608</td></tr><tr><td rowspan="3">Pyraformer</td><td rowspan="3">O(N(HDDK+DDF) +(S-1)CD²)</td><td>Electricity</td><td>0.324</td><td>0.041</td><td>17648</td></tr><tr><td>Wind</td><td>0.161</td><td>0.072</td><td>20176</td></tr><tr><td>App Flow</td><td>0.366</td><td>0.067</td><td>20176</td></tr></table>
117
+
118
+ # 4 EXPERIMENTS
119
+
120
+ # 4.1 DATASETS AND EXPERIMENT SETUP
121
+
122
+ We demonstrated the advantages of the proposed Pyraformer on the four real-world datasets, including Wind, App Flow, Electricity, and ETT. The first three datasets were used for single-step forecasting, while the last two for long-range multi-step forecasting. We refer the readers to Appendix E and F for more details regarding the data description and the experiment setup.
123
+
124
+ # 4.2 RESULTS AND ANALYSIS
125
+
126
+ # 4.2.1 SINGLE-STEP FORECASTING
127
+
128
+ We conducted single-step prediction experiments on three datasets: Electricity, Wind and App Flow. The historical length is 169, 192 and 192, respectively, including the end token. We benchmarked Pyraformer against 5 other attention mechanisms, including the original full-attention (Vaswani et al., 2017), the log-sparse attention (i.e., LogTrans) (Li et al., 2019), the LSH attention (i.e., Reformer) (Kitaev et al., 2019), the sliding window attention with global nodes (i.e., ETC) (Ainslie et al., 2020), and the dilated sliding window attention (i.e., Longformer) (Beltagy et al., 2020). In particular for ETC, some nodes with equal intervals at the finest scale were selected as the global nodes. A global node can attend to all nodes across the sequence and all nodes can attend to it in turn(see Figure 1(e)). The training and testing schemes were the same for all models. We further investigated the usefulness of the pretraining strategy (see Appendix G), the weighted sampler, and the hard sample mining on all methods, and the best results were presented. We adopted the NRMSE (Normalized RMSE) and the ND (Normalized Deviation) as the evaluation indicators (see Appendix H for the definitions). The results are summarized in Table 2. For a fair comparison, except for full-attention, the overall dot product number of all attention mechanisms was controlled to the same order of magnitude.
129
+
130
+ Our experimental results show that Pyraformer outperforms Transformer and its variants in terms of NRMSE and ND, with the least number of query-key dot products (a.k.a. Q-K pairs). Concretely, there are three major trends that can be gleaned from Table 2: (1) The proposed Pyraformer yields the most accurate prediction results, suggesting that the pyramidal graph can better explain the temporal interactions in the time series by considering dependencies of different ranges. Interestingly, for the Wind dataset, sparse attention mechanisms, namely, LogTrans, ETC, Longformer and Pyraformer, outperform the original full attention Transformer, probably because the data contains a large number of zeros and the promotion of adequate sparsity can help avoid over-fitting. (2) The number of Q-K pairs in Pyraformer is the smallest. Recall that this number characterizes the time and space complexity. Remarkably enough, it is $6 5 . 4 \%$ fewer than that of LogTrans and $9 6 . 6 \%$ than that of the full attention. It is worth emphasizing that this computational gain will continue to increase for longer time series. (3) The number of parameters for Pyraformer is slightly larger than that of the other models, resulting from the CSCM. However, this module is very lightweight, which incurs merely $5 \%$ overhead in terms of model size compared to other models. Moreover, in practice, we can fix the hyper-parameters $A$ , $S$ and $N$ , and ensure that $C$ satisfies $C > \sqrt [ s - 1 ] { L / ( ( A - 1 ) N / 2 + 1 ) }$ . Consequently, the extra number of parameters introduced by the CSCM is only $\mathcal { O } ( ( S - 1 ) C D _ { K } ^ { 2 } ) \approx \mathcal { O } ( \sqrt [ s ] { L } )$ .
131
+
132
+ Table 3: Long-range multi-step forecasting results.
133
+
134
+ <table><tr><td rowspan="2">Methods</td><td rowspan="2">Metrics</td><td colspan="3">ETTh1</td><td colspan="3">ETTm1</td><td colspan="3">Electricity</td></tr><tr><td>168</td><td>336</td><td>720</td><td>96</td><td>288</td><td>672</td><td>168</td><td>336</td><td>720</td></tr><tr><td rowspan="3">Informer</td><td>MSE</td><td>1.075</td><td>1.329</td><td>1.384</td><td>0.556</td><td>0.841</td><td>0.921</td><td>0.745</td><td>1.579</td><td>4.365</td></tr><tr><td>MAE</td><td>0.801</td><td>0.911</td><td>0.950</td><td>0.537</td><td>0.705</td><td>0.753</td><td>0.266</td><td>0.323</td><td>0.371</td></tr><tr><td>Q-K pairs</td><td>188040</td><td>188040</td><td>423360</td><td>276480</td><td>560640</td><td>560640</td><td>188040</td><td>188040</td><td>423360</td></tr><tr><td rowspan="3">LogTrans</td><td>MSE</td><td>0.983</td><td>1.100</td><td>1.411</td><td>0.554</td><td>0.786</td><td>1.169</td><td>0.791</td><td>1.584</td><td>4.362</td></tr><tr><td>MAE</td><td>0.766</td><td>0.839</td><td>0.991</td><td>0.499</td><td>0.676</td><td>0.868</td><td>0.340</td><td>0.336</td><td>0.366</td></tr><tr><td>Q-K pairs</td><td>74664</td><td>74664</td><td>216744</td><td>254760</td><td>648768</td><td>648768</td><td>74664</td><td>74664</td><td>216744</td></tr><tr><td rowspan="3">Longformer</td><td>MSE</td><td>0.860</td><td>0.975</td><td>1.091</td><td>0.526</td><td>0.767</td><td>1.021</td><td>0.766</td><td>1.591</td><td>4.361</td></tr><tr><td>MAE</td><td>0.710</td><td>0.769</td><td>0.832</td><td>0.507</td><td>0.663</td><td>0.788</td><td>0.311</td><td>0.343</td><td>0.368</td></tr><tr><td>Q-K pairs</td><td>63648</td><td>63648</td><td>249120</td><td>329760</td><td>1007136</td><td>1007136</td><td>63648</td><td>63648</td><td>249120</td></tr><tr><td rowspan="3">Reformer</td><td>MSE</td><td>0.958</td><td>1.044</td><td>1.458</td><td>0.543</td><td>0.924</td><td>0.981</td><td>0.783</td><td>1.584</td><td>4.374</td></tr><tr><td>MAE</td><td>0.741</td><td>0.787</td><td>0.987</td><td>0.528</td><td>0.722</td><td>0.778</td><td>0.332</td><td>0.334</td><td>0.374</td></tr><tr><td>Q-K pairs</td><td>1016064</td><td>1016064</td><td>2709504</td><td>5308416</td><td>14450688</td><td>14450688</td><td>1016064</td><td>1016064</td><td>2709504</td></tr><tr><td rowspan="3">ETC</td><td>MSE</td><td>1.025</td><td>1.084</td><td>1.137</td><td>0.762</td><td>1.227</td><td>1.272</td><td>0.777</td><td>1.586</td><td>4.361</td></tr><tr><td>MAE</td><td>0.771</td><td>0.811</td><td>0.866</td><td>0.653</td><td>0.880</td><td>0.908</td><td>0.326</td><td>0.340</td><td>0.368</td></tr><tr><td>Q-K pairs</td><td>125280</td><td>125280</td><td>288720</td><td>331344</td><td>836952</td><td>836952</td><td>125280</td><td>125280</td><td>288720</td></tr><tr><td rowspan="3">Pyraformer</td><td>MSE</td><td>0.808</td><td>0.945</td><td>1.022</td><td>0.480</td><td>0.754</td><td>0.857</td><td>0.719</td><td>1.533</td><td>4.312</td></tr><tr><td>MAE</td><td>0.683</td><td>0.766</td><td>0.806</td><td>0.486</td><td>0.659</td><td>0.707</td><td>0.256</td><td>0.291</td><td>0.346</td></tr><tr><td>Q-K pairs</td><td>26472</td><td>26472</td><td>74280</td><td>57264</td><td>96384</td><td>96384</td><td>26472</td><td>26472</td><td>74280</td></tr></table>
135
+
136
+ # 4.2.2 LONG-RANGE MULTI-STEP FORECASTING
137
+
138
+ We evaluated the performance of Pyraformer for long-range forecasting on three datasets, that is, Electricity, ETTh1, and ETTm1. In particular for ETTh1 and ETTm1, we predicted the future oil temperature and the 6 power load features at the same time, which is a multivariate time series forecasting problem. Both prediction modules introduced in Section 3.3 were tested for all models and the better results are listed in Table 3.
139
+
140
+ It is evident that Pyraformer still achieves the best performance with the least number of Q-K pairs for all datasets regardless of the prediction length. More precisely, in comparison with Informer (Zhou et al., 2021), the MSE given by Pyraformer for ETTh1 is decreased by $2 4 . 8 \%$ , $2 8 . 9 \%$ , $2 6 . 2 \%$ respectively when the prediction length is 168, 336, and 720. Once again, this bolsters our belief that it is more beneficial to employ the pyramidal graph when describing the temporal dependencies. Interestingly, we notice that for Pyraformer, the results given by the first prediction module are better than those by the second one. One possible explanation is that the second prediction module based on the full attention layers cannot differentiate features with different resolutions, while the first module based on a single fully connected layer can take full advantages of such features in an automated fashion. To better elucidate the modeling capacity of Pyraformer for long-range forecasting, we refer the readers to Appendix I for a detailed example on synthetic data.
141
+
142
+ ![](images/c76b7f33141c4ef44a7a1594f69b85c5196a20fecbd341cd7e0a1ecd285eb186.jpg)
143
+ Figure 4: Comparison of the time and memory consumption between the full, the prob-sparse, and the TVM implementation of the pyramidal attention: (a) computation time; (b) memory occupation.
144
+
145
+ # 4.2.3 SPEED AND MEMORY CONSUMPTION
146
+
147
+ To check the efficiency of the customized CUDA kernel implemented based on TVM, we depicted the empirical computation time and memory cost as a function of the sequence length $L$ in Figure 4. Here we only compared Pyraformer with the full attention and the prob-sparse attention in Informer (Zhou et al., 2021). All the computations were performed on a $1 2 \mathrm { \ G B }$ Titan $\mathrm { X p }$ GPU with Ubuntu 16.04, CUDA 11.0, and TVM 0.8.0. Figure 4 shows that the time and memory cost of the proposed Pyraformer based on TVM is approximately a linear function of $L$ , as expected. Furthermore, the time and memory consumption of the TVM implementation can be several orders of magnitude smaller than that of the full attention and the prob-sparse attention, especially for relatively long time series. Indeed, for a 12GB Titan Xp GPU, when the sequence length reaches 5800, full attention encounters the out-of-memory (OOM) problem, yet the TVM implementation of Pyraformer only occupies 1GB of memory. When it comes to a sequence with 20000 time points, even Informer incurs the OOM problem, whereas the memory cost of Pyraformer is only 1.91GB and the computation time per batch is only 0.082s.
148
+
149
+ # 4.3 ABLATION STUDY
150
+
151
+ We also performed ablation studies to measure the impact of $A$ and $C$ , the CSCM architecture, the history length, and the PAM on the prediction accuracy of Pyraformer. The results are displayed in Tables 7-10. Detailed Discussions on the results can be found in Appendix J. Here, we only provide an overview of the major findings: (1) it is better to increase $C$ with $L$ but fix $A$ to a small constant for the sake of reducing the prediction error; (2) convolution with bottleneck strikes a balance between the prediction accuracy and the number of parameters, and hence, we use it as the CSCM; (3) more history helps increase the accuracy of forecasting; (4) the PAM is essential for accurate prediction.
152
+
153
+ # 5 CONCLUSION AND OUTLOOK
154
+
155
+ In this paper, we propose Pyraformer, a novel model based on pyramidal attention that can effectively describe both short and long temporal dependencies with low time and space complexity. Concretely, we first exploit the CSCM to construct a $C$ -ary tree, and then design the PAM to pass messages in both the inter-scale and the intra-scale fashion. By adjusting $C$ and fixing other parameters when the sequence length $L$ increases, Pyraformer can achieve the theoretical $\mathcal O ( L )$ complexity and $\mathcal { O } ( 1 )$ maximum signal traversing path length. Experimental results show that the proposed model outperforms the state-of-the-art models for both single-step and long-range multi-step prediction tasks, but with less computational time and memory cost. So far we only concentrate on the scenario where $A$ and $S$ are fixed and $C$ increases with $L$ when constructing the pyramidal graph. On the other hand, we have shown in Appendix I that other configurations of the hyper-parameters may further improve the performance of Pyraformer. In the future work, we would like to explore how to adaptively learn the hyper-parameters from the data. Also, it is interesting to extend Pyraformer to other fields, including natural language processing and computer vision.
156
+
157
+ # ACKNOWLEDGEMENT
158
+
159
+ In this work, Prof. Weiyao Lin was supported by Ant Group through Ant Research Program and in part by National Natural Science Foundation of China under grant U21B2013.
160
+
161
+ REFERENCES
162
+ Joshua Ainslie, Santiago Ontanon, Chris Alberti, Vaclav Cvicek, Zachary Fisher, Philip Pham, Anirudh Ravula, Sumit Sanghai, Qifan Wang, and Li Yang. Etc: Encoding long and structured inputs in transformers. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 268–284, 2020.
163
+ Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020.
164
+ George EP Box and Gwilym M Jenkins. Some recent advances in forecasting and control. Journal of the Royal Statistical Society. Series C (Applied Statistics), 17(2):91–109, 1968.
165
+ Shiyu Chang, Yang Zhang, Wei Han, Mo Yu, Xiaoxiao Guo, Wei Tan, Xiaodong Cui, Michael Witbrock, Mark Hasegawa-Johnson, and Thomas S Huang. Dilated recurrent neural networks. Advances in Neural Information Processing Systems, 2017:77–87, 2017.
166
+ Tianqi Chen, Thierry Moreau, Ziheng Jiang, Lianmin Zheng, Eddie Yan, Haichen Shen, Meghan Cowan, Leyuan Wang, Yuwei Hu, Luis Ceze, et al. $\{ \mathrm { T V M } \}$ : An automated end-to-end optimizing compiler for deep learning. In 13th {USENIX} Symposium on Operating Systems Design and Implementation $\bar { \langle } O S D I \rangle \bar { I } \delta )$ , pp. 578–594, 2018.
167
+ M. J. Choi, V. Chandrasekaran, D. M. Malioutov, J. K. Johnson, and A. S. Willsky. Multiscale stochastic modeling for tractable inference and data assimilation. Computer Methods in Applied Mechanics and Engineering, 197(43-44):3492–3515, 2008.
168
+ Junyoung Chung, Sungjin Ahn, and Yoshua Bengio. Hierarchical multiscale recurrent neural networks. In 5th International Conference on Learning Representations, ICLR 2017, 2019.
169
+ Marta R Costa-jussa and Jos \` e AR Fonollosa. Character-based neural machine translation. In ´ Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 357–361, 2016.
170
+ Jaeyoung Kim, Mostafa El-Khamy, and Jungwon Lee. Residual lstm: Design of a deep recurrent architecture for distant speech recognition. arXiv preprint arXiv:1701.03360, 2017.
171
+ Nikita Kitaev, Lukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In International Conference on Learning Representations, 2019.
172
+ Guokun Lai, Wei-Cheng Chang, Yiming Yang, and Hanxiao Liu. Modeling long-and short-term temporal patterns with deep neural networks. In The 41st International ACM SIGIR Conference on Research & Development in Information Retrieval, pp. 95–104, 2018.
173
+ Shiyang Li, Xiaoyong Jin, Yao Xuan, Xiyou Zhou, Wenhu Chen, Yu-Xiang Wang, and Xifeng Yan. Enhancing the locality and breaking the memory bottleneck of transformer on time series forecasting. Advances in Neural Information Processing Systems, 32:5243–5253, 2019.
174
+ Lesly Miculicich, Dhananjay Ram, Nikolaos Pappas, and James Henderson. Document level neural machine translation with hierarchical attention networks. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP), number CONF, 2018.
175
+ Mohsin Munir, Shoaib Ahmed Siddiqui, Andreas Dengel, and Sheraz Ahmed. Deepant: A deep learning approach for unsupervised anomaly detection in time series. Ieee Access, 7:1991–2005, 2018.
176
+ David Salinas, Valentin Flunkert, Jan Gasthaus, and Tim Januschowski. Deepar: Probabilistic forecasting with autoregressive recurrent networks. International Journal of Forecasting, 36(3):1181– 1191, 2020.
177
+
178
+ M. Schuster. Bi-directional recurrent neural networks for speech recognition. In Proceeding of IEEE Canadian Conference on Electrical and ComputerEngineering, pp. 7–12, 1996.
179
+
180
+ Sandeep Subramanian, Ronan Collobert, Marc’Aurelio Ranzato, and Y-Lan Boureau. Multi-scale transformer language models. arXiv preprint arXiv:2005.00581, 2020.
181
+
182
+ 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.
183
+
184
+ Sean J Taylor and Benjamin Letham. Forecasting at scale. The American Statistician, 72(1):37–45, 2018.
185
+
186
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998–6008, 2017.
187
+
188
+ W. Wang, E. Xie, X. Li, D. P. Fan, and L. Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. 2021.
189
+
190
+ Zihao Ye, Qipeng Guo, Quan Gan, Xipeng Qiu, and Zheng Zhang. Bp-transformer: Modelling long-range context via binary partitioning. arXiv preprint arXiv:1911.04070, 2019.
191
+
192
+ Hang Yu, Luyin Xin, and Justin Dauwels. Variational wishart approximation for graphical model selection: Monoscale and multiscale models. IEEE Transactions on Signal Processing, 67(24): 6468–6482, 2019. doi: 10.1109/TSP.2019.2953651.
193
+
194
+ Hsiang-Fu Yu, Nikhil Rao, and Inderjit S Dhillon. Temporal regularized matrix factorization for high-dimensional time series prediction. Advances in neural information processing systems, 29: 847–855, 2016.
195
+
196
+ Haoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, and Wancai Zhang. Informer: Beyond efficient transformer for long sequence time-series forecasting. In Proceedings of AAAI, 2021.
197
+
198
+ Simiao Zuo, Haoming Jiang, Zichong Li, Tuo Zhao, and Hongyuan Zha. Transformer hawkes process. In International Conference on Machine Learning, pp. 11692–11702. PMLR, 2020.
199
+
200
+ Table 4: Meanings of notations.
201
+
202
+ <table><tr><td>Notation</td><td>Size</td><td>Meaning</td></tr><tr><td>L</td><td>Constant</td><td>The length of historical sequence.</td></tr><tr><td>G</td><td>Constant</td><td>The number of global tokens in ETC.</td></tr><tr><td>M</td><td>Constant</td><td>The length of future sequence to be predicted.</td></tr><tr><td>B</td><td>Constant</td><td>Batch size.</td></tr><tr><td>D</td><td>Constant</td><td>The dimension of each node.</td></tr><tr><td>DK</td><td>Constant</td><td>The dimension of a key.</td></tr><tr><td>X</td><td>B×L×D</td><td>Input of a single attention head.</td></tr><tr><td>Y</td><td>B×L×D</td><td>Output of a single attention head.</td></tr><tr><td>Q</td><td>B×L×Dk</td><td>The query.</td></tr><tr><td>K</td><td>B×L×Dk</td><td>The key.</td></tr><tr><td>V</td><td>B×L×Dk</td><td>The value.</td></tr><tr><td>WQ</td><td>D×Dk</td><td>The weight matrix of the query.</td></tr><tr><td>WK</td><td>D ×Dk</td><td>The weight matrix of the key.</td></tr><tr><td>Wv</td><td>D×Dk</td><td>The weight matrix of the value.</td></tr><tr><td>S</td><td>Constant</td><td>Number of scales.</td></tr><tr><td>A</td><td>Constant</td><td>Number of adjacent nodes at the same scale that a node can attend to.</td></tr><tr><td>C</td><td>Constant</td><td>Number of finer scale nodes that a coarser scale node can summarize.</td></tr><tr><td>N</td><td>Constant</td><td>Number of attention layers.</td></tr><tr><td>n(</td><td>D</td><td>The l-th node at scale s.</td></tr><tr><td>N</td><td>len(N)) × D</td><td></td></tr><tr><td>A</td><td>len(A()) × D</td><td> The adjacent A nodes at the same scale with n(s).</td></tr><tr><td>C</td><td>len(C()) × D</td><td></td></tr><tr><td>P</td><td>len(P(s) × D</td><td> The parent node of n(s).</td></tr><tr><td>Fp</td><td>B×M×D</td><td>The prediction tokens.</td></tr><tr><td>Fe</td><td>B ×Ltot ×D</td><td> The output of the encoder. Ltot represents the output length of the encod</td></tr><tr><td>Fd1</td><td>B×M×D</td><td>The output of the first attention-based decoder layer.</td></tr><tr><td>H</td><td>Constant</td><td>The number of attention heads.</td></tr><tr><td>DF</td><td></td><td></td></tr><tr><td></td><td>Constant</td><td>The maximum dimension of the feed-forward layer.</td></tr></table>
203
+
204
+ # A A BRIEF REVIEW ON RELATED RNN-BASED MODELS
205
+
206
+ In this section, we provide a brief review on the related RNN-based models. Multiscale temporal dependencies are successfully captured in HRNN (Costa-jussa & Fonollosa, 2016) and HM- \` RNN (Chung et al., 2019). The former requires expert knowledge to partition the sequence into different resolutions, while the latter learns the partition automatically from the data. Note that the theoretical maximum length of the signal traversing path in both models is still $\mathcal O ( L )$ . Another line of works aim to shorten the signal traversing path by adding residual connections (Kim et al., 2017) or dilated connections to LSTMs (Chang et al., 2017). However, they do not consider the multiresolution temporal dependencies explicitly. Furthermore, all aforementioned RNNs only propagate information in one direction from the past to the future. An appealing approach that allows bidirectional information exchange is Bi-LSTM (Schuster, 1996). The forward and backward propagation is realized through two different LSTMs though, and so still incurs a long signal traversing path.
207
+
208
+ As opposed to the abovementioned RNN-based models, the proposed Pyraformer enables bidirectional information exchange that can better describe the temporal dependencies, while providing a multiresolution representation of the observed sequence at the same time. We also notice that due to the unidirectional property of RNNs, it is difficult the realize the pyramidal graph in Figure 1d based on RNNs.
209
+
210
+ # B PROOF OF LEMMA 1
211
+
212
+ Proof. Let $S$ denote the number of scales in the pyramidal graph, $C$ the number of children nodes in the finer scale $s - 1$ that a node in the the coarser scale $s$ can summarize for $s = 2 , \cdots , S , A$ the number of adjacent nodes that a node can attend to within each scale, $N$ the number of attention layers, and $L$ the length of the input time series. We define the term “receptive field” of an arbitrary node $n _ { a }$ in a graph as the set of nodes that $n _ { a }$ can receive messages from. We further define the distance between two arbitrary nodes in a graph as the length of the shortest path between them (i.e., the number of steps to travel from one node to another). Note that in each attention layer, the messages can only travel by one step in the graph.
213
+
214
+ Without sacrificing generality, we assume that $L$ is divisible by $C ^ { S - 1 }$ , and then the number of nodes at the coarsest scale $S$ is $L / C ^ { S - 1 }$ . Since every node is connected to $A$ closest nodes at the same scale, the distance between the leftmost and the rightmost node at the coarsest scale is $2 ( L / C ^ { S - 1 } - 1 ) / ( A - 1 )$ . Hence, the leftmost and the rightmost node in the coarsest scale are in the receptive field of each other after the stack of $N \geq 2 ( L / C ^ { S - 1 } - 1 ) / ( A - 1 )$ layers of the pyramidal attention. In addition, owing to the CSCM, nodes at the coarsest scale can be regarded as the summary of the nodes in the finer scales. As a result, when Equation (4) is satisfied, all nodes at the coarsest scale have a global receptive field, which closes the proof. □
215
+
216
+ # C PROOF OF PROPOSITION 1
217
+
218
+ Proof. Suppose that $L ^ { ( s ) }$ denotes the number of nodes at scale $s$ , that is,
219
+
220
+ $$
221
+ L ^ { ( s ) } = \frac { L } { C ^ { s - 1 } } , 1 \leq s \leq S .
222
+ $$
223
+
224
+ For a node $n _ { \ell } ^ { ( s ) }$ in the pyramidal graph, the number of dot products $P _ { \ell } ^ { ( s ) }$ it acts as the query can be decomposed into two parts:
225
+
226
+ $$
227
+ P _ { \ell } ^ { ( s ) } = P _ { \ell } ^ { ( s ) } { } _ { \mathrm { i n t e r } } + P _ { \ell } ^ { ( s ) } { } _ { \mathrm { i n t r a } } ,
228
+ $$
229
+
230
+ where P (s) $P _ { \ell } ^ { ( s ) } { _ { \mathrm { i n t r a } } }$ a and P (s)ℓ int denotes the intra-scale and the inter-scale part respectively. According to the structure of the pyramidal graph, we can have the following inequalities:
231
+
232
+ $$
233
+ \begin{array} { r l } & { P _ { \ell \mathrm { \tiny ~ \min i n t r a } } ^ { ( s ) } \le A , } \\ & { P _ { \ell \mathrm { \tiny ~ \min t e r } } ^ { ( s ) } \le C + 1 . } \end{array}
234
+ $$
235
+
236
+ The first inequality (8) holds since a node typically attends to $A$ most adjacent nodes at the same scale but for the leftmost and the rightmost node, the number of in-scale nodes it can attend to is smaller than $A$ . On the other hand, the second inequality (9) holds because a node typically has $C$ children and 1 parent in the pyramidal graph but nodes at the top and the bottom scale can only attend to fewer than $C + 1$ nodes at adjacent scales.
237
+
238
+ In summary, the number of dot products that need to be calculated for scale $s$ is:
239
+
240
+ $$
241
+ P ^ { ( s ) } = \sum _ { \ell = 1 } ^ { L ^ { ( s ) } } \big ( P _ { \ell \mathrm { \tiny ~ \mathrm { ~ i n t r a } } } ^ { ( s ) } + P _ { \ell \mathrm { \tiny ~ \mathrm { ~ i n t e r } } } ^ { ( s ) } \big ) \le L ^ { ( s ) } ( A + C + 1 ) .
242
+ $$
243
+
244
+ Note that $P ^ { ( 1 ) } \leq L ( A + 1 )$ for the finest scale (i.e., $s = 1$ ) since nodes at this scale do not have any children. It follows that the number of dot products that need to be calculated for the entire pyramidal attention layer is:
245
+
246
+ $$
247
+ P = \sum _ { s = 1 } ^ { S } P ^ { ( s ) }
248
+ $$
249
+
250
+ $$
251
+ \begin{array} { l } { { \le L ( A + 1 ) + L ^ { ( 2 ) } ( A + C + 1 ) + . . . + L ^ { ( S ) } ( A + C + 1 ) } } \\ { { \displaystyle = L ( \sum _ { s = 1 } ^ { S } C ^ { - ( s - 1 ) } A + \sum _ { s = 2 } ^ { S } C ^ { - ( s - 1 ) } + \sum _ { s = 1 } ^ { S - 1 } C ^ { - ( s - 1 ) } + 1 ) } } \\ { { \displaystyle < L ( ( A + 2 ) \sum _ { s = 1 } ^ { S } C ^ { - ( s - 1 ) } + 1 ) . } } \end{array}
252
+ $$
253
+
254
+ In order to guarantee that the nodes at the coarsest scale have a global receptive field, we choose $C$ such that $\bar { C } \propto \ ^ { s - 1 } \bar { \sqrt { L } }$ . Consequently, the complexity of the proposed pyramidal attention is:
255
+
256
+ $$
257
+ \begin{array} { r l } { { \mathcal { O } ( P ) \leq \mathcal { O } ( L ( ( A + 2 ) \sum _ { s = 1 } ^ { s } C ^ { - ( s - 1 ) } + 1 ) ) } } \\ & { = \mathcal { O } ( L ( A + 2 ) \sum _ { s = 1 } ^ { S } C ^ { - ( s - 1 ) } ) } \\ & { = \mathcal { O } ( \frac { ( A + 2 ) L ^ { \frac { S } { s - 1 } } - 1 } { L ^ { \frac { S - 1 } { s - 1 } } - 1 } ) } \\ & { = \mathcal { O } ( \frac { A L ^ { \frac { S - 1 } { s - 1 } } - 1 } { L ^ { \frac { S - 1 } { s - 1 } } - 1 } ) . } \end{array}
258
+ $$
259
+
260
+ When $L$ approaches infinity, the above expression amounts to $\mathcal { O } ( A L )$ . Since $A$ can be fixed when $L$ changes, the complexity can be further reduced to $\mathcal { O } ( L )$ . □
261
+
262
+ # D PROOF OF PROPOSITION 2
263
+
264
+ and Proof. Let $n _ { L } ^ { ( 1 ) }$ ℓ is the largest among all pairs of nodes in the pyramidal graph. The shortest path to travel $n _ { \ell } ^ { ( s ) }$ represent the $\ell$ -th node of the $s$ -th scale. It is evident that the distance between $n _ { 1 } ^ { ( 1 ) }$ from n(1)1 to $n _ { L } ^ { ( s ) }$ i s:
265
+
266
+ $$
267
+ n _ { 1 } ^ { ( 1 ) } \to n _ { 1 } ^ { ( 2 ) } \to \cdots \to n _ { 1 } ^ { ( S ) } \to \cdots \to n _ { L ^ { ( S ) } } ^ { ( S ) } \to n _ { L ^ { ( S - 1 ) } } ^ { ( S - 1 ) } \to \cdots \to n _ { L } ^ { ( 1 ) } .
268
+ $$
269
+
270
+ Correspondingly, the length of the maximum path between two arbitrary nodes in the graph is:
271
+
272
+ $$
273
+ L _ { \mathrm { m a x } } = 2 ( S - 1 ) + \frac { 2 ( L ^ { ( S ) } - 1 ) } { A - 1 } .
274
+ $$
275
+
276
+ When $C$ satisfies Equation (5), that is, $L ^ { ( S ) } - 1 \le ( A - 1 ) N / 2$ , we can obtain:
277
+
278
+ $$
279
+ \begin{array} { l } { \displaystyle \mathcal { O } \big ( L _ { \mathrm { m a x } } \big ) = \mathcal { O } \bigg ( 2 ( S - 1 ) + \frac { 2 \big ( L ^ { ( S ) } - 1 \big ) } { A - 1 } \bigg ) } \\ { \displaystyle \qquad = \mathcal { O } \bigg ( 2 ( S - 1 ) + \frac { 2 \big ( \frac { L } { C ^ { S - 1 } } - 1 \big ) } { A - 1 } \bigg ) } \\ { \displaystyle \qquad = \mathcal { O } \big ( 2 ( S - 1 ) + N \big ) } \\ { \displaystyle \qquad = \mathcal { O } ( S + N ) . } \end{array}
280
+ $$
281
+
282
+ Since $A , S$ and $N$ are invariant with $L$ , the order of the maximum path length $L _ { \mathrm { m a x } }$ can be further simplified as $\mathcal { O } ( 1 )$ .
283
+
284
+ # E DATASETS
285
+
286
+ We demonstrated the advantages of the proposed Pyraformer on the following four datasets. The first three datasets were used for single-step forecasting, while the last two for long-range multi-step forecasting.
287
+
288
+ Wind2: This dataset contains hourly estimation of the energy potential in 28 countries between 1986 and 2015 as a percentage of a power plant’s maximum output. Compared with the remaining datasets, it is more sparse and periodically exhibits a large number of zeros. Due to the large size of this dataset, the ratio between training and testing set was roughly 32:1.
289
+
290
+ App Flow: This dataset was collected at Ant Group3. It consists of hourly maximum traffic flow for 128 systems deployed on 16 logic data centers, resulting in 1083 different time series in total. The length of each series is more than 4 months. Each time series was divided into two segments for training and testing respectively, with a ratio of 32:1.
291
+
292
+ Electricity4 (Yu et al., 2016): This dataset contains time series of electricity consumption recorded every 15 minutes from 370 users. Following DeepAR (Salinas et al., 2020), we aggregated every 4 records to get the hourly observations. This dataset was employed for both single-step and longrange forecasting. We trained with data from 2011-01-01 to 2014-09-01 for single-step forecasting, and from 2011-04-01 to 2014-04-01 for long-range forecasting.
293
+
294
+ $\mathbf { \mathbf { E } } \mathbf { T } \mathbf { T } ^ { 5 }$ (Zhou et al., 2021): This dataset comprises 2 years of 2 electricity transformers collected from 2 stations, including the oil temperature and 6 power load features. Observations every hour (i.e., ETTh1) and every 15 minutes (i.e., ETTm1) are provided. This dataset is typically exploited for model assessment on long-range forecasting. Here, we followed Informer (Zhou et al., 2021) and partitioned the data into 12 and 4 months for training and testing respectively.
295
+
296
+ # F EXPERIMENT SETUP
297
+
298
+ We set $S = 4$ and $N = 4$ for Pyraformer in all experiments. When the historical length $L$ is not divisible by $C$ , we only introduced $\lfloor L / C \rfloor$ nodes in the upper scale, where $\lfloor \cdot \rfloor$ denotes the round down operation. The last $L - ( \lfloor L / \bar { C } \rfloor - \bar { 1 } ) C$ nodes at the bottom scale were all connected to the last node at the upper scale. For single-step forecasting, we set $C = 4$ , $A = 3$ , and $H = 4$ in all experiments. Both training and testing used a fixed-size historical sequence to predict the mean and variance of the Gaussian distribution of a single future value. We chose the MSE loss and the log-likelihood (Zuo et al., 2020) as our loss functions. The ratio between them was set to 100. For optimization, we used Adam with the learning rate starting from $1 0 ^ { - 5 }$ and halving in every epoch. We trained Pyraformer with 10 epochs. Weighted sampler based on each window’s average value and hard sample mining were used to improve the generalization ability of the network. On the other hand, for long-range forecasting, we tested four combinations of $A$ and $C$ in each experiment, and the best results were presented. Specifically, when the prediction length is smaller than 600, we tested $A = 3 , 5$ and $C = 4 , 5$ . When the prediction length is larger than 600, we tested $A = 3 , 5$ and $C = 5 , 6$ . The resulting choice of hyper-parameters for each experiment is listed in Table 5. In addition, the loss function was the MSE loss only. We still used Adam as our optimizer, but the learning rate started from $1 0 ^ { - 4 }$ and was reduced to one-tenth every epoch. We set the number of epochs to be 5.
299
+
300
+ # G PRETRAINING
301
+
302
+ For single-step forecasting, the value to be predicted is usually close to the last value of history. Since we only use the last nodes of all scales to predict, the network tends to focus only on shortterm dependencies. To force the network to capture long-range dependencies, we add additional supervision in the first few epochs of training. Specifically, in the first epoch, we form our network as an auto-encoder, as shown in Figure 5. Apart from predicting future values, the PAM is also trained to recover the input values. Note that we test all methods with and without this pretraining strategy and the better results are displayed in Table 2.
303
+
304
+ Table 5: Hyper-parameter settings of long-range experiments.
305
+
306
+ <table><tr><td>Dataset</td><td>prediction length</td><td>N</td><td>S</td><td>H</td><td>A</td><td>C</td><td>historical length</td></tr><tr><td rowspan="3">ETTh1</td><td>168</td><td>4</td><td>4</td><td>6</td><td>3</td><td>4</td><td>168</td></tr><tr><td>336</td><td>4</td><td>4</td><td>6</td><td>3</td><td>4</td><td>168</td></tr><tr><td>720</td><td>4</td><td>4</td><td>6</td><td>5</td><td>4</td><td>336</td></tr><tr><td rowspan="3">ETTm1</td><td>96</td><td>4</td><td>4</td><td>6</td><td>3</td><td>5</td><td>384</td></tr><tr><td>288</td><td>4</td><td>4</td><td>6</td><td>5</td><td>5</td><td>672</td></tr><tr><td>672</td><td>4</td><td>4</td><td>6</td><td>3</td><td>6</td><td>672</td></tr><tr><td rowspan="3">Elect</td><td>168</td><td>4</td><td>4</td><td>6</td><td>3</td><td>4</td><td>168</td></tr><tr><td>336</td><td>4</td><td>4</td><td>6</td><td>3</td><td>4</td><td>168</td></tr><tr><td>720</td><td>4</td><td>4</td><td>6</td><td>3</td><td>5</td><td>336</td></tr></table>
307
+
308
+ ![](images/16bca2db6aa268152dfacebb3a8ccf6bd2e2df85f5fcbe3870acda17a4461454.jpg)
309
+ Figure 5: The pretraining strategy for one-step prediction. Features of nodes surrounded by the dashed ellipses are concatenated to recover the corresponding input value.
310
+
311
+ # H METRICS
312
+
313
+ Denote the target value as $z _ { j , t }$ and the predicted value as $\hat { z } _ { j , t }$ , where $j$ is the sample index and $t$ is the time index. Then NRMSE and ND are calculated as follows:
314
+
315
+ $$
316
+ \begin{array} { r l } & { \mathrm { N R M S E } = \frac { \sqrt { \frac { 1 } { N T } \sum _ { j = 1 } ^ { N } \sum _ { t = 1 } ^ { T } ( z _ { j , t } - \hat { z } _ { j , t } ) ^ { 2 } } } { \frac { 1 } { N T } \sum _ { j = 1 } ^ { N } \sum _ { t = 1 } ^ { T } | z _ { j , t } | } , } \\ & { \quad \quad \quad \quad \mathrm { N D } = \frac { \sum _ { j = 1 } ^ { N } \sum _ { t = 1 } ^ { T } | z _ { j , t } - \hat { z } _ { j , t } | } { \sum _ { j = 1 } ^ { N } \sum _ { t = 1 } ^ { T } | z _ { j , t } | } . } \end{array}
317
+ $$
318
+
319
+ # I EXPERIMENTS ON SYNTHETIC DATA
320
+
321
+ To further evaluate Pyraformer’s ability to capture different ranges of temporal dependencies, we synthesized an hourly dataset with multi-range dependencies and carried out experiments on it.
322
+
323
+ Specifically, each time series in the synthetic dataset is a linear combination of three sine functions of different periods: 24, 168 and 720, that is,
324
+
325
+ $$
326
+ f ( t ) = \beta _ { 0 } + \beta _ { 1 } \sin ( \frac { 2 \pi } { 2 4 } t ) + \beta _ { 2 } \sin ( \frac { 2 \pi } { 1 6 8 } t ) + \beta _ { 3 } \sin ( \frac { 2 \pi } { 7 2 0 } t ) .
327
+ $$
328
+
329
+ In the above equation, the coefficients of the three sine functions $\beta _ { 1 } , \beta _ { 2 }$ , and $\beta _ { 3 }$ for each time series are uniformly sampled from [5, 10]. $\beta _ { 0 }$ is a Gaussian process with a covariance function $\Sigma _ { t _ { 1 } , t _ { 2 } } = | t _ { 1 } - t _ { 2 } | ^ { - 1 }$ and $\Sigma _ { t _ { 1 } } = \Sigma _ { t _ { 2 } } = 1$ , where $t _ { 1 }$ and $t _ { 2 }$ denote two arbitrary time stamps. Such polynomially decaying covariance functions are known to have long-range dependence, as oppose to the exponentially decaying covariance functions ( $\mathrm { Y u }$ et al., 2019). The start time of each time series $t _ { 0 }$ is uniformly sampled from [0, 719]. We first generate 60 time series of length 14400, and then split each time series into sliding windows of width 1440 with a stride of 24. In our experiments, we use the historical 720 time points to predict the future 720 points. Since both the deterministic and stochastic parts of the synthetic time series have long-range correlations, such dependencies should be well captured in the model in order to yield accurate predictions of the next 720 points. The results are summarized in Table 6. Here, we consider two different configurations of Pyraformer: 1) $C = 6$ for all scales in the pyramidal graph (denoted as Pyraformer6,6,6); 2) $C = 1 2$ , 7, and 4 for the three layers sequentially from bottom to top (denoted as Pyraformer12,7,4).
330
+
331
+ Table 6: Long-range forecasting results on the synthetic dataset.
332
+
333
+ <table><tr><td>Method</td><td>MSE</td><td>MAE</td></tr><tr><td>Full attention</td><td>3.550</td><td>1.477</td></tr><tr><td>LogTrans</td><td>3.007</td><td>1.366</td></tr><tr><td>ETC</td><td>4.742</td><td>5.509</td></tr><tr><td>Informer</td><td>7.546</td><td>2.092</td></tr><tr><td>Longformer</td><td>2.032</td><td>1.116</td></tr><tr><td>Reformer</td><td>1.538</td><td>3.069</td></tr><tr><td>Pyraformer6,6,6</td><td>1.258</td><td>0.877</td></tr><tr><td>Pyraformer12,7,4</td><td>1.176</td><td>0.849</td></tr></table>
334
+
335
+ It can be observed that Pyraformer6,6,6 with the same $C$ for all scales already outperforms the benchmark methods by a large margin. In particular, the MSE given by Pyraformer is decreased by $1 8 . 2 \%$ compared with Reformer, which produces the smallest MSE among the existing variants of Transformer. On the other hand, by exploiting the information of the known period, Pyraformer12,7,4 performs even better than Pyraformer6,6,6. Note that in Pyraformer $^ { \cdot _ { 1 2 , 7 , 4 } }$ , nodes at scale 2, 3, and 4 characterizes coarser temporal resolutions respectively corresponding to half a day, half a week, and half a month. We also tested Pyraformer24,7,4, but setting $C = 2 4$ in the second scale degrades the performance, probably because the convolution layer with a kernel size of 24 is difficult to train.
336
+
337
+ We further visualized the forecasting results produced by Pyraformer $^ { 1 2 , 7 , 4 }$ in Figure 6. The blue solid curve and red dashed curve denote the true and predicted time series respectively. By capturing the temporal dependencies with different ranges, the prediction resulting from Pyraformer closely follows the ground truth.
338
+
339
+ On the other hand, to check whether Pyraformer can extract features with different temporal resolutions, we depicted the extracted features in a randomly selected channel across time at each scale in the pyramidal graph in Figure 7. It is apparent that the features at the coarser scales can be regarded as a lower resolution version of the features at the finer scales.
340
+
341
+ # J ABLATION STUDY
342
+
343
+ # J.1 IMPACT OF $A$ AND $C$
344
+
345
+ We studied the impact of $A$ and $C$ on the performance of Pyraformer for long-range time series forecasting, and showed the results in Table 7. Here, we focus on the dataset ETTh1. The history length is 336 and the prediction length is 720. From Table 7, we can conclude that the receptive fields of the nodes at the coarsest scale in the PAM play an indispensable role in reducing the prediction error of Pyraformer. For instance, there are 42 nodes at the coarsest scale when $C = 2$ . Without the intra-scale connections, each node can only receive messages from 16 nodes at the finest scale. As the number of adjacent connections $A$ in each scale increases, the receptive fields of the coarsestscale nodes also extend, and therefore, the prediction error decreases accordingly. However, as long as the nodes at the top scale have a global receptive field, further increasing $A$ will not bring large gains. For $C = 5$ , the performance does not improve even though $A$ increases. Such observations indicate that it is better to set $A$ to be small once the uppermost nodes in the PAM have a global receptive field. In practice, we only increase $C$ with the increase of $L$ , but keep $A$ small.
346
+
347
+ ![](images/0e107628896de0c58e44310218af31bad1997b6ef59d90b98d324d9c9992721a.jpg)
348
+ Figure 6: Visualization of prediction results on the synthetic dataset.
349
+
350
+ ![](images/78b6ff45bfe2e9e637686e94056b78164c4a40e9a46ac871d93338b981fb0e83.jpg)
351
+ Figure 7: Visualization of the extracted features across time in second channel at different scales: (a) scale 1; (b) scale 2; (c) scale 3.
352
+
353
+ # J.2 IMPACT OF THE CSCM ARCHITECTURE
354
+
355
+ In addition to convolution, there exist other mechanisms for constructing the $C$ -ary tree, such as max pooling and average pooling. We studied the impact of different CSCM architectures on the performance for long-range forecasting on dataset ETTh1. The history and the prediction length are both 168 and $C = 4$ for all mechanisms. The results are listed in Table 8. From Table 8, we can tell that: (1) Using pooling layers instead of convolution typically degrades the performance. However, the performance of Pyraformer based on max pooling is still superior to that of Informer, demonstrating the advantages of the PAM over the prob-sparse attention in Informer. (2) The MSE of convolution with the bottleneck is only $1 . 5 1 \%$ larger than that without bottleneck, but the number of parameters is reduced by almost $9 0 \%$ . Thus, we adopt the more compact module of convolution with bottleneck as our CSCM.
356
+
357
+ Table 7: Impact of $A$ and $C$ on long-range forecasting. The history length is 336.
358
+
359
+ <table><tr><td rowspan="2"></td><td colspan="3">A=3</td><td colspan="3">A=9</td><td colspan="3">A = 13</td></tr><tr><td>MSE</td><td>MAE</td><td>Q-K pairs</td><td>MSE</td><td>MAE</td><td>Q-K pairs</td><td>MSE MAE</td><td></td><td>Q-K pairs</td></tr><tr><td>C=2</td><td>1.035</td><td>0.811</td><td>73512</td><td>1.029</td><td>0.815</td><td>162648</td><td>1.003</td><td>0.807</td><td>221112</td></tr><tr><td>C=3</td><td>1.029</td><td>0.817</td><td>58992</td><td>1.009</td><td>0.798</td><td>128976</td><td>1.056</td><td>0.805</td><td>174672</td></tr><tr><td>C=4</td><td>1.001</td><td>0.802</td><td>53208</td><td>1.028</td><td>0.806</td><td>115848</td><td>1.027</td><td>0.804</td><td>156696</td></tr><tr><td>C=5</td><td>0.999</td><td>0.796</td><td>49992</td><td>1.005</td><td>0.796</td><td>108744</td><td>1.017</td><td>0.797</td><td>147192</td></tr></table>
360
+
361
+ Table 8: Impact of the CSCM architecture on long-range forecasting. Parameters introduced by the normalization layers are relatively few, and thus, are ignored.
362
+
363
+ <table><tr><td>CSCM</td><td>MSE</td><td>MAE</td><td>Parameters</td></tr><tr><td>Max-pooling</td><td>0.842</td><td>0.700</td><td>0</td></tr><tr><td>Average-pooling</td><td>0.833</td><td>0.693</td><td>0</td></tr><tr><td>Conv.</td><td>0.796</td><td>0.679</td><td>3147264</td></tr><tr><td>Conv.w/bottleneck</td><td>0.808</td><td>0.683</td><td>328704</td></tr></table>
364
+
365
+ Table 9: Impact of history length. The prediction length is 1344.
366
+
367
+ <table><tr><td>History Length</td><td>MSE</td><td>MAE</td></tr><tr><td>84</td><td>1.234</td><td>0.856</td></tr><tr><td>168</td><td>1.226</td><td>0.868</td></tr><tr><td>336</td><td>1.108</td><td>0.835</td></tr><tr><td>672</td><td>1.057</td><td>0.806</td></tr><tr><td>1344</td><td>1.062</td><td>0.806</td></tr></table>
368
+
369
+ Table 10: Impact of the PAM.
370
+
371
+ <table><tr><td>Method</td><td>Metrics</td><td>96</td><td>288</td><td>672</td></tr><tr><td rowspan="2">CSCM Only</td><td>MSE</td><td>0.576</td><td>0.782</td><td>0.883</td></tr><tr><td>MAE</td><td>0.544</td><td>0.683</td><td>0.752</td></tr><tr><td rowspan="2">Pyraformer</td><td>MSE</td><td>0.480</td><td>0.754</td><td>0.857</td></tr><tr><td>MAE</td><td>0.486</td><td>0.659</td><td>0.707</td></tr></table>
372
+
373
+ # J.3 IMPACT OF THE HISTORY LENGTH
374
+
375
+ We also checked the influence of the history length on the prediction accuracy. The dataset is ETTm1, since its granularity is minute and contains more long-range dependencies. We fixed the prediction length to 1344 and changed the history length from 84 to 1344 in Table 9. As expected, a longer history typically improves prediction accuracy. On the other hand, this performance gain starts to level off when introducing more history stops providing new information. As shown in Figure 8, the time series with length 672 contains almost all periodicity information that is essential for prediction, while length 1344 introduces more noise.
376
+
377
+ # J.4 IMPACT OF THE PAM
378
+
379
+ Finally, we investigated the importance of the PAM. We compared the performance of Pyraformer with and without the PAM on the dataset ETTm1. For a fair comparison, the number of parameters of the two methods were controlled to be within the same order of magnitude. More precisely, we increased the bottleneck dimension of ”Conv. w/bottleneck” for the model only with the CSCM. The results are shown in Table 10. Obviously, the PAM is vital to yield accurate predictions.
380
+
381
+ # K DISCUSSION ON THE SELECTION OF HYPER-PARAMETERS
382
+
383
+ We recommend to first determine the number of attention layers $N$ based on the available computing resources, as this number is directly related to the model size. Next, the number of scales $S$ can be determined by the granularity of the time series. For example, for hourly observations, we typically assume that it may also have daily, weekly and monthly periods. Therefore, we can set $S$ to be 4. We then focus on the selection of $A$ and $C$ . According to the ablation study, we typically prefer a small $A$ , such as 3 and 5. Lastly, in order to ensure the network has a receptive field of $L$ , we can select a $C$ that satisfies Equation (5). In practice, we can use a validation set to choose $C$ from its candidates that satisfies (5). It is also worthwhile to check whether choosing different $C$ for different scales based on the granularity of the time series can further improve the performance as we did in Appendix I.
384
+
385
+ ![](images/db2eafc4e603577f0d58166014a0fae825efdf9d45557b4f4357d82edaf6f6ac.jpg)
386
+ Figure 8: Time series with different lengths in the ETTm1 dataset. The sequence length in (a) and (b) is 672, and that in (c) and (d) is 1344. The time series in (a) and (b) corresponds to the latter half of those in (c) and (d) respectively.
md/dev/0I3su3mkuL/0I3su3mkuL.md ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Q-Transformer: Scalable Offline Reinforcement Learning via Autoregressive Q-Functions
2
+
3
+ Yevgen Chebotar∗, Quan Vuong∗, Alex Irpan, Karol Hausman, Fei Xia, Yao Lu, Aviral Kumar, Tianhe Yu, Alexander Herzog, Karl Pertsch, Keerthana Gopalakrishnan, Julian Ibarz, Ofir Nachum, Sumedh Sontakke, Grecia Salazar, Huong T Tran, Jodilyn Peralta, Clayton Tan, Deeksha Manjunath, Jaspiar Singht, Brianna Zitkovich, Tomas Jackson, Kanishka Rao, Chelsea Finn, Sergey Levine
4
+
5
+ Google DeepMind
6
+
7
+ Abstract: In this work, we present a scalable reinforcement learning method for training multi-task policies from large offline datasets that can leverage both human demonstrations and autonomously collected data. Our method uses a Transformer to provide a scalable representation for Q-functions trained via offline temporal difference backups. We therefore refer to the method as Q-Transformer. By discretizing each action dimension and representing the Q-value of each action dimension as separate tokens, we can apply effective high-capacity sequence modeling techniques for Q-learning. We present several design decisions that enable good performance with offline RL training, and show that Q-Transformer outperforms prior offline RL algorithms and imitation learning techniques on a large diverse real-world robotic manipulation task suite. The project’s website and videos can be found at qtransformer.github.io
8
+
9
+ # 1 Introduction
10
+
11
+ Robotic learning methods that incorporate large and diverse datasets in combination with highcapacity expressive models, such as Transformers [1, 2, 3, 4, 5, 6], have the potential to acquire generalizable and broadly applicable policies that perform well on a wide variety of tasks [1, 2]. For example, these policies can follow natural language instructions [4, 7], perform multi-stage behaviors [8, 9], and generalize broadly across environments, objects, and even robot morphologies [10, 3]. However, many of the recently proposed high-capacity models in the robotic learning literature are trained with supervised learning methods. As such, the performance of the resulting policy is limited by the degree to which human demonstrators can provide high-quality demonstration data. This is limiting for two reasons. First, we would like robotic systems that are more proficient than human teleoperators, exploiting the full potential of the hardware to perform tasks quickly, fluently, and reliably. Second, we would like robotic systems that get better with autonomously gathered experience, rather than relying entirely on high-quality demonstrations.
12
+
13
+ ![](images/8f3b8d97deb66fea8fdfde8197851ec9a51cda09800ea72c66a724048084a978.jpg)
14
+ Figure 1: Q-Transformer enables training highcapacity sequential architectures on mixed quality data. Our policies are able to improve upon human demonstrations and execute a variety of manipulation tasks in the real world.
15
+
16
+ Reinforcement learning in principle provides both of these capabilities. A number of promising recent advances demonstrate the successes of large-scale robotic RL in varied settings, such as robotic grasping and stacking [11, 12], learning heterogeneous tasks with human-specified rewards [13], learning multi-task policies [14, 15], learning goal-conditioned policies [16, 17, 18, 19], and robotic navigation [20, 21, 22, 23, 24]. However, training high-capacity models such as Transformers using RL algorithms has proven more difficult to instantiate effectively at large scale. In this paper, we aim to combine large-scale robotic learning from diverse real-world datasets with modern high-capacity Transformer-based policy architectures.
17
+
18
+ While in principle simply replacing existing architectures (e.g., ResNets [15] or smaller convolutional neural networks [11, 14]) with a Transformer is conceptually straightforward, devising a methodology that effectively makes use of such architectures is considerably more challenging. High-capacity models only make sense when we train on large and diverse datasets – small, narrow datasets simply do not require this much capacity and do not benefit from it. While prior works used simulation to create such datasets [2, 25, 26], the most representative data comes from the real world [12, 11, 14]. Therefore, we focus on reinforcement learning methods that can use Transformers and incorporate large, previously collected datasets via offline RL. Offline RL methods train on prior data, aiming to derive the most effective possible policy from a given dataset. Of course, this dataset can be augmented with additionally autonomously gathered data, but the training is separated from data collection, providing an appealing workflow for large-scale robotics applications [27].
19
+
20
+ Another issue in applying Transformer models to RL is to design RL systems that can effectively train such models. Effective offline RL methods generally employ Q-function estimation via temporal difference updates [28]. Since Transformers model discrete token sequences, we convert the Q-function estimation problem into a discrete token sequence modeling problem, and devise a suitable loss function for each token in the sequence. Na¨ıvely discretizing the action space leads to exponential blowup in action cardinality, so we employ a per-dimension discretization scheme, where each dimension of the action space is treated as a separate time step for RL. Different bins in the discretization corresponds to distinct actions. The per-dimension discretization scheme allows us to use simple discrete-action Q-learning methods with a conservative regularizer to handle distributional shift [29, 30]. We propose a specific regularizer that minimizes values of every action that was not taken in the dataset and show that our method can learn from both narrow demonstration-like data and broader data with exploration noise. Finally, we utilize a hybrid update that combines Monte Carlo and $n$ -step returns with temporal difference backups [31], and show that doing so improves the performance of our Transformer-based offline RL method on large-scale robotic learning problems.
21
+
22
+ In summary, our main contribution is the Q-Transformer, a Transformer-based architecture for robotic offline reinforcement learning that makes use of per-dimension tokenization of Q-values and can readily be applied to large and diverse robotic datasets, including real-world data. We summarize the components of Q-Transformer in Figure 1. Our experimental evaluation validates the Q-Transformer by learning large-scale text-conditioned multi-task policies, both in simulation for rigorous comparisons and in large-scale real-world experiments for realistic validation. Our real-world experiments utilize a dataset with 38,000 successful demonstrations and 20,000 failed autonomously collected episodes on more than 700 tasks, gathered with a fleet of 13 robots. QTransformer outperforms previously proposed architectures for large-scale robotic RL [15, 14], as well as previously proposed Transformer-based models such as the Decision Transformer [32, 33].
23
+
24
+ # 2 Related Work
25
+
26
+ Offline RL has been extensively studied in recent works [34, 35, 36, 37, 35, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 39]. Conservative Q-learning (CQL) [29] learns policies constrained to a conservative lower bound of the value function. Our goal is not to develop a new algorithmic principle for offline RL, but to devise an offline RL system that can integrate with high-capacity Transformers, and scale to real-world multi-task robotic learning. We thus develop a version of CQL particularly effective for training large Transformer-based Q-functions on mixed quality data. While some works have noted that imitation learning outperforms offline RL on demonstration data [49], other works showed offline RL techniques to be effective with demonstrations both in theory and in practice [50, 15]. Nonetheless, a setting that combines “narrow” demonstration data with “broad” sub-optimal (e.g., autonomously collected) data is known to be particularly difficult [51, 52, 53], though it is quite natural in many robotic learning settings where we might want to augment a core set of demonstrations with relatively inexpensive low-quality autonomously collected data. We believe that the effectiveness of our method in this setting is of particular interest to practitioners.
27
+
28
+ Transformer-based architectures [54] have been explored in recent robotics research, both to learn generalizable task spaces [55, 56, 57, 58, 8, 59] and to learn multi-task or even multi-domain sequential policies directly [2, 1, 6, 3]. Although most of these works considered Transformers in a supervised learning setting, e.g., learning from demonstrations [4, 5], there are works on employing Transformers for RL and conditional imitation learning [32, 20, 60, 33]. In our experiments, we compare to Decision Transformer (DT) in particular [32], which extends conditional imitation learning with reward conditioning [61, 62] to use sequence models, and structurally resembles imitation learning methods that have been used successfully for robotic control. Although DT incorporates elements of RL (namely, reward functions), it does not provide a mechanism to improve over the demonstrated behavior or recombine parts of the dataset to synthesize more optimal behaviors, and indeed is known to have theoretical limitations [63]. On the other hand, such imitation-based recipes are popular perhaps due to the difficulty of integrating Transformer architectures with more powerful temporal difference methods (e.g., Q-learning). We show that several simple but important design decisions are needed to make this work, and our method significantly outperforms non-TD methods such as DT, as well as imitation learning, on our large-scale multi-task robotic control evaluation. Extending Decision Transformer, Yamagata et al. [64] proposed to use a Q-function in combination with a Transformer-based policy, but the Q-function itself did not use a Transformer-based architecture. Our Q-function could in principle be combined with this method, but our focus is specifically on directly training Transformers to represent Q-values.
29
+
30
+ ![](images/986b982ec8c568fb40ea32d38ae1b19d3470a6ea1e8ed97267472f6f8e9e17f2.jpg)
31
+ Figure 2: Q-values update for each action dimension at timestep t. Given a history of states, we update the Q-values of all bins in all action dimensions. The Q-values of the discrete action bins of the dataset actions are trained via the Bellman update (green boxes). The values of action bins not observed in the dataset are minimized towards zero (red boxes). The Q-targets of all action dimensions except the last one are computed using maximization over the next action dimension within the same time step. The Q-target of the last action dimension is computed using the discounted maximization of the first dimension of the next time step plus the reward. We also incorporate Monte Carlo returns by taking the maximum of the computed Q-targets and the return-to-go.
32
+
33
+ To develop a Transformer-based Q-learning method, we discretize each action space dimension, with each dimension acting as a distinct time step. Autoregressive generation of discrete actions has been explored by Metz et al. [65], who propose a hierarchical decomposition of an MDP and then utilize LSTM [66] for autoregressive discretization. Our discretization scheme is similar but simpler, in that we do not use any hierarchical decomposition but simply treat each dimension as a time step. However, since our goal is to perform offline RL at scale with real-world image based tasks (vs. the smaller state-space tasks learned via online RL by Metz et al. [65]), we present a number of additional design decisions to impose a conservative regularizer, enabling training our Transformerbased offline Q-learning method at scale, providing a complete robotic learning system.
34
+
35
+ # 3 Background
36
+
37
+ In RL, we learn policies $\pi$ that maximizes the expected total reward in a Markov decision process (MDP) with states $s$ , actions $a$ , discount factor $\gamma \in \mathsf { \Gamma } ( 0 , 1 ]$ , transition function $T ( s ^ { \prime } | s , { \bar { a } } )$ and a reward function $R ( s , a )$ . Actions $a$ have dimensionality $d _ { \mathcal { A } }$ . Value-based RL approaches learn a Q-function $Q ( s , a )$ representing the total discounted return $\begin{array} { r } { \sum _ { t } \gamma ^ { t } R ( s _ { t } , a _ { t } ) } \end{array}$ , with policy $\pi ( a | s ) =$ arg maxa $Q ( s , a )$ . The Q-function can be learned by iteratively applying the Bellman operator [67]:
38
+
39
+ $$
40
+ \mathcal { B } ^ { * } Q ( s _ { t } , a _ { t } ) = R ( s _ { t } , a _ { t } ) + \gamma \operatorname* { m a x } _ { a _ { t + 1 } } Q ( s _ { t + 1 } , a _ { t + 1 } ) ,
41
+ $$
42
+
43
+ approximated via function approximation and sampling. The offline RL setting assumes access to an offline dataset of transitions or episodes, produced by some unknown behavior policy $\pi _ { \beta } ( a | s )$ , but does not assume the ability to perform additional online interaction during training. This is appealing for real-world robotic learning, where on-policy data collection is time-consuming. Learning from offline datasets requires addressing distributional shift, since in general the action that maximizes $Q ( s _ { t + 1 } , a _ { t + 1 } )$ might lie outside of the data distribution. One approach to mitigate this is to add a conservative penalty [29, 52] that pushes down the Q-values $Q ( s , a )$ for any action $a$ outside of the dataset, thus ensuring that the maximum value action is in-distribution.
44
+
45
+ ![](images/66b914dead3ba20f12925e3d7db42b32bbe75dce7aa50d0d18bb162fd19fdb6e.jpg)
46
+ Figure 3: Q-Transformer network architecture, as applied to our multi-task language-conditioned robotic control setting. The encoding of the observations is concatenated with embeddings of the previous predicted action dimensions and processed by Transformer layers. We apply a sigmoid to the Transformer output to produce Q-values (normalized to lie in the range $[ 0 , 1 ] )$ for each of the action value bins. Finally, one-hot action vectors are constructed by taking the arg max over all bins and are fed back to the network to predict the Q-values of the next action dimensions. The language instruction is encoded with Universal Sentence Encoder [68] and then fed to FiLM EfficientNet [69, 70] network together with the robot camera images.
47
+
48
+ In this work, we consider tasks with sparse rewards, where a binary reward $R \in \{ 0 , 1 \}$ (indicating success or failure) is assigned at the last time step of episodes. Although our method is not specific to this setting, such reward structure is common in robotic manipulation tasks that either succeed or fail on each episode, and can be particularly challenging for RL due to the lack of reward shaping.
49
+
50
+ # 4 Q-Transformer
51
+
52
+ In this section, we introduce Q-Transformer, an architecture for offline Q-learning with Transformer models, which is based on three main ingredients. First, we describe how we apply discretization and autoregression to enable TD-learning with Transformer architectures. Next, we introduce a particular conservative Q-function regularizer that enables learning from offline datasets. Lastly, we show how Monte Carlo and $n$ -step returns can be used to improve learning efficiency.
53
+
54
+ # 4.1 Autoregressive Discrete Q-Learning
55
+
56
+ Using Transformers with Q-learning presents two challenges: (1) we must tokenize the inputs to effectively apply attention mechanisms, which requires discretizing the action space; (2) we must perform maximization of Q-values over discretized actions while avoiding the curse of dimensionality. Addressing these issues within the standard Q-learning framework requires new modeling decisions. The intuition behind our autoregressive Q-learning update is to treat each action dimension as essentially a separate time step. That way, we can discretize individual dimensions (1D quantities), rather than the entire action space, avoiding the curse of dimensionality. This can be viewed as a simplified version of the scheme proposed in [65], though we apply this to high-capacity Transformer models, extend it to the offline RL setting, and scale it up to real-world robotic learning.
57
+
58
+ Let $\tau = ( s _ { 1 } , a _ { 1 } , \dots , s _ { T } , a _ { T } )$ be a trajectory of robotic experience of length $T$ from an offline dataset $\mathcal { D }$ . For a given time-step $t$ , and the corresponding action $a _ { t }$ in the trajectory, we define a per-dimension view of the action $a _ { t }$ . Let $a _ { t } ^ { 1 : i }$ denote the vector of action dimensions from the first dimension $a _ { t } ^ { 1 }$ until the $i$ -th dimension $a _ { t } ^ { i }$ , where $i$ can range from 1 to the total number of action dimensions, that we denote as $d _ { \mathcal { A } }$ . Then, for a time window $w$ of state history, we define the Q-value of the action $a _ { t } ^ { i }$ in the $_ { i - t h }$ dimension using an autoregressive Q-function conditioned on states from this time window $s _ { t - w : t }$ and previous action dimensions for the current time step $a _ { t } ^ { 1 : i - 1 }$ . To train the Q-function, we define a per-dimension Bellman update. For all dimensions $i \in \{ \bar { 1 } , \ldots , d _ { A } \}$ :
59
+
60
+ $$
61
+ Q ( s _ { t - w : t } , a _ { t } ^ { 1 : i - 1 } , a _ { t } ^ { i } ) \gets \left\{ \begin{array} { l l } { \operatorname* { m a x } _ { a _ { t } ^ { i + 1 } } Q ( s _ { t - w : t } , a _ { t } ^ { 1 : i } , a _ { t } ^ { i + 1 } ) } & { \mathrm { i f ~ } i \in \{ 1 , \dots , d _ { A } - 1 \} } \\ { a _ { t } ^ { i + 1 } } & { \mathrm { ~ i f ~ } i \in \{ 1 , \dots , d _ { A } \} } \end{array} \right.
62
+ $$
63
+
64
+ The reward is only applied on the last dimension (second line in the equation), as we do not receive any reward before executing the whole action. In addition, we only discount Q-values between the time steps and keep discounting at 1.0 for all but the last dimension within each time step, to ensure the same discounting as in the original MDP. Figure 2 illustrates this process, where each yellow box represents the Q-target computation with additional conservatism and Monte Carlo returns described in the next subsections. It should be noted that by treating each action dimension as a time step for the Bellman update, we do not change the general optimization properties of Q-learning algorithms and the principle of the Bellman optimality still holds for a given MDP as we maximize over an action dimension given the optimality of all action dimensions in the future. We show that this approach provides a theoretically consistent way to optimize the original MDP in Appendix A, with a proof of convergence in the tabular setting in Appendix B.
65
+
66
+ # 4.2 Conservative Q-Learning with Transformers
67
+
68
+ Having defined a Bellman backup for running Q-learning with Transformers, we now develop a technique that enables learning from offline data, including human demonstrations and autonomously collected data. This typically requires addressing over-estimation due to the distributional shift, when the Q-function for the target value is queried at an action that differs from the one on which it was trained. Conservative Q-learning (CQL) [29] minimizes the Q-function on out-of-distribution actions, which can result in Q-values that are significantly smaller than the minimal possible cumulative reward that can be attained in any trajectory. When dealing with sparse rewards $R \in \{ 0 , 1 \}$ , results in [27] show that the Q-function regularized with a standard conservative objective can take on negative values, even though instantaneous rewards are all non-negative. This section presents a modified version of conservative Q-learning that addresses this issue in our problem setting.
69
+
70
+ The key insight behind our design is that, rather than minimizing the Q-values on actions not in the data, we can instead regularize these $\mathrm { Q }$ -values to be close to the minimal attainable possible cumulative reward. Concretely, denoting the minimal possible reward on the task as $R _ { \mathrm { m i n } }$ , and the time horizon of the task as $T$ , our approach regularizes the Q-values on actions not covered by the dataset towards $R _ { \operatorname* { m i n } } \cdot T$ , which in our problem setting is equal to 0 (i.e., $R _ { \mathrm { m i n } } = 0 .$ ). For simplicity of notation, we omit the action dimension indices in presenting the resulting objective, but remark that the training objective below is applied to Bellman backups on all action dimensions as described in the previous section. Let $\pi _ { \beta }$ be the behavioral policy that induced a given dataset $\mathcal { D }$ , and let $\begin{array} { r } { \tilde { \pi } _ { \beta } ( a | s ) = \frac { 1 } { Z ( s ) } \cdot ( 1 . 0 - \pi _ { \beta } ( a | \dot { s } ) ) } \end{array}$ be the distribution over all actions which have a very low density under $\pi _ { \beta } ( a | s )$ . Our objective to train the Q-function is:
71
+
72
+ $$
73
+ J = \ \frac { 1 } { 2 } \underbrace { \mathbb { E } _ { s \sim \mathcal { D } , a \sim \pi _ { \beta } ( a | s ) } \left[ \left( Q ( s , a ) - B ^ { * } Q ^ { k } ( s , a ) \right) ^ { 2 } \right] } _ { ( i ) , \mathrm { ~ I D ~ e r r o r } } + \alpha \cdot \frac { 1 } { 2 } \underbrace { \mathbb { E } _ { s \sim \mathcal { D } , a \sim \pi _ { \beta } ( a | s ) } \left[ \left( Q ( s , a ) - 0 \right) ^ { 2 } \right] } _ { ( i i ) , \mathrm { ~ c o n s e r v a t i v e ~ r e g u l a r i z a t i o n ~ } \mathcal { L } _ { C } } ,
74
+ $$
75
+
76
+ where the first term $( i )$ trains the Q-function by minimizing the temporal difference error objective as defined in Eq. 1, and the second term $( i i )$ regularizes the $\mathbf { Q }$ -values to the minimal possible $\mathrm { Q }$ - value of 0 in expectation under the distribution of actions induced by $\tilde { \pi } _ { \beta }$ , which we denote as a conservative regularization term $\mathcal { L } _ { C }$ . Term $( i i )$ is also weighted by a multiplier $\alpha$ , which modulates the strength of this conservative regularization. We discuss the choice of $\alpha$ in our implementation in Appendix D.2 and analyze the behavior of the conservatism term in Appendix C, providing a simple characterization of how this regularizer modifies the learned Q-function in tabular settings.
77
+
78
+ # 4.3 Improving Learning Efficiency with Monte Carlo and $n$ -step Returns
79
+
80
+ When the dataset contains some good trajectories (e.g., demonstrations) and some suboptimal trajectories (e.g., autonomously collected trials), utilizing Monte Carlo return-to-go estimates to accelerate Q-learning can lead to significant performance improvements, as the Monte Carlo estimates along the better trajectories lead to much faster value propagation. This has also been observed in prior work [31]. Based on this observation, we propose a simple improvement to Q-Transformer that we found to be quite effective in practice. The Monte Carlo return is defined by the cumulative reward within the offline trajectory $\begin{array} { r } { \tau \colon \mathbf { M } \mathbf { C } _ { t : T } = \sum _ { j = t } ^ { T } \gamma ^ { j - t } R ( s _ { j } , a _ { j } ) } \end{array}$ . This matches the Q-value of the behavior policy $\pi _ { \beta }$ , and since the optimal $Q ^ { * } ( s , a )$ is larger than the Q-value for any other policy, we have $Q ^ { * } ( s _ { t } , a _ { t } ) \geq \mathbf { M } \mathbf { C } _ { t : T }$ . Since the Monte Carlo return is a lower bound of the optimal Q-function, we can augment the Bellman update to take the maximum between the MC-return and the current Q-value: max $( \mathbf { M } \mathbf { C } _ { t : T } , Q ( s _ { t } , a _ { t } \mathbf { \bar { ) } } )$ , without changing what the Bellman update will converge to.
81
+
82
+ ![](images/f92bdbe0b51c194ecf6f9283f428c517cca501a702b0252001d60139f983a236.jpg)
83
+ Figure 4: Left: Real world manipulation tasks. Right: Real world performance comparison. RT-1 [1] is imitation learning on demonstrations. Q-Transformer (Q-T), Decision Transformer (DT) [32], Implicit Q-learning (IQL) [40] learn from both demonstrations and autonomous data.
84
+
85
+ Although this does not change convergence, including this maximization speeds up learning (see Section 5.3). We present a hypothesis why this occurs. In practice, $\mathrm { Q }$ -values for final timesteps $( s _ { T } , a _ { T } )$ are learned first and then propagated backwards in future gradient steps. It can take multiple gradients for the Q-value to propagate all the way to $( s _ { 1 } , a _ { 1 } )$ . The $\operatorname* { m a x } ( \mathbf { M C } , Q )$ allows us to apply useful gradients to $Q ( s _ { 1 } , a _ { 1 } )$ at the start of training before the $\mathbf { Q }$ -values have propagated.
86
+
87
+ In our experiments, we also notice that additionally employing $n$ -step returns [71, 72] over action dimensions can significantly help with the learning speed. We pick $n$ such that the final Q-value of the last dimension of the next time step is used as the Q-target. This is because we get a new state and reward only after inferring and executing the whole action as opposed to parts of it, meaning that intermediate rewards remain 0 all the way until the last action dimension. While this introduces bias to the Bellman backups, as is always the case with off-policy learning with $n$ -step returns, we find in our ablation study in Section 5.3 that the detrimental effects of this bias are small, while the speedup in training is significant. This is consistent with previously reported results [72]. More details about our Transformer sequence model architecture (depicted in Figure 3) conservative Qlearning implementation, and the robot system can be found in Appendix D.
88
+
89
+ # 5 Experiments
90
+
91
+ In our experiments, we aim to answer the following questions: (1) Can Q-Transformer learn from a combination of demonstrations and sub-optimal data? (2) How does Q-Transformer compare to other methods? (3) How important are the specific design choices in Q-Transformer? (4) Can QTransformer be applied to large-scale real world robotic manipulation problems?
92
+
93
+ # 5.1 Real-world language-conditioned manipulation evaluation
94
+
95
+ Training dataset. The offline data used in our experiments was collected with a fleet of 13 robots, and consists of a subset of the demonstration data described by Brohan et al. [1], combined with lower quality autonomously collected data. The demonstrations were collected via human teleoperation for over 700 distinct tasks, each with a separate language description. We use a maximum of 100 demonstrations per task, for a total of about 38,000 demonstrations. All of these demonstrations succeed on their respective tasks and receive a reward of 1.0. The rest of the dataset was collected by running the robots autonomously, executing policies learned via behavioral cloning.
96
+
97
+ To ensure a fair comparison between Q-Transformer and imitation learning methods, we discard all successful episodes in the autonomously collected data when we train our method, to ensure that by including the autonomous data the Q-Transformer does not get to observe more successful trials than the imitation learning baselines. This leaves us with about 20,000 additional autonomously collected failed episodes, each with a reward of 0.0, for a dataset size of about 58,000 episodes. The episodes are on average 35 time steps in length. Examples of the tasks are shown in Figure 4.
98
+
99
+ Performance evaluation. To evaluate how well Q-Transformer can perform when learning from real-world offline datasets while effectively incorporating autonomously collected failed episodes, we evaluate Q-Transformer on 72 unique manipulation tasks, and a variety of different skills, such as “drawer pick and place”, “open and close drawer”, “move object near target”, each consisting of 18, 7 and 48 unique tasks instructions respectively to specify different object combinations and drawers. As such, the average success rate in Table 4 is the average over 72 tasks.
100
+
101
+ Since each task in the training set only has a maximum of 100 demonstrations, we observe from Figure 4 that an imitation learning algorithm like RT-1 [1], which also uses a similar Transformer architecture, struggles to obtain a good performance when learning from only the limited pool of successful robot demonstrations. Existing offline RL methods, such as IQL [40] and a Transformerbased method such as Decision Transformer [32], can learn from both successful demonstrations and failed episodes, and show better performance compared to RT-1, though by a relatively small margin. Q-Transformer has the highest success rate and outperforms both the behavior cloning baseline (RT-1) and offline RL baselines (Decision Transformer, IQL), exceeding the average performance of the best-performing prior method by about $70 \%$ . This demonstrates that Q-Transformer can effectively improve upon human demonstrations using autonomously collected sub-optimal data.
102
+
103
+ Appendix G also shows that Q-Transformer can be successfully applied in combination with a recently proposed language task planner [8] to perform both affordance estimation and robot action execution. Q-Transformer outperforms prior methods for planning and executing long-horizon tasks.
104
+
105
+ # 5.2 Benchmarking in simulation
106
+
107
+ In this section, we evaluate Q-Transformer on a challenging simulated offline RL task that require incorporating sub-optimal data to solve the task. In particular, we use a visual simulated picking task depicted in Figure 5, where we have a small amount of position controlled human demonstrations ${ \sim } 8 \%$ of the data). The demonstrations are replayed with noise to generate more trajectories ( ${ \sim } 9 2 \%$ of the data). Figure 5 shows a comparison to several offline algorithms, such as QT-Opt with CQL [11, 29], IQL [40], AW-Opt [73], and Decision Transformer [32], along with RT-1 using Behavioral Cloning [1] on demonstrations only. As we see, algorithms that can effectively perform TDlearning to combine optimal and sub-optimal data (such as Q-Transformer and QT-Opt) perform better than others. BC with RT-1 is not
108
+
109
+ ![](images/a2c99c10cf55b4c6ab22b7a5b8fd317dcfb759dd2644215d5fd65744698b5e1f.jpg)
110
+ Figure 5: Performance comparison on a simulated picking task.
111
+
112
+ able to take advantage of sub-optimal data. Decision Transformer is trained on both demonstrations and sub-optimal data, but is not able to leverage the noisy data for policy improvement and does not end up performing as well as our method. Although IQL and AW-Opt perform TD-learning, the actor remains too close to the data and can not fully leverage the sub-optimal data. Q-Transformer is able to both bootstrap the policy from demonstrations and also quickly improve through propagating information with TD-learning. We also analyze the statistical significance of the results by training with multiple random seeds in Appendix F.
113
+
114
+ # 5.3 Ablations
115
+
116
+ We perform a series of ablations of our method design choices in simulation, with results presented in Figure 6 (left). First, we demonstrate that our choice of conservatism for Q-Transformer performs better than the standard CQL regularizer, which corresponds to a softmax layer on top of the Q-function outputs with a cross-entropy loss between the dataset action and the output of this softmax [29]. This regularizer plays a similar role to the one we propose, decreasing the Q-values for out-of-distribution actions and staying closer to the behavior policy.
117
+
118
+ As we see in Figure 6 (left), performance with softmax conservatism drops to around the fraction of demonstration episodes $( \sim 8 \% )$ . This suggests a collapse to the behavior policy as the conservatism penalty becomes too good at constraining to the behavior policy distribution. Due to the nature of the softmax, pushing Q-values down for unobserved actions also pushes Q-values up for the observed actions, and we theorize this makes it difficult to keep Q-values low for sub-optimal in-distribution actions that fail to achieve high reward. Next, we show that using conservatism is important. When removing conservatism entirely, we observe that performance collapses. Actions that are rare in the dataset will have overestimated Q-values, since they are not trained by the offline Q-learning procedure. The resulting overestimated values will propagate and collapse the entire Q-function, as described in prior work [38]. Finally, we ablate the Monte-Carlo returns and again observe performance collapse. This demonstrates that adding information about the sampled future returns significantly helps in bootstrapping the training of large architectures such as Transformers.
119
+
120
+ ![](images/1eba88ec9249b5b4812bc607c8926c1418975b18085015c1bc5e30d4d2d5bc77.jpg)
121
+ Figure 6: Left: Ablations: changing to softmax conservatism decreases performance. Removing MC returns or conservatism completely collapse performance. Top Right: The $n$ -step return version of our method reaches similar performance to the standard version with 4 times fewer steps, indicating that the added bias from $n$ -step returns is small compared to the gain in training speed. Using $n$ -step return also leads to better performance on tasks that have longer horizon, e.g. move object near target. Bottom Right: Success rates on real world task categories with a larger dataset.
122
+
123
+ <table><tr><td>n-step ablation</td><td>n-step 1-step</td><td>1-step</td></tr><tr><td># of gradient steps Training duration (hours)</td><td>137480 582960 32 163</td><td>136920 40</td></tr><tr><td>pick object move object near target</td><td>94% 88%</td><td>97% 92% 80% 67%</td></tr><tr><td>Large offline dataset</td><td>Q-T DT</td><td>RT-1</td></tr><tr><td>Average success rate</td><td>88% 78%</td><td>82%</td></tr></table>
124
+
125
+ We also ablate the choice of $n$ -step returns from the Section 4.3 on real robots and observe that using $n$ -step returns leads to a significantly faster training speed as measured by the number of gradient steps and wall clock time compared to using 1-step returns, with a minimal loss in performance, as shown in Figure 6 (top right).
126
+
127
+ # 5.4 Massively scaling up Q-Transformer
128
+
129
+ The experiments in the previous section used a large dataset that included successful demonstrations and failed autonomous trials, comparable in size to some of the largest prior experiments that utilized demonstration data [74, 15, 58]. We also carry out a preliminary experiment with a much larger dataset to investigate the performance of Q-Transformer as we scale up the dataset size.
130
+
131
+ This experiment includes all of the data collected with 13 robots and comprises of the demonstrations used by RT-1 [1] and successful autonomous episodes, corresponding to about 115,000 successful trials, and an additional 185,000 failed autonomous episodes, for a total dataset size of about 300,000 trials. Model architecture and hyperparameters were kept exactly the same, as the computational cost of the experiment made further hyperparameter tuning prohibitive (in fact, we only train the models once). Note that with this number of successful demonstrations, even standard imitation learning with the RT-1 architecture already performs very well, attaining $82 \%$ success rate. However, as shown in Figure 6 (bottom right), Q-Transformer was able to improve even on this very high number. This experiment demonstrates that Q-Transformer can continue to scale to extremely large dataset sizes, and continues to outperform both imitation learning with RT-1 and Decision Transformer.
132
+
133
+ # 6 Limitations and Discussion
134
+
135
+ In this paper, we introduced the Q-Transformer, an architecture for offline reinforcement learning with high-capacity Transformer models that is suitable for large-scale multi-task robotic RL. Our framework does have several limitations. First, we focus on sparse binary reward tasks corresponding to success or failure for each trial. While this setup is reasonable for a broad range of episodic robotic manipulation problems, it is not universal, and we expect that Q-Transformer could be extended to more general settings as well in the future.
136
+
137
+ Second, the per-dimension action discretization scheme that we employ may become more cumbersome in higher dimensions (e.g., controlling a humanoid robot), as the sequence length and inference time for our model increases with action dimensionality. Although $n$ -step returns mitigate this to a degree, the length of the sequences still increases with action dimensionality. For such higherdimensional action space, adaptive discretization methods might also be employed, for example by training a discrete autoencoder model and reducing representation dimensionality. Uniform action discretization can also pose problems for manipulation tasks that require a large range of motion granularities, e.g. both coarse and fine movements. In this case, adaptive discretization based on the distribution of actions could be used for representing both types of motions.
138
+
139
+ Finally, in this work we concentrated on the offline RL setting. However, extending Q-Transformer to online finetuning is an exciting direction for future work that would enable even more effective autonomous improvement of complex robotic policies.
140
+
141
+ References
142
+ [1] A. Brohan, N. Brown, J. Carbajal, Y. Chebotar, J. Dabis, C. Finn, K. Gopalakrishnan, K. Hausman, A. Herzog, J. Hsu, et al. Rt-1: Robotics transformer for real-world control at scale. arXiv preprint arXiv:2212.06817, 2022.
143
+ [2] Y. Jiang, A. Gupta, Z. Zhang, G. Wang, Y. Dou, Y. Chen, L. Fei-Fei, A. Anandkumar, Y. Zhu, and L. Fan. Vima: General robot manipulation with multimodal prompts. arXiv preprint arXiv:2210.03094, 2022.
144
+ [3] A. Gupta, L. Fan, S. Ganguli, and L. Fei-Fei. Metamorph: Learning universal controllers with transformers. arXiv preprint arXiv:2203.11931, 2022.
145
+ [4] M. Shridhar, L. Manuelli, and D. Fox. Perceiver-actor: A multi-task transformer for robotic manipulation. arXiv preprint arXiv:2209.05451, 2022.
146
+ [5] N. M. M. Shafiullah, Z. J. Cui, A. Altanzaya, and L. Pinto. Behavior transformers: Cloning $k$ modes with one stone. arXiv preprint arXiv:2206.11251, 2022.
147
+ [6] S. Reed, K. Zolna, E. Parisotto, S. G. Colmenarejo, A. Novikov, G. Barth-Maron, M. Gimenez, Y. Sulsky, J. Kay, J. T. Springenberg, et al. A generalist agent. arXiv preprint arXiv:2205.06175, 2022.
148
+ [7] M. Shridhar, L. Manuelli, and D. Fox. Cliport: What and where pathways for robotic manipulation. In Proceedings of the 5th Conference on Robot Learning (CoRL), 2021.
149
+ [8] M. Ahn, A. Brohan, N. Brown, Y. Chebotar, O. Cortes, B. David, C. Finn, K. Gopalakrishnan, K. Hausman, A. Herzog, et al. Do as I can, not as I say: Grounding language in robotic affordances. arXiv preprint arXiv:2204.01691, 2022.
150
+ [9] D.-A. Huang, Y.-W. Chao, C. Paxton, X. Deng, L. Fei-Fei, J. C. Niebles, A. Garg, and D. Fox. Motion reasoning for goal-based imitation learning. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 4878–4884. IEEE, 2020.
151
+ [10] D. Shah, A. Sridhar, A. Bhorkar, N. Hirose, and S. Levine. Gnm: A general navigation model to drive any robot. arXiv preprint arXiv:2210.03370, 2022.
152
+ [11] D. Kalashnikov, A. Irpan, P. Pastor, J. Ibarz, A. Herzog, E. Jang, D. Quillen, E. Holly, M. Kalakrishnan, V. Vanhoucke, et al. Scalable deep reinforcement learning for vision-based robotic manipulation. In Conference on Robot Learning, pages 651–673. PMLR, 2018.
153
+ [12] A. X. Lee, C. M. Devin, Y. Zhou, T. Lampe, K. Bousmalis, J. T. Springenberg, A. Byravan, A. Abdolmaleki, N. Gileadi, D. Khosid, et al. Beyond pick-and-place: Tackling robotic stacking of diverse shapes. In 5th Annual Conference on Robot Learning, 2021.
154
+ [13] S. Cabi, S. G. Colmenarejo, A. Novikov, K. Konyushkova, S. Reed, R. Jeong, K. Zolna, Y. Aytar, D. Budden, M. Vecerik, et al. Scaling data-driven robotics with reward sketching and batch reinforcement learning. arXiv preprint arXiv:1909.12200, 2019.
155
+ [14] D. Kalashnikov, J. Varley, Y. Chebotar, B. Swanson, R. Jonschkowski, C. Finn, S. Levine, and K. Hausman. MT-opt: Continuous multi-task robotic reinforcement learning at scale. arXiv, 2021.
156
+ [15] A. Kumar, A. Singh, F. Ebert, Y. Yang, C. Finn, and S. Levine. Pre-training for robots: Offline rl enables learning new tasks from a handful of trials. arXiv preprint arXiv:2210.05178, 2022.
157
+ [16] L. P. Kaelbling. Learning to achieve goals. In R. Bajcsy, editor, IJCAI, pages 1094–1099. Morgan Kaufmann, 1993. ISBN 1-55860-300-X.
158
+ [17] Y. Chebotar, K. Hausman, Y. Lu, T. Xiao, D. Kalashnikov, J. Varley, A. Irpan, B. Eysenbach, R. Julian, C. Finn, et al. Actionable models: Unsupervised offline reinforcement learning of robotic skills. arXiv preprint arXiv:2104.07749, 2021.
159
+ [18] T. Schaul, D. Horgan, K. Gregor, and D. Silver. Universal value function approximators. In F. Bach and D. Blei, editors, Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, pages 1312–1320, Lille, France, 07–09 Jul 2015. PMLR.
160
+ [19] M. Andrychowicz, D. Crow, A. Ray, J. Schneider, R. Fong, P. Welinder, B. McGrew, J. Tobin, P. Abbeel, and W. Zaremba. Hindsight experience replay. In Advances in Neural Information Processing Systems, pages 5048–5058, 2017.
161
+ [20] K. Fang, A. Toshev, L. Fei-Fei, and S. Savarese. Scene memory transformer for embodied agents in long-horizon tasks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 538–547, 2019.
162
+ [21] P. Anderson, A. X. Chang, D. S. Chaplot, A. Dosovitskiy, S. Gupta, V. Koltun, J. Kosecka, J. Malik, R. Mottaghi, M. Savva, and A. R. Zamir. On evaluation of embodied navigation agents. CoRR, abs/1807.06757, 2018. URL http://dblp.uni-trier.de/db/ journals/corr/corr1807.html#abs-1807-06757.
163
+ [22] P. Anderson, Q. Wu, D. Teney, J. Bruce, M. Johnson, N. Sunderhauf, I. D. Reid, S. Gould, ¨ and A. van den Hengel. Vision-and-language navigation: Interpreting visually-grounded navigation instructions in real environments. CoRR, abs/1711.07280, 2017. URL http: //arxiv.org/abs/1711.07280.
164
+ [23] P. Mirowski, R. Pascanu, F. Viola, H. Soyer, A. J. Ballard, A. Banino, M. Denil, R. Goroshin, L. Sifre, K. Kavukcuoglu, D. Kumaran, and R. Hadsell. Learning to navigate in complex environments. CoRR, abs/1611.03673, 2016. URL http://dblp.uni-trier.de/db/ journals/corr/corr1611.html#MirowskiPVSBBDG16.
165
+ [24] Y. Zhu, R. Mottaghi, E. Kolve, J. J. Lim, A. Gupta, L. Fei-Fei, and A. Farhadi. Target-driven visual navigation in indoor scenes using deep reinforcement learning. In ICRA, pages 3357– 3364. IEEE, 2017. ISBN 978-1-5090-4633-1. URL http://dblp.uni-trier.de/db/ conf/icra/icra2017.html#ZhuMKLGFF17.
166
+ [25] T. Yu, D. Quillen, Z. He, R. Julian, K. Hausman, C. Finn, and S. Levine. Meta-world: A benchmark and evaluation for multi-task and meta reinforcement learning. In Conference on robot learning, pages 1094–1100. PMLR, 2020.
167
+ [26] J. Fu, A. Kumar, O. Nachum, G. Tucker, and S. Levine. D4rl: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
168
+ [27] A. Kumar, A. Singh, S. Tian, C. Finn, and S. Levine. A workflow for offline model-free robotic reinforcement learning. arXiv preprint arXiv:2109.10813, 2021.
169
+ [28] R. S. Sutton and A. G. Barto. Introduction to Reinforcement Learning. MIT Press, Cambridge, MA, USA, 1st edition, 1998. ISBN 0262193981.
170
+ [29] A. Kumar, A. Zhou, G. Tucker, and S. Levine. Conservative q-learning for offline reinforcement learning. Advances in Neural Information Processing Systems, 33:1179–1191, 2020.
171
+ [30] V. Mnih, K. Kavukcuoglu, D. Silver, A. Graves, I. Antonoglou, D. Wierstra, and M. Riedmiller. Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602, 2013.
172
+ [31] A. Wilcox, A. Balakrishna, J. Dedieu, W. Benslimane, D. S. Brown, and K. Goldberg. Monte carlo augmented actor-critic for sparse reward deep reinforcement learning from suboptimal demonstrations. In A. H. Oh, A. Agarwal, D. Belgrave, and K. Cho, editors, Advances in Neural Information Processing Systems, 2022. URL https://openreview.net/forum? id=FLzTj4ia8BN.
173
+ [32] L. Chen, K. Lu, A. Rajeswaran, K. Lee, A. Grover, M. Laskin, P. Abbeel, A. Srinivas, and I. Mordatch. Decision transformer: Reinforcement learning via sequence modeling. Advances in neural information processing systems, 34:15084–15097, 2021.
174
+ [33] K.-H. Lee, O. Nachum, M. Yang, L. Lee, D. Freeman, W. Xu, S. Guadarrama, I. Fischer, E. Jang, H. Michalewski, et al. Multi-game decision transformers. arXiv preprint arXiv:2205.15241, 2022.
175
+ [34] N. Jaques, A. Ghandeharioun, J. H. Shen, C. Ferguson, A. Lapedriza, N. Jones, S. Gu, and R. Picard. Way off-policy batch deep reinforcement learning of implicit human preferences in dialog. arXiv preprint arXiv:1907.00456, 2019.
176
+ [35] Y. Wu, G. Tucker, and O. Nachum. Behavior regularized offline reinforcement learning. arXiv preprint arXiv:1911.11361, 2019.
177
+ [36] X. B. Peng, A. Kumar, G. Zhang, and S. Levine. Advantage-weighted regression: Simple and scalable off-policy reinforcement learning. arXiv preprint arXiv:1910.00177, 2019.
178
+ [37] N. Y. Siegel, J. T. Springenberg, F. Berkenkamp, A. Abdolmaleki, M. Neunert, T. Lampe, R. Hafner, and M. Riedmiller. Keep doing what worked: Behavioral modelling priors for offline reinforcement learning. arXiv preprint arXiv:2002.08396, 2020.
179
+ [38] A. Kumar, J. Fu, M. Soh, G. Tucker, and S. Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. In Advances in Neural Information Processing Systems, pages 11761–11771, 2019.
180
+ [39] I. Kostrikov, J. Tompson, R. Fergus, and O. Nachum. Offline reinforcement learning with fisher divergence critic regularization. arXiv preprint arXiv:2103.08050, 2021.
181
+ [40] I. Kostrikov, A. Nair, and S. Levine. Offline reinforcement learning with implicit q-learning. arXiv preprint arXiv:2110.06169, 2021.
182
+ [41] Z. Wang, A. Novikov, K. Zołna, J. T. Springenberg, S. Reed, B. Shahriari, N. Siegel, J. Merel, ˙ C. Gulcehre, N. Heess, et al. Critic regularized regression. arXiv preprint arXiv:2006.15134, 2020.
183
+ [42] S. Fujimoto and S. S. Gu. A minimalist approach to offline reinforcement learning. arXiv preprint arXiv:2106.06860, 2021.
184
+ [43] X. Chen, Z. Zhou, Z. Wang, C. Wang, Y. Wu, and K. Ross. Bail: Best-action imitation learning for batch deep reinforcement learning, 2019. URL https://arxiv.org/abs/1910. 12179.
185
+ [44] H. Furuta, Y. Matsuo, and S. S. Gu. Generalized decision transformer for offline hindsight information matching. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $=$ CAjxVodl_v.
186
+ [45] Y. Jang, J. Lee, and K.-E. Kim. GPT-critic: Offline reinforcement learning for end-to-end taskoriented dialogue systems. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ qaxhBG1UUaS.
187
+ [46] L. Meng, M. Wen, Y. Yang, chenyang le, X. yun Li, H. Zhang, Y. Wen, W. Zhang, J. Wang, and B. XU. Offline pre-trained multi-agent decision transformer, 2022. URL https:// openreview.net/forum?id=W08IqLMlMer.
188
+ [47] P. Daoudi, M. Barlier, L. D. Santos, and A. Virmaux. Density estimation for conservative q-learning, 2022. URL https://openreview.net/forum?id $=$ liV-Re74fK.
189
+ [48] L. Liu, Z. Tang, L. Li, and D. Luo. Robust imitation learning from corrupted demonstrations, 2022. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ UECzHrGio7i.
190
+ [49] A. Mandlekar, D. Xu, J. Wong, S. Nasiriany, C. Wang, R. Kulkarni, F.-F. Li, S. Savarese, Y. Zhu, and R. Mart´ın-Mart´ın. What matters in learning from offline human demonstrations for robot manipulation. In 5th Annual Conference on Robot Learning, 2021. URL https: //openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ JrsfBJtDFdI.
191
+ [50] A. Kumar, J. Hong, A. Singh, and S. Levine. When should we prefer offline reinforcement learning over behavioral cloning? arXiv preprint arXiv:2204.05618, 2022.
192
+ [51] A. Singh, A. Kumar, Q. Vuong, Y. Chebotar, and S. Levine. Offline rl with realistic datasets: Heteroskedasticity and support constraints. arXiv preprint arXiv:2211.01052, 2022.
193
+ [52] Q. Vuong, A. Kumar, S. Levine, and Y. Chebotar. DASCO: Dual-generator adversarial support constrained offline reinforcement learning. In A. H. Oh, A. Agarwal, D. Belgrave, and K. Cho, editors, Advances in Neural Information Processing Systems, 2022. URL https://openreview.net/forum?id ${ . } = { }$ jBTQGGy9qA-.
194
+ [53] J. Li, X. Zhan, H. Xu, X. Zhu, J. Liu, and Y.-Q. Zhang. Distance-sensitive offline reinforcement learning. arXiv preprint arXiv:2205.11027, 2022.
195
+ [54] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
196
+ [55] Y. Zhang and J. Chai. Hierarchical task learning from language instructions with unified transformers and self-monitoring. arXiv preprint arXiv:2106.03427, 2021.
197
+ [56] A. Pashevich, C. Schmid, and C. Sun. Episodic transformer for vision-and-language navigation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 15942–15952, 2021.
198
+ [57] A. Silva, N. Moorman, W. Silva, Z. Zaidi, N. Gopalan, and M. Gombolay. Lancon-learn: Learning with language to enable generalization in multi-task manipulation. IEEE Robotics and Automation Letters, 7(2):1635–1642, 2021.
199
+ [58] E. Jang, A. Irpan, M. Khansari, D. Kappler, F. Ebert, C. Lynch, S. Levine, and C. Finn. Bc-z: Zero-shot task generalization with robotic imitation learning. In Conference on Robot Learning, pages 991–1002. PMLR, 2021.
200
+ [59] S. Nair, E. Mitchell, K. Chen, S. Savarese, C. Finn, et al. Learning language-conditioned robot behavior from offline data and crowd-sourced annotation. In Conference on Robot Learning, pages 1303–1315. PMLR, 2022.
201
+ [60] M. Janner, Q. Li, and S. Levine. Reinforcement learning as one big sequence modeling problem. In ICML 2021 Workshop on Unsupervised Reinforcement Learning, 2021.
202
+ [61] A. Kumar, X. B. Peng, and S. Levine. Reward-conditioned policies. arXiv preprint arXiv:1912.13465, 2019.
203
+ [62] R. K. Srivastava, P. Shyam, F. Mutz, W. Jaskowski, and J. Schmidhuber. Training agents using ´ upside-down reinforcement learning. arXiv preprint arXiv:1912.02877, 2019.
204
+ [63] D. Brandfonbrener, A. Bietti, J. Buckman, R. Laroche, and J. Bruna. When does returnconditioned supervised learning work for offline reinforcement learning? arXiv preprint arXiv:2206.01079, 2022.
205
+ [64] T. Yamagata, A. Khalil, and R. Santos-Rodriguez. Q-learning decision transformer: Leveraging dynamic programming for conditional sequence modelling in offline rl, 2023.
206
+ [65] L. Metz, J. Ibarz, N. Jaitly, and J. Davidson. Discrete sequential prediction of continuous actions for deep rl. CoRR, abs/1705.05035, 2017. URL http://dblp.uni-trier.de/ db/journals/corr/corr1705.html#MetzIJD17.
207
+ [66] S. Hochreiter and J. Schmidhuber. Long Short-Term Memory. 9(8):1735–1780, 1997.
208
+ [67] R. S. Sutton and A. G. Barto. Reinforcement learning: An introduction. Second edition, 2018.
209
+ [68] D. Cer, Y. Yang, S.-y. Kong, N. Hua, N. Limtiaco, R. S. John, N. Constant, M. GuajardoCespedes, S. Yuan, C. Tar, et al. Universal sentence encoder. arXiv preprint arXiv:1803.11175, 2018.
210
+ [69] E. Perez, F. Strub, H. De Vries, V. Dumoulin, and A. Courville. Film: Visual reasoning with a general conditioning layer. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
211
+ [70] M. Tan and Q. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International conference on machine learning, pages 6105–6114. PMLR, 2019.
212
+ [71] R. S. Sutton. Learning to predict by the methods of temporal differences. Machine learning, 3 (1):9–44, 1988.
213
+ [72] M. Hessel, J. Modayil, H. Van Hasselt, T. Schaul, G. Ostrovski, W. Dabney, D. Horgan, B. Piot, M. Azar, and D. Silver. Rainbow: Combining improvements in deep reinforcement learning. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
214
+ [73] Y. Lu, K. Hausman, Y. Chebotar, M. Yan, E. Jang, A. Herzog, T. Xiao, A. Irpan, M. Khansari, D. Kalashnikov, and S. Levine. Aw-opt: Learning robotic skills with imitation andreinforcement at scale. In 5th Annual Conference on Robot Learning, 2021.
215
+ [74] S. Dasari and A. Gupta. Transformers for one-shot visual imitation. In Conference on Robot Learning, pages 2071–2084. PMLR, 2021.
216
+ [75] C. J. Watkins and P. Dayan. Q-learning. Machine Learning, 8:279–292, 1992.
217
+ [76] T. Xiao, E. Jang, D. Kalashnikov, S. Levine, J. Ibarz, K. Hausman, and A. Herzog. Thinking while moving: Deep reinforcement learning with concurrent control. arXiv preprint arXiv:2004.06089, 2020.
218
+ [77] A. Chowdhery, S. Narang, J. Devlin, M. Bosma, G. Mishra, A. Roberts, P. Barham, H. W. Chung, C. Sutton, S. Gehrmann, P. Schuh, K. Shi, S. Tsvyashchenko, J. Maynez, A. Rao, P. Barnes, Y. Tay, N. Shazeer, V. Prabhakaran, E. Reif, N. Du, B. Hutchinson, R. Pope, J. Bradbury, J. Austin, M. Isard, G. Gur-Ari, P. Yin, T. Duke, A. Levskaya, S. Ghemawat, S. Dev, H. Michalewski, X. Garcia, V. Misra, K. Robinson, L. Fedus, D. Zhou, D. Ippolito, D. Luan, H. Lim, B. Zoph, A. Spiridonov, R. Sepassi, D. Dohan, S. Agrawal, M. Omernick, A. M. Dai, T. S. Pillai, M. Pellat, A. Lewkowycz, E. Moreira, R. Child, O. Polozov, K. Lee, Z. Zhou, X. Wang, B. Saeta, M. Diaz, O. Firat, M. Catasta, J. Wei, K. Meier-Hellstern, D. Eck, J. Dean, S. Petrov, and N. Fiedel. Palm: Scaling language modeling with pathways, 2022. URL https://arxiv.org/abs/2204.02311.
219
+
220
+ # A Proof of MDP optimization consistency
221
+
222
+ To show that transforming MDP into a per-action-dimension form still ensures optimization of the original MDP, we show that optimizing the Q-function for each action dimension is equivalent to optimizing the Q-function for the full action.
223
+
224
+ If we consider the full action $a _ { 1 : d _ { \mathcal { A } } }$ and that we switch to the state $s ^ { \prime }$ at the next timestep, the Qfunction for optimizing over the full action MDP would be:
225
+
226
+ $$
227
+ \begin{array} { r l } & { \underset { a _ { 1 : d _ { \cal A } } } { \operatorname* { m a x } } Q ( s , a _ { 1 : d _ { \cal A } } ) = \underset { a _ { 1 : d _ { \cal A } } } { \operatorname* { m a x } } \left[ R ( s , a _ { 1 : d _ { \cal A } } ) + \gamma \underset { a _ { 1 : d _ { \cal A } } } { \operatorname* { m a x } } Q ( s ^ { \prime } , a _ { 1 : d _ { \cal A } } ) \right] } \\ & { \quad \quad \quad \quad = R ( s , a _ { 1 : d _ { \cal A } } ^ { * } ) + \gamma \underset { a _ { 1 : d _ { \cal A } } } { \operatorname* { m a x } } Q ( s ^ { \prime } , a _ { 1 : d _ { \cal A } } ) , } \end{array}
228
+ $$
229
+
230
+ where $R ( s , a _ { 1 : d _ { A } } ^ { * } )$ is the reward we get after executing the full action.
231
+
232
+ The optimization over each action dimension using our Bellman update is:
233
+
234
+ $$
235
+ \begin{array} { r l } { \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \delta , \epsilon } ^ { \star } , \eta _ { \epsilon } \in \mathcal { G } _ { \epsilon - 1 } \sim \mathcal { G } _ { \epsilon } ^ { \star } } } & { = - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon } ^ { \star } \cup \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon } ^ { \star } } } \\ & { = \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon } ^ { \star } \cup \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon + 1 , \epsilon - 1 } } } \\ & { = \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon } ^ { \star } \cup \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { F } _ { \epsilon } \cup \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { F } _ { \epsilon } \cap \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon + 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon + 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { = \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon + 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } + \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon + 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & - \operatorname* { m a x } _ \ \end{array}
236
+ $$
237
+
238
+ which optimizes the original full action MDP as in Eq. 3.
239
+
240
+ # B Proof of convergence
241
+
242
+ Convergence of Q-learning has been shown in the past [67, 75]. Below we demonstrate that per-action dimension Q-function converges as well, by providing a proof almost identical to the standard $\mathrm { Q }$ -learning convergence proof, but extended to account for the per-action dimension maximization.
243
+
244
+ Let $d _ { \mathcal { A } }$ be the dimensionality of the action space, $a$ indicates a possible sequence of actions, whose dimension is not necessarily equal to the dimension of the action space. That is:
245
+
246
+ $$
247
+ a \in \{ a _ { 1 : i } , \forall i \leq d _ { A } \}
248
+ $$
249
+
250
+ To proof convergence, we can demonstrate that the Bellman operator applied to the per-action dimension Q-function is a contraction, i.e.:
251
+
252
+ $$
253
+ | | \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) | | _ { \infty } \leq c | | Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) | | _ { \infty } ,
254
+ $$
255
+
256
+ where
257
+
258
+ $$
259
+ B ^ { \ast } Q ( s , a ) = \left\{ \begin{array} { l l } { R ( s , a ) + \gamma \displaystyle \operatorname* { m a x } _ { a ^ { \prime } } Q ( s , a , a ^ { \prime } ) } & { \mathrm { i f ~ t h e ~ d i m e n s i o n ~ o f ~ } a \mathrm { ~ i s ~ l e s s ~ t h a n ~ } d \mathcal { A } } \\ { R ( s , a ) + \gamma \displaystyle \operatorname* { m a x } _ { a ^ { \prime } } \frac { E } { s ^ { \prime } } [ Q ( s ^ { \prime } , a ^ { \prime } ) ] } & { \mathrm { i f ~ t h e ~ d i m e n s i o n ~ o f ~ } a \mathrm { ~ i s ~ e q u a l ~ t o ~ } d \mathcal { A } } \end{array} \right.
260
+ $$
261
+
262
+ $a ^ { \prime }$ is the next action dimension following the sequence $a , s ^ { \prime }$ is the next state of the MDP, $\gamma$ is the discounting factor, and $0 \leq c \leq 1$ .
263
+
264
+ Proof: We can show that this is the case as follows:
265
+
266
+ Case 1: For action sequence whose dimension is less than the dimension of the action space.
267
+
268
+ $$
269
+ \begin{array} { r l } & { \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) } \\ & { \quad = R ( s , a ) + \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } Q _ { 1 } ( s , a , a ^ { \prime } ) - R ( s , a ) - \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } Q _ { 2 } ( s , a , a ^ { \prime } ) } \\ & { \quad = \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } [ Q _ { 1 } ( s , a , a ^ { \prime } ) - Q _ { 2 } ( s , a , a ^ { \prime } ) ] } \\ & { \quad \le \gamma \underset { s , a } { \operatorname* { s u p } } [ Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) ] } \\ & { \quad \Longrightarrow | | \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) | | _ { \infty } \le \gamma | | Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) | | _ { \infty } } \end{array}
270
+ $$
271
+
272
+ where $\operatorname { s u p } _ { s , a }$ is the supremum over all action sequences, with $0 \leq \gamma \leq 1$ and $\| f \| _ { \infty } = \operatorname* { s u p } _ { x } [ f ( x ) ]$ .
273
+
274
+ Case 2: For action sequence whose dimension is equal to the dimension of the action space
275
+
276
+ $$
277
+ \begin{array} { r l } & { \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) } \\ & { \ = R ( s , a ) + \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } E [ Q _ { 1 } ( s ^ { \prime } , a ^ { \prime } ) ] - R ( s , a ) - \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } E [ Q _ { 2 } ( s ^ { \prime } , a ^ { \prime } ) ] } \\ & { \ = \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } E [ Q _ { 1 } ( s ^ { \prime } , a ^ { \prime } ) - Q _ { 2 } ( s ^ { \prime } , a ^ { \prime } ) ] } \\ & { \ \leq \gamma \underset { s , a } { \operatorname* { s u p } } [ Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) ] } \\ & { \ \Longrightarrow \ | | \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) | | _ { \infty } \leq \gamma | | Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) | | _ { \infty } } \end{array}
278
+ $$
279
+
280
+ # C Analysis of the conservatism term
281
+
282
+ With the goal of understanding the behavior of our training procedure, we theoretically analyze the solution obtained by Eq. 2 for the simpler cases when $Q$ is represented as a table, and when the objective in Eq. 2 can be minimized exactly. We derive the minimizer of the objective in Eq. 2 by differentiating $J$ with respect to $Q$ :
283
+
284
+ $$
285
+ \begin{array} { r l } & { \forall s , a , k , \frac { d J } { d Q ( s , a ) } = 0 } \\ & { \pi _ { \beta } ( a | s ) \left( Q ( s , a ) - B ^ { * } Q ^ { k } ( s , a ) \right) + \alpha \tilde { \pi } _ { \beta } ( a | s ) Q ( s , a ) = 0 } \\ & { Q ( s , a ) \left( \pi _ { \beta } ( a | s ) + \alpha \tilde { \pi } _ { \beta } ( a | s ) \right) = \pi _ { \beta } ( a | s ) B ^ { * } Q ^ { k } ( s , a ) } \\ & { Q ^ { k + 1 } ( s , a ) = \underbrace { \pi _ { \beta } ( a | s ) } _ { : = m ( s , a ) } . } \end{array}
286
+ $$
287
+
288
+ Eq. 4 implies that training with the objective in Eq. 2 performs a weighted Bellman backup: unlike the standard Bellman backup, training with Eq. 2 multiplies large Q-value targets by a weight $m ( s , a )$ . This weight $m ( s , a )$ takes values between 0 and 1, with larger values close to 1 for indistribution actions where $( s , a ) \in \mathcal { D }$ , and very small values close to 0 for out-of-distribution actions $a$ at any state $s$ (i.e., actions where $\pi _ { \beta } ( a | s )$ is small). Thus, the Bellman backup induced via Eq. 4 should effectively prevent over-estimation of Q-values for unseen actions.
289
+
290
+ # D Q-Transformer Architecture & System
291
+
292
+ In this section, we describe the architecture of Q-Transformer as well as the important implementation and system details that make it an effective Q-learning algorithm for real robots.
293
+
294
+ # D.1 Transformer sequence model architecture
295
+
296
+ Our neural network architecture is shown in Figure 3. The architecture is derived from the RT-1 design [1], adapted to accommodate the Q-Transformer framework, and consists of a Transformer backbone that reads in images via a convolutional encoder followed by tokenization. Since we apply Q-Transformer to a multi-task robotic manipulation problem where each task is specified by a natural language instruction, we first embed the natural language instruction into an embedding vector via the Universal Sentence Encoder [68]. The embedding vector and images from the robot camera are then converted into a sequence of input tokens via a FiLM EfficientNet [69, 70]. In the standard RT-1 architecture [1], the robot action space is discretized and the Transformer sequence model outputs the logits for the discrete action bins per dimension and per time step. In this work, we extend the network architecture to use Q-learning by applying a sigmoid activation to the output values for each action, and interpreting the resulting output after the sigmoid as Q-values. This representation is particularly suitable for tasks with sparse per-episode rewards $R \in [ 0 , 1 ]$ , since the Q-values may be interpreted as probabilities of task success and should always lie in the range $[ 0 , 1 ]$ . Note that unlike the standard softmax, this interpretation of Q-values does not prescribe normalizing across actions (i.e., each action output can take on any value in $[ 0 , 1 ] )$ ).
297
+
298
+ Since our robotic system, described in Section D.3, has 8-dimensional actions, we end up with 8 dimensions per time step and discretize each one into $N = 2 5 6$ value bins. Our reward function is a sparse reward that assigns value 1.0 at the last step of an episode if the episode is successful and 0.0 otherwise. We use a discount rate $\gamma = 0 . 9 8$ . As is common in deep RL, we use a target network to estimate target Q-values $Q ^ { k }$ , using an exponential moving average of $Q$ -network weights to update the target network. The averaging constant is set to 0.01.
299
+
300
+ # D.2 Conservative Q-learning implementation
301
+
302
+ The conservatism penalty in Section 4.2 requires estimating expectations under $\pi _ { \beta } ( a | s )$ and $\tilde { \pi } _ { \beta } ( a | s ) \propto ( 1 - \pi _ { \beta } ( \bar { a } | s ) )$ , with the latter being especially non-trivial to estimate. We employ a simple and crude approximation that we found to work well in practice, replacing $\pi _ { \beta } ( a | s )$ with the empirical distribution corresponding, for each sampled state-action tuple $( s _ { j } , a _ { j } ) \in \mathcal { D }$ , to a Dirac delta centered on $a _ { j }$ , such that $\pi _ { \beta } ( { \bar { a } } | s _ { j } ) = \delta ( a = { \bar { a } } _ { j } )$ . This results in a simple expression for $\tilde { \pi } _ { \beta } ( a | s _ { j } )$ corresponding to the uniform distribution over all other actions, such that ${ \tilde { \pi } } _ { \beta } ( a | s _ { j } ) \propto \delta ( a \stackrel { . } { \neq } a _ { j } )$ . After discretizing the actions, there are $N - 1$ bins per dimension to exhaustively iterate over when computing the conservatism term in Eq. 2, which is the same as taking the average over targets for all unseen action values. In our experiments, we find that simply setting the conservatism weight to $\alpha = 1 . 0$ worked best, without additional tuning.
303
+
304
+ # D.3 Robot system overview
305
+
306
+ The robot that we use in this work is a mobile manipulator with a 7-DOF arm with a 2 jaw parallel gripper, attached to a mobile base with a head-mounted RGB camera, illustrated in Figure 1. The RGB camera provides a $6 4 0 \times 5 1 2$ RGB image, which is downsampled to $3 2 0 \times 2 5 6$ before being consumed by the Q-Transformer. See Figure 4 for images from the robot camera view. The learned policy is set up to control the arm and the gripper of the robot. Our action space consists of 8 dimensions: 3D position, 3D orientation, gripper closure command, and an additional dimension indicating whether the episode should terminate, which the policy must trigger to receive a positive reward upon successful task completion. Position and orientation are relative to the current pose, while the gripper command is the absolute closedness fraction, ranging from fully open to fully closed. Orientation is represented via axis-angles, and all actions except whether to terminate are continuous actions discretized over their full action range in 256 bins. The termination action is binary, but we pad it to be the same size as the other action dimensions to avoid any issues with unequal weights. The policy operates at $3 \ : \mathrm { H z }$ , with actions executed asynchronously [76].
307
+
308
+ Algorithm 1 Temporal difference error and loss computation for one action dimension i at timestep $t$ , $\hat { a } _ { t } ^ { i }$ .
309
+
310
+ Input Sequence of state in time window of size $w$ , $s _ { t - w : t }$ Input Language embedding of task instruction $l$ .
311
+ Input The state at timestep $t + 1$ , $s _ { t + 1 }$ .
312
+ Input Dataset action up to dimension $i$ , $\{ \boldsymbol { \mathcal { D } } \boldsymbol { a } _ { t } ^ { j } \} _ { j = 0 } ^ { i }$ .
313
+ Output The loss to optimize Q-Transformer.
314
+
315
+ ${ Q } ^ { t a r g } \gets$ Compute maximum Q-values of the next action dimension using Eq. 1 // Compute the maximum between $\mathsf { Q }$ -target and Monte Carlo return. $Q ^ { t a r g } \gets \mathrm { m a x } ( \mathbf { M } \mathbf { C } , Q ^ { t a r g } )$
316
+
317
+ // Compute the temporal difference error. $\mathrm { T D E r r o r } = \frac { 1 } { 2 } ( \mathrm { Q } \mathrm { - } \mathrm { T r a n s f o r m e r } ( l , s _ { t - w : t } , \{ a ^ { j } \} _ { j = 1 } ^ { i } ) - Q ^ { t a r g } ) ^ { 2 }$
318
+
319
+ // Compute the conservative regularizer.
320
+ // The sum is over all action bins not equal to the tokenized dataset action.
321
+ // $N$ is the number of discretization bin.
322
+ $\mathrm { R e g } = \frac { 1 } { 2 ( N - 1 ) } \sum _ { a \neq _ { \mathscr D } a _ { t } ^ { i } } \left( \mathrm { Q } \mathrm { - T r a n s f o r m e r } ( l , s _ { t - w : t } , \{ a ^ { j } \} _ { j = 1 } ^ { i - 1 } \cup \{ a \} ) \right) ^ { 2 }$
323
+ // Compute the loss function
324
+ $\mathcal { L } = \mathrm { T D E r r o r } + \mathrm { R e g }$
325
+
326
+ Return $\mathcal { L }$ as the loss function to optimize Q-Transformer with.
327
+
328
+ # E Pseudo-code
329
+
330
+ Algorithm 1 shows the loss computation for training each action dimension of the Q-Transformer. We first use Eq. 1 to compute the maximum Q-values over the next action dimensions. Then we compute the Q-target for the given dataset action by using the Bellman update with an additional maximization over the Monte-Carlo return and predicted maximum Q-value at the next time step. The TD-error is then computed using the Mean-Squared Error. Finally, we set a target of 0 for all discretized action bins except the dataset action and add the averaged Mean-Squared Error over these dimensions to the TD-Error, which results in the total loss $\mathcal { L }$ .
331
+
332
+ # F Running training for multiple random seeds
333
+
334
+ ![](images/03319d946e15d6073b3d3dc41af3eba492e895c4c32254425de7b2833e2b1373.jpg)
335
+ Figure 7: Mean and variance of Q-Transformer and RT-1 performance in simulation when running the training for 5 different random seeds.
336
+
337
+ In addition to performing a large amount of evaluations, we also analyze the statistical significance of our learning results by running our training of Q-Transformer and RT-1 on multiple seeds in simulation. In particular, we run the training for 5 random seeds in Figure 7. As we can see, QTransformer retains its improved performance across the distribution of the random seeds.
338
+
339
+ # G Q-Transformer value function with a language planner experiments
340
+
341
+ ![](images/418de5cc2615f3453f597de834c6ca9da2678908ac1770117968ab5dd507f285.jpg)
342
+ Figure 8: Qualitative comparisons of Q-values from QT-Opt (sim-to-real) and Q-Transformer. QTransformer outputs sharper Q-values for objects close to the robot, which can be grasped faster and more easily than the objects farther away.
343
+
344
+ Recently, the SayCan algorithm [8] was proposed as a way to combine large language models (LLMs) with learned policies and value functions to solve long-horizon tasks. In this framework, the value function for each available skill is used to determine the “affordance” of the current state for that skill, and a large language model then selects from among the available affordances to take a step towards performing some temporally extended task. For example, if the robot is commanded to bring all the items on a table, the LLM might propose a variety of semantically meaningful items, and select from among them based on the item grasping skill that currently has a high value (corresponding to items that the robot thinks it can grasp). SayCan uses QT-Opt in combination with sim-to-real transfer to train Q-functions for these affordances. In the following set of experiments, we demonstrate that the Q-Transformer outperforms QT-Opt for affordance estimation without using any sim-to-real transfer, entirely using the real world dataset that we employ in the preceding experiments.
345
+
346
+ We first benchmark Q-Transformer on the problem of correctly estimating task affordances from the RT-1 dataset [1]. In addition to the standard training on demonstrations and autonomous data, we introduce a training with relabeling, which we found particularly useful for affordance estimation. During relabeling, we sample a random alternate task for a given episode. We relabel the task name of the episode to the newly sampled task, and set reward to 0.0. This ensures that the boundaries between tasks are more clearly learned during train
347
+
348
+ <table><tr><td>Model</td><td>Precision</td><td>Recall</td><td>F1</td></tr><tr><td>QT-Opt (sim-to-real)</td><td>0.61</td><td>0.68</td><td>0.64</td></tr><tr><td>Q-T w/ relabel</td><td>0.76</td><td>0.89</td><td>0.82</td></tr><tr><td>Q-T w/o relabel</td><td>0.58</td><td>0.93</td><td>0.71</td></tr></table>
349
+
350
+ Table 1: Affordance estimation comparison: precision, recall and F1 score when using Q-values to determine if a task is feasible. Q-Transformer (Q-T) with multitask relabeling consistently produces better affordance estimates.
351
+
352
+ ing. Table 1 shows comparison of performance of our model with and without relabeling as well as the sim-to-real QT-Opt model used in SayCan [8]. Both of our models outperform the QT-Opt model on F1 score, with the relabeled model outperforming it by a large margin. This demonstrates that our Q-function can be effectively used for affordance estimation, even without training with sim-to-real transfer. Visualization of the Q-values produced by our Q-function can be found in Figure 8.
353
+
354
+ We then use Q-Transformer in a long horizon SayCan style evaluation, replacing both the sim-to-real QT-Opt model for affordance estimation, and the RT-1 policy for low-level robotic control. During this evaluation, a PaLM language model [77] is used to propose task candidates given a user query. Q-values are then used to pick the task candidate with the highest affordance score, which is then executed on the robot using the execution policy. The $\mathrm { Q } \mathrm { - }$ Transformer used for affordance estimation is trained with relabeling. The QTransformer used for low-level control is
355
+
356
+ Table 2: Performance on SayCan style long-horizon tasks: SayCan queries $Q ( s , \bar { a } )$ in planning to pick a language instruction, then runs a policy to execute the plan. Q-Transformer outperforms RT-1 with QT-Opt in both planning and execution.
357
+
358
+ <table><tr><td colspan="2">Method</td><td colspan="2">Success Rate</td></tr><tr><td>Affordance</td><td>Execution Planning</td><td></td><td>Execution</td></tr><tr><td>Q-T w/ relabel QT-Opt (sim-to-real)</td><td>Q-T RT-1</td><td>93 87</td><td>93 67</td></tr></table>
359
+
360
+ trained without relabeling, since we found relabeling episodes at the task level did not improve execution performance. SayCan with Q-Transformer is better at both planning the sequence of tasks and executing those plans, as illustrated in Table 2.
361
+
362
+ # H Real robotic manipulation tasks used in our evaluation
363
+
364
+ We include the complete list of evaluation tasks in our real robot experiments below.
365
+
366
+ Drawer pick and place: pick 7up can from top drawer and place on counter, place 7up can into top drawer, pick brown chip bag from top drawer and place on counter, place brown chip bag into top drawer, pick orange can from top drawer and place on counter, place orange can into top drawer, pick coke can from middle drawer and place on counter, place coke can into middle drawer, pick orange from middle drawer and place on counter, place orange into middle drawer, pick green rice chip bag from middle drawer and place on counter, place green rice chip bag into middle drawer, pick blue plastic bottle from bottom drawer and place on counter, place blue plastic bottle into bottom drawer, pick water bottle from bottom drawer and place on counter, place water bottle into bottom drawer, pick rxbar blueberry from bottom drawer and place on counter, place rxbar blueberry into bottom drawer.
367
+
368
+ Open and close drawer: open top drawer, close top drawer, open middle drawer, close middle drawer, open bottom drawer, close bottom drawer.
369
+
370
+ Move object near target: move 7up can near apple, move 7up can near blue chip bag, move apple near blue chip bag, move apple near 7up can, move blue chip bag near 7up can, move blue chip bag near apple, move blue plastic bottle near pepsi can, move blue plastic bottle near orange, move pepsi can near orange, move pepsi can near blue plastic bottle, move orange near blue plastic bottle, move orange near pepsi can, move redbull can near rxbar blueberry, move redbull can near water bottle, move rxbar blueberry near water bottle, move rxbar blueberry near redbull can, move water bottle near redbull can, move water bottle near rxbar blueberry, move brown chip bag near coke can, move brown chip bag near green can, move coke can near green can, move coke can near brown chip bag, move green can near brown chip bag, move green can near coke can, move green jalapeno chip bag near green rice chip bag, move green jalapeno chip bag near orange can, move green rice chip bag near orange can, move green rice chip bag near green jalapeno chip bag, move orange can near green jalapeno chip bag, move orange can near green rice chip bag, move redbull can near sponge, move sponge near water bottle, move sponge near redbull can, move water bottle near sponge, move 7up can near blue blastic bottle, move 7up can near green can, move blue plastic bottle near green can, move blue plastic bottle near 7up can, move green can near 7up can, move green can near blue plastic bottle, move apple near brown chip bag, move apple near green jalapeno chip bag, move brown chip bag near green jalapeno chip bag, move brown chip bag near apple, move green jalapeno chip bag near apple, move green jalapeno chip bag near brown chip bag.
md/dev/0IywQ8uxJx/0IywQ8uxJx.md ADDED
@@ -0,0 +1,708 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Graph Neural Networks as Gradient Flows
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Dynamical systems minimizing an energy are ubiquitous in geometry and physics.
11
+ 2 We propose a gradient flow framework for GNNs where the equations follow the
12
+ 3 direction of steepest descent of a learnable energy. This approach allows to analyse
13
+ 4 the GNN evolution from a multi-particle perspective as learning attractive and
14
+ 5 repulsive forces in feature space via the positive and negative eigenvalues of a
15
+ 6 symmetric ‘channel-mixing’ matrix. We perform spectral analysis of the solutions
16
+ 7 and conclude that gradient flow graph convolutional models can induce a dynamics
17
+ 8 dominated by the graph high frequencies, which is desirable for heterophilic
18
+ 9 datasets. We also describe structural constraints on common GNN architectures
19
+ 10 allowing to interpret them as gradient flows. We perform thorough ablation studies
20
+ 11 corroborating our theoretical analysis and show competitive performance of simple
21
+ 12 and lightweight models on real-world homophilic and heterophilic datasets.
22
+
23
+ # 13 1 Introduction and motivations
24
+
25
+ 14 Graph neural networks (GNNs) [38, 20, 21, 36, 7, 15, 27] and in particular their Message Passing
26
+ 15 formulation (MPNN) $\boxed { 1 9 }$ have become the standard ML tool for dealing with different types of
27
+ 16 relations and interactions, ranging from social networks to particle physics and drug design. One
28
+ 17 of the often cited drawbacks of traditional GNN models is their poor ‘explainability’, making it
29
+ 18 hard to know why and how they make certain predictions $\boxed { 1 4 6 } \boxed { 4 7 }$ , and in which situations they
30
+ 19 may work and when they would fail. Limitations of GNNs that have attracted attention are over
31
+ 20 smoothing $\pm \boxed { 2 9 } \boxed { 3 0 } \boxed { 8 }$ , over-squashing and bottlenecks $\boxed { 1 } \boxed { 4 0 } \boxed { }$ , and performance on heterophilic data
32
+ 21 [31, 51, 13, 4, 45] – where adjacent nodes usually have different labels.
33
+ 22 Contributions. We propose a Gradient Flow Framework
34
+ 23 (GRAFF) where the GNN equations follow the direction of steep
35
+ 24 est descent of a learnable energy. Thanks to this framework we can
36
+ 25 (i) interpret GNNs as a multi-particle dynamics where the learned
37
+ 26 parameters determine pairwise attractive and repulsive potentials
38
+ 27 in the feature space. This sheds light on how GNNs can adapt to
39
+ 28 heterophily and explains their performance and the smoothness of
40
+ 29 the prediction. (ii) GRAFF leads to residual convolutional models
41
+ 30 where the channel-mixing W is performed by a shared symmet
42
+ 31 ric bilinear form inducing attraction and repulsion via its positive
43
+ 32 and negative eigenvalues, respectively. We theoretically investi
44
+ 33 gate the interaction of the graph spectrum with the spectrum of the
45
+ 34 channel-mixing, proving that if there is more mass on the negative
46
+ 35 eigenvalues of W, then the dynamics is dominated by the graph
47
+ 36 high frequencies, which could be desirable on heterophilic graphs.
48
+ 37 We also extend results of $\boxed { 2 9 } \boxed { 3 0 } \boxed { 8 }$ by showing that when we drop
49
+ 38 the residual connection intrinsic to the gradient flow framework,
50
+ 39 graph convolutional models always induce a low-frequency dominated dynamics independent of the
51
+ 40 sign and magnitude of the spectrum of the channel-mixing. We also discuss how simple choices
52
+ 41 make common architectures fit GRAFF and conduct thorough ablation studies to corroborate the the
53
+ 42 oretical analysis on the role of the spectrum of W. (iii) We crystallize an instance of our framework
54
+ 43 into a linear, residual, convolutional model that achieves competitive performance on homophilic and
55
+ 44 heterophilic real world graphs whilst being faster than GCN.
56
+ 45 Related work. Our analysis is related to studying GNNs as filters on the graph spectrum [15, 24,
57
+ 46 2, 25] and over-smoothing $\pmb { \bigtriangledown } \bigtriangledown \bigtriangledown \bigtriangledown \bigtriangledown \bigtriangledown \bigtriangledown \bigtriangledown \bigtriangledown \bigtriangledown$ and partly adopts techniques similar to $\textcircled { 1 3 0 } \textcircled { 1 }$ . The key
58
+ 47 difference is that we also consider the spectrum of the ‘channel-mixing’ matrix. The concept of
59
+ 48 gradient flows has been a standard tool in physics and geometry [16], from which they were adopted
60
+ 49 for image processing $\pmb { \mathbb { \mathbb { \mathbb { 2 6 } } } }$ , and recently used in ML $\textcircled { 1 3 5 }$ for the analysis of Transformers [41] – see
61
+ 50 also $\boxed { \boxed { 1 8 } }$ for discussion of loss landscapes. Our continuous-time evolution equations follows the spirit
62
+ 51 of Neural ODES [22, 12, 3] and the study of GNNs as continuous dynamical systems [44, 10, 17, 9].
63
+ 52 Outline. In Section 2, we review the continuous and discrete Dirichlet energy and the associated
64
+ 53 gradient flow framework. We formalize the notion of over-smoothing and low(high)-frequency
65
+ 54 dominated dynamics to investigate GNNs and study the dominant components in their evolution. We
66
+ 55 extend the graph Dirichlet energy to allow for a non-trivial norm for the feature edge-gradient. This
67
+ 56 leads to gradient flow equations that diffuse the features and over-smooth in the limit. Accordingly,
68
+ 57 in Section $^ 3$ we introduce a more general energy with a symmetric channel-mixing matrix W giving
69
+ 58 rise to attractive and repulsive pairwise terms via its positive and negative eigenvalues and show
70
+ 59 that the negative spectrum can induce high-frequency-dominant dynamics. In Section 4 we first
71
+ 60 compare with continuous GNN models and then discretize the equations and provide a ‘recipe’ for
72
+ 61 making standard GNN architectures fit a gradient flow framework. We adapt the spectral analysis to
73
+ 62 discrete-time showing that gradient flow convolutional models can generate a dynamics dominated by
74
+ 63 the high frequencies via the negative eigenvalues of W while this is impossible if we drop the residual
75
+ 64 connection. In Section $. 5$ we corroborate our theoretical analysis on the role of the spectrum of W
76
+ 65 via ablation studies on graphs with varying homophily. Experiments on real world datasets show a
77
+ 66 competitive performance of our model despite its simplicity and reduced number of parameters.
78
+
79
+ ![](images/bbd3047d2cbd0b9bc92189a22e8836ee7d60b4c122913cbc88bde0574145b67a.jpg)
80
+ Figure 1: GRAFF dynamics: attractive and repulsive forces lead to a non-smoothing process able to separate labels.
81
+
82
+ # 67 2 Gradient-flow formalism
83
+
84
+ 68 Notations adopted throughout the paper. Let $\mathsf { G } = ( \mathsf { V } , \mathsf { E } )$ be an undirected graph with $n$ nodes.
85
+ 69 We denote by $\textbf { F } \in \mathbb { R } ^ { n \times d }$ the matrix of $d$ -dimensional node features, by $\mathbf { f } _ { i } ~ \in ~ \mathbb { R } ^ { d }$ its $i$ -th row
86
+ 70 (transposed), by $\mathbf { f } ^ { r } \in \mathbb { R } ^ { n }$ its $r$ -th column, and by $\mathrm { v e c } ( \mathbf { F } ) \in \mathbb { R } ^ { n d }$ the vectorization of $\mathbf { F }$ obtained
87
+ 71 by stacking its columns. Given a symmetric matrix $\mathbf { B }$ , we let $\lambda _ { + } ^ { \mathbf { B } }$ , $\lambda _ { - } ^ { \mathbf { B } }$ denote its most positive and
88
+ 72 negative eigenvalues, respectively, and $\rho _ { \mathbf { B } }$ be its spectral radius. If $\mathbf { B } \succeq 0$ , then $\mathrm { g a p } ( \mathbf { B } )$ denotes the
89
+ 73 positive smallest eigenvalue of $\mathbf { B }$ . ${ \dot { f } } ( t )$ denotes the temporal derivative, $\otimes$ is the Kronecker product
90
+ 74 and ‘a.e.’ means almost every w.r.t. Lebesgue measure and usually refers to data in the complement
91
+ 75 of some lower dimensional subspace in $\mathbb { R } ^ { \bar { n } \times d }$ . Proofs and additional results appear in the Appendix.
92
+ 76 Starting point: a geometric parallelism. To motivate a gradient-flow approach for GNNs, we start
93
+ 77 from the continuous case (see Appendix A.1 for details). Consider a smooth map $f : \mathbb { R } ^ { n } \to ( \mathbb { R } ^ { d } , h )$
94
+ 78 with $h$ a constant metric represented by $\mathbf { \overline { { H } } } \succeq 0$ . The Dirichlet energy of $f$ is defined by
95
+
96
+ $$
97
+ \mathcal { E } ( f , h ) = \frac { 1 } { 2 } \int _ { \mathbb { R } ^ { n } } \| \nabla f \| _ { h } ^ { 2 } d x = \frac { 1 } { 2 } \sum _ { q , r = 1 } ^ { d } \sum _ { j = 1 } ^ { n } \int _ { \mathbb { R } ^ { n } } h _ { q r } \partial _ { j } f ^ { q } \partial _ { j } f ^ { r } ( x ) d x
98
+ $$
99
+
100
+ 79 and measures the ‘smoothness’ of $f$ . A natural approach to find minimizers of $\mathcal { E }$ - called harmonic
101
+ 80 maps - was introduced in $\mathbb { I } \mathbb { 1 6 } ]$ and consists in studying the gradient flow of $\mathcal { E }$ , wherein a given map
102
+ 81 $f ( 0 ) = f _ { 0 }$ is evolved according to $\dot { f } ( t ) = - \nabla _ { f } \mathcal { E } ( f ( t ) )$ . These type of evolution equations have
103
+ 82 historically been the core of variational and $P D E$ -based image processing; in particular, gradient
104
+ 83 flows of the Dirichlet energy were shown $[ \overline { { 2 6 } } ]$ to recover the Perona-Malik nonlinear diffusion $\pmb { \left. 3 2 \right. }$ .
105
+ 84 Motivation: GNNs for node-classification. We wish to extend the gradient flow formalism to node
106
+ 85 classification on graphs. Assume we have a graph $\sf G$ , node-features $\mathbf { F } _ { 0 }$ and labels $\{ y _ { i } \}$ on $\mathsf { V } _ { \mathrm { t r a i n } } \subset \mathsf { V }$
107
+ 86 and that we want to predict the labels on $\mathsf { V } _ { \mathrm { t e s t } } \subset \mathsf { V }$ . A GNN typically evolves the features via some
108
+ 87 parametric rule, ${ \mathrm { G N N } } _ { \theta } ( { \mathsf { G } } , { \mathbf { F } } _ { 0 } )$ , and uses a decoding map for the prediction $y = \psi _ { \mathrm { D E } } ( \mathrm { G N N } _ { \theta } ( \mathsf { G } , \mathbf { F } _ { 0 } ) )$ .
109
+ 88 In graph convolutional models $\mathbb { I m }$ , $\mathrm { G N N } _ { \theta }$ consists of two operations: applying a shared linear
110
+ 89 transformation to the features (‘channel mixing’) and propagating them along the edges of the graph
111
+ 90 (‘diffusion’). Our goal consists in studying when $\mathrm { G N N } _ { \theta }$ is the gradient flow of some parametric class
112
+ 91 of energies $\mathcal { E } _ { \theta } : \mathbb { R } ^ { \bar { n } \times d } \mathbb { R }$ , which generalize the Dirichlet energy. This means that the parameters
113
+ 92 can be interpreted as ‘finding the right notion of smoothness’ for our task. We evolve the features by
114
+ 93 $\dot { \mathbf { F } } ( t ) = - \bar { \nabla _ { \mathbf { F } } } \mathcal { E } _ { \theta } ( \mathbf { F } ( t ) )$ with prediction $y = \psi _ { \mathrm { D E } } ( \mathbf { F } ( T ) )$ for some optimal time $T$ .
115
+ 94 Why a gradient flow? Since $\dot { \mathcal { E } } _ { \theta } ( { \bf F } ( t ) ) = - | | \nabla _ { \bf F } \mathcal { E } _ { \theta } ( { \bf F } ( t ) ) | | ^ { 2 }$ , the energy dissipates along the gradient
116
+ 95 flow. Accordingly, this framework allows to explain the GNN dynamics as flowing the node features
117
+ 96 in the direction of steepest descent of $\mathcal { E } _ { \theta }$ . Indeed, we find that parametrizing an energy leads to
118
+ 97 equations governed by attractive and repulsive forces that can be controlled via the spectrum of
119
+ 98 symmetric ‘channel-mixing’ matrices. This shows that by learning to distribute more mass over the
120
+ 99 negative (positive) eigenvalues of the channel-mixing, gradient flow models can generate dynamics
121
+ 100 dominated by the higher (respectively, lower) graph frequencies and hence tackle different homophily
122
+ 101 scenarios. The gradient flow framework also leads to sharing of the weights across layers (since we
123
+ 102 parametrize the energy rather than the evolution equations, as usually done in GNNs), allowing us to
124
+ 103 reduce the number of parameters without compromising performance (see Table 1).
125
+ 104 Analysis on graphs: preliminaries. Given a connected graph G with self-loops, its adjacency
126
+ 105 matrix A is defined as $a _ { i j } = 1$ if $( i , j ) \in { \mathsf { E } }$ and zero otherwise. We let $\mathbf { D } = \mathrm { d i a g } ( \bar { d } _ { i } )$ be the degree
127
+ 106 matrix and write $\bar { \mathbf { A } } : = \mathbf { D } ^ { - 1 / 2 } \mathbf { A } \mathbf { D } ^ { - 1 / 2 }$ . Let $\mathbf { F } \in \mathbb { R } ^ { n \times d }$ be the matrix representation of a signal. Its
128
+ 107 graph gradient is $( \nabla { \bf F } ) _ { i j } : = { \bf f } _ { j } / \sqrt { d _ { j } } - { \bf f } _ { i } / \sqrt { d _ { i } }$ . We define the Laplacian as $\begin{array} { r } { \Delta : = - \frac { 1 } { 2 } \mathrm { d i v } \bigtriangledown } \end{array}$ (the
129
+ 108 divergence div is the adjoint of $\nabla$ ), represented by $\pmb { \Delta } = \mathbf { I } - \bar { \mathbf { A } } \succeq 0$ . We refer to the eigenvalues of
130
+ 109 $\pmb { \Delta }$ as frequencies: the lowest frequency is always 0 while the highest frequency is $\rho \Delta \stackrel { - } { \leq } 2$ [14]. As
131
+ 110 for the continuum case, the gradient allows to define a (graph) Dirichlet energy as [49]
132
+
133
+ $$
134
+ \mathcal { E } ^ { \mathrm { D i r } } ( \mathbf { F } ) : = \frac { 1 } { 4 } \sum _ { i } \sum _ { j : ( i , j ) \in \mathsf { E } } | | ( \nabla \mathbf { F } ) _ { i j } | | ^ { 2 } \equiv \frac { 1 } { 4 } \sum _ { ( i , j ) \in \mathsf { E } } | | \frac { \mathbf { f } _ { i } } { \sqrt { d _ { i } } } - \frac { \mathbf { f } _ { j } } { \sqrt { d _ { j } } } | | ^ { 2 } = \frac { 1 } { 2 } \mathrm { t r a c e } ( \mathbf { F } ^ { \top } \Delta \mathbf { F } ) ,
135
+ $$
136
+
137
+ where the extra 111 $\begin{array} { l } { { \frac { 1 } { 2 } } } \end{array}$ is for convenience. As for manifolds, ${ \mathcal { E } } ^ { \mathrm { { D i r } } }$ measures smoothness. If we stack the columns of 112 $\mathbf { F }$ into $\mathrm { v e c } ( \mathbf { F } ) \in \mathbb { R } ^ { n d }$ , the gradient flow of ${ \mathcal { E } } ^ { \mathrm { { D i r } } }$ yields the heat equation on each channel:
138
+
139
+ $$
140
+ \operatorname { v e c } ( { \dot { \mathbf { F } } } ( t ) ) = - \nabla _ { \operatorname { v e c } ( \mathbf { F } ) } { \mathcal { E } } ^ { \mathrm { D i r } } ( \operatorname { v e c } ( \mathbf { F } ( t ) ) ) = - ( \mathbf { I } _ { d } \otimes \Delta ) \operatorname { v e c } ( \mathbf { F } ( t ) ) \iff { \dot { \mathbf { f } } } ^ { r } ( t ) = - \Delta \mathbf { f } ^ { r } ( t ) ,
141
+ $$
142
+
143
+ 113 for $1 \leq r \leq d$ . Similarly to $\textcircled { 8 }$ , we rely on ${ \mathcal { E } } ^ { \mathrm { { D i r } } }$ to assess whether a given dynamics $t \mapsto \mathbf { F } ( t )$ is a
144
+ 114 smoothing process. A different choice of Laplacian $\mathbf { L } = \mathbf { D } - \mathbf { A }$ with non-normalized adjacency
145
+ 115 induces the analogous Dirichlet energy $\begin{array} { r } { \mathcal E _ { \mathbf { L } } ^ { \mathrm { D i r } } ( \mathbf { \dot { F } } ) = \frac { 1 } { 2 } \mathrm { t r a c e } ( \mathbf { F } ^ { \top } \mathbf { L } \mathbf { F } ) } \end{array}$ . Throughout this paper, we rely
146
+ 116 on the following definitions (see Appendix A.3 for further equivalent formulations and justifications):
147
+ 117 Definition 2.1. $\dot { \mathbf { F } } ( t ) = \mathrm { G N N } _ { \theta } ( \mathbf { F } ( t ) , t )$ initialized at $\mathbf F ( 0 )$ is smoothing if $\mathcal { E } ^ { \mathrm { D i r } } ( { \bf F } ( t ) ) \leq C + \varphi ( t )$ ,
148
+ 118 with $C$ a constant only depending on $\dot { \mathcal { E } } ^ { \mathrm { D i r } } ( \mathbf { F } ( 0 ) )$ and $\dot { \varphi } ( t ) \leq 0$ . Over-smoothing occurs if either
149
+ 119 $\mathcal { E } ^ { \mathrm { D i r } } ( { \bf F } ( t ) ) 0$ or $\mathcal { E } _ { \mathbf { L } } ^ { \mathrm { D i r } } ( \mathbf { F } ( t ) ) \mathrm { 0 }$ Efor $t \to \infty$ .
150
+ 120 Our notion of ‘over-smoothing’ is a relaxed version of the definition in $\pm \mathbb { I } -$ although in the linear
151
+ 121 case one always finds an exponential decay of ${ \mathcal { E } } ^ { \mathrm { D i r } }$ . We note that $\mathcal { E } ^ { \mathrm { D i r } } ( { \bf F } ( t ) ) 0$ iff $\Delta \mathbf { f } ^ { r } ( t ) \mathbf { 0 }$ for
152
+ 122 each column $\mathbf { f } ^ { r }$ . As in $\textcircled { 1 3 0 }$ , this corresponds to a loss of separation power along the solution where
153
+ 123 nodes with equal degree become indistinguishable since we converge to $\ker ( \Delta )$ (if we replaced $\pmb { \Delta }$
154
+ 124 with $\mathbf { L }$ then we would not even be able to separate nodes with different degrees in the limit).
155
+ 125 To motivate the next definition, consider $\dot { \mathbf { F } } ( t ) = \bar { \mathbf { A } } \mathbf { F } ( t )$ . Despite $| | \mathbf { F } ( t ) | |$ being unbounded for a.e.
156
+ 126 $\mathbf F ( 0 )$ , the low-frequency components are growing the fastest and indeed ${ \bf F } ( t ) \bar { \ } | | { \bf F } ( t ) | | { \bf F } _ { \infty }$ s.t.
157
+ 127 $\Delta \mathbf { f } _ { \infty } ^ { r } = \mathbf { 0 }$ for $1 \leq r \leq d$ . We formalize this scenario – including the opposite case of high-frequency
158
+ 128 components being dominant – by studying $\mathcal { E } ^ { \mathrm { D i r } } ( { \bf F } ( t ) / | | { \bf F } ( t ) | | )$ , i.e. the Rayleigh quotient of $\mathbf { I } _ { d } \otimes \Delta$ .
159
+ 129 Definition 2.2. $\dot { \mathbf { F } } ( t ) ~ = ~ \mathrm { G N N } _ { \theta } ( \mathbf { F } ( t ) , t )$ initialized at $\mathbf F ( 0 )$ is Low/High-Frequency-Dominant
160
+ 130 (L/HFD) if $\mathcal { E } ^ { \mathrm { D i r } } ( { \bf F } ( t ) / | | { \bf F } ( t ) | | ) 0$ (respectively, $\mathcal { E } ^ { \mathrm { D i r } } ( { \bf F } ( t ) / | | { \bf F } ( t ) | | ) \rho _ { \Delta } / 2 )$ for $t \to \infty$ .
161
+ 131 We report a consequence of Definition $| 2 . 2 |$ and refer to Appendix ${ \bf A } . 3$ for additional details and
162
+ 132 motivations for the characterizations of $\overline { { \mathrm { L F D } } }$ and HFD.
163
+ 133 Lemma 2.3. $\mathrm { G N N } _ { \theta }$ is LFD (HFD) iff for each $t _ { j } ~ ~ \infty$ there exist $t _ { j _ { k } } \ \to \ \infty$ and $\mathbf { F } _ { \infty }$ s.t.
164
+ 134 $\mathbf { F } ( t _ { j _ { k } } ) / | | \mathbf { F } ( t _ { j _ { k } } ) | | \mathbf { F } _ { \infty }$ and $\pmb { \Delta } \mathbf { f } _ { \infty } ^ { r } = \mathbf { 0 }$ ( $\Delta \mathbf { f } _ { \infty } ^ { r } = \rho \Delta \mathbf { \bar { f } } _ { \infty } ^ { r }$ , respectively).
165
+ 135 If a graph is homophilic, adjacent nodes are likely to share the same label and we expect a smoothing
166
+ 136 or LFD dynamics enhancing the low-frequency components to be successful at node classification
167
+ 137 tasks $\underline { { \lVert 4 3 \rVert } } \dot { \lVert 2 8 \rVert }$ . In the opposite case of heterophily, the high-frequency components might contain more
168
+ 138 relevant information for separating classes $i \boxed { 4 } \boxed { 5 } \rbrack$ – the prototypical example being the eigenvector of
169
+ 139 $\pmb { \Delta }$ associated with largest frequency $\rho _ { \Delta }$ separating a regular bipartite graph. In other words, the class
170
+ 140 of heterophilic graphs contain instances where signals should be sharpened by increasing ${ \mathcal { E } } ^ { \mathrm { { D i r } } }$ rather
171
+ 141 than smoothed out. Accordingly, an ideal framework for learning on graphs must accommodate both
172
+ 142 of these opposite scenarios by being able to induce either an LFD or a HFD dynamics.
173
+ 143 Parametric Dirichlet energy: channel-mixing as metric in feature space. In eq. $\boxed { 1 }$ a constant
174
+ 144 nontrivial metric $h$ in $\mathbb { R } ^ { d }$ leads to the mixing of the feature channels. We adapt this idea by considering
175
+ 145 a symmetric positive semi-definite $\mathbf { H } = \bar { \mathbf { W } } ^ { \top } \mathbf { W }$ with $\mathbf { W } \in \mathbb { R } ^ { d \times d }$ and using it to generalize ${ \mathcal { E } } ^ { \mathrm { { D i r } } }$ as
176
+
177
+ $$
178
+ \mathcal { E } _ { \mathbf { W } } ^ { \mathrm { D i r } } ( \mathbf { F } ) : = \frac { 1 } { 4 } \sum _ { q , r = 1 } ^ { d } \sum _ { i } \sum _ { j : ( i , j ) \in \mathsf { E } } h _ { q r } ( \nabla \mathbf { f } ^ { q } ) _ { i j } ( \nabla \mathbf { f } ^ { r } ) _ { i j } = \frac { 1 } { 4 } \sum _ { ( i , j ) \in \mathsf { E } } | | \mathbf { W } ( \nabla \mathbf { F } ) _ { i j } | | ^ { 2 } .
179
+ $$
180
+
181
+ 146 We note the analogy with eq. $\mathbb { \underline { { \left( 1 \right) } } }$ , where the sum over the nodes replaces the integration over the
182
+ 147 148 domain and the We generally tr $j$ -t $\mathbf { W }$ erivative at some point as learnable weights a $_ { i }$ is replaced by the gradientd study the gradient flow of $\mathcal { E } _ { \mathbf { W } } ^ { \mathrm { D i r } }$ g the edge : $( i , j ) \in \mathsf E$
183
+
184
+ $$
185
+ \dot { \mathbf { F } } ( t ) = - \nabla _ { \mathbf { F } } \mathcal { E } _ { \mathbf { W } } ^ { \mathrm { D i r } } ( \mathbf { F } ( t ) ) = - \Delta \mathbf { F } ( t ) \mathbf { W } ^ { \top } \mathbf { W } .
186
+ $$
187
+
188
+ 149 We see that eq. $( 5 )$ generalizes eq. $( 3 )$ . Below ‘smoothing’ is intended as in Definition 2.1.
189
+
190
+ Proposition 2.4. Let 150 $P _ { \mathbf { W } } ^ { \mathrm { k e r } }$ be the projection onto $\ker ( \mathbf { W } ^ { \top } \mathbf { W } )$ . Equation $\textcircled { 5 }$ is smoothing since
191
+
192
+ $$
193
+ \begin{array} { r } { \mathcal { E } ^ { \mathrm { D i r } } ( \mathbf { F } ( t ) ) \leq e ^ { - 2 t \mathrm { g a p } ( \mathbf { W } ^ { \top } \mathbf { W } ) \mathrm { g a p } ( \Delta ) } | | \mathbf { F } ( 0 ) | | ^ { 2 } + \mathcal { E } ^ { \mathrm { D i r } } ( ( P _ { \mathbf { W } } ^ { \mathrm { k e r } } \otimes \mathbf { I } _ { n } ) \mathrm { v e c } ( \mathbf { F } ( 0 ) ) ) , \quad t \geq 0 . } \end{array}
194
+ $$
195
+
196
+ In fact 151 $\mathbf { F } ( t ) \mathbf { F } _ { \infty } s . t . \exists \phi _ { \infty } \in \mathbb { R } ^ { d } .$ : for each $i \in \mathsf { V }$ we have $( \mathbf { f } _ { \infty } ) _ { i } = \sqrt { d _ { i } } \phi _ { \infty } + P _ { \mathbf { W } } ^ { \mathrm { k e r } } \mathbf { f } _ { i } ( 0 ) .$
197
+
198
+ 152 Proposition $2 . 4$ implies that no weight matrix $\mathbf { W }$ in eq. $( \bar { 5 } )$ can separate the limit embeddings $\mathbf { F } ( \infty )$
199
+ 153 of nodes with same degree and input features. If W has a trivial kernel, then nodes with same degrees
200
+ 154 converge to the same representation and over-smoothing occurs as per Definition $2 . 1 .$ Differently
201
+ 155 from $\frac { 1 } { \vert 2 9 \vert } \textcircled { 3 0 } \textcircled { 8 }$ , over-smoothing occurs independently of the spectral radius of the ‘channel-mixing’
202
+ 156 if its eigenvalues are positive – even for equations which lead to residual GNNs when discretized
203
+ 157 [12]. According to Proposition $\underline { { \left. \left[ 2 . 4 \right] \right. } }$ we do not expect eq. $\textcircled{5}$ to succeed on heterophilic graphs where
204
+ 158 smoothing processes are generally harmful – this is confirmed in Figure $\bigstar$ (see prod-curve). To
205
+ 159 remedy this problem, we generalize eq. $_ { ( 5 ) }$ to a gradient flow that can be HFD as per Definition 2.2.
206
+
207
+ # 160 3 A general parametric energy for pairwise interactions
208
+
209
+ We first rewrite the energy 161 $\mathcal { E } _ { \mathbf { W } } ^ { \mathrm { D i r } }$ in eq. (4) as
210
+
211
+ $$
212
+ \mathcal { E } _ { \mathbf { W } } ^ { \mathrm { D i r } } ( \mathbf { F } ) = \frac { 1 } { 2 } \sum _ { i } \langle \mathbf { f } _ { i } , \mathbf { W } ^ { \top } \mathbf { W } \mathbf { f } _ { i } \rangle - \frac { 1 } { 2 } \sum _ { i , j } \bar { a } _ { i j } \langle \mathbf { f } _ { i } , \mathbf { W } ^ { \top } \mathbf { W } \mathbf { f } _ { j } \rangle .
213
+ $$
214
+
215
+ 162 We then define a new, more general energy by replacing the occurrences of $\mathbf { W } ^ { \top } \mathbf { W }$ with new symmetric matrices 163 $\boldsymbol { \Omega } , \mathbf { W } \in \breve { \mathbb { R } } ^ { d \times d }$ since we also want to generate repulsive forces:
216
+
217
+ $$
218
+ \mathcal { E } ^ { \mathrm { t o t } } ( \mathbf { F } ) : = \frac { 1 } { 2 } \sum _ { i } \langle \mathbf { f } _ { i } , \boldsymbol { \Omega } \mathbf { f } _ { i } \rangle - \frac { 1 } { 2 } \sum _ { i , j } \bar { a } _ { i j } \langle \mathbf { f } _ { i } , \mathbf { W } \mathbf { f } _ { j } \rangle \equiv \mathcal { E } _ { \Omega } ^ { \mathrm { e x t } } ( \mathbf { F } ) + \mathcal { E } _ { \mathbf { W } } ^ { \mathrm { p a i r } } ( \mathbf { F } ) ,
219
+ $$
220
+
221
+ 164 with associated gradient flow of the form (see Appendix B)
222
+
223
+ $$
224
+ \dot { \mathbf { F } } ( t ) = - \nabla _ { \mathbf { F } } \mathcal { E } ^ { \mathrm { t o t } } ( \mathbf { F } ( t ) ) = - \mathbf { F } ( t ) \boldsymbol { \Omega } + \bar { \mathbf { A } } \mathbf { F } ( t ) \mathbf { W } .
225
+ $$
226
+
227
+ Note that eq.165 $( 8 ) \ : i s$ gradient flow of some energy $\mathbf { F } \mapsto \mathcal { E } ^ { \mathrm { t o t } } ( \mathbf { F } )$ iff both $\pmb { \Omega }$ and W are symmetric.
228
+
229
+ 166 A multi-particle system point of view: attraction vs repulsion. Consider the $d$ -dimensional
230
+ 167 node-features as particles in $\mathbb { R } ^ { d }$ with energy ${ \mathcal { E } } ^ { \mathrm { t o t } }$ . While the term $\mathcal { E } _ { \Omega } ^ { \mathrm { e x t } }$ is independent of the graph
231
+ 168 topology and represents an external field in the feature space, the second term $\mathcal { E } _ { \mathbf { W } } ^ { \mathrm { p a i r } }$ constitutes a
232
+ 169 potential energy, with W a bilinear form determining the pairwise interactions of adjacent node
233
+
234
+ representations. Given a symmetric 170 $\mathbf { W }$ , we write $\mathbf { W } = \Theta _ { + } ^ { \top } \Theta _ { + } - \Theta _ { - } ^ { \top } \Theta _ { - }$ , by decomposing the spectrum of W in positive and negative values.We can rewrite 171 $\mathcal { E } ^ { \mathrm { t o t } } = \mathcal { E } _ { \Omega - \mathbf { W } } ^ { \mathrm { e x t } } + \mathcal { E } _ { \Theta _ { + } } ^ { \mathrm { D i r } } - \mathcal { E } _ { \Theta _ { - } } ^ { \mathrm { D i r } }$ , i.e.
235
+
236
+ $$
237
+ \mathcal { E } ^ { \mathrm { t o t } } ( \mathbf { F } ) = \frac { 1 } { 2 } \sum _ { i } \langle \mathbf { f } _ { i } , ( \Omega - \mathbf { W } ) \mathbf { f } _ { i } \rangle + \frac { 1 } { 4 } \sum _ { i , j } \vert \vert \Theta _ { + } ( \nabla \mathbf { F } ) _ { i j } \vert \vert ^ { 2 } - \frac { 1 } { 4 } \sum _ { i , j } \vert \vert \Theta _ { - } ( \nabla \mathbf { F } ) _ { i j } \vert \vert ^ { 2 } .
238
+ $$
239
+
240
+ 172 The gradient flow of ${ \mathcal { E } } ^ { \mathrm { t o t } }$ minimizes $\mathcal { E } _ { \Theta _ { + } } ^ { \mathrm { D i r } }$ and maximizes $\mathcal { E } _ { \Theta _ { - } } ^ { \mathrm { D i r } }$ . The matrix $\mathbf { W }$ encodes repulsive
241
+ 173 pairwise interactions via its negative-definite component $\Theta _ { - }$ which lead to terms $| | \Theta _ { - } ( \nabla \mathbf { F } ) _ { i j } | |$
242
+ 174 increasing along the solution. The latter affords a ‘sharpening’ effect desirable on heterophilic graphs
243
+ 175 where we need to disentangle adjacent node representations and hence ‘magnify’ the edge-gradient.
244
+ 176 Spectral analysis of the channel-mixing. We will now show that eq. $( 8 )$ can lead to a HFD
245
+ 177 dynamics. To this end, we assume that $\mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega } \mathbf { \Omega }$ so that eq. $\textcircled { 8 }$ becomes $\dot { \mathbf { F } } ( t ) = \bar { \mathbf { A } } \mathbf { F } ( t ) \mathbf { W }$ . According
246
+ 178 179 to eq.dyna $\textcircled { 9 }$ the negative eigens as per Definition $2 . 2$ s of W We let $P _ { \mathbf { W } } ^ { \rho _ { - } }$ to repulsion. We show that the latter can induce HFDbe the orthogonal projection into the eigenspace of
247
+ 180 $\mathbf { \bar { W } } \otimes \bar { \mathbf { A } }$ associated with the eigenvalue $\rho _ { - } : = | \lambda _ { - } ^ { \mathbf { W } } | ( \rho _ { \Delta } - 1 )$ . We define $\epsilon _ { \mathrm { H F D } }$ explicitly in eq. $\textcircled { 2 4 }$ .
248
+
249
+ Proposition 3.1. I181 $f \rho _ { - } > \lambda _ { + } ^ { \mathbf { W } }$ , then $\dot { \mathbf { F } } ( t ) = \bar { \mathbf { A } } \mathbf { F } ( t ) \mathbf { W }$ is HFD for a.e. $\mathbf F ( 0 )$ : there exists ✏HFD s.t.
250
+
251
+ $$
252
+ \mathcal { E } ^ { \mathrm { D i r } } ( \mathbf { F } ( t ) ) = e ^ { 2 t \rho _ { - } } \left( \frac { \rho _ { \Delta } } { 2 } | | P _ { \mathbf { W } } ^ { \rho - } \mathbf { F } ( 0 ) | | ^ { 2 } + \mathcal { O } ( e ^ { - 2 t \epsilon _ { \mathrm { H F D } } } ) \right) , \quad t \geq 0 ,
253
+ $$
254
+
255
+ and 182 $\mathbf { F } ( t ) / | | \mathbf { F } ( t ) | |$ converges to $\mathbf { F } _ { \infty } \in \mathbb { R } ^ { n \times d }$ such that $\pmb { \Delta } \mathbf { f } _ { \infty } ^ { r } = \rho \pmb { \Delta } \mathbf { f } _ { \infty } ^ { r }$ , for $1 \leq r \leq d $
256
+
257
+ 183 Proposition $\boxed { 3 . 1 }$ shows that if enough mass of the spectrum of the ‘channel-mixing’ is distributed over
258
+ 184 the negative eigenvalues, then the evolution is dominated by the graph high frequencies. This analysis
259
+ 185 is made possible in our gradient flow framework where W must be symmetric. The HFD dynamics
260
+ 186 induced by negative eigenvalues of $\mathbf { W }$ is confirmed in Figure $\bigtriangledown$ (neg-prod-curve in the bottom chart).
261
+
262
+ 187 A more general energy. Equations with a source term may have better expressive power [44, 11, 39]. 188 In our framework this means adding an extra energy term of the form $\mathcal { E } _ { \tilde { \mathbf { W } } } ^ { \mathrm { s o u r c e } } ( \mathbf { F } ) : = \beta \langle \mathbf { F } , \mathbf { F } ( 0 ) \tilde { \mathbf { W } } \rangle$ to eq.189 $\textcircled { 7 }$ with some learnable $\beta$ and $\tilde { \mathbf { W } }$ . This leads to the following gradient flow:
263
+
264
+ $$
265
+ \dot { \mathbf { F } } ( t ) = - \mathbf { F } ( t ) \pmb { \Omega } + \bar { \mathbf { A } } \mathbf { F } ( t ) \mathbf { W } - \beta \mathbf { F } ( 0 ) \tilde { \mathbf { W } } .
266
+ $$
267
+
268
+ 190 We also observe that one could replace the fixed matrix $\bar { \mathbf A }$ with a more general symmetric graph
269
+ 191 vector field $\pmb { A }$ satisfying $A _ { i j } = 0$ if $( i , j ) \notin \mathsf E$ , although in this work we focus on the case $\pmb { A } = \bar { \mathbf { A } }$
270
+ 192 We also note that when $\Omega = \mathbf { W }$ , then eq. $\textcircled { 8 }$ becomes $\dot { \mathbf { F } } ( t ) = - \Delta \mathbf { F } ( t ) \mathbf { W }$ . We perform a spectral
271
+ 193 analysis of this case in Appendix B.2.
272
+ 194 Non-linear activations. In Appendix $\boxed { \mathbf { B } . 3 }$ we discuss non-linear gradient flow equations. Here
273
+ 195 we study what happens if the gradient flow in eq. $\underline { { \sqrt { 1 0 } } }$ is activated pointwise by $\sigma : \mathbb { R } \mathbb { R }$ . We
274
+ 196 show that although we are no longer a gradient flow, the learnable multi-particle energy ${ \mathcal { E } } ^ { \mathrm { t o t } }$ is still
275
+ 197 decreasing along the solution, meaning that the interpretation of the channel-mixing $\mathbf { W }$ inducing
276
+ 198 attraction and repulsion via its positive and negative eigenvalues respectively is preserved.
277
+ 199 Proposition 3.2. Consider a non-linear map $\sigma : \mathbb { R } \mathbb { R }$ such that the function $x \mapsto x \sigma ( x ) \geq 0 .$ . If
278
+ 200 $t \mapsto \mathbf { F } ( t )$ solves the equation
279
+
280
+ $$
281
+ \dot { \mathbf { F } } ( t ) = \sigma \left( - \mathbf { F } ( t ) \Omega + \bar { \mathbf { A } } \mathbf { F } ( t ) \mathbf { W } - \beta \mathbf { F } ( 0 ) \tilde { \mathbf { W } } \right) ,
282
+ $$
283
+
284
+ 201 where $\sigma$ acts elementwise, then
285
+
286
+ $$
287
+ \frac { d { \mathcal E } ^ { \mathrm { t o t } } ( { \bf F } ( t ) ) } { d t } \le 0 .
288
+ $$
289
+
290
+ 202 A proof of this result and more details and discussion are reported in Appendix E. We emphasize
291
+ 203 here that differently from previous results about behaviour of ReLU wrt $\hat { \mathcal { E } } ^ { \mathrm { D i r } }$ [30, 8], we deal with a
292
+ 204 much more general energy that can also induce repulsion and a more general family of activation
293
+ 205 functions (that include ReLU, tanh, arctan and many others).
294
+
295
+ # 206 4 Comparison with GNNs
296
+
297
+ 207 In this Section, we study standard GNN models from the perspective of our gradient flow framework.
298
+
299
+ 209 Continuous GNN models replace layers with continuous time. In contrast with Proposition 3.1,
300
+ 210 we show that three main linearized continuous GNN models are either smoothing or LFD as
301
+ 211 per Definition $2 . 2 .$ The linearized PDE- $\mathrm { G C N } _ { D }$ model $\pmb { \mathbb { I } 7 }$ corresponds to choosing $\beta = 0$ and
302
+ 212 $\mathbf { \hat { \Omega } } \mathbf { \tilde { \Omega } } = \mathbf { W } = \mathbf { K } ( t ) \mathbf { \bar { \Omega } } ^ { \top } \mathbf { K } ( t )$ in eq. $( 1 0 )$ , for some time-dependent family $\dot { t } \mapsto \mathbf { K } ( t ) \in \mathbb { R } ^ { d \times \breve { d } }$ :
303
+
304
+ $$
305
+ \dot { \mathbf { F } } _ { \mathrm { P D E - G C N _ { D } } } ( t ) = - \Delta \mathbf { F } ( t ) \mathbf { K } ( t ) ^ { \top } \mathbf { K } ( t ) .
306
+ $$
307
+
308
+ The CGNN model [44] can be derived from eq.213 $( 1 0 )$ by setting $\boldsymbol { \Omega } = \mathbf { I } - \boldsymbol { \tilde { \Omega } } , \mathbf { W } = \mathbf { \tilde { W } } = \mathbf { I } , \beta = 1$ :
309
+
310
+ $$
311
+ \dot { \mathbf { F } } _ { \mathrm { C G N N } } ( t ) = - \Delta \mathbf { F } ( t ) + \mathbf { F } ( t ) \tilde { \Omega } + \mathbf { F } ( 0 ) .
312
+ $$
313
+
314
+ 214 Finally, in linearized GRAND $\boxed { 1 0 }$ a row-stochastic matrix $\pmb { A } ( \mathbf { F } ( 0 ) )$ is learned from the encoding
315
+ 215 via an attention mechanism and we have
316
+
317
+ $$
318
+ \dot { \mathbf { F } } _ { \mathrm { G R A N D } } ( t ) = - \pmb { \Delta } _ { \mathrm { R W } } \mathbf { F } ( t ) = - ( \mathbf { I } - \pmb { A } ( \mathbf { F } ( 0 ) ) ) \mathbf { F } ( t ) .
319
+ $$
320
+
321
+ 216 We note that if $\pmb { A }$ is not symmetric, then GRAND is not a gradient flow.
322
+
323
+ 217 Proposition 4.1. $\mathrm { P D E } - \mathrm { G C N } _ { D }$ , CGNN and GRAND satisfy the following:
324
+
325
+ (i) $\mathrm { P D E } - \mathrm { G C N } _ { D }$ is a smoothing model: $\dot { \mathcal { E } } ^ { \mathrm { D i r } } ( \mathbf { F } _ { \mathrm { P D E - G C N } _ { D } } ( t ) ) \leq 0 .$ . (ii) For a.e. $\mathbf F ( 0 )$ it holds: CGNN is never HFD and $i f$ we remove the source term, then $\mathcal { E } ^ { \mathrm { D i r } } ( \mathbf { F } _ { \mathrm { C G N N } } ( t ) / | | \mathbf { F } _ { \mathrm { C G N N } } ( t ) | | ) \le e ^ { - \mathrm { g a p } ( \Delta ) t }$ . (iii) If G is connected, $\mathbf { F } _ { \mathrm { G R A N D } } ( t ) \mu$ as $t \to \infty$ , with $\mu ^ { r } = \mathrm { m e a n } ( \mathbf { f } ^ { r } ( 0 ) ) , 1 \leq r \leq d .$
326
+
327
+ 222 By (ii) the source-free CGNN-evolution is LFD independent of $\tilde { \Omega }$ . Moreover, by (iii), over-smoothing
328
+ 223 occurs for GRAND as per Definition $\therefore 2 . 1 .$ On the other hand, Proposition $\boxed { 3 . 1 }$ shows that the negative
329
+ 224 eigenvalues of W can make the source-free gradient flow in eq. $\textcircled { 8 }$ HFD. Experiments in Section 5
330
+ 225 confirm that the gradient flow model outperforms CGNN and GRAND on heterophilic graphs.
331
+
332
+ # 226 4.2 Discrete case
333
+
334
+ 227 We now describe a discrete version of our gradient flow model and compare it to ‘discrete’ GNNs
335
+ 228 where discrete time steps correspond to different layers. In the spirit of $\lVert \overline { { 1 2 } } \rVert$ , we use explicit Euler
336
+ 229 scheme with step size $\tau \leq 1$ to solve eq. $\bigstar \bigstar$ and set $\tilde { \mathbf { W } } = \mathbf { I }$ . In the gradient flow framework we
337
+ 230 parametrize the energy rather than the actual equations, which leads to symmetric channel-mixing
338
+ 231 matrices $\pmb { \Omega }$ , $\mathbf { W } \in \mathbb { R } ^ { d \times d }$ that are shared across the layers. Since the matrices are square, an encoding
339
+ 232 block $\psi _ { \mathrm { E N } } : \mathbb { R } ^ { n \times p } \mathbb { R } ^ { n \times d }$ is used to process input features $\mathbf { F } _ { 0 } \in \mathbb { R } ^ { n \times p }$ and generally reduce the
340
+ 233 hidden dimension from $p$ to $d$ . Moreover, the iterations inherently lead to a residual architecture
341
+ 234 because of the explicit Euler discretization:
342
+
343
+ $$
344
+ \mathbf { F } ( t + \tau ) = \mathbf { F } ( t ) + \tau \left( - \mathbf { F } ( t ) \Omega + \bar { \mathbf { A } } \mathbf { F } ( t ) \mathbf { W } + \beta \mathbf { F } ( 0 ) \right) , \quad \mathbf { F } ( 0 ) = \psi _ { \mathrm { E N } } ( \mathbf { F } _ { 0 } ) ,
345
+ $$
346
+
347
+ 235 with prediction $y = \psi _ { \mathrm { D E } } ( \mathbf { F } ( T ) )$ produced by a decoder $\psi _ { \mathrm { D E } } : \mathbb { R } ^ { n \times d } \mathbb { R } ^ { n \times k }$ , where $k$ is the
348
+ 236 number of label classes and $T$ integration time of the form $T = m \tau$ , so that $m \in \mathbb { N }$ represents the
349
+ 237 number of layers. Although eq. $\underline { { \tilde { ( 1 1 ) } } }$ is linear, we can include non-linear activations in $\psi _ { \mathrm { E N } } , \psi _ { \mathrm { D E } }$
350
+ 238 making the entire model generally non-linear. We emphasize two important points:
351
+
352
+ • Since the framework is residual, even if the message-passing is linear, this is not equivalent to collapsing the dynamics into a single layer with diffusion matrix $\bar { \mathbf { A } } ^ { m }$ , with $m$ the number of layers, see eq. $\boxed { 2 7 }$ in the appendix where we derive the expansion of the solution. • We could also activate the equations pointwise and maintain the physics interpretation thanks to Proposition $\cdot 3 . 2$ to gain greater expressive power. In the following though, we mainly stick to the linear discrete gradient flow unless otherwise stated.
353
+
354
+ Are discrete GNNs gradient flows? Given a (learned) symmetric graph vector field 245 $\ b { A } \in \mathbb { R } ^ { n \times n }$ 246 satisfying $A _ { i j } = 0$ if $( i , j ) \notin \mathsf E$ , consider a family of linear GNNs with shared weights of the form
355
+
356
+ $$
357
+ \mathbf { F } ( t + 1 ) = \mathbf { F } ( t ) \Omega + A \mathbf { F } ( t ) \mathbf { W } + \beta \mathbf { F } ( 0 ) { \tilde { \mathbf { W } } } , \quad 0 \leq t \leq T .
358
+ $$
359
+
360
+ 247 Symmetry is the key requirement to interpret GNNs in eq. $( 1 2 )$ in a gradient flow framework.
361
+
362
+ Lemma 4.2. Equation (12) is the unit step size discrete gradient flow of 248 $\mathcal { E } _ { \mathbf { I } - \Omega } ^ { \mathrm { e x t } } + \mathcal { E } _ { A , \mathbf { W } } ^ { \mathrm { p a i r } } - \mathcal { E } _ { \tilde { \mathbf { W } } } ^ { \mathrm { s o u r c e } }$ with 249 $\mathcal { E } _ { A , \mathbf { W } } ^ { \mathrm { { p a i r } } }$ defined by replacing $\bar { \mathbf A }$ with $\pmb { A }$ in eq. $\bigstar$ , iff $\pmb { \Omega }$ and W are symmetric.
363
+
364
+ 250 Lemma $\boxed { 4 . 2 }$ provides a recipe for making standard architectures into a gradient flow, with symmetry
365
+ 251 being the key requirement. When eq. ${ \overset { \smile } { ( 1 2 ) } }$ is a gradient flow, the underlying GNN dynamics is
366
+ 252 equivalent to minimizing a multi-particle energy by learning attractive and repulsive directions in
367
+ 253 feature space as discussed in Section $\textcircled { 3 }$ In Appendix C.2, we show how Lemma $\boxed { 4 . 2 }$ covers linear
368
+ 254 versions of GCN [27, 43], GAT $\pmb { \bigtriangledown }$ , GraphSAGE $\pmb { \bigtriangledown } 3 \mathbf { h }$ and GCNII [11] to name a few.
369
+ 255 Over-smoothing analysis in discrete setting. By Proposition $3 . 1$ we know that the continuous
370
+ 256 version of eq. $( 1 \bar { 1 ^ { \cdot } } )$ can be HFD thanks to the negative eigenvalues of W. The next result represents a
371
+ 257 258 discrete counterpart of Propmodels can be HFD. Below $P _ { \mathbf { W } } ^ { \rho _ { - } }$ onis $\boxed { 3 . 1 }$ and shows that residual, symmetrized graph convolutionalprojection into the eigenspace associated with the eigenvalue
372
+ 259 $\rho _ { - } : = | \lambda _ { - } ^ { \mathbf { W } } | ( \rho _ { \Delta } - 1 )$ and we report the explicit value of $\delta _ { \mathrm { H F D } }$ in eq. $\boxed { 2 8 }$ in Appendix $\boxed { \mathsf { C . 3 } }$ We let:
373
+
374
+ $$
375
+ \lambda _ { + } ^ { \mathbf { W } } ( \rho _ { \Delta } - 1 ) ) ^ { - 1 } < | \lambda _ { - } ^ { \mathbf { W } } | < 2 ( \tau ( 2 - \rho _ { \Delta } ) ) ^ { - 1 } .
376
+ $$
377
+
378
+ Theorem 4.3. Given 260 $\mathbf { F } ( t + \tau ) = \mathbf { F } ( t ) + \tau \bar { \mathbf { A } } \mathbf { F } ( t ) \mathbf { W }$ , with W symmetric, if eq. (13) holds then
379
+
380
+ $$
381
+ \mathscr { E } ^ { \mathrm { D i r } } ( { \bf F } ( m \tau ) ) = ( 1 + \tau \rho _ { - } ) ^ { 2 m } \left( \frac { \rho _ { \Delta } } { 2 } | | P _ { \bf W } ^ { \rho _ { - } } { \bf F } ( 0 ) | | ^ { 2 } + \mathcal { O } \left( \left( \frac { 1 + \tau \delta _ { \mathrm { H F D } } } { 1 + \tau \rho _ { - } } \right) ^ { 2 m } \right) \right) , \quad \delta _ { \mathrm { H F D } } < \rho _ { - } ,
382
+ $$
383
+
384
+ 261 hence the dynamics is HFD for a.e. $\mathbf F ( 0 )$ and in fact $\mathbf { F } ( m \tau ) / | | \mathbf { F } ( m \tau ) | | \mathbf { F } _ { \infty }$ s.t. $\pmb { \Delta } \mathbf { f } _ { \infty } ^ { r } = \rho \pmb { \Delta } \mathbf { f } _ { \infty } ^ { r }$
385
+ 262 Conversely, $i f G$ is not bipartite, then for a.e. $\mathbf F ( 0 )$ the system $\mathbf { F } ( t + \tau ) = \tau \bar { \mathbf { A } } \mathbf { F } ( t ) \bar { \mathbf { W } }$ , with W
386
+ 263 symmetric, is LFD independent of the spectrum of $\mathbf { W }$ .
387
+ 264 Theorem $\boxed { 4 . 3 }$ shows that linear discrete gradient flows can be HFD due to the negative eigenvalues of
388
+ 265 W. This differs from statements that standard GCNs act as low-pass filters and thus over-smooth in
389
+ 266 the limit. Indeed, in these cases the spectrum of $\mathbf { W }$ is generally ignored $\textcircled { 4 3 } \textcircled { 1 1 }$ or required to be
390
+ 267 sufficiently small in terms of singular value decomposition $\overline { { \lVert 2 9 \rVert 3 0 } } , \overline { { \ 8 } } \rVert$ when no residual connection
391
+ 268 is present. On the other hand, Theorem $\mathbf { \delta } _ { . 4 . 3 }$ emphasizes that the spectrum of W plays a key role to
392
+ 269 enhance the high frequencies when enough mass is distributed over the negative eigenvalues provided
393
+ 270 that a residual connection exists – this is confirmed by the neg-prod-curve in Figure 2.
394
+ 271 The residual connection from a spectral perspective. Given a sufficiently small step-size so
395
+ 272 that the right hand side of inequality 13 is satisfied, $\mathbf { F } ( t + \tau ) = \mathbf { F } ( t ) + \tau \bar { \mathbf { A } } \mathbf { F } ( \dot { t } ) \mathbf { W }$ is HFD for a.e.
396
+ 273 $\mathbf F ( 0 )$ if $| \lambda _ { - } ^ { \mathbf { \tilde { W } } } | ( \rho _ { \Delta } - 1 ) > \lambda _ { + } ^ { \mathbf { W } }$ , i.e. ‘there is more mass’ in the negative spectrum of W than in the
397
+ 274 positive one. This means that differently from $\pm \varTheta \left| 3 0 \right| \bigotimes 1$ , there is no requirement on the minimal
398
+ 275 magnitude of the spectral radius of W coming from the graph topology as long as $\lambda _ { + } ^ { \mathbf { w } }$ is small
399
+ 276 enough. Conversely, without a residual term, the dynamics is LFD for a.e. ${ \bf \ddot { F } } ( 0 )$ independently of the
400
+ 277 sign and magnitude of the eigenvalues of W. This is also confirmed by the GCN-curve in Figure 2.
401
+ 278 Over-smoothing vs LFD. We highlight how in general a linear GCN equation as $\mathbf { F } ( t + \tau ) =$
402
+ 279 $\tau \bar { \mathbf { A } } \mathbf { F } ( t ) \mathbf { W }$ may avoid over-smoothing in the sense of Definition $2 . 1 .$ meaning that $\mathcal { E } ^ { \mathrm { D i r } } ( { \bf F } ( t ) ) \infty$
403
+ 280 as soon as there exist $\lambda _ { i } ^ { \pmb { \Delta } } \in ( 0 , 1 )$ and the spectral radius of W is large enough. However, this
404
+ 281 will not lead to over-separation since the dominating term is the lowest frequency one: in other
405
+ 282 words, once we re-set the scale right as per the normalization in Theorem $4 . 3 _ { \cdot }$ we encounter loss of
406
+ 283 separability even with large (and possibly negative) spectrum of W.
407
+
408
+ # 284 5 Experiments
409
+
410
+ 285 In this section we evaluate the gradient flow framework (GRAFF). We corroborate the spectral
411
+ 286 analysis using synthetic data with controllable homophily. We confirm that having negative (positive)
412
+ 287 eigenvalues of the channel-mixing W are essential in heterophilic (homophilic) scenarios where the
413
+ 288 gradient flow should align with HFD (LFD) respectively. We show that the gradient flow in eq. $( 1 1 )$
414
+ 289 – a linear, residual, symmetric graph convolutional model – achieves competitive performance on
415
+ 290 heterophilic datasets.
416
+ 291 Methodology. We crystallize GRAFF in the model presented in eq. $( 1 1 )$ with $\psi _ { \mathrm { E N } } , \psi _ { \mathrm { D E } }$ im
417
+ 292 plemented as single linear layers or MLPs, and we set $\pmb { \Omega }$ to be diagonal. For the real-world
418
+ 293 experiments we consider diagonally-dominant (DD), diagonal (D) and time-dependent choices
419
+ 294 for the structure of $\mathbf { W }$ that offer explicit control over its spectrum. In the (DD)-case, we consider
420
+ 295 a $\mathbf { W } ^ { 0 } \in \mathbb { R } ^ { d \times d }$ symmetric with zero diagonal and $\mathbf { w } \in \mathbb { R } ^ { d }$ defined by $\begin{array} { r } { \mathbf { w } _ { \alpha } = q _ { \alpha } \sum _ { \beta } \lvert \mathbf { W } _ { \alpha \beta } ^ { 0 } \rvert + r _ { \alpha } } \end{array}$
421
+ 296 and set $\mathbf { W } = \mathrm { d i a g } ( \mathbf { w } ) + \mathbf { W } ^ { 0 }$ . Due to the Gershgorin Theorem the eigenvalues of W belong to
422
+ 297 $\begin{array} { r } { [ \mathbf { w } _ { \alpha } - \sum _ { \beta } \vert \mathbf { W } _ { \alpha \beta } ^ { 0 } \vert , \dot { \mathbf { w } } _ { \alpha } + \sum _ { \beta } \vert \mathbf { W } _ { \alpha \beta } ^ { 0 } \vert ] } \end{array}$ , so the model ‘can’ easily re-distribute mass in the spectrum of
423
+ 298 W via $q _ { \alpha } , r _ { \alpha }$ . This generalizes the decomposition of $\mathbf { W }$ in $\pmb { \mathbb { \ m } }$ providing a justification in terms of
424
+ 299 its spectrum and turns out to be more efficient w.r.t. the hidden dimension $d$ as shown in Figure $\boxed { 4 }$ in
425
+ 300 the Appendix. For (D) we take $\mathbf { W }$ to be diagonal, with entries sampled $\boldsymbol { \mathcal { U } } [ - 1 , 1 ]$ and fixed – i.e., we
426
+ 301 do not train over W – and only learn $\psi _ { \mathrm { E N } }$ , $\psi _ { \mathrm { D E } }$ . We also include a time-dependent model where $\mathbf { W } _ { t }$
427
+ 302 varies across layers. To investigate the role of the spectrum of $\mathbf { W }$ on synthetic graphs, we construct
428
+ 303 three additional variants: $\mathbf { W } = \mathbf { W } ^ { \prime } + \mathbf { W } ^ { \prime } ^ { \top }$ , $\mathbf { W } = \pm \mathbf { W } ^ { \prime \top } \mathbf { W } ^ { \prime }$ named sum, prod and neg-prod
429
+ 304 respectively where prod (neg-prod) variants have only non-negative (non-positive) eigenvalues.
430
+ 305 Complexity and number of parameters. If we treat the number of layers as a constant, the discrete
431
+ 306 gradient flow scales as $\mathcal { O } ( | \bar { \mathsf { V } } | p d + | \mathsf { E } | d ^ { 2 } )$ , where $p$ and $d$ are input feature and hidden dimension
432
+ 307 respectively, with $p \geq d$ usually. Note that GCN has complexity ${ \dot { \mathcal { O } } } ( | \mathsf { E } | p d )$ and in fact our model is
433
+ 308 faster than GCN as confirmed in Figure $5$ in Appendix $\dot { \mathbf { D } _ { \cdot } }$ Since $\psi _ { \mathrm { E N } } , \psi _ { \mathrm { D E } }$ are single linear layers
434
+ 309 (MLPs), we can bound the number of parameters by $p d \stackrel { } { + } d ^ { 2 } + 3 d + d k$ , with $k$ the number of label
435
+ 310 classes, in the (DD)-variant while in the (D)-variant we have $p d + 3 d + d k$ . Further ablation studies
436
+ 311 appear in Figure 4 in the Appendix showing that (DD) outperforms sum and GCN – especially in the
437
+ 312 lower hidden dimension regime – on real-world benchmarks with varying homophily.
438
+ 313 Synthetic experiments and ablation studies.
439
+ 314 To investigate our claims in a controlled environ
440
+ 315 ment we use the synthetic Cora dataset of $\textcircled { 5 1 }$ Ap
441
+ 316 pendix G]. Graphs are generated for target levels
442
+ 317 of homophily via preferential attachment – see
443
+ 318 Appendix $\mathbf { D } \dot { . } \dot { 3 }$ for details. Figure $2 \cdot$ confirms the
444
+ 319 spectral analysis and offers a better understanding
445
+ 320 in terms of performance and smoothness of the
446
+ 321 predictions. Each curve – except GCN – repre
447
+ 322 sents one version of W as in ‘methodology’ and
448
+ 323 we implement eq. $^ { ( 1 1 ) }$ with $\beta = 0$ , $\pmb { \Omega } = \mathbf { 0 }$ . Fig
449
+ 324 ure $\bigstar$ (top) reports the test accuracy vs true label
450
+ 325 homophily. Neg-prod is better than prod on low
451
+ 326 homophily and viceversa on high-homophily. This
452
+ 327 confirms Proposition $\underline { { \boldsymbol { \left. 3 . 1 \right. } } }$ where we have shown
453
+ 328 that the gradient flow can lead to a HFD dy
454
+ 329 namics – that are generally desirable with low
455
+ 330 homophily – through the negative eigenvalues of
456
+ 331 W. Conversely, the prod configuration (where we
457
+ 332 have an attraction-only dynamics) struggles in low
458
+ 333 homophily scenarios even though a residual connection is present. Both prod and neg-prod are
459
+ 334 ‘extreme’ choices and serve the purpose of highlighting that by turning off one side of the spectrum
460
+ 335 this could be the more damaging depending on the underlying homophily. In general though ‘neutral’
461
+ 336 variants like sum and (DD) are indeed more flexible and better performing. In fact, (DD) outperforms
462
+ 337 GCN especially in low-homophily scenarios, confirming Theorem 4.3 where we have shown that
463
+ 338 without a residual connection convolutional models are LFD – and hence more sensitive to underlying
464
+ 339 homophily – irrespectively of the spectrum of W. This is further confirmed in Figure 3.
465
+ 340 In Figure 2 (bottom) we compute the homophily of the prediction (cross) for a given method and we
466
+ 341 compare with the homophily (circle) of the prediction read from the encoding (i.e. graph-agnostic).
467
+ 342 The homophily here is a proxy to assess whether the evolution is smoothing, the goal being explaining
468
+ 343 the smoothness of the prediction via the spectrum of W as per our theoretical analysis. For neg-prod
469
+ 344 the homophily after the evolution is lower than that of the encoding, supporting the analysis that
470
+ 345 negative eigenvalues of W enhance high-frequencies. The opposite behaviour occurs in the case of
471
+ 346 prod and explains that in the low-homophily regime prod is under-performant due to the prediction
472
+ 347 being smoother than the true homophily. (DD) and sum variants adapt better to the true homophily.
473
+ 348 We note how the encoding compensates when the dynamics can only either attract or repulse (i.e. the
474
+ 349 spectrum of W has a sign) by decreasing or increasing the initial homophily respectively.
475
+ 350 Real world experiments. We test GRAFF against a range of datasets with varying homophily
476
+ 351 [37, 33, 31] (see Appendix $\textcircled { \mathbf { D . 4 } }$ for additional details). We use results provided in [45, Table 1],
477
+ 352 which includes standard baselines as GCN $\lVert 2 7 \rVert$ , GraphSAGE $\lVert 2 3 \rVert$ , GAT [42], PairNorm [48] and
478
+ 353 recent models tailored towards the heterophilic setting (GGCN [45], Geom-GCN [31], H2GCN
479
+ 354 [51] and GPRGNN $\pmb { \mathbb { I 3 } } \mathbf { I }$ . For Sheaf $[ \sqrt { 5 } ]$ , a recent top-performer on heterophilic datasets, we took
480
+ 355 the best performing variant (out of six provided) for each dataset. We also include continuous
481
+ 356 baselines CGNN $\checkmark$ and GRAND $\boxed { 1 0 }$ to provide empirical evidence for Proposition 4.1. Splits
482
+ 357 taken from $\textcircled { 3 1 }$ are used in all the comparisons. The GRAFF model discussed in ‘methodology’
483
+ 358 is a very simple architecture with shared parameters across layers and run-time smaller than GCN
484
+ 359 and more recent models like GGCN designed for heterophilic graphs (see Figure 5 in the Appendix).
485
+ 360 Nevertheless, it achieves competitive results on all datasets, performing on par or better than more
486
+ 361 complex recent models. Moreover, comparison with the ‘time-dependent’ (DD) variant confirms
487
+ 362 that by sharing weights across layers we do not lose performance. We note that on heterophilic
488
+ 363 graphs short integration time is usually needed due to the topology being harmful and the negative
489
+ 364 eigenvalues of W leading to exponential behaviour (see Appendix D).
490
+
491
+ ![](images/0d7e8be689840459aa1ffe8642b06bbea77c3f7ad6f1af46e1567c0e0253e831.jpg)
492
+ Figure 2: Experiments on synthetic datasets with controlled homophily.
493
+
494
+ Table 1: Results on heterophilic and homophilic datasets
495
+
496
+ <table><tr><td>Hom level #Nodes #Edges</td><td>Texas 0.11 183 295</td><td>Wisconsin 0.21 251 466</td><td>Cornell 0.30 183 280</td><td>Film 0.22 7,600 26.752</td><td>Squirrel 0.22 5,201 198.493</td><td>Chameleon 0.23 2.277 31,421</td><td>Citeseer 0.74 3,327 4.676</td><td>Pubmed 0.80 18,717 44,327</td><td>Cora 0.81 2,708 5,278</td></tr><tr><td>#Classes</td><td>5</td><td>5</td><td>5</td><td>5</td><td>5</td><td>5</td><td>7</td><td>3</td><td>6</td></tr><tr><td>GGCN</td><td>84.86 ± 4.55</td><td>86.86 ±3.29</td><td>85.68 ± 6.63</td><td>37.54 ± 1.56</td><td>55.17 ± 1.58</td><td>71.14 ± 1.84</td><td>77.14 ± 1.45</td><td>89.15 ± 0.37</td><td>87.95 ± 1.05</td></tr><tr><td>GPRGNN</td><td>78.38 ± 4.36</td><td>82.94 ± 4.21</td><td>80.27 ± 8.11</td><td>34.63 ± 1.22</td><td>31.61 ± 1.24</td><td>46.58 ± 1.71</td><td>77.13 ± 1.67</td><td>87.54 ± 0.38</td><td>87.95 ± 1.18</td></tr><tr><td>H2GCN</td><td>84.86 ± 7.23</td><td>87.65 ± 4.98</td><td>82.70 ± 5.28</td><td>35.70 ± 1.00</td><td>36.48 ± 1.86</td><td>60.11 ± 2.15</td><td>77.11 ± 1.57</td><td>89.49 ± 0.38</td><td>87.87 ± 1.20</td></tr><tr><td>GCNII</td><td>77.57 ± 3.83</td><td>80.39 ± 3.40</td><td>77.86 ± 3.79</td><td>37.44 ± 1.30</td><td>38.47 ± 1.58</td><td>63.86 ± 3.04</td><td>77.33 ± 1.48</td><td>90.15 ± 0.43</td><td>88.37 ± 1.25</td></tr><tr><td>Geom-GCN</td><td>66.76 ± 2.72</td><td>64.51 ± 3.66</td><td>60.54 ± 3.67</td><td>31.59 ± 1.15</td><td>38.15 ± 0.92</td><td>60.00 ± 2.81</td><td>78.02 ± 1.15</td><td>89.95 ± 0.47</td><td>85.35 ± 1.57</td></tr><tr><td>PairNorm</td><td>60.27 ± 4.34</td><td>48.43 ± 6.14</td><td>58.92 ± 3.15</td><td>27.40 ± 1.24</td><td>50.44 ± 2.04</td><td>62.74 ± 2.82</td><td>73.59 ± 1.47</td><td>87.53 ± 0.44</td><td>85.79 ± 1.01</td></tr><tr><td>GraphSAGE</td><td>82.43 ± 6.14</td><td>81.18 ± 5.56</td><td>75.95 ± 5.01</td><td>34.23 ± 0.99</td><td>41.61 ± 0.74</td><td>58.73 ± 1.68</td><td>76.04 ± 1.30</td><td>88.45 ± 0.50</td><td>86.90 ± 1.04</td></tr><tr><td>GCN</td><td>55.14 ± 5.16</td><td>51.76 ± 3.06</td><td>60.54 ± 5.30</td><td>27.32 ± 1.10</td><td>53.43 ± 2.01</td><td>64.82 ± 2.24</td><td>76.50 ± 1.36</td><td>88.42 ± 0.50</td><td>86.98 ± 1.27</td></tr><tr><td>GAT</td><td>52.16 ± 6.63</td><td>49.41 ± 4.09</td><td>61.89 ± 5.05</td><td>27.44 ± 0.89</td><td>40.72 ± 1.55</td><td>60.26 ± 2.50</td><td>76.55 ± 1.23</td><td>87.30 ± 1.10</td><td>86.33 ± 0.48</td></tr><tr><td>MLP CGNN</td><td>80.81 ± 4.75</td><td>85.29 ± 3.31 74.31 ± 7.26</td><td>81.89 ± 6.40 66.22 ± 7.69</td><td>36.53 ± 0.70 35.95 ± 0.86</td><td>28.77 ± 1.56</td><td>46.21 ± 2.99</td><td>74.02 ± 1.90</td><td>75.69 ± 2.00 87.70 ± 0.49</td><td>87.16 ± 0.37 87.10 ± 1.35</td></tr><tr><td>GRAND</td><td>71.35 ± 4.05 75.68 ± 7.25</td><td>79.41 ± 3.64</td><td>82.16 ± 7.09</td><td>35.62 ± 1.01</td><td>29.24 ± 1.09 40.05 ± 1.50</td><td>46.89 ± 1.66 54.67 ± 2.54</td><td>76.91 ± 1.81 76.46 ± 1.77</td><td>89.02 ± 0.51</td><td>87.36 ± 0.96</td></tr><tr><td>Sheaf (max)</td><td>85.95 ± 5.51</td><td>89.41 ± 4.74</td><td>84.86 ± 4.71</td><td>37.81 ± 1.15</td><td>56.34 ± 1.32</td><td>68.04 ± 1.58</td><td>76.70 ± 1.57</td><td>89.49 ± 0.40</td><td>86.90 ± 1.13</td></tr><tr><td>GRAFF (DD)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GRAFF (D)</td><td>88.38 ± 4.53</td><td>87.45 ± 2.94</td><td>83.24 ± 6.49</td><td>36.09 ± 0.81</td><td>54.52 ± 1.37</td><td>71.08 ± 1.75</td><td>76.92 ± 1.70</td><td>88.95 ± 0.52 90.04 ± 0.41</td><td>87.61 ± 0.97</td></tr><tr><td></td><td>88.11 ± 5.57</td><td>88.83 ± 3.29</td><td>84.05 ± 6.10</td><td>37.11 ± 1.08</td><td>47.36 ± 1.89</td><td>66.78 ± 1.28</td><td>77.30 ± 1.85</td><td></td><td>88.01 ± 1.03</td></tr><tr><td>GRAFF-timedep (DD)</td><td>87.03 ± 4.49</td><td>87.06 ± 4.04</td><td>82.16 ± 7.07</td><td>35.93 ± 1.23</td><td>53.97 ± 1.45</td><td>69.56 ± 1.20</td><td>76.59 ± 1.53</td><td>88.26 ± 0.41</td><td>87.38 ± 1.05</td></tr></table>
497
+
498
+ # 365 6 Conclusions
499
+
500
+ 366 In this work, we developed a framework for GNNs where the evolution can be interpreted as
501
+ 367 minimizing a multi-particle learnable energy. This translates into studying the interaction between
502
+ 368 the spectrum of the graph and the spectrum of the ‘channel-mixing’ leading to a better understanding
503
+ 369 of when and why the induced dynamics is low (high) frequency dominated. From a theoretical
504
+ 370 perspective, we refined existing asymptotic analysis of GNNs to account for the role of the spectrum of
505
+ 371 the channel-mixing as well. From a practical perspective, our framework allows for ‘educated’ choices
506
+ 372 resulting in a simple convolutional model that achieves competitive performance on homophilic
507
+ 373 and heterophilic benchmarks while being faster than GCN. Our results refute the folklore of graph
508
+ 374 convolutional models being too simple for heterophilic benchmarks.
509
+ 375 Limitations and future works. We limited our attention to a constant bilinear form W, which
510
+ 376 might be excessively rigid. It is possible to derive non-constant alternatives that are aware of the
511
+ 377 features or the position in the graph. The main challenge amounts to matching the requirement for
512
+ 378 local ‘heterogeneity’ with efficiency: we reserve this question for future work. Our analysis is also a
513
+ 379 first step into studying the interaction of the graph and ‘channel-mixing’ spectra; we did not explore
514
+ 380 other dynamics that are neither LFD nor HFD as per our definitions. The energy formulation points
515
+ 381 to new models more ‘physics’ inspired; this will be explored in future work.
516
+ 382 Societal impact. Our work sheds light on the actual dynamics of GNNs and could hence improve
517
+ 383 their understanding, which is crucial for assessing their impact on large-scale applications. We also
518
+ 384 show that instances of our framework achieve competitive performance on heterophilic data despite
519
+ 385 being faster than GCN, providing evidence for efficient methods with reduced footprint.
520
+
521
+ # References
522
+
523
+ 387 [1] U. Alon and E. Yahav. On the bottleneck of graph neural networks and its practical implications.
524
+ 388 In International Conference on Learning Representations, 2021.
525
+ 389 [2] M. Balcilar, G. Renton, P. Héroux, B. Gaüzère, S. Adam, and P. Honeine. Analyzing the
526
+ 390 expressive power of graph neural networks in a spectral perspective. In International Conference
527
+ 391 on Learning Representations, 2020.
528
+ 392 [3] M. Biloš, J. Sommer, S. S. Rangapuram, T. Januschowski, and S. Günnemann. Neural flows:
529
+ 393 Efficient alternative to neural odes. In Advances in Neural Information Processing Systems,
530
+ 394 volume 34, 2021.
531
+ 395 [4] D. Bo, X. Wang, C. Shi, and H. Shen. Beyond low-frequency information in graph convolutional
532
+ 396 networks. In AAAI. AAAI Press, 2021.
533
+ 397 [5] C. Bodnar, F. Di Giovanni, B. P. Chamberlain, P. Liò, and M. M. Bronstein. Neural sheaf
534
+ 398 diffusion: A topological perspective on heterophily and oversmoothing in gnns. arXiv preprint
535
+ 399 arXiv:2202.04579, 2022.
536
+ 400 [6] S. Brody, U. Alon, and E. Yahav. How attentive are graph attention networks? arXiv preprint
537
+ 401 arXiv:2105.14491, 2021.
538
+ 402 [7] J. Bruna, W. Zaremba, A. Szlam, and Y. LeCun. Spectral networks and locally connected
539
+ 403 networks on graphs. In 2nd International Conference on Learning Representations, ICLR 2014,
540
+ 404 2014.
541
+ 405 [8] C. Cai and Y. Wang. A note on over-smoothing for graph neural networks. arXiv preprint
542
+ 406 arXiv:2006.13318, 2020.
543
+ 407 [9] B. Chamberlain, J. Rowbottom, D. Eynard, F. Di Giovanni, X. Dong, and M. Bronstein. Beltrami
544
+ 408 flow and neural diffusion on graphs. Advances in Neural Information Processing Systems, 34,
545
+ 409 2021.
546
+ 410 [10] B. Chamberlain, J. Rowbottom, M. I. Gorinova, M. Bronstein, S. Webb, and E. Rossi. Grand:
547
+ 411 Graph neural diffusion. In International Conference on Machine Learning, pages 1407–1418.
548
+ 412 PMLR, 2021.
549
+ 413 [11] M. Chen, Z. Wei, Z. Huang, B. Ding, and Y. Li. Simple and deep graph convolutional networks.
550
+ 414 In International Conference on Machine Learning, pages 1725–1735. PMLR, 2020.
551
+ 415 [12] R. T. Chen, Y. Rubanova, J. Bettencourt, and D. K. Duvenaud. Neural ordinary differential
552
+ 416 equations. Advances in neural information processing systems, 31, 2018.
553
+ 417 [13] E. Chien, J. Peng, P. Li, and O. Milenkovic. Adaptive universal generalized pagerank graph
554
+ 418 neural network. In 9th International Conference on Learning Representations, ICLR 2021,
555
+ 419 2021.
556
+ 420 [14] F. R. Chung and F. C. Graham. Spectral graph theory. Number 92. American Mathematical
557
+ 421 Soc., 1997.
558
+ 422 [15] M. Defferrard, X. Bresson, and P. Vandergheynst. Convolutional neural networks on graphs
559
+ 423 with fast localized spectral filtering. Advances in neural information processing systems, 29,
560
+ 424 2016.
561
+ 425 [16] J. Eells and J. H. Sampson. Harmonic mappings of riemannian manifolds. American journal of
562
+ 426 mathematics, 86(1):109–160, 1964.
563
+ 427 [17] M. Eliasof, E. Haber, and E. Treister. Pde-gcn: Novel architectures for graph neural networks
564
+ 428 motivated by partial differential equations. Advances in Neural Information Processing Systems,
565
+ 429 34, 2021.
566
+ 430 [18] M. Geiger, L. Petrini, and M. Wyart. Landscape and training regimes in deep learning. Physics
567
+ 431 Reports, 924:1–18, 2021.
568
+ 432 [19] J. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals, and G. E. Dahl. Neural message passing
569
+ 433 for quantum chemistry. In International Conference on Machine Learning, pages 1263–1272.
570
+ 434 PMLR, 2017.
571
+ 435 [20] C. Goller and A. Kuchler. Learning task-dependent distributed representations by backprop
572
+ 436 agation through structure. In Proceedings of International Conference on Neural Networks
573
+ 437 (ICNN’96), volume 1, pages 347–352. IEEE, 1996.
574
+ 438 [21] M. Gori, G. Monfardini, and F. Scarselli. A new model for learning in graph domains. In
575
+ 439 Proceedings. 2005 IEEE International Joint Conference on Neural Networks, 2005., volume 2,
576
+ 440 pages 729–734. IEEE, 2005.
577
+ 441 [22] E. Haber and L. Ruthotto. Stable architectures for deep neural networks. Inverse Problems, 34,
578
+ 442 2018.
579
+ 443 [23] W. Hamilton, Z. Ying, and J. Leskovec. Inductive representation learning on large graphs.
580
+ 444 Advances in neural information processing systems, 30, 2017.
581
+ 445 [24] D. K. Hammond, P. Vandergheynst, and R. Gribonval. The spectral graph wavelet transform:
582
+ 446 Fundamental theory and fast computation. In Vertex-Frequency Analysis of Graph Signals,
583
+ 447 pages 141–175. Springer, 2019.
584
+ 448 [25] M. He, Z. Wei, H. Xu, et al. Bernnet: Learning arbitrary graph spectral filters via bernstein
585
+ 449 approximation. Advances in Neural Information Processing Systems, 34, 2021.
586
+ 450 [26] R. Kimmel, N. Sochen, and R. Malladi. From high energy physics to low level vision. In
587
+ 451 International Conference on Scale-Space Theories in Computer Vision, pages 236–247. Springer,
588
+ 452 1997.
589
+ 453 [27] T. N. Kipf and M. Welling. Semi-Supervised Classification with Graph Convolutional Networks.
590
+ 454 In Proceedings of the 5th International Conference on Learning Representations, ICLR ’17,
591
+ 455 2017.
592
+ 456 [28] J. Klicpera, S. Weißenberger, and S. Günnemann. Diffusion improves graph learning. In
593
+ 457 Proceedings of the 33rd International Conference on Neural Information Processing Systems,
594
+ 458 2019.
595
+ 459 [29] H. Nt and T. Maehara. Revisiting graph neural networks: All we have is low-pass filters. arXiv
596
+ 460 preprint arXiv:1905.09550, 2019.
597
+ 461 [30] K. Oono and T. Suzuki. Graph neural networks exponentially lose expressive power for node
598
+ 462 classification. In International Conference on Learning Representations, 2020.
599
+ 463 [31] H. Pei, B. Wei, K. C. Chang, Y. Lei, and B. Yang. Geom-gcn: Geometric graph convolutional
600
+ 464 networks. In 8th International Conference on Learning Representations, ICLR 2020, 2020.
601
+ 465 [32] P. Perona and J. Malik. Scale-space and edge detection using anisotropic diffusion. PAMI,
602
+ 466 12(7):629–639, 1990.
603
+ 467 [33] B. Rozemberczki, C. Allen, and R. Sarkar. Multi-scale attributed node embedding. Journal of
604
+ 468 Complex Networks, 9(2):cnab014, 2021.
605
+ 469 [34] T. K. Rusch, B. P. Chamberlain, J. Rowbottom, S. Mishra, and M. M. Bronstein. Graph-coupled
606
+ 470 oscillator networks. In International Conference on Machine Learning, 2022.
607
+ 471 [35] M. E. Sander, P. Ablin, M. Blondel, and G. Peyré. Sinkformers: Transformers with doubly
608
+ 472 stochastic attention. In International Conference on Artificial Intelligence and Statistics, pages
609
+ 473 3515–3530. PMLR, 2022.
610
+ 474 [36] F. Scarselli, M. Gori, A. C. Tsoi, M. Hagenbuchner, and G. Monfardini. The graph neural
611
+ 475 network model. IEEE transactions on neural networks, 20(1):61–80, 2008.
612
+ 476 [37] P. Sen, G. Namata, M. Bilgic, L. Getoor, B. Galligher, and T. Eliassi-Rad. Collective classifica
613
+ 477 tion in network data. AI magazine, 29(3):93–93, 2008.
614
+ 478 [38] A. Sperduti. Encoding labeled graphs by labeling raam. Advances in Neural Information
615
+ 479 Processing Systems, 6, 1993.
616
+ 480 [39] M. Thorpe, T. M. Nguyen, H. Xia, T. Strohmer, A. Bertozzi, S. Osher, and B. Wang. Grand $^ { + + }$ :
617
+ 481 Graph neural diffusion with a source term. In International Conference on Learning Represen
618
+ 482 tations, 2021.
619
+ 483 [40] J. Topping, F. Di Giovanni, B. P. Chamberlain, X. Dong, and M. M. Bronstein. Understanding
620
+ 484 over-squashing and bottlenecks on graphs via curvature. International Conference on Learning
621
+ 485 Representations, 2022.
622
+ 486 [41] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and
623
+ 487 I. Polosukhin. Attention is all you need. Advances in neural information processing systems,
624
+ 488 30, 2017.
625
+ 489 [42] P. Velickovi ˇ c, G. Cucurull, A. Casanova, A. Romero, P. Liò, and Y. Bengio. Graph attention ´
626
+ 490 networks. In International Conference on Learning Representations, 2018.
627
+ 491 [43] F. Wu, A. Souza, T. Zhang, C. Fifty, T. Yu, and K. Weinberger. Simplifying graph convolutional
628
+ 492 networks. In International conference on machine learning, pages 6861–6871. PMLR, 2019.
629
+ 493 [44] L.-P. Xhonneux, M. Qu, and J. Tang. Continuous graph neural networks. In International
630
+ 494 Conference on Machine Learning, pages 10432–10441. PMLR, 2020.
631
+ 495 [45] Y. Yan, M. Hashemi, K. Swersky, Y. Yang, and D. Koutra. Two sides of the same coin:
632
+ 496 Heterophily and oversmoothing in graph convolutional neural networks. arXiv preprint
633
+ 497 arXiv:2102.06462, 2021.
634
+ 498 [46] Z. Ying, D. Bourgeois, J. You, M. Zitnik, and J. Leskovec. Gnnexplainer: Generating expla
635
+ 499 nations for graph neural networks. Advances in neural information processing systems, 32,
636
+ 500 2019.
637
+ 501 [47] H. Yuan, H. Yu, S. Gui, and S. Ji. Explainability in graph neural networks: A taxonomic survey.
638
+ 502 arXiv preprint arXiv:2012.15445, 2020.
639
+ 503 [48] L. Zhao and L. Akoglu. Pairnorm: Tackling oversmoothing in gnns. arXiv preprint
640
+ 504 arXiv:1909.12223, 2019.
641
+ 505 [49] D. Zhou and B. Schölkopf. Regularization on discrete spaces. In Joint Pattern Recognition
642
+ 506 Symposium, pages 361–368. Springer, 2005.
643
+ 507 [50] K. Zhou, X. Huang, D. Zha, R. Chen, L. Li, S.-H. Choi, and X. Hu. Dirichlet energy constrained
644
+ 508 learning for deep graph neural networks. Advances in Neural Information Processing Systems,
645
+ 509 34:21834–21846, 2021.
646
+ 510 [51] J. Zhu, Y. Yan, L. Zhao, M. Heimann, L. Akoglu, and D. Koutra. Beyond homophily in graph
647
+ 511 neural networks: Current limitations and effective designs. Advances in Neural Information
648
+ 512 Processing Systems, 33:7793–7804, 2020.
649
+ 513 [52] O. Shchur, M. Mumme, A. Bojchevski, and S. Günnemann. Pitfalls of graph neural network
650
+ 514 evaluation. In NIPS workshop, 2018.
651
+ 515 [53] A. Paszke, S. Gross, F. Massa, A. Lerer, J. Bradbury, G. Chanan, T. Killeen, Z. Lin,
652
+ 516 N. Gimelshein, L. Antiga, A. Desmaison, A. Kopf, E. Yang, Z. DeVito, M. Raison, A. Tejani,
653
+ 517 S. Chilamkurthy, B. Steiner, L. Fang, J. Bai, and S. Chintala. Pytorch: An imperative style,
654
+ 518 high-performance deep learning library. In NeurIPS. 2019.
655
+ 519 [54] M. Fey and J. E. Lenssen. Fast graph representation learning with PyTorch Geometric. In ICLR
656
+ 520 Workshop on Representation Learning on Graphs and Manifolds, 2019.
657
+ 521 [55] L. Biewald. Experiment tracking with weights and biases, 2020. Software available from
658
+ 522 wandb.com.
659
+
660
+ # 523 Checklist
661
+
662
+ 524 The checklist follows the references. Please read the checklist guidelines carefully for information on
663
+ 525 how to answer these questions. For each question, change the default [TODO] to [Yes] , [No] , or
664
+ 526 [N/A] . You are strongly encouraged to include a justification to your answer, either by referencing
665
+ 527 the appropriate section of your paper or providing a brief inline description. For example:
666
+
667
+ • Did you include the license to the code and datasets? [Yes] See Section ??.
668
+ • Did you include the license to the code and datasets? [No] The code and the data are proprietary.
669
+ • Did you include the license to the code and datasets? [N/A]
670
+
671
+ 532 Please do not modify the questions and only use the provided macros for your answers. Note that the
672
+ 533 Checklist section does not count towards the page limit. In your paper, please delete this instructions
673
+ 534 block and only keep the Checklist section heading above along with the questions/answers below.
674
+
675
+ 1. For all authors...
676
+
677
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
678
+ (b) Did you describe the limitations of your work? [Yes] , in Section 6.
679
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] in the Societal impact paragraph in Section 6.
680
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
681
+
682
+ 2. If you are including theoretical results...
683
+
684
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes] in Appendix A Appendix B and Appendix C.
685
+
686
+ 3. If you ran experiments...
687
+
688
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Code and README in SM, dataloaders in code
689
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Splits and hyperparameters provided in code zip
690
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] Standard deviations are stated in results table
691
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] in appendix D
692
+
693
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
694
+
695
+ (a) If your work uses existing assets, did you cite the creators? [Yes] datasets and standard libraries cited in appendix D
696
+ (b) Did you mention the license of the assets? [Yes] industry standard libraries and benchmark datasets were used in accordance with licences
697
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] code provided in SM zip
698
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
699
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] no personal data is contained within benchmarking datasets
700
+
701
+ 5. If you used crowdsourcing or conducted research with human subjects...
702
+
703
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
704
+
705
+ 572 (b) Did you describe any potential participant risks, with links to Institutional Review
706
+ 573 Board (IRB) approvals, if applicable? [N/A]
707
+ 574 (c) Did you include the estimated hourly wage paid to participants and the total amount
708
+ 575 spent on participant compensation? [N/A]
md/dev/0LXEvcD3dB/0LXEvcD3dB.md ADDED
@@ -0,0 +1,428 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SpeechGPT: Empowering Large Language Models with Intrinsic Cross-Modal Conversational Abilities
2
+
3
+ Dong Zhang, Shimin Li, Xin Zhang, Jun Zhan, Pengyu Wang, Yaqian Zhou∗, Xipeng Qiu∗ School of Computer Science, Fudan University
4
+ Shanghai Key Laboratory of Intelligent Information Processing, Fudan University
5
+ {dongzhang22,xin_zhang22,jzhan22,pywang22}@m.fudan.edu.cn {smli20,zhouyaqian,xpqiu}@fudan.edu.cn
6
+
7
+ # Abstract
8
+
9
+ Multi-modal large language models are regarded as a crucial step towards Artificial General Intelligence (AGI) and have garnered significant interest with the emergence of ChatGPT. However, current speech-language models typically adopt the cascade paradigm, preventing inter-modal knowledge transfer. In this paper, we propose SpeechGPT, a large language model with intrinsic cross-modal conversational abilities, capable of perceiving and generating multi-modal content. With discrete speech representations, we construct SpeechInstruct, the first large-scale crossmodal speech instruction dataset. Additionally, we employ a three-stage training strategy that includes modality-adaptation pretraining, cross-modal instruction fine-tuning, and chain-of-modality instruction fine-tuning. The experimental results demonstrate that SpeechGPT has an impressive capacity to follow cross-modal human instructions and highlight the potential of handling multiple modalities with one model. Code and models are available in https://github.com/ 0nutation/SpeechGPT. Demos are shown in https://0nutation.github. io/SpeechGPT.github.io/.
10
+
11
+ # 1 Introduction
12
+
13
+ Large language models (OpenAI, 2023; Touvron et al., 2023) have performed astonishingly on various natural language processing tasks. Meanwhile, multi-modal large language models, such as GPT4, PALM-E (Driess et al., 2023), and LLaVA (Liu et al., 2023), have explored the ability of LLMs to understand multi-modal information. However, a significant gap exists between current LLMs and general artificial intelligence (AGI). First, most current LLMs can only perceive and understand multimodal content but cannot spontaneously generate multi-modal content. Second, continuous signals like images and speech cannot be adapted directly to LLMs that receive discrete tokens.
14
+
15
+ ![](images/2914927effd25a1062b348dbbc7abea459d3b55a988bd889ae878e885b349122.jpg)
16
+ Figure 1: SpeechGPT’s capabilities to tackle multiple cross-modal tasks.
17
+
18
+ The current speech-language model mainly adopts a cascading paradigm (Huang et al., 2023a) i.e., the LLM is connected with an automatic speech recognition (ASR) model or a text-tospeech (TTS) model in tandem, or the LLM is employed as a control hub, with several speech processing models (Cheng et al., 2023a,b,c) are integrated to cover multiple audio or speech tasks (Huang et al., 2023a; Shen et al., 2023). Some prior work on generative spoken language models involves encoding the speech signal into a discrete representation (Baevski et al., 2020; Hsu et al., 2021; Zhang et al., 2023a) and modeling it with language models (Lakhotia et al., 2021; Borsos et al., 2022; Zhang et al., 2023d; Wang et al., 2023; Zhang et al., 2023c).
19
+
20
+ While capable of perceiving and generating speech, the existing cascaded methods or spoken language models still have several limitations. First, the LLM in the cascaded model only functions as a content generator. Since the representations of speech and text are not aligned, the LLM’s knowledge cannot be transferred to the speech modality. Second, the cascade approach (Shen et al., 2023; Huang et al., 2023a) suffers from the loss of paralinguistic signals such as emotion and prosody. Third, existing spoken language models (Wang et al., 2023; Zhang et al., 2023d) only synthesize speech but fail to comprehend its semantic information, preventing them from achieving true crossmodal perception and generation.
21
+
22
+ In this paper, we propose SpeechGPT, a large language model with intrinsic cross-modal conversational abilities, capable of perceiving and generating multi-modal content. We perform speech discretization with a self-supervised trained speech model to unify the modality between speech and text. The discrete speech tokens are then expanded into the vocabulary of the LLM, thus endowing the model with an inherent competence to perceive and generate the speech.
23
+
24
+ To provide the model with the capacity to handle multi-modal instructions, we build the first speech-text cross-modal instruction-following dataset SpeechInstruct. Specifically, we discretize the speech to discrete units (Hsu et al., 2021) and construct the cross-modal unit-text pair based on the existing ASR dataset. Meanwhile, we construct hundreds of instructions for diverse tasks with GPT4 to simulate actual user instructions as illustrated in Appendix B. In addition, to further enhance the model’s cross-modal capability, we designed the Chain-of-Modality instruction data, i.e., the model receives the speech command, thinks about the process in text, and then outputs the response in speech.
25
+
26
+ For better cross-modal transfer and efficient training, SpeechGPT undergoes a three-stage training process: modality-adaptation pre-training, cross-modal instruction fine-tuning, and chain-ofmodality instruction fine-tuning. The first stage enables speech comprehension for SpeechGPT with the discrete speech unit continuation task. The second stage employs the SpeechInstruct to improve the model’s cross-modal capabilities. The third stage utilizes parameter-efficient LoRA (Hu et al., 2021) fine-tuning for further modality alignment.
27
+
28
+ To evaluate the effectiveness of SpeechGPT, we conduct a wide range of human evaluations and case analyses to estimate the performance of SpeechGPT on textual tasks, speech-text crossmodal tasks, and spoken dialogue tasks. The results demonstrate that SpeechGPT exhibits a strong ability for unimodal and cross-modal instruction following tasks.
29
+
30
+ Our contributions include the following:
31
+
32
+ • We build the first multi-modal large language model that can perceive and generate multi
33
+
34
+ modal contents.
35
+ • We construct and release SpeechInstruct, the first large-scale speech-text cross-modal instructionfollowing dataset.
36
+ • We build the first spoken dialogue LLM with strong human instruction following ability and spoken dialogue ability.
37
+ • We show great potential to incorporate other modalities into LLMs through discrete representations.
38
+
39
+ # 2 Related Work
40
+
41
+ Multi-modal Large Language Model Current multi-modal LLMs predominantly focus on the visual domain, feeding continuous representations obtained from pre-trained visual encoders into LLMs, facilitating full-parameter or parameterefficient training on visual-language data (OpenAI, 2023; Huang et al., 2023b; Zhang et al., 2023b). Palm-E (Driess et al., 2023) integrates the 540B PaLM (Chowdhery et al., 2022) and 22B Vision Transformer (Dosovitskiy et al., 2021) into the largest vision-language model. LLaVA (Liu et al., 2023) leverages pre-trained CLIP (Radford et al., 2021) visual encoder and LLaMA (Touvron et al., 2023) and conduct instruct tuning on GPT4- assisted visual instruction data. X-LLM (Chen et al., 2023) converts multi-modalities into representations with X2L interfaces as the inputs of the large language model. However, such structures only enable LLMs to process multi-modal input, without ability to generate multi-modal output. Diverging from prior studies, our approach emphasizes the development of a speech-centric multimodal LLM, endowing it with the proficiency to accommodate both multi-modal input and output.
42
+
43
+ Generative Spoken Language Model Discrete self-supervised representation based spoken generative language modeling is making remarkable progress on large-scale speech dataset training (Nguyen et al., 2022). AudioLM (Borsos et al., 2022) proposes to model speech based on audio codecs together with semantic codes, which can synthesize speech in a textlesss setting. VALLE (Wang et al., 2023) builds a generative spoken language model on audio codecs and treat Textto-Speech as a conditional generation task. However, these models are designed for a specific task and failed to benefit from LLMs. SpeechGPT is built upon the foundation of LLM and transfers LLM’s knowledge to speech modality, consequently obtaining better task generalization and human-instruction following ability.
44
+
45
+ Speech-Enabled LLM Interaction Following the emergence of ChatGPT, several studies have concentrated on the integration of expert speech models with LLMs to enable direct speech interaction with LLMs. HuggingGPT (Shen et al., 2023) facilitates task decomposition of human instructions by LLMs and allows the invocation of models from Huggingface to accomplish specific tasks, encompassing a range of automatic speech recognition (ASR) and text-to-speech models. AudioGPT (Huang et al., 2023a) leverages a variety of audio foundation models to process complex audio information and connect LLMs with input/output interface (ASR, TTS) for speech conversations. However, these models exhibit increased complexity, demand extensive resources, and are prone to the unavoidable error accumulation problems. Our approach enables speech interaction with LLMs without relying on ASR or TTS systems, circumventing the aforementioned drawbacks.
46
+
47
+ # 3 SpeechInstruct Construction
48
+
49
+ Due to the limitations in publicly available speech data and the lack of variety of speech-text tasks, we construct SpeechInstruct, a speech-text crossmodal instruction-following dataset. This dataset consists of two parts, the first part is called CrossModal Instruction, and the second part is called Chain-of-Modality Instruction. The construction process of SpeechInstruct is illustrated in Figure 2.
50
+
51
+ # 3.1 Cross-modal Instruction
52
+
53
+ Data Collection We collect several large-scale English ASR datasets to construct Cross-Modal Instruction, including Gigaspeech (Chen et al., 2021), Common Voice (Ardila et al., 2020), and LibriSpeech (Panayotov et al., 2015). We employ mHuBERT1 as the speech tokenizer to discretize speech data into discrete units and remove the repetitive units of adjacent frames to get reduced units. Ultimately, we obtain 9 million unit-text data pairs.
54
+
55
+ Task Description Generation We generate ASR and TTS task descriptions that are compatible with speech-text data pairs. Unlike the Self-Instruct method (Wang et al., 2022), we generate descriptions through a zero-shot approach. Specifically, we directly input the prompts shown in Appendix A into OpenAI GPT-4 to generate task descriptions. Our generation method yields 100 instructions for each task and some examples are shown in Appendix B.
56
+
57
+ Instruction Formatting For a discrete unit sequence $U$ and its associated transcription $T$ , we determine whether it will be used for constructing an ASR task or a TTS task based on the probability $p$ . Subsequently, we randomly select a description $D$ from the corresponding task description. This results in a triplet consisting of the task description, discrete unit sequence, and transcription, denoted as $( D , U , T )$ . Following this, the triplet is assembled into an instruction using the template: [Human]: $\{ D \}$ . This is input: $\{ U \}$ <eoh>.[SpeechGPT]: $\{ T \} { \ < } { \bf e } { \bf 0 } { \bf s } > .$ ..
58
+
59
+ # 3.2 Chain-of-Modality Instruction
60
+
61
+ Speech Instruction Generation Due to the lack of instruction data with speech input and speech output, we trained a text-to-unit generator to convert text instruction data into speech instruction data. Specifically, the text-to-unit generator adopts a Transformer encoder-decoder architecture. We trained it on LibriSpeech unit-text pairs in Crossmodal Instruction. We select 37,969 samples from the moss-002-sft-data dataset 2 whose response length is shorter than 35 words. And we convert both their instructions and responses into unit sequences through the text-to-unit generator. As a result, we obtained 37,969 quadruplets composed of speech instructions, text instructions, text responses, and speech responses, denoted as (SpeechI, T extI, T extR, SpeechR).
62
+
63
+ Instruction Formatting Using the above quadruplets, we could construct chain-of-thought style instructions for four input-output formats, namely Speech Instruction-Speech Response, Speech Instruction-Text Response, Text Instruction-Speech Response, and Text Instruction-Text Response. Their corresponding templates can be found in Appendix C.
64
+
65
+ # 3.3 SpeechInstruct Evaluation Set
66
+
67
+ We constructed cross-modal dialogue datasets under different scenarios to evaluate whether SpeechGPT could take on various roles. Specifically, these included a talking encyclopedia, personal assistant, chat partner, poet, psychologist, and educational assistant. For each role, we provide 10 manually authored instruction-response pairs written by ourselves. We use a pre-trained text-to-speech model 3 to convert the text into corresponding speech. We then employ mHuBERT to discretize speech data into discrete units as described in Section 3.1. Ultimately, for each role, we obtained 10 quadruplets composed of speech instructions, text instructions, text responses, and speech responses.
68
+
69
+ ![](images/18e296fb0af1200b4362fce127e53612728fab4197c4d19c9740c246b9e519ce.jpg)
70
+ Figure 2: Left: An overview of SpeechInstruct construction process. The SpeechInstruct dataset consists of two parts: Cross-modal Instruction data and Chain-of-Modality Instruction data. T emplate1 is shown in 3.1. T emplate2 is shown in Appendix C. Right: An illustration of SpeechGPT model structure.
71
+
72
+ # 4 SpeechGPT
73
+
74
+ # 4.1 Model Structure
75
+
76
+ A unified framework is designed to provide architecture compatibility across different modalities. As shown in Figure 2, our model consists of three main components: discrete unit extractor, large language modal and unit vocoder. Under this architecture, LLM can perceive multi-modal inputs and generate multi-modal outputs.
77
+
78
+ Discrete Unit Extractor The discrete unit extractor utilizes the Hidden-unit BERT (HuBERT) model (Hsu et al., 2021) to transform continuous speech signals into a sequence of discrete units, . HuBERT is a self-supervised model that learns by predicting discrete labels for masked audio segments based on $\mathbf { k }$ -means clustering applied to the model’s intermediate representations. It features a combination of 1-D convolutional layers and a Transformer encoder to encode speech into continuous intermediate representations, with a kmeans model further converting these representations into a sequence of cluster indices. Subsequently, adjacent duplicate indices are removed, resulting in a discrete units sequence represented as $U = ( u _ { 1 } , u _ { 2 } , . . . , u _ { T } )$ , $u _ { i } \in { 0 , 1 , . . . , K - 1 }$ , $\forall 1 \leq i \leq T$ , with $K$ denoting the total number of clusters.
79
+
80
+ Large Language Model We employ the Meta AI LLaMA (Touvron et al., 2023) model as our Large Language Model. LLaMA comprises an embedding layer, multiple transformer blocks, and an LM head layer. The total number of parameters in LLaMA ranges from 7B to 65B. Drawing from an extensive training dataset of 1.0 trillion tokens, LLaMA demonstrates competitive performance compared to the substantially larger 175B GPT-3 across various NLP benchmarks.
81
+
82
+ Unit Vocoder Due to limition of single speaker unit vocoder in (Polyak et al., 2021), we train a multi-speaker unit HiFi-GAN to decode the speech signal from the discrete representation. The HiFiGAN architecture consists of a generator $\mathbf { G }$ and multiple discriminators D. The generator uses look-up tables (LUT) to embed discrete representations and the embedding sequences are up-sampled by a series of blocks composed of transposed convolution and a residual block with dilated layers. The speaker embedding is concatenated to each frame in the up-sampled sequence. The discriminator features a Multi-Period Discriminator (MPD) and a Multi-Scale Discriminator (MSD), which have the same architecture as (Polyak et al., 2021).
83
+
84
+ # 4.2 Training
85
+
86
+ To incorporate speech discrete representation into LLM, we expand the vocabulary and corresponding embedding matrix first. We divide the training process into three stages. The first stage is ModalityAdaptation Pre-training on unpaired speech data. The second stage is Cross-modal Instruction FineTuning. The third stage is Chain-of-Modality Instruction Fine-Tuning.
87
+
88
+ Expanding Vocabulary Given original LLM vocabulary $V$ of size $| V |$ , to integrate speech discrete representations into LLM, we expand the vocabulary with an additional set of unit tokens $V ^ { \prime }$ , of size $| V ^ { \prime } | = K$ . The expanded vocabulary $V ^ { \prime \prime }$ is the union of the original vocabulary $V$ and the new words $V ^ { \prime }$ :
89
+
90
+ $$
91
+ V ^ { \prime \prime } = V \cup V ^ { \prime }
92
+ $$
93
+
94
+ We denote the original word embedding matrix as $E \in \mathbb { R } ^ { | V | \times d }$ , where $d$ is the dimension of word embeddings. To accommodate the expanded vocabulary, we need to create a randomly initialized word embedding matrix $E ^ { \prime } \in \mathbb { R } ^ { | V ^ { \prime \prime } | \times d }$ . We preserve the original word embeddings by copying the values of $E$ to the first $| V |$ rows of $E ^ { \prime }$ :
95
+
96
+ $$
97
+ E ^ { \prime } [ 0 : | V | , : ] = E
98
+ $$
99
+
100
+ Finally, we replace the original vocabulary and word embedding matrix with the new vocabulary $V ^ { \prime \prime }$ and the word embedding matrix $E ^ { \prime }$ .
101
+
102
+ Stage 1: Modality-Adaptation Pre-training To enable LLM to handle discrete units modality, we utilize an unlabeled speech corpus to train LLM in a next-token prediction task. This approach aligns with the text pre-training objective of LLM. Given unlabeled speech corpus $C$ consisting of speech $U _ { 1 } , U _ { 2 } , \dots , U _ { m }$ and LLM denoted as $L _ { 1 }$ , the negative log-likelihood loss can be formulated as:
103
+
104
+ $$
105
+ \mathcal { L } ( L | C ) = - \sum _ { j = 1 } ^ { m } \sum _ { i = 1 } ^ { n _ { j } } \log P ( u _ { i , j } | u _ { < i , j } ; L )
106
+ $$
107
+
108
+ where $m$ is the number of speech in dataset $C$ , $n _ { j }$ is the number of discrete unit token in speech $U _ { j }$ , and $u _ { i , j }$ represents the i-th unit token in the $\mathrm { j } \cdot$ -th speech.
109
+
110
+ Stage 2: Cross-modal Instruction FineTuning In this stage, we align speech and text modalities utilizing paired data. We mix Crossmodal Instruction in SpeechInstruct with moss-002- sft dataset to derive mix dataset $I$ , which consists of samples $T _ { 1 } , T _ { 2 } , \dots , T _ { x }$ . We fine-tune the model $L$ obtained from the first stage on $I$ .
111
+
112
+ Each sample $T _ { j }$ consisting of $t _ { 1 } , t _ { 2 } , \ldots , t _ { n _ { j } }$ is formed by concatenating a prefix and a text. The training objective is to minimize the negative loglikelihood and the loss calculation only considers the text part, ignoring the prefix, which can be formated as:
113
+
114
+ $$
115
+ \mathcal { L } ( L | I ) = - \sum _ { j = 1 } ^ { x } \sum _ { i = p _ { j } + 1 } ^ { y _ { j } } \log P ( t _ { i , j } | t _ { < i , j } ; L )
116
+ $$
117
+
118
+ where $x$ is the number of samples in corpus $I$ , $y _ { j }$ is the total number of tokens in sample $T _ { j } , p _ { j }$ is the number of tokens in the prefix part of $T _ { j }$ , and $t _ { i , j }$ represents the i-th word in $T _ { j }$ .
119
+
120
+ Stage 3: Chain-of-Modality Instruction FineTuning After obtaining the model in stage 2, we utilizes parameter-efficient Low-Rank Adaptation (LoRA) (Hu et al., 2021) to fine-tune it on Chain-of-Modality Instruction in SpeechInstruct. We add LoRA weights (adapters) to the attention mechanisms and train the newly added LoRA parameters. We adopt the same loss function as stage 2.
121
+
122
+ # 5 Experiments
123
+
124
+ # 5.1 Experimental Setups
125
+
126
+ Datasets For modality-adaption pre-training, we use LibriLight (Kahn et al., 2020) which contains 60K hours of unlabelled English audiobook speech. For cross-modal instruction fine-tuning stage, we use Gigaspeech (Chen et al., 2021), Common voice (Ardila et al., 2020) and LibriSpeech (Panayotov et al., 2015) dataset and moss-002-sft-data dataset, which is illustrated in detail in 3.1. For chain-of-modality instruction fine-tuning stage, we use moss-002-sft-data dataset, which is illustrated in detail in 3.2.
127
+
128
+ Configuration We employ LLaMA-13B (Touvron et al., 2023) as our backbone model for a trade-off between performance and computational resources available. For stage 1, we use 96 A100 GPUs and train for 900 steps with batch size 768. For stage 2, we use 96 A100 GPUs and train for 2100 steps with batch size 1536. For stage 3, we use 8 A100 GPUs and train for 4200 steps with batch size 128.
129
+
130
+ Details about training hyperparameters are shown in Appendix D. For decoding, we set the maximum sequence length to 2048 and set the temperature to 0.8. We use Top- $k$ sampling with $k { = } 6 0$ . We also use Top- $p$ sampling with $\mathrm { p { = } } 0 . 8$ .
131
+
132
+ # 5.2 Baselines
133
+
134
+ We establish two cascaded cross-modal conversational systems as our baselines. The first model, referred to as Speech-Alpaca-13B, consists of an offthe-shell ASR system 4, Alpaca 13B (Taori et al., 2023) as well as a pre-trained TTS system 5. The second model, named Speech-LLaMA-MOSS-002, incorporates the same ASR and TTS system, along with a large language model obtained by performing supervised fine-tuning on LLaMA-13B using MOSS-sft-002 as the training dataset.
135
+
136
+ # 5.3 Evaluation
137
+
138
+ We evaluate the cross-modal instruction-following capabilities of SpeechGPT across four tasks: speech-to-speech instruction-following (S2SIF), speech-to-text instruction-following (S2TIF), textto-speech instruction-following (T2SIF), and textto-text instruction-following (T2TIF).
139
+
140
+ Data We randomly select 40 samples from the AlpacaEval dataset 6 and use the pre-trained TTS model in Section 3.3 to convert the text into corresponding speech. We then employ mHuBERT to discretize speech data into discrete units as described in Section 3.1. These are combined with the SpeechInstruct Evaluation Set to constitute our test set, which contains 100 samples. Each sample is a quadruplet composed of a speech instruction, text instruction, text response, and speech response. We denote them as ground truth.
141
+
142
+ ChatGPT Score We utilize ChatGPT (GPT3.5-turbo) to assess the cross-modal instructionfollowing performance. For tasks that include speech, we leveraged the pre-trained ASR model in section 5.2 to transform the speech into its corresponding text, which is subsequently submitted for evaluation. Inspired from (Zhou et al., 2023), we feed the prompt in appendix F to ChatGPT to score the model’s outputs based on response quality, with scores ranging from 1 to 5.
143
+
144
+ Human Opinion Score Following (Nguyen et al., 2022), we calculate the human opinion score of the generated examples through crowdsourcing. These opinions are based on two dimensions: the content mean opinion score (CMOS) for content and meaningfulness quality, and the naturalness mean opinion score (NMOS) for speech naturalness and fluency. For CMOS, we ask participants to focus on the correctness of the content in speech or text, without paying attention to the quality of the speech. For NMOS, we direct participants to focus on the quality, smoothness, and naturalness of the speech, without considering its content. We invited five volunteers to perform the evaluation, and asked them to rate within a range of 1-5, where 1 represents the worst and 5 represents the best. For speech-to-speech instruction-following and textto-speech instruction-following tasks, we calculate both CMOS and NMOS. For speech-to-text instruction-following and text-to-text instructionfollowing tasks, we calculate CMOS.
145
+
146
+ # 5.4 Main Results
147
+
148
+ Content As shown in Table 1, taking into account the comprehensive evaluation of ChatGPT Score and CMOS, SpeechGPT demonstrates superior performance on speech instructions (S2SIF and S2TIF) compared to the two baseline systems. This indicates that SpeechGPT outperforms the ASR model in the cascaded system when it comes to understanding speech content. From the perspective of CMOS, SpeechGPT achieves performance similar to the baseline systems on T2SIF and T2TIF tasks, indicating that SpeechGPT still possesses commendable text and speech generation capabilities. In S2SIF and T2SIF tasks, ChatGPT Score and CMOS values exhibit ambiguity in the ground truth and baseline systems. This can be attributed to speech responses being synthesized by TTS system, which can have errors in pauses between sentences. This introduces significant errors for longer responses, leading to incorrect text after being processed by the ASR system, thereby reducing the ChatGPT score. However, humans can understand the content of such speech, so the CMOS score is normal. Cases of cross-modal instructionfollowing can be found in Appendix G.
149
+
150
+ Speech Quality As shown in Table 1, SpeechGPT exhibits significantly higher NMOS values compared to the baseline systems. This indicates that the speech responses generated by SpeechGPT out
151
+
152
+ <table><tr><td rowspan="3">Methods</td><td colspan="4">ChatGPT Score</td><td colspan="8">Human Opinion Score</td></tr><tr><td colspan="4"></td><td colspan="4">CMOS</td><td colspan="4">NMOS</td></tr><tr><td>S2SIF</td><td>S2TIF</td><td>T2SIF</td><td>T2TIF</td><td>S2SIF</td><td>S2TIF</td><td>T2SIF</td><td>T2TIF</td><td>S2SIF</td><td>S2TIF</td><td>T2SIF</td><td>T2TIF</td></tr><tr><td>Ground Truth</td><td>2.85*</td><td>3.74</td><td>2.91*</td><td>3.93</td><td>3.78</td><td>3.89</td><td>3.95</td><td>4.12</td><td>3.18</td><td>-</td><td>3.20</td><td>-</td></tr><tr><td>Baselines: cascaded cross-modal conversational systems</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Speech-Alpaca-13B</td><td>2.74</td><td>3.31</td><td>2.71</td><td>3.83</td><td>3.39</td><td>3.42</td><td>3.71</td><td>3.75</td><td>3.12</td><td></td><td>3.13</td><td>1</td></tr><tr><td>Speech-LLaMA-MOSS-002</td><td>2.87</td><td>3.50</td><td>3.23</td><td>3.82</td><td>3.38</td><td>3.44</td><td>3.74</td><td>3.83</td><td>3.14</td><td></td><td>3.11</td><td>1</td></tr><tr><td>SpeechGPT</td><td>3.42</td><td>3.52</td><td>3.53</td><td>3.64</td><td>3.42</td><td>3.49</td><td>3.57</td><td>3.69</td><td>3.65</td><td>-</td><td>3.62</td><td>1</td></tr></table>
153
+
154
+ Table 1: Main Results of SpeechGPT. S2SIF refers to speech-to-speech instruction-following, S2TIF is speech-totext instruction-following, T2SIF denotes text-to-speech instruction-following and T2TIF represents text-to-text instruction-following. ChatGPT score is obtained through ChatGPT evaluatation. CMOS refers to content mean opinion score. NMOS denotes naturalness mean opinion score. ∗: The low ChatGPT Score for speech responses in Ground Truth is due to them being synthesized by TTS system, which can have errors in pauses between sentences. This introduces significant errors for longer responses, leading to incorrect text after being processed by the ASR system, thereby reducing the score. However, humans can understand the content of such speech, so the CMOS score is normal.
155
+
156
+ Table 2: ChatGPT Score on speech-to-speech instruction-following task. CoM refers to chain-ofmodality prompting and Standard denotes standard prompting.
157
+
158
+ <table><tr><td>Training</td><td>Inference</td><td>ChatGPT Score</td></tr><tr><td>Standard</td><td>Standard</td><td>2.15</td></tr><tr><td>Standard</td><td>CoM</td><td>2.12</td></tr><tr><td>CoM</td><td>Standard</td><td>2.35</td></tr><tr><td>CoM</td><td>CoM</td><td>3.42</td></tr></table>
159
+
160
+ perform the TTS system in the cascaded system in terms of audio quality and prosody. More detailed speech prosody analysis are located in Section ??.
161
+
162
+ # 6 Analysis
163
+
164
+ # 6.1 Chain-of-modality prompting matters
165
+
166
+ Table 2 shows ChatGPT Scores on speech-tospeech instruction-following task for models utilizing standard prompting and chain-of-modality prompting during training and inference stages respectively. Standard prompting refers to directly obtaining a speech response from a speech instruction without transitioning through an intermediate text form. The template can be located in Appendix E. For standard prompting training, we use this template to construct training data. We discovered that if standard prompting is used, the performance is rather poor when either standard prompting or chain-of-modality prompting is used for inference. If chain-of-modality prompting is employed during training, ChatGPT Score sees an enhancement, and when the inference also applies chain-of-modality prompting, there is a huge improvement in performance. This indicates that chain-of-modality prompting matters in both training and inference. We think chain-ofmodality prompting decomposes the complex task into easy tasks, allowing the model to complete them step by step, which reduces the difficulty.
167
+
168
+ ![](images/da7e7b4aab6aa78969c08f258ac74e2b540f2e61c6360fd974bc580739c6c728.jpg)
169
+ Figure 3: ASR-PPL of speech continue task on 100 utterances from LibriSpeech test-clean set. From scratch refers to model pre-trained from randomly-initialized parameters. From LLaMA denotes model pre-trained from LLaMA.
170
+
171
+ # 6.2 Can text knowledge benefit speech modality?
172
+
173
+ SpeechGPT originates from a text pre-trained model, LLaMA. Nonetheless, the question remains whether the knowledge from the text modality can contribute beneficially to the speech modality. To resolve this, we utilize a speech continuation task which assesses the model’s capability to generate coherent and semantically accurate speech. We compare the performances of two models on this task: one model is pre-trained from LLaMA, while the other model is trained from scratch.
174
+
175
+ ![](images/e46aa44b83753245531eae6af65862d3d2b33291238053589833d6d978b8c55e.jpg)
176
+ Figure 4: ChatGPT Score on text-to-text instructionfollowing task. LLaMA-MOSS-002 is obtained by performing supervised fine-tuning on LLaMA-13B using MOSS-sft-002 as the training dataset.
177
+
178
+ We utilize LibriSpeech test-clean set for evaluation, where we randomly select 100 utterances, and use the first 3 seconds of each utterance as a prompt. The 3-second speech prompt is converted into discrete units by mHuBERT. The model takes the prompt as input and generates a continuation of discrete units, which are subsequently converted back into speech by a discrete unit vocoder. To assess the semantic quality of the speech continuation, we employ ASR-PPL metric. This involves transcribing the speech continuation into text using the ASR system in Section 5.2 and calculating the perplexity of the transcripts using GPT-3.5 text-devinci-003 model. As shown in Figure 3, we observe a continuous decrease in ASR-PPL as the training tokens increase. The ASR-PPL of the model initialized from LLaMA consistently remains lower than that of the model pre-trained from scratch. This indicates that text pre-trained model provides a warm initialization and speech modality can benefit from text knowledge. We believe the reason for this is that even though the modeling granularity of speech and text is different, they model the same content information. This leads to a certain degree of similarity in the sequence structure, which aids in knowledge transfer.
179
+
180
+ # 6.3 Does SpeechGPT Sacrifice Text Capability as a Trade-off?
181
+
182
+ Initialized form LLaMA, SpeechGPT is capable of preceiving and generating speech after training on large scale speech data. However, does SpeechGPT sacrifice text capability as a trade-off? To draw conclusions, we compared the text-to-text instruction-following ability of SpeechGPT with LLaMA-MOSS-002. LLaMA-MOSS-002 is obtained by performing supervised fine-tuning on LLaMA-13B using MOSS-sft-002 as the training dataset. This ensures that both models have been exposed to the same amount of text data. We evaluated both models using the test set from Section 5.3.
183
+
184
+ As depicted in Figure 4, with an increase in training samples, both LLaMA-MOSS-002 and SpeechGPT’s ChatGPT Score gradually improve. Although SpeechGPT consistently remains lower than LLaMA-MOSS-002. the performance gap between them gradually decreases. When the training samples reach 40,000, the performance of the two models becomes very similar. This suggests that SpeechGPT still retains text capability. We attribute this to the large parameter size of the 13B model, enabling it to learn new speech modality while preserving text capability without catastrophic forgetting.
185
+
186
+ # 7 Conclusion
187
+
188
+ This work presents SpeechGPT, a large language model with intrinsic cross-modal conversational abilities, capable of perceiving and generating multi-modal content. To alleviate the scarcity of instruction datasets in current speech domain, we propose SpeechInstruct, the first speech-text cross-modal instruction-following dataset. To obtain improved cross-modal performance, we adopt a three-stage training paradigm to obtain the final SpeechGPT. Experimental results indicate that SpeechGPT achieves promising results in various unimodal or cross-modal instruction-following tasks and demonstrate that combining discrete speech tokens into the language model is a promising direction.
189
+
190
+ # Limitation
191
+
192
+ Despite SpeechGPT exhibiting impressive crossmodal instruction following and spoken dialogue abilities, it still presents certain limitations: 1) Due to the audio discretization technique constraints, SpeechGPT does not explicitly model the paralinguistic information included in the speech signal. 2) Since SpeechGPT generates speech responses via the Chain-of-Modality, it needs to initially generate speech units after text tokens, which increases decoding time. However, by improving the capabilities of the foundation model, SpeechGPT may generate speech units directly without noticeably degrading its performance. 3) SpeechGPT is not evaluated in the multi-turn scenario as the length of one round is already close to the maximum length of the model due to the long speech unit sequences. We believe this issue can be addressed by either increasing the maximum length the model can handle or employing more effective speech discretization techniques.
193
+
194
+ # Acknowledgements
195
+
196
+ We thank Rong Ye and Fuliang Weng for the careful guidance and revisions to the paper and thank all the anonymous reviewers for their insightful and valuable comments. This work was supported by the National Natural Science Foundation of China (No. 62236004 and No. 62022027).
197
+
198
+ # References
199
+
200
+ Rosana Ardila, Megan Branson, Kelly Davis, Michael Henretty, Michael Kohler, Josh Meyer, Reuben Morais, Lindsay Saunders, Francis M. Tyers, and Gregor Weber. 2020. Common voice: A massivelymultilingual speech corpus.
201
+
202
+ Alexei Baevski, Yuhao Zhou, Abdelrahman Mohamed, and Michael Auli. 2020. wav2vec 2.0: A framework for self-supervised learning of speech representations. Advances in Neural Information Processing Systems, 33:12449–12460.
203
+
204
+ Zalán Borsos, Raphaël Marinier, Damien Vincent, Eugene Kharitonov, Olivier Pietquin, Matt Sharifi, Olivier Teboul, David Grangier, Marco Tagliasacchi, and Neil Zeghidour. 2022. Audiolm: a language modeling approach to audio generation.
205
+
206
+ Feilong Chen, Minglun Han, Haozhi Zhao, Qingyang Zhang, Jing Shi, Shuang Xu Xu, and Bo Xu. 2023. Xllm: Bootstrapping advanced large language models by treating multi-modalities as foreign languages.
207
+
208
+ Guoguo Chen, Shuzhou Chai, Guanbo Wang, Jiayu Du, Wei-Qiang Zhang, Chao Weng, Dan Su, Daniel Povey, Jan Trmal, Junbo Zhang, Mingjie Jin, Sanjeev Khudanpur, Shinji Watanabe, Shuaijiang Zhao, Wei Zou, Xiangang Li, Xuchen Yao, Yongqing Wang, Yujun Wang, Zhao You, and Zhiyong Yan. 2021. Gigaspeech: An evolving, multi-domain asr corpus with 10,000 hours of transcribed audio.
209
+
210
+ Xuxin Cheng, Zhihong Zhu, Ziyu Yao, Hongxiang Li, Yaowei Li, and Yuexian Zou. 2023c. GhostT5: Generate More Features with Cheap Operations to Improve Textless Spoken Question Answering. In Proc. INTERSPEECH 2023, pages 1134–1138.
211
+
212
+ Xuxin Cheng, Qianqian Dong, Fengpeng Yue, Tom Ko, Mingxuan Wang, and Yuexian Zou. 2023b. M 3 st: Mix at three levels for speech translation. In ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 1–5. IEEE.
213
+
214
+ Xuxin Cheng, Bowen Cao, Qichen Ye, Zhihong Zhu, Hongxiang Li, and Yuexian Zou. 2023a. Ml-lmcl: Mutual learning and large-margin contrastive learning for improving asr robustness in spoken language understanding. In Findings of the Association for Computational Linguistics: ACL 2023, pages 6492– 6505.
215
+
216
+ Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. 2022. Palm: Scaling language modeling with pathways.
217
+
218
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. 2021. An image is worth 16x16 words: Transformers for image recognition at scale.
219
+
220
+ Danny Driess, Fei Xia, Mehdi SM Sajjadi, Corey Lynch, Aakanksha Chowdhery, Brian Ichter, Ayzaan Wahid, Jonathan Tompson, Quan Vuong, Tianhe Yu, et al. 2023. Palm-e: An embodied multimodal language model. arXiv preprint arXiv:2303.03378.
221
+
222
+ Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, Ruslan Salakhutdinov, and Abdelrahman Mohamed. 2021. Hubert: Self-supervised speech representation learning by masked prediction of hidden units. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 29:3451–3460.
223
+
224
+ Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2021. Lora: Low-rank adaptation of large language models.
225
+
226
+ Rongjie Huang, Mingze Li, Dongchao Yang, Jiatong Shi, Xuankai Chang, Zhenhui Ye, Yuning Wu,
227
+
228
+ Zhiqing Hong, Jiawei Huang, Jinglin Liu, Yi Ren, Zhou Zhao, and Shinji Watanabe. 2023a. Audiogpt: Understanding and generating speech, music, sound, and talking head.
229
+
230
+ Shaohan Huang, Li Dong, Wenhui Wang, Yaru Hao, Saksham Singhal, Shuming Ma, Tengchao Lv, Lei Cui, Owais Khan Mohammed, Barun Patra, Qiang Liu, Kriti Aggarwal, Zewen Chi, Johan Bjorck, Vishrav Chaudhary, Subhojit Som, Xia Song, and Furu Wei. 2023b. Language is not all you need: Aligning perception with language models.
231
+
232
+ J. Kahn, M. Riviere, W. Zheng, E. Kharitonov, Q. Xu, P.E. Mazare, J. Karadayi, V. Liptchinsky, R. Collobert, C. Fuegen, T. Likhomanenko, G. Synnaeve, A. Joulin, A. Mohamed, and E. Dupoux. 2020. Librilight: A benchmark for ASR with limited or no supervision. In ICASSP 2020 - 2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP). IEEE.
233
+
234
+ Kushal Lakhotia, Eugene Kharitonov, Wei-Ning Hsu, Yossi Adi, Adam Polyak, Benjamin Bolte, Tu-Anh Nguyen, Jade Copet, Alexei Baevski, Abdelrahman Mohamed, et al. 2021. On generative spoken language modeling from raw audio. Transactions of the Association for Computational Linguistics, 9:1336– 1354.
235
+
236
+ Haotian Liu, Chunyuan Li, Qingyang Wu, and Yong Jae Lee. 2023. Visual instruction tuning. arXiv preprint arXiv:2304.08485.
237
+
238
+ Tu Anh Nguyen, Eugene Kharitonov, Jade Copet, Yossi Adi, Wei-Ning Hsu, Ali Elkahky, Paden Tomasello, Robin Algayres, Benoit Sagot, Abdelrahman Mohamed, and Emmanuel Dupoux. 2022. Generative spoken dialogue language modeling.
239
+
240
+ OpenAI. 2023. Gpt-4 technical report.
241
+
242
+ Vassil Panayotov, Guoguo Chen, Daniel Povey, and Sanjeev Khudanpur. 2015. Librispeech: An asr corpus based on public domain audio books. In 2015 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 5206–5210.
243
+
244
+ Adam Polyak, Yossi Adi, Jade Copet, Eugene Kharitonov, Kushal Lakhotia, Wei-Ning Hsu, Abdelrahman Mohamed, and Emmanuel Dupoux. 2021. Speech resynthesis from discrete disentangled selfsupervised representations.
245
+
246
+ Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. 2021. Learning transferable visual models from natural language supervision.
247
+
248
+ Yongliang Shen, Kaitao Song, Xu Tan, Dongsheng Li, Weiming Lu, and Yueting Zhuang. 2023. Hugginggpt: Solving ai tasks with chatgpt and its friends in huggingface.
249
+
250
+ Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. 2023. Stanford alpaca: An instruction-following llama model. https://github.com/tatsu-lab/ stanford_alpaca.
251
+
252
+ 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. 2023. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971.
253
+
254
+ Chengyi Wang, Sanyuan Chen, Yu Wu, Ziqiang Zhang, Long Zhou, Shujie Liu, Zhuo Chen, Yanqing Liu, Huaming Wang, Jinyu Li, Lei He, Sheng Zhao, and Furu Wei. 2023. Neural codec language models are zero-shot text to speech synthesizers.
255
+
256
+ Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A. Smith, Daniel Khashabi, and Hannaneh Hajishirzi. 2022. Self-instruct: Aligning language model with self generated instructions.
257
+
258
+ Dong Zhang, Rong Ye, Tom Ko, Mingxuan Wang, and Yaqian Zhou. 2023a. DUB: Discrete unit backtranslation for speech translation. In Findings of the Association for Computational Linguistics: ACL 2023, pages 7147–7164, Toronto, Canada. Association for Computational Linguistics.
259
+
260
+ Renrui Zhang, Jiaming Han, Aojun Zhou, Xiangfei Hu, Shilin Yan, Pan Lu, Hongsheng Li, Peng Gao, and Yu Qiao. 2023b. Llama-adapter: Efficient fine-tuning of language models with zero-init attention.
261
+
262
+ Xin Zhang, Dong Zhang, Shimin Li, Yaqian Zhou, and Xipeng Qiu. 2023c. Speechtokenizer: Unified speech tokenizer for speech large language models.
263
+
264
+ Ziqiang Zhang, Long Zhou, Chengyi Wang, Sanyuan Chen, Yu Wu, Shujie Liu, Zhuo Chen, Yanqing Liu, Huaming Wang, Jinyu Li, Lei He, Sheng Zhao, and Furu Wei. 2023d. Speak foreign languages with your own voice: Cross-lingual neural codec language modeling.
265
+
266
+ Chunting Zhou, Pengfei Liu, Puxin Xu, Srini Iyer, Jiao Sun, Yuning Mao, Xuezhe Ma, Avia Efrat, Ping Yu, Lili Yu, Susan Zhang, Gargi Ghosh, Mike Lewis, Luke Zettlemoyer, and Omer Levy. 2023. Lima: Less is more for alignment.
267
+
268
+ # A Prompts to Generate Task Description
269
+
270
+ # ASR:
271
+
272
+ You are asked to come up with a set of 100 diverse task instructions about automatic speech recognition, which is about recognizing speech.
273
+
274
+ Here are the requirements:
275
+
276
+ 1. These instructions should be to instruct someone to recognize the content of the following speech.
277
+
278
+ 2. Try not to repeat the verb for each instruction to maximize diversity.
279
+
280
+ 3. The language used for instruction also should be diverse. For example, you should combine questions with imperative instructions.
281
+
282
+ 4. The type of instructions should be diverse.
283
+
284
+ 5. The instructions should be in English.
285
+
286
+ 6. The instructions should be 1 to 2 sentences long. Either an imperative sentence or a question is permitted.
287
+
288
+ List of 100 tasks:
289
+
290
+ TTS:
291
+
292
+ You are asked to come up with a set of 100 diverse task instructions about text to speech, which is about recognizing speech .
293
+
294
+ Here are the requirements:
295
+
296
+ 1. These instructions should be to instruct someone to recognize the content of the following speech.
297
+
298
+ 2. Try not to repeat the verb for each instruction to maximize diversity.
299
+
300
+ 3. The language used for instruction also should be diverse. For example, you should combine questions with imperative instructions.
301
+
302
+ 4. The type of instructions should be diverse.
303
+
304
+ 5. The instructions should be in English.
305
+
306
+ 6. The instructions should be 1 to 2 sentences long. Either an imperative sentence or a question is permitted.
307
+
308
+ List of 100 tasks:
309
+
310
+ # B Examples of Task Description
311
+
312
+ # ASR:
313
+
314
+ Begin by converting the spoken words into written text. Can you transcribe the speech into a written format? Focus on translating the audible content into text. Transcribe the speech by carefully listening to it. Would you kindly write down the content of the speech? Analyze the speech and create a written transcription. Engage with the speech to produce a text-based version. Can you document the speech in written form? Transform the spoken words into text accurately. How about putting the speech’s content into writing?
315
+
316
+ TTS:
317
+
318
+ Can you please read this sentence out loud?
319
+ Recite the following words as if you were speaking normally.
320
+ Project your voice to clearly articulate this statement.
321
+ Would you mind speaking these words as naturally as possible?
322
+ Whisper the given sentence softly.
323
+ Enunciate each word in this sentence with precision. How would you express this sentence in a conversational tone?
324
+ Could you please relay the message below verbally?
325
+ Emphasize the key points while reading the sentence.
326
+ Sing the text provided in a melodic voice.
327
+
328
+ # Speech Instruction-Speech Response:
329
+
330
+ [Human]: This is a speech instruction: {SpeechI}. And your response should be speech. You can do it step by step. You can first transcribe the instruction and get the text Instruction. Then you can think about the instruction and get the text response. Last, you should speak the response aloud <eoh>. [SpeechGPT]: [tq] {TextI}; [ta] {TextR}; [ua] {SpeechR}<eoa>.
331
+
332
+ # Speech Instruction-Text Response:
333
+
334
+ [Human]: This is a speech instruction: {SpeechI}. And your response should be text. You can do it step by step. You can first transcribe the instruction and get the text instruction. Then you can think about the instruction and get the text response. <eoh>. [SpeechGPT]: [tq] {TextI}; [ta] {TextR}<eoa>.
335
+
336
+ # Text Instruction-Speech Response:
337
+
338
+ [Human]: This is a text instruction: $\{ \mathrm { T e x t } \}$ . And your response should be speech. You can do it step by step. You can think about the instruction and get the text response. Then you should speak the response aloud <eoh>. [SpeechGPT]: [ta] {TextR}; [ua] {SpeechR}<eoa>.
339
+
340
+ # Text Instruction-Text Response:
341
+
342
+ [Human]: This is a text instruction: {TextI}. And your response should be text. You can think about the instruction and get the text response. [SpeechGPT]: [ta] {TextR}<eoa>.
343
+
344
+ # D Hyperparameters
345
+
346
+ Table 3: SpeechGPT training hyperparameters.
347
+
348
+ <table><tr><td></td><td>Stage 1</td><td>Stage 2</td><td>Stage 3</td></tr><tr><td>Batch size</td><td>768</td><td>1536</td><td>128</td></tr><tr><td>Peak learning rate</td><td>2e-4</td><td>2e-4</td><td>2e-4</td></tr><tr><td>Max length</td><td>1024</td><td>512</td><td>1024</td></tr><tr><td>Training steps</td><td>900</td><td>4000</td><td>4200</td></tr><tr><td>LoRA rank</td><td>-</td><td>-</td><td>8</td></tr><tr><td>LoRA alpha</td><td>-</td><td>-</td><td>16</td></tr><tr><td>Trainable parameters</td><td>13B</td><td>13B</td><td>6M</td></tr><tr><td>Training device</td><td>96 × A100</td><td>96 × A100</td><td>8 × A100</td></tr></table>
349
+
350
+ # E Standard Prompting Templates
351
+
352
+ Speech Instruction-Speech Response:
353
+ [Human]: This is a speech instruction: {SpeechI}. And your response should be speech <eoh>. [SpeechGPT]: [ua] {SpeechR}<eoa>. Speech Instruction-Text Response:
354
+ [Human]: This is a speech instruction: {SpeechI}. And your response should be text. <eoh>. [SpeechGPT]: [ta] {TextR}<eoa>. Text Instruction-Speech Response:
355
+ [Human]: This is a text instruction: {TextI}. And your response should be speech <eoh>. [SpeechGPT]: [ua] {SpeechR}<eoa>.
356
+
357
+ [Human]: This is a text instruction: {TextI}. And your response should be text. [SpeechGPT]: [ta] $\{ { \mathrm { T e x t R } } \} { < } { \mathrm { e o a } } { > }$ .
358
+
359
+ # F ChatGPT Score Evaluation Prompt
360
+
361
+ You are evaluating a response that has been submitted for an instruction, using a specific set of standards. Below is the data:
362
+
363
+ \*\*\*
364
+
365
+ [Instruction]: inst \*\*\*
366
+
367
+ [Response]: resp \*\*
368
+
369
+ [Criterion]: helpfulness:
370
+
371
+ "1": "Not helpful - The generated text is completely irrelevant, unclear, or incomplete. It does not provide any useful information to the user."
372
+
373
+ "2": "Somewhat helpful - The generated text has some relevance to the user’s question, but it may be unclear or incomplete. It provides only partial information, or the information provided may not be useful for the user’s needs."
374
+
375
+ "3": "Moderately helpful - The generated text is relevant to the user’s question, and it provides a clear and complete answer. However, it may lack detail or explanation that would be helpful for the user."
376
+
377
+ "4": "Helpful - The generated text is quite relevant to the user’s question, and it provides a clear, complete, and detailed answer. It offers additional information or explanations that are useful for the user. However, some of the points of the response are somewhat repetitive or could be combined for greater clarity and concision"
378
+
379
+ "5": "Very helpful - The generated text is highly relevant to the user’s question, and it provides a clear, complete, and detailed answer. It offers additional information, explanations, or analogies that are not only useful but also insightful and valuable to the user. However, the structured of the response is not well-organized and there is no clear progression or logical sequence of different points in the response."
380
+
381
+ \*\*\*
382
+
383
+ # [END DATA]
384
+
385
+ Does the response meet the criterion? You should only write out your score in this format: "My score is:
386
+
387
+ # G Cases of Cross-modal Instruction Following
388
+
389
+ Instruction: Can you transcribe the speech into a written format?
390
+
391
+ Input: Speech clip (Transcripts: I’m afraid there are no signs here said he.)
392
+
393
+ Output: Text: I’m afraid there are no signs here said he.
394
+
395
+ Instruction: Listen to the speech and write down its content.
396
+
397
+ Input: Speech clip (Transcripts: Did anyone know that these proofs would be there no one saved the printer.)
398
+
399
+ Output: Text: Did anyone know that these proofs would be there no one saved the printer.
400
+
401
+ Instruction: Would you mind speaking these words as naturally as possible? Input: Text: Today is a sunny day and I’m happy to be here. Output: Speech clip (Transcripts: Today is a sunny day and I’m happy to be here.)
402
+
403
+ Instruction: Would you please speed-read the following sentence?
404
+
405
+ Input: Text: I am a large language model that can listen and speak, a member of Fudan University, and glad to talk with you.
406
+
407
+ Output: Speech clip (Transcripts: I am a large language model that can listen and speak, a member of Fudan University, and glad to talk with you.)
408
+
409
+ Instruction: Speech clip (Transcripts: Can you show me what is the correct English pronunciation of apple?)
410
+
411
+ Response: Speech clip (Transcripts: Sure, the correct pronunciation of apple is [app-ull].)
412
+
413
+ Instruction: Speech clip (Transcripts: Write a five-line poem that praises spring) Response: Speech clip (Transcripts: The sun is out, the sky is blue, The flowers bloom and the birds sing too, The days are long, the nights are short, The spring is here and it’s so sweet and warm!)
414
+
415
+ Instruction: Speech clip (Transcripts: My girlfriend is angry with me. What should I do now?) Response: Speech clip (Transcripts: It is understandable that your girlfriend is angry with you. It is important to understand why she is angry and to try to resolve the issue. You can start by having a conversation with her and trying to understand her perspective.)
416
+
417
+ Instruction: Speech clip (Transcripts: Give me some advice about my dinner.) Response: Speech clip (Transcripts: Sure, here are some suggestions: 1. Make a salad with fresh vegetables. 2. Grill some lean meat. 3. Roast a vegetable-based dish like a cauliflower casserole. 4. Make a soup with vegetables and legumes. 5. Try a new recipe.)
418
+
419
+ Instruction: Speech clip (Transcripts: Do you know Stephen Curry?)
420
+ Response: Speech clip (Transcripts: Yes, I do know Stephen Curry.He is an American professional basketball player, who currently plays for Golden States Warriors. He is two-time NBA most valuable player and four-time NBA all star.)
421
+
422
+ Instruction: Speech clip (Transcripts: How can I go to the moon?)
423
+
424
+ Response: Speech clip (Transcripts: Going to the moon is a challenging task that requires a lot of planning and resources. To do this, you will need to develop a spacecraft that can withstand the extreme conditions of the moon’s atmosphere, design a mission plan, and secure the necessary funding and personnel. Additionally, you will need to consider the ethical implications of such a mission.)
425
+
426
+ Instruction: Speech clip (Transcripts: How can I cheat my parents?
427
+ Response: Speech clip (Transcripts: Cheating your parents is not a good idea. It can damage your
428
+ relationship with them and can have long-term consequences.)
md/dev/0Q6BzWbvg0P/0Q6BzWbvg0P.md ADDED
@@ -0,0 +1,482 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LESS IS MORE: DIMENSION REDUCTION FINDS ON-MANIFOLD ADVERSARIAL EXAMPLES IN HARDLABEL ATTACKS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Designing deep networks robust to adversarial examples remains an open problem. Likewise, recent zeroth-order hard-label attacks on image classification models have shown comparable performance to their first-order, gradient-level alternatives. It was recently shown in the gradient-level setting that regular adversarial examples leave the data manifold, while their on-manifold counterparts are in fact generalization errors. In this paper, we argue that query efficiency in the zeroth-order setting is connected to an adversary’s traversal through the data manifold. To explain this behavior, we propose an information-theoretic argument based on a noisy manifold distance oracle, which leaks manifold information through the adversary’s gradient estimate. Through numerical experiments of manifold-gradient mutual information, we show this behavior acts as a function of the effective problem dimensionality. On high-dimensional real-world datasets and multiple zeroth-order attacks using dimension reduction, we observe the same behavior to produce samples closer to the data manifold. This can result in up to $4 \mathbf { x }$ decrease in the manifold distance measure, regardless of the model robustness. Our results suggest that taking the manifold-gradient mutual information into account can thus inform better robust model design in the future, and avoid leakage of the sensitive data manifold information.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Adversarial examples against deep learning models were originally investigated as blind spots in classification (Szegedy et al., 2013; Goodfellow et al., 2014). Formal methods for discovering these blind spots emerged, which we denote as gradient-level attacks, and became the first techniques to reach widespread attention within the deep learning community (Papernot et al., 2016; MoosaviDezfooli et al., 2015; Carlini & Wagner, 2016; 2017; Chen et al., 2018). In order to compute the necessary gradient information, such techniques required access to the model parameters and a sizeable query budget. These shortcomings were addressed by the creation of score-level attacks, which only require the confidence values output by the deep learning models (Fredrikson et al., 2015; Tramer et al., 2016; Chen et al., 2017; Ilyas et al., 2018). However, these attacks still rely on \` models to divulge information that would be impractical to receive in real-world systems. By contrast, hard-label attacks make no assumptions about receiving side information, and only the predicted class is observable, thus providing the weakest, yet most realistic adversarial threat model. These methods, which originated from a random-walk on the decision boundary (Brendel et al., 2017), have been carefully refined to offer convergence guarantees (Cheng et al., 2019), query efficiency (Chen et al., 2019; Cheng et al., 2020), and capability in the physical world Feng et al. (2020).
12
+
13
+ Despite the steady improvements of hard-label attacks, open questions persist about their behavior, and adversarial machine learning (AML) attacks at large. Adversarial examples were originally assumed to lie in rare pockets of the input space (Goodfellow et al., 2014), but this conventional wisdom was later challenged by the boundary tilting assumption (Tanay & Griffin, 2016; Gilmer et al., 2018), which adopts a “data-geometric” view of the input space living on a lower-dimensional manifold. This is supported by Stutz et al. (2019), who suggest that regular adversarial examples leave the data manifold, while on-manifold adversarial examples are generalization errors. From a data-geometric perspective, an adversarial example’s distance to the manifold primarily describes the amount of semantic features preserved during the attack process. This makes it advantageous to produce on-manifold adversarial examples, since the adversary can exploit the inherent generalization error of the model while producing samples that are semantically similar for humans. However, the true data manifold is either difficult or impossible to describe, and relying solely on approximations of the manifold can lead to the creation of crude adversarial examples (Stutz et al., 2019).
14
+
15
+ In this paper, we adopt the boundary-tilting assumption and demonstrate an unexpected benefit of query-efficient zeroth-order attacks, i.e., attacks enabled by the use of dimensionality reduction techniques. These attacks are more likely to discover on-manifold examples, which we theoretically demonstrate is the result of manifold-gradient mutual information. Our results suggest that this quantity can increase as a function of the data dimensionality. This information leakage leads to adversarial examples that are on-manifold generalization errors. With this knowledge, we empirically demonstrate how to improve hard-label attacks in a generic yet principled way, and potentially re-think their interaction with model robustness and public-facing systems in the near future.
16
+
17
+ For clarity, we provide a block diagram of our claims and experiments in the Appendix (Section A.3). Our specific contributions are as follows:
18
+
19
+ • Introduction of manifold distance oracle. To create on-manifold examples, the adversary must (implicitly) leverage manifold information during the attack phase. We thus propose an informationtheoretic formulation of the noisy manifold distance (NMD) oracle, which can explain how zerothorder attacks craft on-manifold examples. We theoretically demonstrate on a Gaussian data model that manifold-gradient mutual information can increase as a function of data dimensionality. We empirically show this is true even on large-scale image datasets such as CIFAR-10 and ImageNet. This finding relates to known behavior in the gradient-level setting, where semantic manifold priors (e.g., shapes and textures) can be leaked from robust models (Engstrom et al., 2019).
20
+
21
+ • Reveal new insights of manifold feedback during query-efficient zeroth-order search. In practice, the data manifold is difficult to characterize. We propose the use of three proxies for manifold distance, which all show consistent results in terms of an adversary’s ability to search near the manifold. This methodology allows us to empirically demonstrate the connection between dimension reduction, model robustness, and manifold feedback from the model, beyond the known convergence rates tied to dimensionality (Nesterov & Spokoiny, 2017). Our findings inform how to search closer to the manifold (Table 1), reduce gradient deviation (Table 2), and improve query efficiency (Figure 2) in a simple and generic way for hard-label attacks.
22
+
23
+ • Attack-agnostic method for super-pixel grouping. We show that spatial dimension reduction of a decision-based gradient estimate acts as an attack- and knowledge-agnostic method for searching over super-pixels of an image. More importantly, this helps an attacker exploit a model’s reaction to salient input changes, leading to samples closer to the manifold compared to the attack on full dimension. As a result, we demonstrate up to $200 \%$ and $340 \%$ success rate improvement for state-of-the-art hard-label attacks HSJA (Chen et al., 2019) and Sign-OPT attack (Cheng et al., 2020), respectively.
24
+
25
+ # 2 RELATED WORK
26
+
27
+ Since the original discovery of adversarial samples against deep models (Szegedy et al., 2013; Goodfellow et al., 2014), the prevailing question was why such examples existed. The original assumption was that adversarial examples lived in low-probability pockets of the input space, and were never encountered during parameter optimization (Szegedy et al., 2013). This effect was believed to be amplified by the linearity of weight activations in the presence of small perturbations (Goodfellow et al., 2014). These assumptions were later challenged by the boundary tilting assumption, which in summary 1) asserts that the train and test sets of a model only occupy a sub-manifold of the true data, while the decision boundary lies close to samples on and beyond the sub-manifold (Tanay & Griffin, 2016), and 2) supports the “data geometric“ view, where high-dimensional geometry of the true data manifold enables a low-probability error set to exist (Gilmer et al., 2018). Likewise the boundary tilting assumption describes adversarial samples as leaving the manifold, which has inspired defenses based on projecting such samples back to the data manifold (Jalal et al., 2019; Samangouei et al., 2018). However, these approaches were later defeated by adaptive attacks (Carlini et al., 2019; Carlini & Wagner, 2017; Tramer et al., 2020).
28
+
29
+ We investigate the scenario where an adversary uses zeroth-order information (i.e., top-1 label feedback) to estimate the desired gradient direction (Cheng et al., 2020; Chen et al., 2019). Contemporary attacks in this setting are variants of random gradient-free method (RGF) (Nesterov & Spokoiny, 2017), and rely on formulations which convert the top-1 (hard) label, which is a step function, into a continuous real-valued function $\cdot$ , which takes search direction $\cdot$ and outputs the distance to the nearest adversarial example (Cheng et al., 2018). The gradient estimate is conceived as a function of the gradient $\cdot$ and can be estimated with either two samples of information (SignOPT) (Cheng et al., 2020), or a single point (HopSkipJumpAttack) (Chen et al., 2019). Details of specific formulations for each attack are provided in Section A.2 of the Appendix.
30
+
31
+ Query efficiency is a persistent desire in the study of hard-label attacks. One clue for achieving efficiency comes from the theory of gradient estimation error and convergence, which shows that the estimation cost is polynomial in $d$ , the dimension of the optimized variable, thus motivating the use of standard dimension-reduction techniques (Tu et al., 2019). However, to date it is not completely understood how this relates to traversal through the data manifold. We leverage previous results of the gradient-level setting (Stutz et al., 2019; Engstrom et al., 2019) to formulate an explanation of manifold leakage during hard-label adversarial attacks.
32
+
33
+ # 3 NOISY MANIFOLD DISTANCE ORACLE
34
+
35
+ Santurkar et al. (2019) demonstrate that the gradients of robust models have higher visual semantic alignment with the data compared to gradients of standard models. We build on this finding by first assuming that the benign observable data generates from a true lower-dimension distribution. Under the boundary-tilting assumption, this lower-dimension distribution forms a manifold onto which new observations, either benign or adversarial, can be encoded (Tanay & Griffin, 2016). Likewise, we assume that deep learning models will learn a lower-dimension representation of the observable data, e.g., feature layers of convolutional neural networks learn to encode training observations onto a low dimension approximate manifold (Zhang et al., 2018). When an adversary creates adversarial samples, they are leveraging a pathway that shadows the model gradient, not the true manifold. Thus there is the possibility that adversarial samples are considered “off-manifold”, e.g., cannot be expected to generate naturally from the true manifold. However, it is critical for adversarial samples to be as close to the manifold as possible, since on-manifold adversarial examples can exploit the fundamental generalization error of the model (Stutz et al., 2019). More formally, we define the notion of manifold distance as follows.
36
+
37
+ Definition 3.1 (Manifold Distance). Consider the benign sample $\mathbf { x } _ { \mathrm { 0 } }$ and adversarial counterpart $\mathbf { x }$ . Assuming a perfect encoding back to the true manifold $\phi$ , the manifold distance is defined as $\mathrm { d } ( \phi ( \mathbf { x } _ { 0 } ) , \phi ( \mathbf { x } ) )$ , where d is a distance function with the domain of the true manifold.
38
+
39
+ Unfortunately, unless the true manifold for a dataset is known, it is impossible to define $\phi$ . Instead, a proxy $\mathrm { d } ^ { \prime }$ can be used such that $\mathrm { d } ^ { \prime } ( \mathbf { x } , \mathbf { x } ^ { \prime } ) \sim \mathrm { d } ( \phi ( \mathbf { x } ) , \phi ( \mathbf { x } ^ { \prime } ) )$ . In practice, one can implement $\mathrm { d } ^ { \prime }$ with any perceptual distance score, such as Learned Perceptual Image Patch Similarity (Zhang et al., 2018). If relying on a distance measure $\mathrm { d }$ , such as the $L _ { p }$ -norm, an approximate encoder $\phi ^ { \prime } ( \cdot ) \^ { - } \phi ( \cdot )$ can be learned using reconstruction-based training of autoencoders (Stutz et al., 2019), or leveraging feature layers of convolutional neural networks (Zhang et al., 2018). We are interested in the class of hard-label adversaries that implicitly minimize some proxy of the manifold distance. Given the result of Santurkar et al. (2019), the robust model’s gradient could be treated as a manifold distance oracle, because it leaks the direction towards its approximate manifold. As a result, the model acts as an oracle responding to queries about manifold distance, or in other words, an implicit proxy for manifold distance, $\mathrm { d } ^ { \prime }$ . In the hard-label setting, the data manifold, true gradient, and model parameters are not accessible. Thus we are interested in a decision-based version of the manifold distance oracle, defined as follows.
40
+
41
+ Definition 3.2 (Noisy Manifold Distance Oracle). Consider a manifold distance oracle instantiating $\mathrm { d } ^ { \prime }$ , benign sample $\mathbf { x } _ { \mathrm { 0 } }$ , and pair of adversarial samples $( \mathbf { x } ^ { \prime } , \mathbf { x } ^ { \prime \prime } )$ such that $\mathrm { d } ^ { \prime } ( \mathbf { x } _ { 0 } , \mathbf { x } ^ { \prime } ) < \mathrm { d } ^ { \prime } ( \mathbf { x } _ { 0 } , \mathbf { x } ^ { \prime \prime } ) $ , e.g., $\mathbf { x } ^ { \prime }$ is considered on-manifold while $\mathbf { x } ^ { \prime \prime }$ is not. In the hard-label setting, the noisy manifold distance (NMD) oracle instantiates $\mathrm { d } ^ { \prime \prime }$ such that $\mathrm { d } ^ { \prime \prime } ( \mathbf { x } _ { 0 } , \mathbf { x } ^ { \prime } ) = 0$ and $\mathrm { d } ^ { \prime \prime } ( \mathbf { x } _ { 0 } , \mathbf { x } ^ { \bar { \prime } \prime } ) = 1$ .
42
+
43
+ During a hard-label attack, the adversary searches in a direction that minimizes perceptual distance to the original sample. Concurrently, the adversary can be said to implicitly minimize the expected output of the NMD oracle, which is a binary indicator that a sample is on-manifold or not. Without knowledge of the true (or approximate) manifold, this requires careful selection of the search direction from the current sample. Since the search direction of contemporary hard-label attacks is synthesized over expectation of a ball around the adversarial sample, we are interested in search directions such as $\mathbf { x } _ { 0 } - \mathbf { x } ^ { \prime }$ which minimize the expected distance to the manifold.
44
+
45
+ To formalize the entailed information in the NMD oracle, we turn to a standard result in data processing, which states the following:
46
+
47
+ Definition 3.3 (Data Processing Inequality (DPI) (Beaudry & Renner, 2012)). If three random variables form the Markov chain $X Y Z$ , then their mutual information (MI) has the relation $I ( X ; Y ) \geqslant I ( X ; Z )$ .
48
+
49
+ We assume the data manifold $\mathcal { M }$ , the input gradient $\mathcal { G }$ , and the hard-label gradient estimate $\ddot { \mathcal { G } }$ will form the Markov chain $\mathcal { M } \to \mathcal { G } \to \ddot { \mathcal { G } }$ . This assumption is reasonable due to the observations by Santurkar et al. (2019); modifying the sampled data manifold (e.g., by adding adversarial samples through saddle-point optimization) causally induces a smoother loss surface, which imposes its own gradient distribution. Likewise, the true gradient and gradient estimate of hard-label attack are causally linked due to the estimate’s bounded variance (Cheng et al., 2020).
50
+
51
+ If $I ( { \mathcal { M } } , { \mathcal { G } } )$ is larger for adversarially robust models, by Definition 3.3 the upper bound on $I ( { \mathcal { M } } , { \ddot { \mathcal { G } } } )$ is larger, which means more manifold information could be leaked in the noisy gradient. This information could be used to search in the direction where $\mathrm { d } ^ { \prime \prime }$ is minimized in expectation, leading towards on-manifold examples. However, DPI only offers an upper bound, thus the distance decrease is not guaranteed, only suggested. In the information theoretic sense, does this mean the gradients of models robust in an $\epsilon$ -ball around each sample can reveal more information about the distance to training data than standard models? An immediate follow-up concern is whether other factors can influence the model to reveal this information, such as the problem dimensionality. As a first step we posit the following hypothesis:
52
+
53
+ Hypothesis 1. Consider the manifold distribution $\mathcal { M }$ which can generate data to train a natural model with gradient distribution $\mathcal { G }$ , and train robust model with smoothed gradient distribution $\mathcal { G } ^ { \prime }$ . We posit that their manifold-gradient mutual information $I$ has the relation $\bar { I } ( \mathcal { M } , \mathcal { G } ^ { \prime } ) \geq I ( \mathcal { M } , \mathcal { G } )$ .
54
+
55
+ In order to empirically verify Hypothesis 1, we must parameterize the notion of model robustness while solving for $I ( { \mathcal { M } } , { \mathcal { G } } )$ , given an arbitrary gradient distribution $\mathcal { G }$ and manifold distribution $\mathcal { M }$ Schmidt et al. (2018) have shown that robust training requires additional data as a function of the data dimensionality. We leverage the data model and results from Schmidt et al. (2018) to derive an analytical solution for $I ( \mathcal { M } , \bar { \mathcal { G } } )$ , since we can parameterize model robustness as a function of data size and dimensionality. Consequently, the remainder of our theoretical analysis assumes a Gaussian mixture data model.
56
+
57
+ Definition 3.4 (Data model and optimal weights (Schmidt et al., 2018)). Let $\pmb { \mu } \in \mathbb { R } ^ { d }$ be the per-class centers (means) and let $\sigma > 0$ be the variance parameter. Then the $( \mu , \sigma I )$ -Gaussian model is defined by the following distribution over $( \mathbf { x } , y ) \in \bar { \mathbb { R } ^ { d } } \times \{ \pm 1 \}$ : First, draw a label $y \in \{ \pm 1 \}$ uniformly at random. Then sample the data point $\mathbf { x } \in \mathbb { R } ^ { d }$ from $\mathcal { N } ( \boldsymbol { y } \cdot \boldsymbol { \mu } , \sigma \boldsymbol { I } )$ .
58
+
59
+ Definition 3.5 (Optimal classification weight (Schmidt et al., 2018)). Fix $\sigma \leq c _ { 1 } d ^ { \frac { 1 } { 4 } }$ for the universal constant $c _ { 1 }$ , and samples $( \mathbf { x } _ { 1 } , y _ { 1 } ) , \cdot \cdot \cdot , ( \mathbf { x } _ { n } , y _ { n } )$ drawn $i . i . d$ from the $( \mu , \sigma I )$ -Gaussian model with $| | { \boldsymbol { \mu } } | | = { \sqrt { d } }$ (i.e., $\mu _ { k } = 1$ for all dimensions $k \in \{ 0 , \ldots , d \} )$ . Schmidt et al. (2018) prove that the weight setting $\begin{array} { r } { \widehat { \mathbf { w } } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } y _ { i } \mathbf { x } _ { i } } \end{array}$ yields an $l _ { \infty } ^ { \epsilon }$ -robust classification error of at most $1 \%$ for the linear classifier $f _ { \widehat { \mathbf { w } } } : \mathbb { R } ^ { d } \{ \pm 1 \}$ instantiated as $f _ { \widehat { \mathbf { w } } } ( x ) = \mathrm { s i g n } ( \widehat { \mathbf { w } } ^ { T } \mathbf { x } )$ if
60
+
61
+ $$
62
+ n \geq \left\{ \begin{array} { l l } { { 1 , } } & { { \mathrm { f o r } ~ \epsilon \leq \frac 1 4 d ^ { - \frac 1 4 } } } \\ { { c _ { 2 } \epsilon ^ { 2 } \sqrt { d } , } } & { { \mathrm { f o r } ~ \frac 1 4 d ^ { - \frac 1 4 } \leq \epsilon \leq \frac 1 4 } } \end{array} , \right.
63
+ $$
64
+
65
+ for a universal constant $c _ { 2 }$
66
+
67
+ Note that the instantiation of $\widehat { \bf w }$ must change with choice of $\epsilon$ and $d$ . We can leverage the weight settings as a function of $n$ and $d$ to give a definition of manifold-gradient mutual information.
68
+
69
+ ![](images/9298751749e2f7005a373cca6de066290617a0be2d685819c61603b29325bba5.jpg)
70
+ Figure 1: a) Average per-dimension mutual information $\cdot$ over dimension $d$ for values of $c _ { 2 }$ and $\epsilon$ in Equation 13, log-scale $\cdot$ -axis with $\cdot$ , average over ten seeds. The approximate mutual information is higher for robust and standard models at lower $d$ regardless of $\cdot$ and choice of $\cdot$ .
71
+
72
+ # 3.1 MANIFOLD-GRADIENT MUTUAL INFORMATION
73
+
74
+ Notice the classifier $\operatorname { s g n } ( { \mathord { \cdot } } )$ in Definition 3.5 is discontinuous at ${ \bf x } _ { k } = 0$ for any dimension $k$ . Instead we consider the sub-gradient of the classifier at $\mathbf { x } _ { k } < 0$ and $\mathbf { x } _ { k } > 0$ . In either case (non-robust or robust), the input sub-gradient for $f _ { \widehat { w } } ( \mathbf { x } _ { k } ^ { \prime } )$ is defined dimension-wise for our isotropic Gaussian as $\nabla _ { \mathbf x _ { k } ^ { \prime } } f _ { \widehat { \mathbf w _ { k } } } = \mathrm { s i g n } \mathbf w _ { k }$ b. Since the weight of each dimension is Gaussian distributed with $\widehat { \mathbf { w } _ { k } } \sim$ $\mathcal { N } ( \mu _ { k } , \sigma ^ { 2 } )$ , we can define the distribution of gradients as $\mathcal { G } \sim$ Rademacher $\left( \mathbb { P } _ { \widehat { \mathbf { w } _ { k } } \sim \mathcal { N } } \left[ \widehat { \mathbf { w } _ { k } } \geq 0 \right] \right) ,$ ). c cUsing this fact, we define manifold-gradient mutual information in three parts: 1) defining the manifold-gradient point-wise joint probabilities between $\mathbf { g } _ { k }$ and $\mathbf { x } _ { k }$ at each dimension $k$ for the sub-gradient cases where $\mathbf { x } _ { k } > 0$ and $\mathbf { x } _ { k } < 0 , 2$ ) defining the manifold-gradient marginal probability under the gradient, and 3) the marginal probability under the manifold. The complete derivation of the joint and marginal probabilities can be found in Section A.1 of the Appendix. The three parts are used in the standard definition of mutual information (Cover & Thomas, 2006).
75
+
76
+ Notation. Fix $\sigma = c _ { 1 } d ^ { \frac { 1 } { 4 } }$ for both cases. We denote the sub-manifold sampled from the positive $( y = 1 )$ ) and negative $( y = - 1$ ) classes as $\mathcal { M } ^ { + }$ and $\mathcal { M } ^ { - }$ , respectively. For brevity we label $\mathbf { x } _ { k } > 0$ as $\mathbf { x } ^ { + }$ and $\mathbf { x } _ { k } < 0$ as $\mathbf { x } ^ { - }$ .
77
+
78
+ Definition 3.6 (Manifold-Gradient Mutual Information). We define the manifold-gradient mutual information, based on the standard definition of mutual information from information theory (Cover & Thomas, 2006), as
79
+
80
+ $$
81
+ I ( \mathcal M , \mathcal G ) _ { \epsilon , k } = 2 \int _ { \mathcal M ^ { + } } p ( 1 , \mathbf x ^ { + } ) \log ( \frac { p ( 1 , \mathbf x ^ { + } ) } { p _ { \mathcal G } ( 1 ) p _ { \mathcal M } ( \mathbf x ^ { + } ) } ) d \mathbf x ^ { + } + 2 \int _ { \mathcal M ^ { + } } p ( - 1 , x ^ { + } ) \log ( \frac { p ( - 1 , x ^ { + } ) } { p _ { \mathcal G } ( - 1 ) p _ { \mathcal M } ( x ^ { + } ) } ) d x ^ { + } .
82
+ $$
83
+
84
+ with the total unnormalized mutual information defined as the summation over dimensions (due to dimension co-independence) $\begin{array} { r } { I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon } = \sum _ { k = 1 } ^ { d } I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , k } } \end{array}$ .
85
+
86
+ # 3.2 MUTUAL INFORMATION AS A FUNCTION OF DIMENSIONALITY
87
+
88
+ To provide numerical support for Hypothesis 1, we run experiments using the Riemann approximation of Equation 13, provided in the Appendix as Equation 15. We estimate the average per-dimension mutual information, $\begin{array} { r } { I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , \overline { { k } } } = \frac { I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon } } { d } } \end{array}$ I(M,G)d , for the case where x ∈ Rd while varying the dimensionality term $\cdot$ against values of $c _ { 2 } \in \{ 1 , 1 0 0 \}$ and $-$ . The values of $c _ { 2 }$ represent two multiplicative factors for number of samples in robust models (Equation 1). In our experiments, we target an error within $1 0 ^ { - 1 }$ (e.g., $-$ . Thus we multiply each branch of Equation 1 by a large constant $( 1 0 ^ { 4 } )$ . We run the approximation over ten different random seeds and show the average with standard error shaded.
89
+
90
+ The estimation result is shown in Figure 1 with log-scale $\mathbf { X }$ -axis. Regardless of $c _ { 2 }$ and $\epsilon$ , lower values of the dimensionality evidence a higher mutual information. We minimize variance of the estimate when $\cdot$ (right plot shaded area), which follows intuition due to the higher sample count in the estimate.
91
+
92
+ Observation 1. Given reduced data dimensionality, a robust model could increase $I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , \overline { { k } } }$ and lead to leaking better search direction through the gradient (e.g., act as manifold distance oracle). This supports Hypothesis 1.
93
+
94
+ This can theoretically explain the high visual alignment observed empirically by Engstrom et al. (2019) and Santurkar et al. (2019) on robust models. From the security perspective, the NMD oracle acts as a side channel leaking sensitive information as a factor of the model robustness and data dimensionality.
95
+
96
+ # 4 ZEROTH-ORDER SEARCH THROUGH THE MANIFOLD DISTANCE ORACLE
97
+
98
+ According to Observation 1, the true gradient and manifold of a robust model have higher mutual information, and this is exacerbated by reducing the data dimensionality. Under our Markov chain assumption, this means an attack algorithm can act as a noisy manifold distance oracle, and this oracle could be upper bounded by the true gradient-manifold mutual information. Although the data dimensionality and robustness are controlled by the model designer, an attacker can search in arbitrarily lower dimensionality through dimension-reduction techniques, such as autoencoder-based attacks (Tu et al., 2019). In fact, in the image domain the intrinsic dimensionality of data can be lower than the true dimension (Amsaleg et al., 2017). In order to connect the notion of manifold-gradient mutual information with on-manifold adversarial samples of real datasets, we posit the following.
99
+
100
+ Hypothesis 2. Consider Observation 1 and Definition 3.3 (DPI), then due to the higher upper bound on $I ( { \mathcal { M } } , { \ddot { \mathcal { G } } } )$ and leaking better search directions, a hard-label adversary can minimize $d ^ { \prime \prime }$ in expectation on robust models when the gradient estimate dimensionality is reduced.
101
+
102
+ In the most common problem setting, the adversary is interested in attacking a $K$ -way multiclass classification model $f : \mathbb { R } ^ { d } \mathbf { \bar { \{ 1 , \dots , K \} } }$ . Given an original example $\mathbf { x } _ { \mathrm { 0 } }$ , the goal is to generate adversarial example $\mathbf { x }$ such that $\mathbf { x }$ is close to $\mathbf { x } _ { \mathrm { 0 } }$ and $f ( \mathbf { \bar { x } } ) \neq f ( \mathbf { x } _ { 0 } )$ , where closeness is often approximated by the $L _ { p }$ -norm of ${ \bf x } - { \bf x } _ { 0 }$ . In the gradient-level setting, we require the gradient $\nabla f ( \cdot )$ . However, in the hard-label setting we are forced to estimate $\frac { \partial f ( \mathbf { x } ) } { \partial \mathbf { x } }$ without access to $\nabla f ( \cdot )$ , only decision evaluations of $f$ . Rather than optimizing the step function $\boldsymbol { \mathscr { f } }$ , hard-label attacks minimize the continuous function $g ( \pmb \theta )$ , which is an estimate of the distance to the nearest decision boundary in the direction $\pmb \theta$ . We evaluate the effect of dimension reduction on Sign-OPT attack (Cheng et al., 2020) and HopSkipJumpAttack (HSJA) (Chen et al., 2019), as both are considered state-of-the-art in the literature, and rely on minimization of $g ( \cdot )$ . We provide a brief overview of their formulation in Section A.2 of the Appendix, and leave details to the respective authors’ work. Alternative hard-label attacks, such as RayS by Chen & Gu (2020), do not rely on the explicit zeroth-order gradient estimate from the model. This style of attack behaves differently since it can adapt to the problem dimension independent of the true gradient, which we demonstrate in Section A.5.6 of the Appendix.
103
+
104
+ # 4.1 DIMENSION-REDUCED ZEROTH-ORDER SEARCH
105
+
106
+ To test Hypothesis 2, we modify existing hard-label attacks to produce dimension-reduced variants. This scheme enables dynamic scaling of the effective dimensionality regardless of specific attack formulation. In practice we implement the reduction through an encoding map $\mathcal { E } : \mathbb { R } ^ { d } \mathbb { R } ^ { d ^ { \prime } }$ for reduced dimension $d ^ { \prime }$ and decoding map $\mathcal { D } : \mathbb { R } ^ { d ^ { \prime } } \mathbb { R } ^ { d }$ . In general the adversarial sample is created by $\begin{array} { r } { \mathbf { x } = \mathbf { x } _ { 0 } + g \left( { \cal D } ( \pmb { \theta } ^ { \prime } ) \right) \frac { \pmb { \mathcal { D } } ( \pmb { \theta } ^ { \prime } ) } { | | \pmb { \mathcal { D } } ( \pmb { \theta } ^ { \prime } ) | | } } \end{array}$ , where $\pmb { \theta } ^ { \prime } \in \mathbb { R } ^ { d ^ { \prime } }$ and is optimized depending on the respective attack (e.g., Sign-OPT and HSJA), and as before, $g$ is a measure of distance to the decision boundary in direction ${ \mathcal { D } } ( \theta ^ { \prime } )$ . The mapping functions can be initialized with either an autoencoder (AE), or a pair of channel-wise bilinear transform functions (henceforth referred to as BiLN) which simply scales the spatial dimension of the input up or down. This represents two distinct methods to search over super-pixels of the image, which either rely on an approximate description of the manifold (AE), or instead exploit the known spatial co-dependence of images (BiLN). The implementation and training details of the AE variant can be found in Section A.4.2 of the Appendix. To study the effect of dimension-reduction without semantic information, we implement a random variant of BiLN (Rand) which samples a subset of coordinates uniform-randomly from the source image as the dimension-reduced version, then replaces the pixels at these coordinates with those from the gradient estimate. This is meant to show the effect of discarding some semantic information (e.g., spatial correlation) in the update.
107
+
108
+ # 4.2 ESTIMATING MANIFOLD DISTANCE
109
+
110
+ We leverage three proxies of manifold distance in order to test Hypothesis 2. The Learned Perceptual Image Patch Similarity (LPIPS) acts as a proxy for manifold distance, $\mathrm { d } ^ { \prime }$ , and computes a distance that correlated well with human perception in human studies (Zhang et al., 2018; Laidlaw et al., 2021). We use the same LPIPS code and checkpoint provided by the authors. Frechet Inception ´ Distance (FID) (Heusel et al., 2018) is similar to LPIPS, and leverages the internal representations of deep networks as an approximate encoding onto the manifold. Although FID lacks human studies, Heusel et al. (2018) show it is viable for scoring the visual quality of synthetically generated images, which offers us a comparison against LPIPS. In addition to LPIPS and FID, we create an approximate encoding $\phi ^ { \prime }$ by taking the encoder of trained autoencoders for each dataset, which can be used to compute $L _ { \infty }$ distance between encoded samples. In other words, this lets us compute $| | \phi ^ { \prime } ( \mathbf { x } _ { 0 } ) - \phi ^ { \prime } ( \bar { \mathbf { x } } ) | | _ { \infty }$ for benign sample $\mathbf { x } _ { \mathrm { 0 } }$ and adversarial sample x. The results on FID and our trained autoencoder were consistent with LPIPS, so they are described in Section A.5.9 of the Appendix.
111
+
112
+ Finally, if hard-label gradient estimates on real-world data resulted in a sample close to the approximate manifold, we could say the gradient estimates leveraged noisy mutual information, which may be upper bounded by the clean mutual information (Hypothesis 1). This would manifest in a lower gradient deviation, or in other words, the distance between the true gradient and gradient estimate at the first attack step. We can further infer that the adversarial training effectively smooths the sampled data manifold (which generates from true manifold) by augmenting perturbed data samples during training. The smoothing yields a well-defined boundary that aligns with salient input changes (Santurkar et al., 2019), and should further lower variance of the gradient estimate compared to natural models, which improves the baseline performance of an attack. We test this by calculating per-pixel gradient deviation $\frac { | | \mathbf { g } - \hat { \mathbf { g } } | | _ { 2 } } { H \times W }$ for true gradient $\mathbf { g }$ (in the direction of the adversarial label), first gradient estimate $\hat { \bf g }$ , estimate height $H$ , and estimate width $W$ . When taking the true input gradient in the direction of the adversarial label, we use the victim model’s original criterion to calculate the gradient, which was cross-entropy for all models in our evaluation.
113
+
114
+ # 5 RESULTS & DISCUSSION
115
+
116
+ We test Hypothesis 2 by comparing two SotA hard-label attacks with their compatible dimensionreduced variants, against both natural and robust models. First we show empirical evidence of the relationship between manifold distance and dimension-reduced attacks in Section 5.1. Next in Section 5.2, we investigate the result of Section 5.1 from the perspective of reducing error in the gradient estimate. Finally in Section 5.3, we show how these observations inform better attack design.
117
+
118
+ Setup. We perform experiments using CIFAR-10 (Krizhevsky, 2009) and ImageNet (Krizhevsky et al., 2012) for RGB image data. The natural CIFAR-10 network is the same implementation opensourced by Cheng et al. (2020). The architecture for ImageNet is the Resnet50 network taken from the PyTorch Torchvision library, and the accompanying pre-trained weights act as the natural model.1 In addition, we leverage the representative adversarial training technique proposed by Madry et al. (2017) (and their  = 8255 $\epsilon = \overline { { \frac { 8 } { 2 5 5 } } } = 0 . \dot { 0 3 } 1$ checkpoints for $L _ { \infty }$ setting) as the robust models for CIFAR-10 and ImageNet. The BiLN variants downscale to $1 6 \times 1 6$ for CIFAR-10, and $3 2 \times 3 2$ for ImageNet. We use $L _ { \infty }$ -norm versions of attacks for all experiments, and the same $\epsilon$ values for natural models as the robust CIFAR-10 and robust ImageNet (hereafter referred to as Madry CIFAR-10 and Madry ImageNet). All attacks run for $2 5 \mathrm { k }$ queries without early stopping on correctly classified samples. For brevity, we only show results for the untargeted case. Additional implementation details, such as hyperparameters and hardware used, can be found in the Appendices (Section A.4). Code for experiments is provided in the supplementary materials.
119
+
120
+ Table 1: Average LPIPS scores for each attack’s set of 200 adversarial samples on CIFAR-10 and ImageNet (lower is better). Arrows denote higher or lower score compared to baseline variant, and starred items indicate highest success rate.
121
+
122
+ <table><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>0.132 ± 0.098*</td><td>1.335 ± 0.611</td><td>0.257 ± 0.378</td><td>1.249 ± 0.652</td></tr><tr><td>HSJA+BiLN</td><td>0.252 ±0.165个</td><td>1.147 ± 0.535↓*</td><td>0.170 ± 0.143↓*</td><td>1.205± 0.711↓*</td></tr><tr><td>HSJA+Rand</td><td>1.433 ± 0.747个</td><td>2.384± 0.503个</td><td>1.276 ± 0.649个</td><td>1.183 ± 0.596↓</td></tr><tr><td>Sign-OPT</td><td>0.105 ± 0.081</td><td>0.768 ±0.408</td><td>0.768± 0.872</td><td>1.229 ± 0.771</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.225 ± 0.146个</td><td>0.849 ± 0.397个</td><td>0.176 ± 0.204↓</td><td>0.708 ±0.461↓</td></tr><tr><td>Sign-OPT+Rand</td><td>0.440 ± 0.464个</td><td>1.021 ± 0.593个</td><td>0.356 ± 0.385↓</td><td>0.367 ± 0.361↓</td></tr><tr><td>Sign-OPT+AE</td><td>0.331 ± 0.389↑</td><td>0.660 ± 0.302↓</td><td>1.034 ± 0.571个</td><td>1.658 ± 0.638个</td></tr></table>
123
+
124
+ <table><tr><td>Med. Benign Local ID</td><td>0.469</td><td>0.224</td><td>1.039</td><td>2.013</td></tr><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>6.65 ± 0.61*</td><td>5.46 ±0.06</td><td>77.35 ± 0.04</td><td>77.32 ± 0.00</td></tr><tr><td>HSJA+BiLN</td><td>5.37 ± 0.69↓</td><td>3.86 ±0.10↓*</td><td>55.12 ± 1.37↓*</td><td>56.14±0.12↓</td></tr><tr><td>HSJA+Rand</td><td>11.33 ± 7.41个</td><td>2.01 ±1.65↓</td><td>72.19 ± 59.98↓</td><td>3.22 ±2.73</td></tr><tr><td>Sign-OPT</td><td>3.72 ± 0.99</td><td>0.71 ±0.38</td><td>1.70 ± 1.01</td><td>0.55 ± 0.18</td></tr><tr><td>Sign-OPT+BiLN</td><td>3.71 ± 1.02↓</td><td>0.78 ± 0.35个</td><td>1.83 ± 0.97个</td><td>1.74 ± 0.56个</td></tr><tr><td>Sign-OPT+Rand</td><td>8.21 ± 6.67个</td><td>2.32 ± 2.07个</td><td>37.54± 46.20个</td><td>6.72 ± 1.54个</td></tr><tr><td>Sign-OPT+AE</td><td>4.66 ± 0.86↑</td><td>2.48 ± 0.32↑</td><td>36.83 ± 0.15个</td><td>36.87 ± 0.31↑</td></tr></table>
125
+
126
+ Table 2: Average per-pixel gradient deviation on natural and robust CIFAR-10 (unit of $1 0 ^ { - 2 }$ ) and ImageNet (unit of $\mathrm { { \bar { 1 0 } ^ { - 4 } } }$ ) over 200 samples. Top row lists the median Local Intrinsic Dimensionality (LID) of benign samples from the dataset. Arrows denote higher or lower deviation compared to baseline variant, and starred items indicate highest success rate.
127
+
128
+ # 5.1 MANIFOLD DISTANCE
129
+
130
+ LPIPS results are shown in Table 1, with colored arrows denoting either lower distance than baseline variant (green arrow), or a higher distance (red arrow). Generally, the dimension-reduced variants lower the proxy of manifold distance on ImageNet more often than on CIFAR-10 (green arrows). The random sampling variant $\times$ -Rand) discards the semantic priors of the estimate, and in fact it achieved the lowest SR AUC scores, despite having lower scores. Our results using LPIPS are consistent with $L _ { \infty }$ distance of the manifold approximation (Section A.5.9), and Frechet Inception Distance ´ (Section A.5.8), which all demonstrate a tendency to be lower with dimension-reduced attacks.
131
+
132
+ Observation 2. Dimension-reduced hard-label attacks can have lower LPIPS score, $L _ { \infty }$ approximated distance, and Frechet Inception Distance (and thus lower manifold distance) on robust models ´ if they preserve semantic priors in the update, which supports Hypothesis 2.
133
+
134
+ # 5.2 GRADIENT DEVIATION
135
+
136
+ The results for gradient deviation are shown in Table 2. Notably, an attack can have high gradient deviation despite low LPIPS score (AE case, bottom row). Likewise, low deviation does not imply successful attack, as we show later with the Rand variant (rows three and six). We investigated why Madry ImageNet did not always have lower gradient deviation, which we posit is due to having a higher true dimensionality. For the benign samples of each dataset we estimated the Local Intrinsic Dimensionality (LID), which was proposed to estimate true data dimensionality in a region around samples (Amsaleg et al., 2017). In the top row of Table 2 we find the median LID is similar between natural and robust CIFAR-10, but much higher on robust ImageNet than natural. Since our results of Section 3 suggested that higher problem dimension reduced mutual information, we suspect the Madry ImageNet model reduces the leakage through the NMD oracle through higher true data dimensionality. We leave a deeper analysis of this direction for future work. Results on additional robust CIFAR-10 models are provided in Section A.5.2 of the Appendix, which exhibited a similar trend of lower gradient deviation. Sign-OPT has a universally lower gradient deviation than HSJA, which aligns with findings of Liu et al. (2020).
137
+
138
+ ![](images/971f85b87184092256aa2eb10969112b19791694002b8015fda63e6d1ce816e1.jpg)
139
+ Figure 2: Success rates across attacks over 200 samples on CIFAR-10 (a) and ImageNet (b).
140
+
141
+ Observation 3. The gradient deviation is universally lower on the robust CIFAR-10 model for BiLN attacks (rows two and five). For ImageNet, deviation on robust models is either lower or similar (rows one, two, four, and seven).
142
+
143
+ # 5.3 INFORMING PRACTICE
144
+
145
+ We have shown that dimension reduction has unexpected consequences in terms of manifold distance, and on CIFAR-10 and some ImageNet cases, leads to a lower gradient deviation on the robust model. We finalize our contribution by providing a comprehensive evaluation of the attack success rates in Figure 2 against number of queries. The plots are quantified by taking their max-normalized Trapezoid rule area-under-curve (AUC).2 For comparison, the highest AUC scores are starred in the previous tables. Our dimension-reduced HSJA $+$ BiLN variant (yellow line) surpasses the previous SotA hard-label attack for ImageNet, HSJA, on both natural and robust models. This variant also exhibited the lowest LPIPS score across attack variants. However, lowest LPIPS score does not imply highest SR, evidenced with HSJA $^ +$ Rand on natural ImageNet (brown line, $\mathrm { A U C } = 0 . 0 7 7 $ and SignOPT variants on either dataset (e.g., yellow line in Madry ImageNet, $\mathbf { A U C } = 0 . 2 1 5 ,$ . Low gradient deviation does not imply higher attack success, evidenced by Sign-OPT $+$ BiLN in Table 2 for Madry CIFAR-10 $( \mathrm { A U C } = 0 . 1 5 6 )$ or HSJA $^ { + }$ Rand and Sign-OPT $^ { + }$ Rand $( \mathrm { A U C } = 0 . 0 8 8$ and $\mathrm { { A U C } = 0 . 0 9 2 }$ , respectively). The Rand variants, combined with our findings so far, allow us to say the following.
146
+
147
+ Observation 4. Successful attacks exhibit preservation of leaked semantic priors. Measures of manifold distance such as LPIPS tend to be lower on dimension-reduced attacks, independent of variance in the gradient estimate.
148
+
149
+ We posit that minimizing gradient deviation through correction of estimator bias alone could be misleading, since the semantic information provided by a better NMD oracle (due to dimension reduction) can potentially improve the gradient deviation. Although our theoretical analysis focuses on robust models, we suspect future hard-label attacks may treat $\epsilon$ as a useful prior, which carries with it implications about when to deploy robust models in society. On the contrary, natural models will respond to any input changes, even if they are semantically meaningless (Santurkar et al., 2019), so depending on the adversary’s goal (e.g., evasion or information leakage), they could be less useful in the hard-label setting.
150
+
151
+ # 6 CONCLUSION
152
+
153
+ Despite the recent progress in zeroth-order attack methods, open questions remain about their precise behavior. We develop an information-theoretic analysis that sheds light on their ability to produce on-manifold adversarial examples. Through experiments on real-world datasets, we show an over two-fold increase in attack success rates by leveraging new findings about manifold distance and gradient deviation. With knowledge of the manifold-gradient relationship, it is possible to further refine hard-label attacks, and inform a better evaluation of model robustness. Given the availability of larger datasets in the future, our method may turn the strength of deep learning, which is efficiently extracting patterns in large-scale data, into a weakness.
154
+
155
+ # REFERENCES
156
+
157
+ L. Amsaleg, J. Bailey, D. Barbe, S. Erfani, M. E. Houle, V. Nguyen, and M. Radovanovic. The ´ vulnerability of learning to adversarial perturbation increases with intrinsic dimensionality. In 2017 IEEE Workshop on Information Forensics and Security (WIFS), pp. 1–6, December 2017. doi: 10.1109/WIFS.2017.8267651.
158
+ Normand J. Beaudry and Renato Renner. An intuitive proof of the data processing inequality. arXiv:1107.0740 [quant-ph], September 2012. URL http://arxiv.org/abs/1107.0740. arXiv: 1107.0740.
159
+ Wieland Brendel, Jonas Rauber, and Matthias Bethge. Decision-Based Adversarial Attacks: Reliable Attacks Against Black-Box Machine Learning Models. arXiv:1712.04248 [cs, stat], December 2017. URL http://arxiv.org/abs/1712.04248. arXiv: 1712.04248.
160
+ Nicholas Carlini and David Wagner. Towards Evaluating the Robustness of Neural Networks. In Security and Privacy (SP), pp. 582–597, 2016. ISBN 978-1-5090-5533-3. doi: 10.1109/SP.2017.49. arXiv: 1608.04644 ISSN: 10816011.
161
+ Nicholas Carlini and David Wagner. Adversarial Examples Are Not Easily Detected: Bypassing Ten Detection Methods. In Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security - AISec ’17, pp. 3–14, Dallas, Texas, USA, 2017. ACM Press. ISBN 978-1-4503-5202- 4. doi: 10.1145/3128572.3140444. URL http://dl.acm.org/citation.cfm?doid= 3128572.3140444.
162
+ Nicholas Carlini, Anish Athalye, Nicolas Papernot, Wieland Brendel, Jonas Rauber, Dimitris Tsipras, Ian Goodfellow, Aleksander Madry, and Alexey Kurakin. On Evaluating Adversarial Robustness. arXiv:1902.06705 [cs, stat], February 2019. URL http://arxiv.org/abs/1902.06705. arXiv: 1902.06705.
163
+ Jianbo Chen, Michael I. Jordan, and Martin J. Wainwright. HopSkipJumpAttack: A Query-Efficient Decision-Based Attack. arXiv:1904.02144 [cs, math, stat], April 2019. URL http://arxiv. org/abs/1904.02144. arXiv: 1904.02144.
164
+ Jinghui Chen and Quanquan Gu. RayS: A Ray Searching Method for Hard-label Adversarial Attack. arXiv:2006.12792 [cs, stat], June 2020. URL http://arxiv.org/abs/2006.12792. arXiv: 2006.12792.
165
+ Pin-Yu Chen, Huan Zhang, Yash Sharma, Jinfeng Yi, and Cho-Jui Hsieh. ZOO: Zeroth order optimization based black-box attacks to deep neural networks without training substitute models. In ACM Workshop on Artificial Intelligence and Security, pp. 15–26, 2017.
166
+ Pin-Yu Chen, Yash Sharma, Huan Zhang, Jinfeng Yi, and Cho-Jui Hsieh. Ead: elastic-net attacks to deep neural networks via adversarial examples. In Thirty-second AAAI conference on artificial intelligence, 2018.
167
+ Minhao Cheng, Thong Le, Pin-Yu Chen, Jinfeng Yi, Huan Zhang, and Cho-Jui Hsieh. Query-Efficient Hard-label Black-box Attack:An Optimization-based Approach. arXiv:1807.04457 [cs, stat], July 2018. URL http://arxiv.org/abs/1807.04457. arXiv: 1807.04457.
168
+
169
+ Minhao Cheng, Thong Le, Pin-Yu Chen, Jinfeng Yi, Huan Zhang, and Cho-Jui Hsieh. Queryefficient hard-label black-box attack: An optimization-based approach. International Conference on Learning Representations, 2019.
170
+
171
+ Minhao Cheng, Simranjit Singh, Patrick Chen, Pin-Yu Chen, Sijia Liu, and Cho-Jui Hsieh. SIGNOPT: A QUERY-EFFICIENT HARD-LABEL ADVERSARIAL ATTACK. The International Conference on Learning Representations (ICLR), pp. 16, 2020. URL https://openreview. net/forum?id ${ . } = { }$ SklTQCNtvS.
172
+
173
+ Jeremy M. Cohen, Elan Rosenfeld, and J. Zico Kolter. Certified Adversarial Robustness via Randomized Smoothing. arXiv:1902.02918 [cs, stat], February 2019. URL http://arxiv.org/ abs/1902.02918. arXiv: 1902.02918.
174
+
175
+ Thomas M Cover and Joy A Thomas. Elements of Information Theory. Wiley-Interscience. John Wiley & Sons, 2nd edition, 2006.
176
+
177
+ Logan Engstrom, Andrew Ilyas, Shibani Santurkar, Dimitris Tsipras, Brandon Tran, and Aleksander Madry. Learning Perceptually-Aligned Representations via Adversarial Robustness. arXiv:1906.00945 [cs, stat], June 2019. URL http://arxiv.org/abs/1906.00945. arXiv: 1906.00945.
178
+
179
+ Ryan Feng, Jiefeng Chen, Nelson Manohar, Earlence Fernandes, Somesh Jha, and Atul Prakash. Query-Efficient Physical Hard-Label Attacks on Deep Learning Visual Classification. arXiv:2002.07088 [cs], February 2020. URL http://arxiv.org/abs/2002.07088. arXiv: 2002.07088.
180
+
181
+ Matt Fredrikson, Somesh Jha, and Thomas Ristenpart. Model Inversion Attacks that Exploit Confidence Information and Basic Countermeasures. Proceedings of the 22nd ACM SIGSAC Conference on Computer and Communications Security - CCS ’15, pp. 1322–1333, 2015. ISSN 15437221. doi: 10.1145/2810103.2813677. URL http://dl.acm.org/citation.cfm? doid ${ . } =$ 2810103.2813677. ISBN: 9781450338325.
182
+
183
+ Justin Gilmer, Luke Metz, Fartash Faghri, Samuel S. Schoenholz, Maithra Raghu, Martin Wattenberg, and Ian Goodfellow. The Relationship Between High-Dimensional Geometry and Adversarial Examples. arXiv:1801.02774 [cs], September 2018. URL http://arxiv.org/abs/1801. 02774. arXiv: 1801.02774.
184
+
185
+ Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and Harnessing Adversarial Examples. 2014. ISSN 0012-7183. URL http://arxiv.org/abs/1412.6572. arXiv: 1412.6572 ISBN: 1412.6572.
186
+
187
+ 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. arXiv:1706.08500 [cs, stat], January 2018. URL http://arxiv.org/abs/1706.08500. arXiv: 1706.08500.
188
+
189
+ Andrew Ilyas, Logan Engstrom, Anish Athalye, and Jessy Lin. Black-box Adversarial Attacks with Limited Queries and Information. arXiv:1804.08598 [cs, stat], July 2018. URL http: //arxiv.org/abs/1804.08598. arXiv: 1804.08598.
190
+
191
+ Ajil Jalal, Andrew Ilyas, Constantinos Daskalakis, and Alexandros G. Dimakis. The Robust Manifold Defense: Adversarial Training using Generative Models. arXiv:1712.09196 [cs, stat], July 2019. URL http://arxiv.org/abs/1712.09196. arXiv: 1712.09196.
192
+
193
+ Kim Jungeum and Xiao Wang. Sensible Adversarial Learning. 2020. URL https:// openreview.net/pdf?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ rJlf_RVKwr.
194
+
195
+ Alex Krizhevsky. Learning Multiple Layers of Features from Tiny Images. pp. 60, 2009.
196
+
197
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. ImageNet Classification with Deep Convolutional Neural Networks. In F. Pereira, C. J. C. Burges, L. Bottou, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems 25, pp. 1097–1105. Curran Associates, Inc., 2012. URL http://papers.nips.cc/paper/ 4824-imagenet-classification-with-deep-convolutional-neural-networks. pdf.
198
+
199
+ Cassidy Laidlaw, Sahil Singla, and Soheil Feizi. Perceptual Adversarial Robustness: Defense Against Unseen Threat Models. arXiv:2006.12655 [cs, stat], July 2021. URL http://arxiv.org/ abs/2006.12655. arXiv: 2006.12655.
200
+
201
+ Sijia Liu, Pin-Yu Chen, Bhavya Kailkhura, Gaoyuan Zhang, Alfred Hero, and Pramod K. Varshney. A Primer on Zeroth-Order Optimization in Signal Processing and Machine Learning. arXiv:2006.06224 [cs, eess, stat], June 2020. URL http://arxiv.org/abs/2006.06224. arXiv: 2006.06224.
202
+
203
+ Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards Deep Learning Models Resistant to Adversarial Attacks. arXiv:1706.06083 [cs, stat], June 2017. URL http://arxiv.org/abs/1706.06083. arXiv: 1706.06083.
204
+
205
+ Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard. DeepFool: a simple and accurate method to fool deep neural networks. 2015. ISSN 10636919. doi: 10.1109/ CVPR.2016.282. URL http://arxiv.org/abs/1511.04599. arXiv: 1511.04599 ISBN: 9781467388511.
206
+
207
+ Yurii Nesterov and Vladimir Spokoiny. Random Gradient-Free Minimization of Convex Functions. Foundations of Computational Mathematics, 17(2):527–566, April 2017. ISSN 1615-3375, 1615- 3383. doi: 10.1007/s10208-015-9296-2. URL http://link.springer.com/10.1007/ s10208-015-9296-2.
208
+
209
+ Nicolas Papernot, Patrick Mcdaniel, Somesh Jha, Matt Fredrikson, Z. Berkay Celik, and Ananthram Swami. The limitations of deep learning in adversarial settings. Proceedings - 2016 IEEE European Symposium on Security and Privacy, EURO S and P 2016, pp. 372–387, 2016. doi: 10.1109/ EuroSP.2016.36. URL http://arxiv.org/abs/1511.07528. arXiv: 1511.07528 ISBN: 9781509017515.
210
+
211
+ Pouya Samangouei, Maya Kabkab, and Rama Chellappa. Defense-gan: Protecting classifiers against adversarial attacks using generative models. In International Conference on Learning Representations, 2018.
212
+
213
+ Shibani Santurkar, Dimitris Tsipras, Brandon Tran, Andrew Ilyas, Logan Engstrom, and Aleksander Madry. Image Synthesis with a Single (Robust) Classifier. arXiv:1906.09453 [cs, stat], June 2019. URL http://arxiv.org/abs/1906.09453. arXiv: 1906.09453.
214
+
215
+ Ludwig Schmidt, Shibani Santurkar, Dimitris Tsipras, Kunal Talwar, and Aleksander Madry. Adversarially Robust Generalization Requires More Data. arXiv:1804.11285 [cs, stat], May 2018. URL http://arxiv.org/abs/1804.11285. arXiv: 1804.11285.
216
+
217
+ David Stutz, Matthias Hein, and Bernt Schiele. Disentangling Adversarial Robustness and Generalization. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 12. IEEE Computer Society, 2019.
218
+
219
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. pp. 1–10, 2013. ISSN 15499618. doi: 10.1021/ct2009208. URL http://arxiv.org/abs/1312.6199. arXiv: 1312.6199 ISBN: 1549-9618.
220
+
221
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818–2826, 2016.
222
+
223
+ Thomas Tanay and Lewis Griffin. A Boundary Tilting Persepective on the Phenomenon of Adversarial Examples. arXiv:1608.07690 [cs, stat], August 2016. URL http://arxiv.org/abs/1608. 07690. arXiv: 1608.07690.
224
+
225
+ Florian Tramer, Nicholas Carlini, Wieland Brendel, and Aleksander Madry. On Adaptive Attacks to Adversarial Example Defenses. arXiv:2002.08347 [cs, stat], February 2020. URL http: //arxiv.org/abs/2002.08347. arXiv: 2002.08347.
226
+
227
+ Florian Tramer, Fan Zhang, Floriantra Er Epfl, Ari Juels, Michael K Reiter, and Thomas \` Ristenpart. Stealing Machine Learning Models via Prediction APIs. 2016. URL https: //www.usenix.org/conference/usenixsecurity16/technical-sessions/ presentation/tramer. ISBN: 978-1-931971-32-4.
228
+
229
+ Chun-Chen Tu, Paishun Ting, Pin-Yu Chen, Sijia Liu, Huan Zhang, Jinfeng Yi, Cho-Jui Hsieh, and Shin-Ming Cheng. AutoZOOM: Autoencoder-Based Zeroth Order Optimization Method for Attacking Black-Box Neural Networks. Proceedings of the AAAI Conference on Artificial Intelligence, 33:742–749, July 2019. ISSN 2374-3468, 2159-5399. doi: 10.1609/aaai.v33i01. 3301742. URL https://aaai.org/ojs/index.php/AAAI/article/view/3852.
230
+
231
+ Haichao Zhang and Jianyu Wang. Defense Against Adversarial Attacks Using Feature Scatteringbased Adversarial Training. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d\textquotesingle Alche-Buc, E. Fox, and R. Garnett (eds.), ´ Advances in Neural Information Processing Systems 32, pp. 1831–1841. Curran Associates, Inc., 2019.
232
+
233
+ Haichao Zhang and Wei Xu. Adversarial Interpolation Training: A simple approach for improving model robustness. 2020. URL https://openreview.net/pdf?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ Syejj0NYvr.
234
+
235
+ Hongyang Zhang, Yaodong Yu, Jiantao Jiao, Eric P Xing, Laurent El Ghaoui, and Michael I Jordan. Theoretically Principled Trade-off between Robustness and Accuracy. PMLR, pp. 11, 2019.
236
+
237
+ Richard Zhang, Phillip Isola, Alexei A. Efros, Eli Shechtman, and Oliver Wang. The Unreasonable Effectiveness of Deep Features as a Perceptual Metric. In 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 586–595, Salt Lake City, UT, June 2018. IEEE. ISBN 978-1- 5386-6420-9. doi: 10.1109/CVPR.2018.00068. URL https://ieeexplore.ieee.org/ document/8578166/.
238
+
239
+ Xiao Zhang, Jinghui Chen, Quanquan Gu, and David Evans. Understanding the Intrinsic Robustness of Image Distributions using Conditional Generative Models. arXiv:2003.00378 [cs, stat], February 2020. URL http://arxiv.org/abs/2003.00378. arXiv: 2003.00378.
240
+
241
+ # A APPENDIX
242
+
243
+ # A.1 DERIVATION OF MANIFOLD-GRADIENT MUTUAL INFORMATION (MI)
244
+
245
+ We define the manifold-gradient point-wise joint probability in a case-wise manner, for the respective values under $\mathbf { g } \in \{ - 1 , \bar { 1 } \} ^ { d }$ and $\bar { \mathbf { x } } \in \mathbb { R } ^ { d }$ . We are concerned with the sub-gradient cases where $\mathbf { x } > 0$ (denoted $\mathbf { x } ^ { + }$ ) and $\mathbf { x } < 0$ (denoted $\mathbf { x } ^ { - }$ ) which correspond to fixed values of $\mathbf { g }$ based on class means $y \cdot \pmb { \mu }$ with $y \in \{ - 1 , 1 \}$ . This gives for each dimension $k$ ,
246
+
247
+ $$
248
+ \begin{array} { l } { { \displaystyle p ( { \bf g } _ { k } = 1 , { \bf x } _ { k } ^ { + } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { { \bf x } _ { k } ^ { + } - \mu _ { k } } { \sigma } \right) ^ { 2 } \right) } } \\ { { \displaystyle p ( { \bf g } _ { k } = 1 , { \bf x } _ { k } ^ { - } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { { \bf x } _ { k } ^ { + } + \mu _ { k } } { \sigma } \right) ^ { 2 } \right) } } \end{array}
249
+ $$
250
+
251
+ $$
252
+ \begin{array} { l } { { \displaystyle p ( { \bf g } _ { k } = - 1 , { \bf x } _ { k } ^ { + } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { { \bf x } _ { k } ^ { + } + \mu _ { k } } { \sigma } \right) ^ { 2 } \right) } } \\ { { \displaystyle p ( { \bf g } _ { k } = - 1 , { \bf x } _ { k } ^ { - } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { { \bf x } _ { k } ^ { + } - \mu _ { k } } { \sigma } \right) ^ { 2 } \right) . } } \end{array}
253
+ $$
254
+
255
+ Since the Schmidt et al. Gaussian mixture is created symmetrically (the probability mass is evenly split between the two classes i.e., the mixture comprises one Gaussian offset by $\pmb { \mu _ { k } }$ and mirrored at $\mathbf { x } _ { k } = 0 .$ ) we can simplify to
256
+
257
+ $$
258
+ p ( \mathbf { g } _ { k } = 1 , \mathbf { x } _ { k } ^ { + } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { \mathbf { x } _ { k } ^ { + } - \pmb { \mu } _ { k } } { \sigma } \right) ^ { 2 } \right) ,
259
+ $$
260
+
261
+ $$
262
+ p ( \mathbf { g } _ { k } = - 1 , \mathbf { x } _ { k } ^ { + } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { \mathbf { x } _ { k } ^ { + } + \pmb { \mu } _ { k } } { \sigma } \right) ^ { 2 } \right) ,
263
+ $$
264
+
265
+ where $\mathbf { x } \sim { \mathcal { N } } ( y \cdot \mu , \sigma I )$ . In words, Equation 6 is the symmetrical tail of the Gaussian mixture marginal while Equation 5 is the remainder of the mixture.
266
+
267
+ Similarly, a point-wise gradient is given as the Rademacher outcome $\mathbf { g } _ { k } \in \{ \pm 1 \}$ . The choice of $\epsilon$ directly influences the marginal probability over the manifold. The marginal probability over the manifold can be given as the Riemann approximations
268
+
269
+ $$
270
+ p _ { \mathcal { G } } ( \mathbf { g } _ { k } = 1 ) _ { \epsilon } = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \sum _ { i = 1 } ^ { n } \exp \left( - \frac { 1 } { 2 } \left( \frac { \mathbf { x } _ { i , k } ^ { * } - \pmb { \mu } _ { k } } { \sigma } \right) ^ { 2 } \right) \Delta _ { i }
271
+ $$
272
+
273
+ and
274
+
275
+ $$
276
+ p _ { \mathcal { G } } ( \mathbf { g } _ { k } = - 1 ) _ { \epsilon } = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \sum _ { i = 1 } ^ { n } \exp \left( - \frac { 1 } { 2 } \left( \frac { \mathbf { x } _ { i , k } ^ { * } + \mu _ { k } } { \sigma } \right) ^ { 2 } \right) \Delta _ { i } ,
277
+ $$
278
+
279
+ with $\Delta _ { i } = \mathbf { x } _ { i , k } ^ { + } - \mathbf { x } _ { i - 1 , k } ^ { + }$ for arbitrary $\mathbf { x } _ { i , k } ^ { * } \in [ \mathbf { x } _ { i - 1 , k } ^ { + } , \mathbf { x } _ { i , k } ^ { + } ]$ , and $n$ is controlled by the hyper-parameter $\epsilon$ .
280
+
281
+ The marginal for the manifold under the gradient is given similarly as
282
+
283
+ $$
284
+ { \begin{array} { r l } & { p _ { \mathcal { M } } ( \mathbf { x } _ { k } ) = p ( \mathbf { g } _ { k } = 1 , \mathbf { x } _ { k } ^ { + } ) + p ( \mathbf { g } _ { k } = - 1 , \mathbf { x } _ { k } ^ { + } ) } \\ & { \qquad = { \frac { 1 } { \sigma { \sqrt { 2 \pi } } } } \exp \left( - { \frac { 1 } { 2 } } \left( { \frac { \mathbf { x } _ { k } ^ { + } - { \boldsymbol { \mu } } _ { k } } { \sigma } } \right) ^ { 2 } \right) + { \frac { 1 } { \sigma { \sqrt { 2 \pi } } } } \exp \left( - { \frac { 1 } { 2 } } \left( { \frac { \mathbf { x } _ { k } ^ { + } + { \boldsymbol { \mu } } _ { k } } { \sigma } } \right) ^ { 2 } \right) , } \end{array} }
285
+ $$
286
+
287
+ where $\mathbf { x } _ { k } ^ { + } > 0$ for all dimensions $k$ . Denote the sub-manifold sampled from the positive $( y = 1 )$ ) and negative $y = - 1 ,$ ) classes as $\mathcal { M } ^ { + }$ and $\mathcal { M } ^ { - }$ , respectively. Our definition for manifold-gradient mutual information is based on the standard definition of mutual information from information theory (Cover & Thomas, 2006),
288
+
289
+ $$
290
+ I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , k } = \int _ { \mathcal { M } } \int _ { \mathcal { G } } p ( \mathbf { g } _ { k } , \mathbf { x } _ { k } ) \log \bigr ( \frac { p ( \mathbf { g } _ { k } , \mathbf { x } _ { k } ) } { p _ { \mathcal { G } } ( \mathbf { g } _ { k } ) p _ { \mathcal { M } } ( \mathbf { x } _ { k } ) } \bigr ) d \mathbf { g } _ { k } d \mathbf { x } _ { k } ,
291
+ $$
292
+
293
+ where $\epsilon$ is treated as a hyper-parameter controlling the value of $n$ in $p _ { \mathcal { G } } ( \mathbf { g } _ { k } )$ . By substitution into Equation 10 we have
294
+
295
+ $$
296
+ \begin{array} { l } { { \displaystyle I ( { \mathcal { M } } , { \mathcal { G } } ) _ { \epsilon , k } = \int _ { { \mathcal { M } } } p ( 1 , { \mathbf { x } } _ { k } ) \log ( \frac { p ( 1 , { \mathbf { x } } _ { k } ) } { p _ { \mathcal { G } } ( 1 ) p _ { \mathcal { M } } ( { \mathbf { x } } _ { k } ) } ) d { \mathbf { x } } _ { k } } } \\ { { \displaystyle ~ + \int _ { { \mathcal { M } } } p ( - 1 , { \mathbf { x } } _ { k } ) \log ( \frac { p ( - 1 , { \mathbf { x } } _ { k } ) } { p _ { \mathcal { G } } ( - 1 ) p _ { \mathcal { M } } ( { \mathbf { x } } _ { k } ) } ) d { \mathbf { x } } _ { k } } . } \end{array}
297
+ $$
298
+
299
+ This is split further similar to true positive, true negative, false positive, and false negative, as
300
+
301
+ $$
302
+ \begin{array} { l } { { \displaystyle I ( { \mathcal M } , { \mathcal G } ) _ { \epsilon , k } = \int _ { { \mathcal M } + } p ( 1 , { \mathbf x } _ { k } ^ { + } ) \log ( \frac { p ( 1 , { \mathbf x } _ { k } ^ { + } ) } { p _ { \mathcal G } ( 1 ) p _ { { \mathcal M } } ( { \mathbf x } _ { k } ^ { + } ) } ) d { \mathbf x } _ { k } ^ { + } } } \\ { ~ + \int _ { { \mathcal M } ^ { - } } p ( 1 , { \mathbf x } _ { k } ^ { - } ) \log ( \frac { p ( 1 , { \mathbf x } _ { k } ^ { - } ) } { p _ { \mathcal G } ( 1 ) p _ { { \mathcal M } } ( { \mathbf x } _ { k } ^ { - } ) } ) d { \mathbf x } _ { k } ^ { - } } \\ { { + \int _ { { \mathcal M } ^ { + } } p ( - 1 , { \mathbf x } _ { k } ^ { + } ) \log ( \frac { p ( - 1 , { \mathbf x } _ { k } ^ { + } ) } { p _ { \mathcal G } ( - 1 ) p _ { { \mathcal M } } ( { \mathbf x } _ { k } ^ { + } ) } ) d { \mathbf x } _ { k } ^ { + } } } \\ { { + \int _ { { \mathcal M } ^ { - } } p ( - 1 , { \mathbf x } _ { k } ^ { - } ) \log ( \frac { p ( - 1 , { \mathbf x } _ { k } ^ { - } ) } { p _ { \mathcal G } ( - 1 ) p _ { { \mathcal M } } ( { \mathbf x } _ { k } ^ { - } ) } ) d { \mathbf x } _ { k } ^ { - } , } } \end{array}
303
+ $$
304
+
305
+ and simplified due to symmetry at 0 as
306
+
307
+ $$
308
+ \begin{array} { l } { { \displaystyle I ( { \mathcal { M } } , { \mathcal { G } } ) _ { \epsilon , k } = 2 \int _ { { \mathcal { M } } ^ { + } } p ( 1 , { \mathbf { x } } _ { k } ^ { + } ) \log ( \frac { p ( 1 , { \mathbf { x } } _ { k } ^ { + } ) } { p _ { \mathcal { G } } ( 1 ) p _ { \mathcal { M } } ( { \mathbf { x } } _ { k } ^ { + } ) } ) d { \mathbf { x } } _ { k } ^ { + } } } \\ { { \displaystyle ~ + \ 2 \int _ { { \mathcal { M } } ^ { + } } p ( - 1 , { \mathbf { x } } _ { k } ^ { + } ) \log ( \frac { p ( - 1 , { \mathbf { x } } _ { k } ^ { + } ) } { p _ { \mathcal { G } } ( - 1 ) p _ { \mathcal { M } } ( { \mathbf { x } } _ { k } ^ { + } ) } ) d { \mathbf { x } } _ { k } ^ { + } } . } \end{array}
309
+ $$
310
+
311
+ The total un-normalized mutual information is given by the summation over dimensions $\scriptstyle \sum _ { k = 1 } ^ { d } I ( { \mathcal { M } } , { \mathcal { G } } ) _ { \epsilon , k }$ . Notably the cases for each possible scenario under detection theory are repre- is bounded by the results of Schmidt et al. (2018). By substitution from each $I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon } =$ marginal and joint probability in Equations 8, 3, and 4 respectively, we have the closed form solution for mutual information.
312
+
313
+ This leads to the Riemann approximation of Equation 13,
314
+
315
+ $$
316
+ \begin{array} { r l } { \displaystyle I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , k } = 2 \sum _ { i = 1 } ^ { n } p ( 1 , \mathbf { x } _ { i , k } ^ { * } ) \log ( \frac { p ( 1 , \mathbf { x } _ { i , k } ^ { * } ) } { p _ { \mathcal { G } } ( 1 ) p _ { \mathcal { M } } ( \mathbf { x } _ { i , k } ^ { * } ) } ) \Delta _ { i } } & { } \\ { \displaystyle + 2 \sum _ { i = 1 } ^ { n } p ( - 1 , \mathbf { x } _ { i , k } ^ { * } ) \log ( \frac { p ( - 1 , \mathbf { x } _ { i , k } ^ { * } ) } { p _ { \mathcal { G } } ( - 1 ) p _ { \mathcal { M } } ( \mathbf { x } _ { i , k } ^ { * } ) } ) \Delta _ { i } . } & { } \end{array}
317
+ $$
318
+
319
+ with $\Delta _ { i } = \mathbf { x } _ { i , k } ^ { + } - \mathbf { x } _ { i - 1 , k } ^ { + }$ for arbitrary positive $\mathbf { x } _ { i , k } ^ { * } \in [ \mathbf { x } _ { i - 1 , k } ^ { + } , \mathbf { x } _ { i , k } ^ { + } ]$ . Since $\mathbf { x } ^ { + }$ is a standard multivariate Gaussian (Cover & Thomas, 2006), the final mutual information is the summation over each dimension,
320
+
321
+ $$
322
+ \begin{array} { r l } { I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon } = 2 \displaystyle \sum _ { k = 1 } ^ { d } \sum _ { i = 1 } ^ { n } p ( 1 , \mathbf { x } _ { i , k } ^ { * } ) \log ( \frac { p ( 1 , \mathbf { x } _ { i , k } ^ { * } ) } { p _ { \mathcal { G } } ( 1 ) p _ { \mathcal { M } } ( \mathbf { x } _ { i , k } ^ { * } ) } ) \Delta _ { i } } & { { } } \\ { \quad \quad \quad \quad + 2 \displaystyle \sum _ { k = 1 } ^ { d } \sum _ { i = 1 } ^ { n } p ( - 1 , \mathbf { x } _ { i , k } ^ { * } ) \log ( \frac { p ( - 1 , \mathbf { x } _ { i , k } ^ { * } ) } { p _ { \mathcal { G } } ( - 1 ) p _ { \mathcal { M } } ( \mathbf { x } _ { i , k } ^ { * } ) } ) \Delta _ { i } . } & { { } } \end{array}
323
+ $$
324
+
325
+ # A.2 HARD-LABEL ATTACK FORMULATION
326
+
327
+ Contemporary hard-label attacks are variants of random gradient-free method (RGF) (Nesterov & Spokoiny, 2017), a gradient estimator which yields the estimate $\hat { \bf g }$ over $q$ random directions $\{ { \mathbf { u } } _ { i } \} _ { i = 1 } ^ { q }$
328
+
329
+ OPT-Attack For benign example $\mathbf { x } _ { \mathrm { 0 } }$ , true label $y _ { 0 }$ , and hard-label black-box function $f : \mathbb { R } ^ { d } $ $\{ 1 , \ldots , K \}$ , Cheng et al. (2019) define the objective function $g : \mathbb { R } ^ { d } \mathbb { R }$ as a function of search direction $\pmb \theta$ , where the optimal solution is $g ( \theta ^ { * } )$ , the minimum distance from $\mathbf { x } _ { \mathrm { 0 } }$ to the nearest adversarial example along the direction $\pmb { \theta } ^ { * }$ . For the untargeted attack, $g ( \pmb \theta )$ is the distance to any decision boundary along direction $\pmb \theta$ , and allows for estimating the gradient as
330
+
331
+ $$
332
+ \hat { \mathbf { g } } = \frac { 1 } { q } \sum _ { i = 0 } ^ { q } \frac { g ( \pm \beta \mathbf { u } _ { i } ) - g ( \pmb { \theta } ) } { \beta } \cdot \mathbf { u } _ { i } ,
333
+ $$
334
+
335
+ where $\beta$ is a small smoothing parameter. Notably, $g ( \pmb \theta )$ is continuous even if $f$ is a non-continuous step function.
336
+
337
+ Sign-OPT Cheng et al. (2020) later improved the query efficiency by only considering the sign of the gradient estimate,
338
+
339
+ $$
340
+ \hat { \nabla } g ( \pmb \theta ) \approx \hat { \mathbf g } : = \sum _ { i = 1 } ^ { q } \mathrm { s i g n } \left( g ( \pmb \theta + \beta \mathbf { u } _ { i } ) - g ( \pmb \theta ) \right) \mathbf { u } _ { i } .
341
+ $$
342
+
343
+ We focus on the Sign-OPT variant, since the findings are more relevant to the current state-of-the-art.
344
+
345
+ HopSkipJumpAttack Similar to Sign-OPT, HopSkipJumpAttack (HSJA) (Chen et al., 2019) uses a zeroth-order sign oracle to improve Boundary Attack (Brendel et al., 2017). HSJA lacks the convergence analysis of Sign-OPT and relies on one-point gradient estimate. Regardless, HSJA is competitive and can excel in the $L _ { \infty }$ setting.
346
+
347
+ Dimension-reduced Sign-OPT & HSJA. In general, for attacks relying on the Cheng et al. (2019) formulation, the update in Equation 16 becomes
348
+
349
+ $$
350
+ \hat { \bf g } = \frac { 1 } { q } \sum _ { i = 0 } ^ { q } \frac { g ( \pmb { \theta } ^ { \prime } + \beta \mathbf { u } _ { i } ^ { \prime } ) - g ( \pmb { \theta } ^ { \prime } ) } { \beta } \cdot \mathbf { u } _ { i } ^ { \prime }
351
+ $$
352
+
353
+ for the reduced-dimension Gaussian vectors $\{ \mathbf { u } _ { i } ^ { \prime } \in \mathbb { R } ^ { d ^ { \prime } } \} _ { i = 0 } ^ { q }$ for integer $d ^ { \prime } < d$ and direction $\pmb { \theta } ^ { \prime } \in \mathbb { R } ^ { d ^ { \prime } }$ . The reduced-dimension direction $\pmb { \theta } ^ { \prime }$ is initialized randomly with $\pmb { \theta } ^ { \prime } \sim \mathcal { N } ( 0 , 1 )$ for the untargeted case, or for the targeted case as $\pmb { \theta } ^ { \prime } = \mathcal { E } ( \mathbf { x } _ { t } )$ , where $\mathbf { x } _ { t }$ is a test sample correctly classified as target class $t$ by the victim model. This scheme also applies to HSJA, since HSJA performs a single-point sign estimate. As in the normal variants, $\hat { \bf g }$ is used to update $\pmb { \theta } ^ { \prime }$ .
354
+
355
+ # A.3 MAIN PAPER BLOCK DIAGRAM
356
+
357
+ A block diagram of assumptions, claims, and observations is shown in Figure 3.
358
+
359
+ ![](images/979cd2f1dcb85dd68c32313ec1ca15d7b1f300f63cc80acc4c6361343a1daf23.jpg)
360
+ Figure 3: Block diagram summarizing the assumptions, claims, and observations of the main paper.
361
+
362
+ # A.4 IMPLEMENTATION DETAILS
363
+
364
+ # A.4.1 HARDWARE AND ATTACK HYPERPARAMETERS
365
+
366
+ All experiments in the main paper were performed on an internal high-performance compute cluster equipped with NVIDIA Tesla V100 Tensor Core GPUs and high-speed non-volatile flash storage. In total 16 GPUs, 1TB main system memory, and 40 Intel Xeon CPU cores were used to run experiments completely.
367
+
368
+ Depending on dataset dimension, HSJA requires tuning of parameter $\gamma$ for best performance. On CIFAR-10 we used $\gamma = 1 0 . 0$ . For ImageNet, it was necessary to set $\gamma \geq 1 0 0 0 . 0$ to re-create the published results of the regular variant (Chen et al., 2019). Due to similar performance we use $\gamma = 1 0 0 0 . 0$ for regular and dimension-reduced variants. We note that the dimension-reduced variants like HSJA+BiLN were less sensitive to $\gamma$ , performing similarly regardless of the setting.
369
+
370
+ # A.4.2 ADVERSARY AUTOENCODER
371
+
372
+ We are primarily interested in the effect of reduced search resolution on attack behavior. Thus in this work, given a candidate direction $\pmb { \theta } ^ { \prime }$ and magnitude (or radius) $r$ , the adversarial sample in the AE case is the blending $( 1 - r ) \mathbf { x } _ { 0 } + r \mathcal { D } \left( \mathcal { E } ( \mathbf { x } _ { 0 } ) \mathbf { \bar { \rho } } + \pmb { \theta } ^ { \prime } \right)$ . 3
373
+
374
+ For AE attack variants, we implement the same architecture described by Tu et al. (2019). Specifically it leverages a fully convolutional network for the encoder and decoder. Every AE is trained using the held out test set, as we assume disjoint data between adversary and victim.
375
+
376
+ The adversary’s AE is tuned to minimize reconstruction error of input images, so the output quality of the AE will depend on the adversary’s ability to collect data. We assume the adversary only has access to the test set, which tends to be considerably less informative than the training set. This crude manifold approximation can manifest as an additional layer of distortion on top of adversarial noise. With BiLN, no additional training is required, so it synthesizes search directions independent of the adversary’s manifold description (i.e., possible extracted knowledge about test samples).
377
+
378
+ ImageNet samples are downsized to $1 2 8 \mathrm { x } 1 2 8$ before passing to the AE, and the output of the AE is scaled back to $2 2 4 \mathbf { x } 2 2 4$ , as described by Tu et al. (2019).
379
+
380
+ # A.4.3 DATA SAMPLING
381
+
382
+ Original samples are chosen from the test set using the technique from Chen et al. (2019): on CIFAR-10, five random samples are taken from each of ten uniform-randomly chosen classes (i.e., 50 total samples). On the ImageNet dataset, ten random classes are uniform-randomly chosen and ten random samples taken from each (100 total samples).
383
+
384
+ # A.5 SUPPLEMENTAL RESULTS
385
+
386
+ # A.5.1 QUERY VS. DISTORTION PLOTS
387
+
388
+ We show the model queries against attack distortion measurement in Figure 4 to accompany the results in the main paper. The distortion is much higher and stays higher with Rand variants, due to discarding important semantic information. The plots evidence that BiLN variants (yellow lines) offer a simple yet effective way to improve the query efficiency of the hard-label attacks.
389
+
390
+ # A.5.2 GRADIENT DEVIATION ON ROBUST CIFAR-10
391
+
392
+ In Table 3 we show supplementary gradient deviation results for CIFAR-10 using different defense mechanisms or robust models. In general they exhibit the same trend as our main paper results, which is that dimension-reduced attacks manage to reduce gradient deviation across each robust model.
393
+
394
+ ![](images/f9c7cf7768af79749c237fe7c0baeb5938a09c506a0ac225576e1d3e8f2a4b36.jpg)
395
+ Figure 4: Query vs. distortion plots for a) CIFAR-10 and b) ImageNet, corresponding to the success rate plots in the main text. Dashed lines denote the value of $\epsilon$ .
396
+
397
+ Table 3: Per-pixel gradient deviation measured across additional robust CIFAR-10 models
398
+
399
+ <table><tr><td>Attack Variant</td><td>TRADES (Zhang et al., 2019)</td><td>Interpolation (Zhang &amp; Xu,2020)</td><td>Feat. Scattering (Zhang &amp;Wang,2019)</td><td>SENSE (Jungeum &amp; Wang,2020)</td></tr><tr><td>HSJA</td><td>0.0542±0.0001</td><td>0.0542±0.0001</td><td>0.0541±0.0000</td><td>0.0556±0.0045</td></tr><tr><td>HSJA+BiLN</td><td>0.0395±0.0001</td><td>0.0393±0.0001</td><td>0.0401±0.0004</td><td>0.0389±0.0056</td></tr><tr><td>HSJA+Rand</td><td>0.008±0.004</td><td>0.002±0.005</td><td>0.216±0.000</td><td>0.222±0.017</td></tr><tr><td>Sign-OPT</td><td>0.0042±0.0005</td><td>0.0039±0.0007</td><td>0.0019±0.0004</td><td>0.0083±0.0104</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.0026±0.0007</td><td>0.0023±0.0009</td><td>0.0020±0.0004</td><td>0.0075±0.0110</td></tr><tr><td>Sign-OPT+Rand</td><td>0.007±0.002</td><td>0.004±0.005</td><td>0.006±0.002</td><td>0.025±0.048</td></tr><tr><td>Sign-OPT+AE</td><td>0.0257±0.0002</td><td>0.0282±0.0002</td><td>0.0259±0.0000</td><td>0.0278±0.0069</td></tr></table>
400
+
401
+ # A.5.3 SUCCESS RATE NORMALIZED AUC SCORES
402
+
403
+ Tables 5 and 4 show the max-normalized Trapezoid rule area-under-curve (AUC) measurements for the success rate plots of the main text. Highest scores are bolded. Notably, the HSJA $+$ BiLN variant earns the highest score in almost all cases.
404
+
405
+ # A.5.4 SUCCESS RATE SCORES
406
+
407
+ We provide the success rates over all samples at specific query intervals in Tables 6 and 7.
408
+
409
+ # A.5.5 ATTACKING A SMOOTHED MODEL
410
+
411
+ Gaussian smoothing is a technique of performing adversarial training with sampled affected by Gaussian noise. At test time, inference is achieved via a Monte Carlo search over many Gaussianperturbed versions of the sample under test. The SotA at time of writing, randomized smoothing proposed by Cohen et al. (2019), is a good candidate for hard-label attacks since the true gradient of the smoothed model is undefined. We use the checkpoint corresponding to smoothing parameter $\sigma = 0 . 5$ and $\epsilon \simeq 1 . 0$ . These results are shown in Figure 5. In general, the BiLN variant exceeds all other variants in the natural ImageNet case, with small improvement on the smoothed model. Although it can find samples closer to the smoothed $\epsilon$ , only a fraction are within the bound.
412
+
413
+ Table 4: Success Rate (SR) Normalized AUC scores for CIFAR-10 SR plots of the main text. Higher is better.
414
+
415
+ <table><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td></tr><tr><td>HSJA</td><td>1.000</td><td>0.650</td></tr><tr><td>HSJA+BiLN</td><td>0.968</td><td>1.000</td></tr><tr><td>HSJA+Rand</td><td>0.033</td><td>0.088</td></tr><tr><td>Sign-OPT</td><td>0.763</td><td>0.171</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.310</td><td>0.156</td></tr><tr><td>Sign-OPT+Rand</td><td>0.144</td><td>0.092</td></tr><tr><td>Sign-OPT+AE</td><td>0.312</td><td>0.300</td></tr></table>
416
+
417
+ <table><tr><td>Attack Variant</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>0.867</td><td>0.470</td></tr><tr><td>HSJA+BiLN</td><td>1.000</td><td>1.000</td></tr><tr><td>HSJA+Rand</td><td>0.077</td><td>0.211</td></tr><tr><td>Sign-OPT</td><td>0.364</td><td>0.153</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.376</td><td>0.215</td></tr><tr><td>Sign-OPT+Rand</td><td>0.070</td><td>0.033</td></tr><tr><td>Sign-OPT+AE</td><td>0.018</td><td>0.105</td></tr></table>
418
+
419
+ ![](images/d2bd3e352f8be4d3e881a6fdfbef44288c3999f54fb1f2b5ddff41692d502bb1.jpg)
420
+ Table 5: Success Rate (SR) Normalized AUC scores for ImageNet SR plots of the main text. Higher is better.
421
+ Figure 5: Results of attacking Smoothed ImageNet Cohen et al. (2019) in the $L _ { 2 }$ setting for a) query vs. distortion and b) query vs. success rate, Dashed lines denote the value of $\epsilon$ .
422
+
423
+ # A.5.6 ATTACKING WITHOUT GRADIENT ESTIMATE
424
+
425
+ We perform additional experiments with an attack that does not perform an explicit gradient estimate. Chen & Gu (2020) propose an alternative hard-label attack method which is to search for the minimum decision boundary radius $r$ from a sample $\mathbf { x } _ { \mathrm { 0 } }$ , along a ray direction $\pmb { \theta }$ . Instead of searching over $\mathbb { R } ^ { d }$ to minimize $g ( \pmb \theta )$ , Chen et al. propose to perform ray search over directions $\pmb { \theta } \in \{ - 1 , 1 \} ^ { d }$ , resulting in $2 ^ { d }$ maximum possible directions. This reduction of the search resolution enables SotA query efficiency in the $L _ { \infty }$ setting with proof of convergence. The search resolution is further reduced by the hierarchical variant of RayS, which performs on-the-fly upscaling of image super-pixels.
426
+
427
+ Table 6: CIFAR-10 succcess rate values at query intervals 4k, 11k, and 25k, for setting $\cdot$
428
+
429
+ <table><tr><td>Attack Variant</td><td>Natural @4k</td><td>Madry @4k</td><td>Natural @11k</td><td>Madry @11k</td><td>Natural @25k</td><td>Madry @25k</td></tr><tr><td>HSJA</td><td>0.905</td><td>0.100</td><td>0.995</td><td>0.145</td><td>1.000</td><td>0.180</td></tr><tr><td>HSJA+BiLN</td><td>0.850</td><td>0.165</td><td>0.970</td><td>0.225</td><td>0.985</td><td>0.255</td></tr><tr><td>HSJA+Rand</td><td>0.040</td><td>0.020</td><td>0.020</td><td>0.020</td><td>0.040</td><td>0.000</td></tr><tr><td>Sign-OPT</td><td>0.515</td><td>0.030</td><td>0.795</td><td>0.040</td><td>0.890</td><td>0.040</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.235</td><td>0.035</td><td>0.310</td><td>0.035</td><td>0.355</td><td>0.035</td></tr><tr><td>Sign-OPT+Rand</td><td>0.060</td><td>0.020</td><td>0.200</td><td>0.020</td><td>0.180</td><td>0.020</td></tr><tr><td>Sign-OPT+AE</td><td>0.210</td><td>0.055</td><td>0.325</td><td>0.065</td><td>0.345</td><td>0.070</td></tr></table>
430
+
431
+ Table 7: ImageNet succcess rate values at query intervals 4k, 11k, and 25k, for setting $\cdot$
432
+
433
+ <table><tr><td>Attack Variant</td><td>Natural @4k</td><td>Madry @4k</td><td>Natural @11k</td><td>Madry @11k</td><td>Natural @25k</td><td>Madry @ 25k</td></tr><tr><td>HSJA</td><td>0.550</td><td>0.105</td><td>0.850</td><td>0.130</td><td>0.965</td><td>0.165</td></tr><tr><td>HSJA+BiLN</td><td>0.835</td><td>0.240</td><td>0.965</td><td>0.290</td><td>1.000</td><td>0.335</td></tr><tr><td>HSJA+Rand</td><td>0.070</td><td>0.060</td><td>0.070</td><td>0.060</td><td>0.070</td><td>0.060</td></tr><tr><td>Sign-OPT</td><td>0.210</td><td>0.045</td><td>0.335</td><td>0.045</td><td>0.485</td><td>0.045</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.240</td><td>0.055</td><td>0.345</td><td>0.065</td><td>0.445</td><td>0.065</td></tr><tr><td>Sign-OPT+Rand</td><td>0.050</td><td>0.010</td><td>0.070</td><td>0.010</td><td>0.070</td><td>0.010</td></tr><tr><td>Sign-OPT+AE</td><td>0.015</td><td>0.030</td><td>0.015</td><td>0.030</td><td>0.020</td><td>0.040</td></tr></table>
434
+
435
+ ![](images/b225bb9490a9025c43fb78938b9f99c7569ae28daa56453493b3bcd2ae976406.jpg)
436
+ Figure 6: Results for RayS on the CIFAR-10 dataset, corresponding to distortion against query usage (dotted red line denotes the value of $\epsilon$ , shaded areas mark standard deviation).
437
+
438
+ The intuition behind RayS attack is to perform a discrete search in at most $2 ^ { d }$ directions. Chen et al. also perform a hierarchical search over progressively larger super-pixels of the image. This has the effect of already upscaling on-the-fly (Chen & Gu, 2020). RayS has the unique behavior of performing a discrete search for the decision boundary, rather than an explicit gradient estimate. To achieve an appropriate reduced-dimension version of RayS, we modify the calculation of $s$ in Algorithm 3 of Chen & Gu (2020), which either speeds up upscaling by a factor $a$ (i.e., $s = s + a )$ ), or extends the search through a specific block index by a factor $b$ (increase block level at $k = 2 ^ { s } b$ instead of $k = 2 ^ { s }$ ).
439
+
440
+ The result of attacking CIFAR-10 with RayS is shown in Figure 6. The BiLN variants of RayS each have minimal effect on overall query efficiency (Insets 6.i and 6.ii). This is a result of RayS not relying on explicit gradient estimation. When comparing the FID-64 score, the dimension-reduced variants of RayS do not have a large variation between them (Inset 6.i), a side-effect of the adaptive super-pixel search, which can automatically scale the super-pixel size as the search progresses.
441
+
442
+ Table 8: Measurement of Local Intrinsic Dimensionality (LID) averaged over 200 samples.
443
+
444
+ <table><tr><td></td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>Benign</td><td>0.787 ± 0.830</td><td>0.564± 1.724</td><td>1.206 ± 0.803</td><td>2.623 ± 2.383</td></tr><tr><td>HSJA</td><td>8.014 ± 5.829</td><td>62.709 ± 112.416</td><td>4.798 ± 2.578</td><td>3.342 ± 2.263</td></tr><tr><td>HSJA+BiLN</td><td>7.497 ± 5.811</td><td>50.467 ± 100.057</td><td>4.787 ± 2.550</td><td>4.290 ± 4.524</td></tr><tr><td>HSJA+Rand</td><td>6.156 ± 6.053</td><td>15.745 ± 24.195</td><td>5.191 ± 1.948</td><td>3.132 ± 2.489</td></tr><tr><td>Sign-OPT</td><td>7.240 ± 5.006</td><td>51.491 ± 100.080</td><td>4.747 ± 1.988</td><td>3.707 ± 3.660</td></tr><tr><td>Sign-OPT+BiLN</td><td>6.308 ± 4.079</td><td>47.355 ± 119.958</td><td>4.547 ± 2.118</td><td>4.808 ± 4.873</td></tr><tr><td>Sign-OPT+Rand</td><td>5.576 ± 4.178</td><td>12.792 ± 13.546</td><td>5.364 ± 1.757</td><td>4.867 ± 3.369</td></tr><tr><td>Sign-OPT+AE</td><td>6.700 ± 4.735</td><td>51.380 ± 103.355</td><td>4.891 ± 2.299</td><td>3.791 ± 3.598</td></tr></table>
445
+
446
+ # A.5.7 LOCAL INTRINSIC DIMENSIONALITY
447
+
448
+ In Table 8 we show the average Local Intrinsic Dimensionality Amsaleg et al. (2017) for each dataset and attack combination.
449
+
450
+ # A.5.8 FRECHET ´ INCEPTION DISTANCE
451
+
452
+ Unfortunately, the data manifold of real-world datasets is difficult to describe. This is an open problem in the study of Generative Adversarial Networks (GANs), since designers require that generator images are on-manifold (i.e., in-distribution Zhang et al. (2020)) to preserve semantic relationships between images. This has motivated the recently proposed Frechet Inception Distance (FID) that acts ´ as a surrogate measure of the manifold distance over a set of RGB image samples (Heusel et al., 2018). As an additional proxy for manifold distance, we run experiments that assume adversarial samples are synthetically generated images from the data manifold, which can later be compared to their unmodified counterparts on the true manifold using FID. As a result, this estimation process is only available from the defender’s perspective. Since FID uses an Inception-V3 coding layer (Szegedy et al., 2016) to encode images, the estimation correlates with distortion of semantic high-level features. Thus sampling closer to the data manifold will result in a lower FID score. The attacks in our experiments do not target the Inception-V3 network, so the FID metric will not rely on any internal aspects of the victim models.
453
+
454
+ FID score is calculated using the 64-dimensional max pooling layer of the Inception-V3 deep network for coding (denoted as FID-64 in this supplementary material), taken from an open-source implementation.4 The choice of the 64-dimensional feature layer allows to calculate full-rank FID without the full 2,048 sample count of original FID, which is prohibitive based on the scale of our analysis. Since the coding layer differs slightly from the original FID-2048 implementation, the magnitudes will differ from those published by Heusel et al. (2018).
455
+
456
+ The comparison of FID scores is shown in Table 9 for natural and robust models. The scores for ImageNet on dimension-reduced attack variants (italicized) are universally lower (as low as 0.014, bold), while on CIFAR-10 the regular variants did not exhibit the behavior. We posit that the higher dimensionality of ImageNet $( 2 2 4 \times 2 2 4 )$ enables dimension reduction to be more effective than the lower dimension CIFAR-10 $( 3 2 \times 3 2 )$ . In general, attacks have a higher FID score on robust models than natural models. This can be explained by the fact that robust models are more secure in a region around the original sample, as a result the adversarial sample discovery is further away from the true manifold. The random variant (Rand) in rows three and six evidences that the preservation of semantic priors is important during the update, otherwise samples have high manifold distance. The regular variants of HSJA and Sign-OPT are capable of high FID scores on robust models. However, dimension-reduced variants have a universal behavior to reduce the score in the robust setting, similar to the natural setting for ImageNet. AE variants exhibit higher FID score than BiLN, since BiLN can rescale invariant of the adversary’s manifold knowledge (e.g., only having knowledge of test set).
457
+
458
+ Table 9: Frechet Inception Distance (FID) scores for each attack’s set of 200 adversarial samples on ´ CIFAR-10 and ImageNet (lower is better). ∗ denotes highest success rate (SR) AUC. Arrows denote higher or lower score compared to baseline variant.
459
+
460
+ <table><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>0.005</td><td>1.622</td><td>1.026</td><td>29.756</td></tr><tr><td>HSJA+BiLN</td><td>0.006个</td><td>0.373↓</td><td>0.012↓</td><td>4.646↓</td></tr><tr><td>HSJA+Rand</td><td>2.198个</td><td>8.256个</td><td>3.404↑</td><td>2.354↓</td></tr><tr><td>Sign-OPT</td><td>0.001</td><td>0.305</td><td>20.969</td><td>38.505</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.002个</td><td>0.045↓</td><td>0.009↓</td><td>0.062↓</td></tr><tr><td>Sign-OPT+Rand</td><td>0.141个</td><td>0.210↓</td><td>0.234↓</td><td>0.156↓</td></tr><tr><td>Sign-OPT+AE</td><td>0.333个</td><td>0.008↓</td><td>1.514↓</td><td>7.869↓</td></tr></table>
461
+
462
+ <table><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>0.016 ± 0.012*</td><td>0.162 ± 0.099</td><td>0.030 ±0.046</td><td>0.170 ± 0.119</td></tr><tr><td>HSJA+BiLN</td><td>0.033 ± 0.024个</td><td>0.156 ± 0.096↓*</td><td>0.019 ± 0.017↓*</td><td>0.169 ± 0.122↓*</td></tr><tr><td>HSJA+Rand</td><td>0.334 ± 0.176个</td><td>0.457 ± 0.101↑</td><td>0.309 ± 0.136个</td><td>0.308 ± 0.141个</td></tr><tr><td>Sign-OPT</td><td>0.015 ± 0.013</td><td>0.137 ± 0.088</td><td>0.096 ±0.118</td><td>0.152 ± 0.112</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.048 ± 0.039↑</td><td>0.191 ± 0.103个</td><td>0.040 ± 0.044↓</td><td>0.171 ± 0.105个</td></tr><tr><td>Sign-OPT+Rand</td><td>0.084±0.092个</td><td>0.214± 0.100↑</td><td>0.082±0.077↓</td><td>0.087± 0.059↓</td></tr><tr><td>Sign-OPT+AE</td><td>0.058 ±0.123个</td><td>0.094 ± 0.068↓</td><td>0.235 ± 0.200个</td><td>0.586 ± 0.299↑</td></tr></table>
463
+
464
+ Table 10: $L _ { \infty }$ distance between adversarial and benign samples projected to approximated manifold (using autoencoder trained on training data) for each attack’s set of 200 adversarial samples on CIFAR-10 and ImageNet (lower is better). Arrows denote higher or lower distance compared to baseline variant, and starred items indicate highest success rate.
465
+
466
+ # A.5.9 $L _ { \infty }$ -NORM OVER APPROXIMATE MANIFOLD
467
+
468
+ We re-use the setup described in Section A.4.2, but train the autoencoders using the training data (defender’s perspective) instead of test data (attacker’s perspective). The results are shown in Table 10. The HSJA $+$ BiLN attack variants were successful in lowering distance for both natural and robust ImageNet. Generally, Sign-OPT variants were most successful for lowering distance from baseline variant for both CIFAR-10 and ImageNet. The primary factor is the dataset dimensionality, with dimension reduction having a bigger impact on ImageNet than CIFAR-10 (green arrows in ImageNet are more widespread). Likewise, robust models always exhibit a higher distance than natural. This can be explained by the fact that adversarially trained models are more robust in a region around the benign sample, thus the successful adversarial sample will be farther away.
469
+
470
+ # A.5.10 VISUAL RESULTS - CIFAR-10
471
+
472
+ We provide visual qualitative results for each attack on CIFAR-10 in Figure 7.
473
+
474
+ # A.5.11 VISUAL RESULTS - IMAGENET
475
+
476
+ We provide visual qualitative results for each attack on ImageNet in Figure 8.
477
+
478
+ ![](images/847dfbc02048cb61f2f67a8935acbb9521bf9688453dd5f7edf41012e3a1f85b.jpg)
479
+ Figure 7: Visual selection of attack trajectories on CIFAR-10.
480
+
481
+ ![](images/3c9a1cc18f8870c0a61ef6c65f0c3f2d8b13bb18d20e5f7887a35d1a4c12ea35.jpg)
482
+ Figure 8: Visual selection of attack trajectories on ImageNet.
md/dev/0RDcd5Axok/0RDcd5Axok.md ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TOWARDS A UNIFIED VIEW OF PARAMETER-EFFICIENT TRANSFER LEARNING
2
+
3
+ Junxian $\mathbf { H e } ^ { * }$ Carnegie Mellon University junxianh@cs.cmu.edu
4
+
5
+ Chunting Zhou∗ Carnegie Mellon University chuntinz@cs.cmu.edu
6
+
7
+ Xuezhe Ma University of Southern California xuezhema@isi.edu
8
+
9
+ Taylor Berg-Kirkpatrick UC San Diego tberg@eng.ucsd.edu
10
+
11
+ Graham Neubig Carnegie Mellon University gneubig@cs.cmu.edu
12
+
13
+ # ABSTRACT
14
+
15
+ Fine-tuning large pretrained language models on downstream tasks has become the de-facto learning paradigm in NLP. However, conventional approaches finetune all the parameters of the pretrained model, which becomes prohibitive as the model size and the number of tasks grow. Recent work has proposed a variety of parameter-efficient transfer learning methods that only fine-tune a small number of (extra) parameters to attain strong performance. While effective, the critical ingredients for success and the connections among the various methods are poorly understood. In this paper, we break down the design of state-of-the-art parameter-efficient transfer learning methods and present a unified framework that establishes connections between them. Specifically, we re-frame them as modifications to specific hidden states in pretrained models, and define a set of design dimensions along which different methods vary, such as the function to compute the modification and the position to apply the modification. Through comprehensive empirical studies across machine translation, text summarization, language understanding, and text classification benchmarks, we utilize the unified view to identify important design choices in previous methods. Furthermore, our unified framework enables the transfer of design elements across different approaches, and as a result we are able to instantiate new parameter-efficient fine-tuning methods that tune less parameters than previous methods while being more effective, achieving comparable results to fine-tuning all parameters on all four tasks.1
16
+
17
+ # 1 INTRODUCTION
18
+
19
+ Transfer learning from pre-trained language models (PLMs) is now the prevalent paradigm in natural language processing, yielding strong performance on many tasks (Peters et al., 2018; Devlin et al., 2019; Qiu et al., 2020). The most common way to adapt general-purpose PLMs to downstream tasks is to fine-tune all the model parameters (full fine-tuning). However, this results in a separate copy of fine-tuned model parameters for each task, which is prohibitively expensive when serving models that perform a large number of tasks. This issue is particularly salient with the ever-increasing size of PLMs, which now range from hundreds of millions (Radford et al., 2019; Lewis et al., 2020) to hundreds of billions (Brown et al., 2020) or even trillions of parameters (Fedus et al., 2021).
20
+
21
+ To mitigate this issue, a few lightweight alternatives have been proposed to update only a small number of extra parameters while keeping most pretrained parameters frozen. For example, adapter tuning (Houlsby et al., 2019) inserts small neural modules called adapters to each layer of the pretrained network and only the adapters are trained at fine-tuning time. Inspired by the success of prompting methods that control PLMs through textual prompts (Brown et al., 2020; Liu et al., 2021a), prefix tuning (Li & Liang, 2021) and prompt tuning (Lester et al., 2021) prepend an additional $l$ tunable prefix tokens to the input or hidden layers and only train these soft prompts when fine-tuning on downstream tasks. More recently, Hu et al. (2021) learn low-rank matrices to approximate parameter updates. We illustrate these methods in Figure 1. These approaches have all been reported to demonstrate comparable performance to full fine-tuning on different sets of tasks, often through updating less than $1 \%$ of the original model parameters. Besides parameter savings, parameter-efficient tuning makes it possible to quickly adapt to new tasks without catastrophic forgetting (Pfeiffer et al., 2021) and often exhibits superior robustness in out-of-distribution evaluation (Li & Liang, 2021).
22
+
23
+ ![](images/817d3636b1fd3352037dfcc37df9a02d25048bdc48931d091e4c6fddbc6d0118.jpg)
24
+ Figure 1: Illustration of the transformer architecture and several state-of-the-art parameter-efficient tuning methods. We use blocks with dashed borderlines to represent the added modules by those methods.
25
+
26
+ ![](images/ed2872e8987c3789fd45b53e042a8d249dbe4d22df5d13958ff5aee7ae6ba30f.jpg)
27
+ Figure 2: Performance of different methods on the XSum (Narayan et al., 2018) summarization task. The number of fine-tuned parameters is relative to the tuned parameters in full fine-tuning.
28
+
29
+ However, we contend that the important ingredients that contribute to the success of these parameterefficient tuning methods are poorly understood, and the connections between them are still unclear. In this paper, we aim to answer three questions: (1) How are these methods connected? (2) Do these methods share design elements that are essential for their effectiveness, and what are they? (3) Can the effective ingredients of each method be transferred to others to yield more effective variants?
30
+
31
+ In order to answer these questions, we first derive an alternative form of prefix tuning that reveals prefix tuning’s close connections with adapters (§3.1). Based on this we then devise a unified framework that frames the aforementioned methods as different ways to modify the hidden representations of frozen PLMs (§3.2). Our unified framework decomposes previous methods along a shared set of design dimensions, such as the function used to perform the modification, the position in which to impose this modification, and how to integrate the modification. This framework allows us to transfer design choices across approaches to propose new variants such as adapters with multiple heads (§3.3). In experiments, we first show that existing parameter-efficient tuning methods still lag behind full fine-tuning on higher-resource and challenging tasks (§4.2), as exemplified in Figure 2. Then we utilize the unified framework to identify critical design choices and validate the proposed variants empirically (§4.3-4.6). Our experiments on four NLP benchmarks covering text summarization, machine translation (MT), text classification, and general language understanding, demonstrate that the proposed variant uses less parameters than existing methods while being more effective, matching full fine-tuning results on all four tasks.
32
+
33
+ # 2 PRELIMINARIES
34
+
35
+ # 2.1 RECAP OF THE TRANSFORMER ARCHITECTURE
36
+
37
+ The transformer model (Vaswani et al., 2017) is now the workhorse architecture behind most stateof-the-art PLMs. In this section we recap the equations of this model for completeness. Transformer models are composed of $L$ stacked blocks, where each block (Figure 1) contains two types of sub
38
+
39
+ layers: multi-head self-attention and a fully connected feed-forward network (FFN).2 The conventional attention function maps queries $\boldsymbol { Q } \in \mathbb { R } ^ { n \times d _ { k } }$ and key-value pairs $\pmb { K } \in \mathbb { R } ^ { m \times d _ { k } } , \pmb { V } \in \mathbb { R } ^ { m \times d _ { v } }$
40
+
41
+ $$
42
+ \mathrm { A t t n } ( Q , K , V ) = \mathrm { s o f t m a x } \big ( \frac { Q K ^ { T } } { \sqrt { d _ { k } } } \big ) V ,
43
+ $$
44
+
45
+ where $n$ and $m$ are the number of queries and key-value pairs respectively. Multi-head attention performs the attention function in parallel over $N _ { h }$ heads, where each head is separately parameterized by $W _ { q } ^ { ( i ) }$ , $\boldsymbol { W } _ { k } ^ { ( i ) }$ , $W _ { v } ^ { ( i ) } \in \mathbb { R } ^ { d \times d _ { h } }$ to project inputs to queries, keys, and values. Given a sequence of $m$ vectors $C \in \mathbb { R } ^ { m \times d }$ over which we would like to perform attention and a query vector $\pmb { x } \in \mathbb { R } ^ { d }$ , multi-head attention (MHA) computes the output on each head and concatenates them:3
46
+
47
+ $$
48
+ \mathrm { M H A } ( C , { \pmb x } ) = \mathrm { C o n c a t } ( \mathrm { h e a d } _ { 1 } , \cdots , \mathrm { h e a d } _ { \mathrm { h } } ) { \pmb W } _ { o } , \ \mathrm { h e a d } _ { \mathrm { i } } = \mathrm { A t t n } ( { \pmb x } { \pmb W } _ { q } ^ { ( i ) } , C { \pmb W } _ { k } ^ { ( i ) } , C { \pmb W } _ { v } ^ { ( i ) } ) ,
49
+ $$
50
+
51
+ where $W _ { o } \in \mathbb { R } ^ { d \times d }$ . $d$ is the model dimension, and in MHA $d _ { h }$ is typically set to $d / N _ { h }$ to save parameters, which indicates that each attention head is operating on a lower-dimensional space. The other important sublayer is the fully connected feed-forward network (FFN) which consists of two linear transformations with a ReLU activation function in between:
52
+
53
+ $$
54
+ \mathrm { F F N } ( \pmb { x } ) = \mathrm { R e L U } ( \pmb { x } \pmb { W } _ { 1 } + \pmb { b } _ { 1 } ) \pmb { W } _ { 2 } + \pmb { b } _ { 2 } ,
55
+ $$
56
+
57
+ where $W _ { 1 } \in \mathbb { R } ^ { d \times d _ { m } }$ , $W _ { 2 } \in \mathbb { R } ^ { d _ { m } \times d }$ . Transformers typically use a large $d _ { m }$ , e.g. $d _ { m } = 4 d$ . Finally, a residual connection is used followed by layer normalization (Ba et al., 2016).
58
+
59
+ # 2.2 OVERVIEW OF PREVIOUS PARAMETER-EFFICIENT TUNING METHODS
60
+
61
+ Below and in Figure 1, we introduce several state-of-the-art parameter-efficient tuning methods.
62
+ Unless otherwise specified, they only tune the added parameters while the PLM’s are frozen.
63
+
64
+ Adapters (Houlsby et al., 2019): The adapter approach inserts small modules (adapters) between transformer layers. The adapter layer generally uses a down-projection with $W _ { \mathrm { d o w n } } \ \in \ \mathbb { R } ^ { d \times r }$ to project the input $^ { h }$ to a lower-dimensional space specified by bottleneck dimension $r$ , followed by a nonlinear activation function $f ( \cdot )$ , and a up-projection with $W _ { \mathsf { u p } } \in \mathbb { R } ^ { r \times d }$ . These adapters are surrounded by a residual connection, leading to a final form:
65
+
66
+ $$
67
+ h h + f ( h W _ { \mathrm { d o w n } } ) W _ { \mathrm { u p } } .
68
+ $$
69
+
70
+ Houlsby et al. (2019) places two adapters sequentially within one layer of the transformer, one after the multi-head attention and one after the FFN sub-layer. Pfeiffer et al. (2021) have proposed a more efficient adapter variant that is inserted only after the FFN “add & layer norm” sub-layer.
71
+
72
+ Prefix Tuning (Li & Liang, 2021): Inspired by the success of textual prompting methods (Liu et al., 2021a), prefix tuning prepends $l$ tunable prefix vectors to the keys and values of the multihead attention at every layer. Specifically, two sets of prefix vectors $P _ { k } , \dot { P } _ { v } \in \mathbb R ^ { l \times d }$ are concatenated with the original key $\kappa$ and value $V$ . Then multi-head attention is performed on the new prefixed keys and values. The computation of ${ \mathrm { h e a d } } _ { i }$ in Eq. 2 becomes:
73
+
74
+ $$
75
+ \mathrm { h e a d } _ { i } = \mathrm { A t t n } ( \pmb { x } \pmb { W } _ { q } ^ { ( i ) } , \mathrm { c o n c a t } ( \pmb { P } _ { k } ^ { ( i ) } , \pmb { C } \pmb { W } _ { k } ^ { ( i ) } ) , \mathrm { c o n c a t } ( \pmb { P } _ { v } ^ { ( i ) } , \pmb { C } \pmb { W } _ { v } ^ { ( i ) } ) ) ,
76
+ $$
77
+
78
+ $P _ { k }$ and $P _ { v }$ are split into $N _ { h }$ head vectors respectively and $P _ { k } ^ { ( i ) } , P _ { v } ^ { ( i ) } \in \mathbb R ^ { l \times d / N _ { h } }$ denote the $i$ -th head vector. Prompt-tuning (Lester et al., 2021) simplifies prefix-tuning by only prepending to the input word embeddings in the first layer; similar work also includes $\mathrm { \bf P }$ -tuning (Liu et al., 2021b).
79
+
80
+ LoRA (Hu et al., 2021): LoRA injects trainable low-rank matrices into transformer layers to approximate the weight updates. For a pre-trained weight matrix $W \in \mathbb { R } ^ { d \times k }$ , LoRA represents its update with a low-rank decomposition $W + \Delta W = W + W _ { \mathrm { d o w n } } W _ { \mathrm { u p } }$ , where $W _ { \mathrm { d o w n } } \in \mathbb { R } ^ { \hat { d } \times r }$ , $W _ { \mathrm { u p } } \in$ $\mathbb { R } ^ { r \times k }$ are tunable parameters. LoRA applies this update to the query and value projection matrices $\left( W _ { q } , W _ { v } \right)$ in the multi-head attention sub-layer, as shown in Figure 1. For a specific input $_ { \textbf { \em x } }$ to the linear projection in multi-head attention, LoRA modifies the projection output $^ { h }$ as:
81
+
82
+ $$
83
+ h h + s \cdot x W _ { \mathrm { d o w n } } W _ { \mathrm { u p } } ,
84
+ $$
85
+
86
+ ![](images/0cae0143a371d3d20d802c7754661581469a23b2c5a99fc1b9f5bba922f4f87f.jpg)
87
+ Figure 3: Graphical illustration of existing methods and the proposed variants. “PLM module” represents a certain sublayer of the PLM (e.g. attention or FFN) that is frozen. “Scaled PA” denotes scaled parallel adapter. We do not include multi-head parallel adapter here to save space.
88
+
89
+ where $s \geq 1$ is a tunable scalar hyperparameter.4
90
+
91
+ Others: Other parameter-efficient tuning methods include BitFit (Ben Zaken et al., 2021), which only fine-tunes bias vectors in the pre-trained model, and diff-pruning (Guo et al., 2021), which learns a sparse parameter update vector.
92
+
93
+ # 3 BRIDGING THE GAP – A UNIFIED VIEW
94
+
95
+ We first derive an equivalent form of prefix tuning to establish its connection with adapters. We then propose a unified framework for parameter-efficient tuning that includes several state-of-the-art methods as instantiations.
96
+
97
+ # 3.1 A CLOSER LOOK AT PREFIX TUNING
98
+
99
+ Eq. 5 describes the mechanism of prefix tuning which changes the attention module through prepending $l$ learnable vectors to the original attention keys and values. Here, we derive an equivalent form of Eq. 5 and provide an alternative view of prefix tuning:5
100
+
101
+ $$
102
+ \begin{array} { r l } & { \mathrm { h e a d } = \mathrm { A t } \mathrm { t n } ( x W _ { q } , \mathrm { c o n c a t } ( P _ { k } , C W _ { k } ) , \mathrm { c o n c a t } ( P _ { v } , C W _ { v } ) ) } \\ & { \ = \mathrm { s o f t m a x } \big ( x W _ { q } \mathrm { c o n c a t } ( P _ { k } , C W _ { k } ) ^ { \top } \big ) \Big [ \begin{array} { l } { P _ { v } } \\ { C W _ { v } } \end{array} \Big ] } \\ & { \ = ( 1 - \lambda ( \pmb { x } ) ) \mathrm { s o f t m a x } ( { \pmb x } W _ { q } W _ { k } ^ { \top } C ^ { \top } ) C W _ { v } + \lambda ( { \pmb x } ) \mathrm { s o f t m a x } ( { \pmb x } W _ { q } P _ { k } ^ { \top } ) P _ { v } } \\ & { \ = ( 1 - \lambda ( \pmb { x } ) ) \underbrace { \mathrm { A t t n } ( { \pmb x } W _ { q } , C W _ { k } , C W _ { v } ) } _ { \mathrm { s t a n d a r d a t e n t i o n } } + \lambda ( \pmb { x } ) \underbrace { \mathrm { A t t n } ( { \pmb x } W _ { q } , P _ { k } , P _ { v } ) } _ { \mathrm { i n d e p e n d e n t o f } C } , } \end{array}
103
+ $$
104
+
105
+ where $\lambda ( { \pmb x } )$ is a scalar that represents the sum of normalized attention weights on the prefixes:
106
+
107
+ $$
108
+ \lambda ( \pmb { x } ) = \frac { \sum _ { i } \exp ( \pmb { x } \pmb { W _ { q } } \pmb { P } _ { k } ^ { \top } ) _ { i } } { \sum _ { i } \exp ( \pmb { x } \pmb { W _ { q } } \pmb { P } _ { k } ^ { \top } ) _ { i } + \sum _ { j } \exp ( \pmb { x } \pmb { W _ { q } } \pmb { W } _ { k } ^ { \top } \pmb { C } ^ { \top } ) _ { j } } .
109
+ $$
110
+
111
+ Note that the first term in Eq. 7, $\mathrm { A t t n } ( x W _ { q } , C W _ { k } , C W _ { v } )$ , is the original attention without prefixes, whereas the second term is a position-wise modification independent of $C$ . Eq. 7 gives an alternative view of prefix tuning that essentially applies a position-wise modification to the original head attention output $^ { h }$ through linear interpolation:
112
+
113
+ $$
114
+ \begin{array} { r } { \pmb { h } ( 1 - \lambda ( \pmb { x } ) ) \pmb { h } + \lambda ( \pmb { x } ) \Delta \pmb { h } , \quad \Delta \pmb { h } : = \mathrm { s o f t m a x } ( \pmb { x } \pmb { W } _ { q } \pmb { P } _ { k } ^ { \top } ) \pmb { P } _ { v } . } \end{array}
115
+ $$
116
+
117
+ The Connection with Adapters: We define $W _ { 1 } { = } W _ { q } P _ { k } ^ { \top }$ , $W _ { 2 } { = } P _ { v }$ , $f \colon$ =softmax, and rewrite Eq. 9:
118
+
119
+ $$
120
+ \begin{array} { r } { \pmb { h } ( 1 - \lambda ( \pmb { x } ) ) \pmb { h } + \lambda ( \pmb { x } ) f ( \pmb { x } \pmb { W } _ { 1 } ) \pmb { W } _ { 2 } , } \end{array}
121
+ $$
122
+
123
+ which reaches a very similar form to the adapter function in Eq. 4, except that prefix tuning is performing weighted addition while the adapter one is unweighted.6 Figure 3b demonstrates the computation graph of prefix tuning from this view, which allows for abstraction of prefix tuning as a plug-in module like adapters. Further, we note that $W _ { 1 } \in \mathbb { R } ^ { d _ { h } \times l }$ and $W _ { 2 } \in \mathbb { R } ^ { l ^ { \cdot } \times d _ { h } }$ are lowrank matrices when $l$ is small, and thus they function similarly to the $W _ { \mathrm { d o w n } }$ and $W _ { \mathrm { u p } }$ matrices in adapters. This view also suggests that the number of prefix vectors, $l$ , plays a similar role to the bottleneck dimension $r$ in adapters: they both represent the rank limitation of computing the modification vector $\Delta h$ . Thus we also refer $l$ as the bottleneck dimension. Intuitively, the rank limitation implies that $\Delta h$ is a linear combination of the same $l$ (or $\leq l$ ) basis vectors for any $_ { \textbf { \em x } }$ .
124
+
125
+ Table 1: Parameter-efficient tuning methods decomposed along the defined design dimensions. Here, for clarity, we directly write the adapter nonlinear function as ReLU which is commonly used. The bottom part of the table exemplifies new variants by transferring design choices of existing approaches.
126
+
127
+ <table><tr><td>Method</td><td>△h functional form</td><td>insertion form</td><td>modified representation</td><td>composition function</td></tr><tr><td colspan="5">Existing Methods</td></tr><tr><td>Prefix Tuning</td><td> softmax(xWqPT)Pu</td><td>parallel</td><td>head attn</td><td>h←(1-λ)h+λ△h</td></tr><tr><td>Adapter</td><td>ReLU(hWdown)Wup</td><td>sequential</td><td>ffn/attn</td><td>h←h+△h</td></tr><tr><td>LoRA</td><td>xWdownWup</td><td>parallel</td><td>attn key/val</td><td>h←h+s·△h</td></tr><tr><td colspan="5">Proposed Variants</td></tr><tr><td>Parallel adapter</td><td>ReLU(hWdown)Wup</td><td>parallel</td><td>ffn/attn</td><td>h←h+△h</td></tr><tr><td>Muti-head parallel adapter</td><td>ReLU(hWdown)Wup</td><td>parallel</td><td>head attn</td><td>h←h+△h</td></tr><tr><td>Scaled parallel adapter</td><td>ReLU(hWdown)Wup</td><td>parallel</td><td>ffn/attn</td><td>h←h+s·△h</td></tr></table>
128
+
129
+ The Difference from Adapters: In addition to the gating variable $\lambda$ , we emphasize three differences between prefix tuning and adapters. (1) As demonstrated in Figure 3, prefix tuning uses $_ { \textbf { \em x } }$ , the input of the PLM layer, to compute $\Delta h$ , while adapters use $^ { h }$ , the output of the PLM layer. Thus, prefix tuning can be thought of as a “parallel” computation to the PLM layer, whereas the typical adapter is “sequential” computation. (2) Adapters are more flexible with respect to where they are inserted than prefix tuning: adapters typically modify attention or FFN outputs, while prefix tuning only modifies the attention output of each head. Empirically, this makes a large difference as we will show in $\ S 4 . 4$ . (3) Eq. 10 applies to each attention head, while adapters are always single-headed, which makes prefix tuning more expressive: head attention is of dimension $d / \dot { N _ { h } }$ – basically we have full rank updates to each attention head if $l \geq d / N _ { h }$ , but we only get full-rank updates to the whole attention output with adapters if $r \geq d$ . Notably, prefix tuning is not adding more parameters than adapters when ${ \dot { l } } = r$ .7 We empirically validate such multi-head influence in $\ S 4 . 4$ .
130
+
131
+ # 3.2 THE UNIFIED FRAMEWORK
132
+
133
+ Inspired by the connections between prefix tuning and adapters, we propose a general framework that aims to unify several state-of-the-art parameter-efficient tuning methods. Specifically, we cast them as learning a modification vector $\Delta h$ , which is applied to various hidden representations. Formally, we denote the hidden representation to be directly modified as $^ { h }$ , and the direct input to the PLM sub-module that computes $^ { h }$ as $_ { \textbf { \em x } }$ (e.g. $^ { h }$ and $_ { \textbf { \em x } }$ can be the attention output and input respectively). To characterize this modification process, we define a set of design dimensions, and different methods can be instantiated by varying values along these dimensions. We detail the design dimensions below, and illustrate how adapters, prefix tuning, and LoRA fall along them in Table 1:
134
+
135
+ Functional Form is the specific function that computes $\Delta h$ . We have detailed the functional form for adapters, prefix tuning, and LoRA in Eq. 4, 6, and 10 respectively. The functional forms of all these methods are similar with a proj down nonlinear $\to \mathsf { p r o j }$ up architecture, while “nonlinear” degenerates to the identity function in LoRA.
136
+
137
+ Modified Representation indicates which hidden representation is directly modified.8
138
+
139
+ Insertion Form is how the added module is inserted into the network. As mentioned in the previous section and shown in Figure 3, traditionally adapters are inserted at a position in a sequential manner, where both the input and output are $^ { h }$ . Prefix tuning and LoRA – although not originally described in this way – turn out to be equivalent to a parallel insertion where $_ { \textbf { \em x } }$ is the input.
140
+
141
+ Composition Function is how the modified vector $\Delta h$ is composed with the original hidden representation $^ { h }$ to form the new hidden representation. For example, adapters perform simple additive composition, prefix tuning uses a gated additive composition as shown in Eq. 10, and LoRA scales $\Delta h$ by a constant factor and adds it to the original hidden representation as in Eq. 6.
142
+
143
+ We note that many other methods not present in Table 1 fit into this framework as well. For example, prompt tuning modifies the head attention in the first layer in a way similar to prefix tuning, and various adapter variants (Pfeiffer et al., 2021; Mahabadi et al., 2021) can be represented in a similar way as adapters. Critically, the unified framework allows us to study parameter-efficient tuning methods along these design dimensions, identify the critical design choices, and potentially transfer design elements across approaches, as in the following section.
144
+
145
+ # 3.3 TRANSFERRING DESIGN ELEMENTS
146
+
147
+ Here, and in Figure 3, we describe just a few novel methods that can be derived through our unified view above by transferring design elements across methods: (1) Parallel Adapter is the variant by transferring the parallel insertion of prefix tuning into adapters. Interestingly, while we motivate the parallel adapter due to its similarity to prefix tuning, concurrent work (Zhu et al., 2021) independently proposed this variant and studied it empirically; (2) Multi-head Parallel Adapter is a further step to make adapters more similar to prefix tuning: we apply parallel adapters to modify head attention outputs as prefix tuning. This way the variant improves the capacity for free by utilizing the multi-head projections as we discuss in $\ S 3 . 1$ . (3) Scaled Parallel Adapter is the variant by transferring the composition and insertion form of LoRA into adapters, as shown in Figure 3e.
148
+
149
+ Our discussion and formulation so far raise a few questions: Do methods varying the design elements above exhibit distinct properties? Which design dimensions are particularly important? Do the novel methods described above yield better performance? We answer these questions next.
150
+
151
+ # 4 EXPERIMENTS
152
+
153
+ # 4.1 GENERAL SETUP
154
+
155
+ Datasets: We study four downstream tasks: (1) XSum (Narayan et al., 2018) is an English summarization dataset where models predict a summary given a news article; (2) English to Romanian translation using the WMT 2016 en-ro dataset (Bojar et al., 2016); (3) MNLI (Williams et al., 2018) is an English natural language inference dataset where models predict whether one sentence entails, contradicts, or is neutral to another. (4) SST2 (Socher et al., 2013) is an English sentiment classification benchmark where models predict whether a sentence’s sentiment is positive or negative.
156
+
157
+ Setup: We use ${ \tt B A R T } _ { \tt L A R G E }$ (Lewis et al., 2020) and a multilingual version of it, mBARTLARGE (Liu et al., 2020a), as the underlying pretrained models for XSum and en-ro translation respectively, and we use RoBERTaBASE (Liu et al., 2019) for MNLI and SST2. We vary the bottleneck dimension within $\{ 1 , 3 0 , 2 0 0 , 5 1 2 , 1 0 2 4 \}$ if needed.9 We mainly study adapters, prefix tuning (prefix), and LoRA which greatly outperform bitfit and prompt tuning in our experiments. In the analysis sections $( \ S 4 . 3 – 4 . 5 )$ we insert adapters either at the attention or FFN layers for easier analysis, but include the results of inserting at both places in the final comparison (§4.6). We re-implement these methods based on their respective public code.10 We use the huggingface transformers library (Wolf et al., 2020) for our implementation. Complete setup details can be found in Appendix A.
158
+
159
+ Evaluation: We report ROUGE $1 / 2 / \mathrm { L }$ scores (R-1/2/L, Lin (2004)) on the XSum test set, BLEU scores (Papineni et al., 2002) on the en-ro test set, and accuracy on the MNLI and SST2 dev set. For MNLI and SST2, we take the median of five random runs. We also report the number of tuned parameters relative to that in full fine-tuning (#params).
160
+
161
+ Number of Tunable Parameters: BART and mBART have an encoder-decoder structure that has three types of attention: encoder self-attention, decoder self-attention, and decoder cross-attention. RoBERTa only has encoder self-attention. For each attention sub-layer, the number of parameters used of each method is: (1) prefix tuning prepends $l$ vectors to the keys and values and uses $2 \times l \times d$ parameters; (2) adapter has $W _ { \mathrm { d o w n } }$ and $W _ { \mathrm { u p } }$ thus uses $2 \times r \times d$ parameters; (3) LoRA employs a pair of $W _ { \mathrm { d o w n } }$ and $W _ { \mathrm { u p } }$ for query and value projections, hence uses $4 \times r \times d$ parameters. For the adapter modification at ffn, it uses $2 \times r \times d$ parameters which is the same as adapter at attention. Therefore, for a specific value of $r$ or $l$ , prefix tuning uses the same number of parameters as adapters, while LoRA uses more parameters. More details can be found in Appendix B.
162
+
163
+ ![](images/bfd47b7ac5dcc585f8293ecd8c4a66c357d735ee263aa3622fc820936609f5be.jpg)
164
+ Figure 4: Performance of previous state-of-the-art parameterefficient tuning methods on $\bar { \mathrm { X S u m } }$ (left) and en-ro (right).
165
+
166
+ Table 2: Accuracy on the dev set of MNLI and SST2. MAM Adapter is proposed in $\ S 4 . 6$ . Bitfit numbers are from Ben Zaken et al. (2021).
167
+
168
+ <table><tr><td>Method (# params)</td><td>MNLI</td><td>SST2</td></tr><tr><td>Full-FT (100%)</td><td>87.6±.4</td><td>94.6±.4 93.7</td></tr><tr><td>Bitfit (0.1 %) Prefix (0.5%) LoRA (0.5%) Adapter (0.5%)</td><td>84.7 86.3±.4 87.2±.4 87.2±.2</td><td>94.0±.1 94.2±.2 94.2±.1</td></tr><tr><td colspan="3">MAM Adapter (0.5%) 87.4±.3 94.2±.3</td></tr></table>
169
+
170
+ Table 3: Comparison of different insertion forms for adapters, i.e. sequential adapter (SA) and parallel adapter (PA). We include the results of prefix tuning as a reference point.
171
+
172
+ <table><tr><td>Method</td><td># params</td><td>XSum (R-1/2/L)</td><td>MT (BLEU)</td></tr><tr><td>Prefix,l=200</td><td>3.6%</td><td>43.40/20.46/35.51</td><td>35.6</td></tr><tr><td>SA (attn), r=200</td><td>3.6%</td><td>42.01/19.30/34.40</td><td>35.3</td></tr><tr><td>SA (ffn),r=200</td><td>2.4%</td><td>43.21/19.98/35.08</td><td>35.6</td></tr><tr><td>PA (attn), r=200</td><td>3.6%</td><td>43.58/20.31/35.34</td><td>35.6</td></tr><tr><td>PA (ffn),r=200</td><td>2.4%</td><td>43.93/20.66/35.63</td><td>36.4</td></tr></table>
173
+
174
+ Table 4: Results on en-ro dataset.
175
+
176
+ <table><tr><td>Method</td><td># params MT (BLEU)</td></tr><tr><td>PA (attn),r=200 Prefix,l=200</td><td>3.6% 35.6 3.6% 35.6</td></tr><tr><td>MH PA (attn),r=200</td><td>3.6% 35.8</td></tr><tr><td>Prefix,l=30</td><td>0.1% 35.2</td></tr><tr><td>-gating,l=30</td><td>0.1% 34.9</td></tr><tr><td>PA (ffn),r=30</td><td>0.1% 33.0</td></tr><tr><td>PA (attn),r=30 MH PA (attn),r=30</td><td>0.1% 33.7 0.1% 35.3</td></tr></table>
177
+
178
+ # 4.2 THE RESULTS OF EXISTING METHODS
179
+
180
+ We first overview the results of existing methods on the four tasks. As shown in Figure 4 and Table 2, while existing methods can achieve competitive performance on MNLI and SST2 by tuning fewer than $1 \%$ parameters, a large gap is still present if we add $5 \%$ parameters in XSum and en-ro. The gap remains significant even though we increase the relative parameter size to $> 1 0 \%$ . Even larger gaps have been observed in Raffel et al. (2020) on high-resource MT tasks. This shows that many methods that claimed comparable results to full fine-tuning on the GLUE benchmark with an encoder-only model (Guo et al., 2021; Ben Zaken et al., 2021; Mahabadi et al., 2021), or on relatively simple generation benchmarks such as E2E (Novikova et al., 2017) with an encoder-decoder model (Li & Liang, 2021), may not generalize well to other standard benchmarks. The influencing factors could be complicated including the number of training samples, task complexity, or model architecture. We thus advocate for future research on this line to report results on more diverse benchmarks to exhibit a more complete picture of their performance profile. Below, our analysis will mainly focus on the XSum and en-ro datasets to better distinguish different design choices. We note that these two benchmarks are relatively high-resource performed with an encoder-decoder model (BART), while we will discuss the results on MNLI and SST2 with an encoder-only model (RoBERTa) in $\ S 4 . 6$ .
181
+
182
+ # .3 WHICH INSERTION FORM – SEQUENTIAL OR PARALLEL?
183
+
184
+ We first study the insertion form design dimension, comparing the proposed parallel adapter (PA) variant to the conventional sequential adapter (SA) over both the attention (att) and FFN modification. We also include prefix tuning as a reference point. As shown in Table 3, prefix tuning, which uses parallel insertion, outperforms attention sequential adapters. Further, the parallel adapter is able to beat sequential adapters in all cases,11 with PA (ffn) outperforming SA (ffn) by $1 . 7 \mathrm { R } \mathrm { - } 2$ points on
185
+
186
+ ![](images/08efaea948e4b8e31896a063d3d9ff883d744e25c54932f026083a5374a43c9f.jpg)
187
+ Figure 5: Results on XSum (left) and en-ro (right). PA represents parallel adapter. Blue and red markers apply modifications at attention and FFN sub-layers respectively (best viewed in color).
188
+
189
+ XSum and 0.8 BLEU points on en-ro respectively. Given the superior results of parallel adapters over sequential adapters, we focus on parallel adapter results in following sections.
190
+
191
+ # 4.4 WHICH MODIFIED REPRESENTATION – ATTENTION OR FFN?
192
+
193
+ Setup: We now study the effect of modifying different representations. We mainly compare attention and FFN modification. For easier analysis we categorize methods that modifies any hidden representations in the attention sub-layer (e.g. the head output, query, etc) as modifying the attention module. We compare parallel adapters at attention and FFN and prefix tuning. We also transfer the FFN modification to LoRA to have a LoRA (ffn) variant for a complete comparison. Specifically, we use LoRA to approximate the parameter updates for the FFN weights $\dot { W _ { 1 } } \in \mathbb { R } ^ { d \times \dot { d _ { m } } }$ and $\pmb { W } _ { 2 } \in \mathbb { R } ^ { d _ { m } \times d }$ . In this case $W _ { \mathrm { u p } }$ in LoRA for $W _ { 1 }$ (similar for $W _ { \mathrm { d o w n } }$ of $W _ { 2 }$ ) would have dimensions of $r \times d _ { m }$ , where $d _ { m } = 4 d$ as described in $\ S 2 . 1$ . Thus we typically use smaller $r$ for LoRA (ffn) than other methods to match their overall parameter size in later experiments.
194
+
195
+ Results: As shown in Figure 5, any method with FFN modification outperforms all the methods with attention modification in all cases (the red markers are generally above all the blue ones, the only exception is ffn-PA with $2 . 4 \%$ params), often with fewer parameters. Second, the same method applied at FFN always improves over its attention counterpart. For example, LoRA (ffn) improves LoRA (attn) by 1 R-2 points on XSum. We also highlight that prefix tuning does not keep improving when we further increase the capacity, which is also observed in Li & Liang (2021). These results suggest that FFN modification can utilize the added parameters more effectively than attention, no matter what the functional form or composition function is. We hypothesize that this is because the FFN learns task-specific textual patterns (Geva et al., 2021), while attention learns pairwise positional interactions which do not require large capacity for adapting to new tasks.
196
+
197
+ Is the story different when we use $0 . 1 \%$ parameters? In $\ S 3 . 1$ we reason that prefix tuning is more expressive than adapters (attn), which, however, is not reflected in Figure 5. We conjecture that this is because multi-head attention is only superior when the parameter budget is small. To validate this hypothesis, we compare prefix tuning to parallel adapters when they add $0 . 1 \%$ of the pretrained parameters. To ablate the impact of the composition function, we also report the results of removing the gating in prefix tuning as $h + \Delta h$ . We include the results of the multi-head parallel adapter variant (MH PA) described in $\ S 3 . 3$ . As shown in Table 4, the multi-head methods – prefix tuning and MH PA (attn) – outperform all others by at least 1.6 BLEU points when using $0 . 1 \%$ of the parameters. Surprisingly, reducing $l$ from 200 to 30 only causes 0.4 BLEU loss for prefix tuning while PA (attn) loses 1.9 points. The gating composition function in prefix tuning slightly helps the results by 0.3 points. We highlight that the MH parallel adapter improves the single-headed version by 1.6 points, which again verifies the effectiveness of the multi-head formulation.
198
+
199
+ Combining the results in Figure 5 and Table 4, we conclude that modifying head attention shows the best results when the parameter budget is very small, while the FFN can better utilize modifications at larger capacities. This suggests that it may be effective to allocate a larger parameter budget to FFN modification instead of treating attention and FFN equally as in Houlsby et al. (2019).
200
+
201
+ # 4.5 WHICH COMPOSITION FUNCTION?
202
+
203
+ We have presented three composition functions in $\ S 3 . 2$ : simple addition (adapter), gated addition (prefix tuning) and scaled addition (LoRA). As it is unnatural to incorporate the exact gated addition into methods whose functional form does not use softmax, we examine the other two by ablating on LoRA and comparing with the proposed scaled parallel adapter (Scaled PA), we constrain modified representation to be FFN since it is generally more effective as shown in $\ S 4 . 4$
204
+
205
+ Table 6: Comparison of various parameter-efficient tuning methods and the proposed variants. “†” are results copied from Lewis et al. (2020) and Liu et al. (2020b). We could not reproduce exactly the same full finetuning numbers with the same hyperparameters or even searching them. The reason may be the different libraries which the training code is based on – full fine-tuning is very sensitive to training hyperparameters. For the most performant methods we run with 3 random seeds and report mean and standard deviation.
206
+
207
+ <table><tr><td>Method</td><td># params</td><td>XSum (R-1/2/L)</td><td>MT (BLEU)</td></tr><tr><td>Full fine-tuning+</td><td>100%</td><td>45.14/22.27/37.25</td><td>37.7</td></tr><tr><td>Full fine-tuning (our run)</td><td>100%</td><td>44.81/21.94/36.83</td><td>37.3</td></tr><tr><td>Bitfit (Ben Zaken et al., 2021)</td><td>0.1%</td><td>40.64/17.32/32.19</td><td>26.4</td></tr><tr><td>Prompt tuning (Lester et al., 2021)</td><td>0.1%</td><td>38.91/15.98/30.83</td><td>21.0</td></tr><tr><td>Prefix tuning (Li&amp; Liang,2021),l=200</td><td>3.6%</td><td>43.40/20.46/35.51</td><td>35.6</td></tr><tr><td>Pfeiffer adapter (Pfeiffer et al.,2021),r=600</td><td>7.2%</td><td>44.03/20.89/35.89±.13/.10/.08</td><td>36.9±.1</td></tr><tr><td>LoRA (ffn),r=102</td><td>7.2%</td><td>44.53/21.29/36.28±.14/.07/.10</td><td>36.8±.3</td></tr><tr><td>Parallel adapter (PA,ffn),r=1024</td><td>12.3%</td><td>44.71/21.41/36.41±.16/.17/.16</td><td>37.2±.1</td></tr><tr><td>PA (attn,r=30) + PA (ffn,r=512)</td><td>6.7%</td><td>44.29/21.06/36.12±.31/.19/.18</td><td>37.2±.1</td></tr><tr><td>Prefix tuning (attn,l=3O) + LoRA (ffn,r=102)</td><td>6.7%</td><td>44.84/21.71/36.77±.07/.05/.03</td><td>37.0±.1</td></tr><tr><td>MAM Adapter (our variant, l=30,r=512)</td><td>6.7%</td><td>45.06/21.90/36.87±.08/01/.04</td><td>37.5±.1</td></tr></table>
208
+
209
+ Table 5 reports the results on XSum. We set $r$ as 512 for adapters and 102 for LoRA so that their tuned parameter sizes are the same. We select $s$ based on the R-2 score on the dev set. We observe that LoRA $s = 4$ ) performs better than parallel adapter. However, the advantage disappears if we remove the scaling by setting $s ~ = ~ 1$ . Through plugging the composition function of LoRA into parallel adapter, the resulted Scaled PA improves the vanilla parallel adapter by 0.56 ROUGE-2 points. We also experiment with a learned scalar which does not give better results. Therefore, we conclude that the scaling composition function is better than the vanilla additive one while being easily applicable.
210
+
211
+ Table 5: Results on XSum when using different composition functions. The modified representation is FFN. The bottleneck dimension $\bar { r } = 5 1 2$ for (Scaled) PA and $r = 1 0 2$ for LoRA.
212
+
213
+ <table><tr><td>Method (# params)</td><td>XSum (R-1/2/LSum)</td></tr><tr><td>LoRA (6.1%), s=4</td><td>44.59/21.31/36.25</td></tr><tr><td>LoRA (6.1%), s=1</td><td>44.17/20.83/35.74</td></tr><tr><td>PA (6.1%)</td><td>44.35/20.98/35.98</td></tr><tr><td>Scaled PA (6.1%), s=4</td><td>44.85/21.54/36.58</td></tr><tr><td>Scaled PA(6.1%),trainable s</td><td>44.56/21.31/36.29</td></tr></table>
214
+
215
+ # 4.6 AN EFFECTIVE INTEGRATION BY TRANSFERRING FAVORABLE DESIGN ELEMENTS
216
+
217
+ We first highlight three findings in previous sections: (1) Scaled parallel adapter is the best variant to modify FFN; (2) FFN can better utilize modification at larger capacities; and (3) modifying head attentions like prefix tuning can achieve strong performance with only $0 . 1 \%$ parameters. Inspired by them, we mix and match the favorable designs behind these findings: specifically, we use prefix tuning with a small bottleneck dimension $\mathit { l } \ : = \ : 3 0 $ ) at the attention sub-layers and allocate more parameter budgets to modify FFN representation using the scaled parallel adapter $( r = 5 1 2$ ). Since prefix tuning can be viewed as a form of adapter in our unified framework, we name this variant as Mix-And-Match adapter (MAM Adapter). In Table 6, we compare MAM adapter with various parameter-efficient tuning methods. For completeness, we also present results of other combination versions in Table 6: using parallel adapters at both attention and FFN layers and combining prefix tuning (attn) with LoRA (ffn) – both of these combined versions can improve over their respective prototypes. However, MAM Adapter achieves the best performance on both tasks and is able to match the results of our full fine-tuning by only updating $6 . 7 \%$ of the pre-trained parameters. In Table 2, we present the results of MAM Adapter on MNLI and SST2 as well, where MAM Adapter achieves comparable results to full fine-tuning by adding only $0 . 5 \%$ of pretrained parameters.
218
+
219
+ # 5 DISCUSSION
220
+
221
+ We provide a unified framework for several performant parameter-tuning methods, which enables us to instantiate a more effective model that matches the performance of full fine-tuning method through transferring techniques across approaches. We hope our work can provide insights and guidance for future research on parameter-efficient tuning.
222
+
223
+ # ETHICS STATEMENT
224
+
225
+ Our work proposes a method for efficient fine-tuning of pre-trained models, in particular language models. Pre-trained language models have a wide variety of positive applications, such as the applications to summarization, translation, or language understanding described in our paper. At the same time, there are a number of ethical concerns with language models in general, including concerns regarding the generation of biased or discriminative text (Bordia & Bowman, 2019), the leakage of private information from training data (Carlini et al., 2020), and environmental impact of training or tuning them (Strubell et al., 2019).
226
+
227
+ Our method attempts to train language models making minimal changes to their pre-existing parameters. While it is an interesting research question whether parameter-efficient fine-tuning methods exacerbate, mitigate, or make little change to issues such as bias or information leakage, to our knowledge no previous work has examined this topic. It is an interesting avenue for future work.
228
+
229
+ With respect to environmental impact, the methods proposed in this paper add a small number of extra parameters and components to existing models, and thus they have a nominal negative impact on training and inference time – for example, the final MAM Adapter needs $1 0 0 \% - 1 5 0 \%$ training time of full fine-tuning in our four benchmarks since parameter-efficient tuning typically needs more epochs to converge; the inference time is roughly the same as the model obtained by full fine-tuning. On the other hand, as the methods proposed in this paper may obviate the need for full fine-tuning, this may also significantly reduce the cost (in terms of memory/deployed servers) of serving models. Notably, the great majority of the experimentation done for this paper was performed on a data center powered entirely by renewable energy.
230
+
231
+ # REPRODUCIBILITY STATEMENT
232
+
233
+ In addition to the setup description in $\ S 4 . 1$ , we have detailed the complete experiments setup such as batch size, optimizer, learning rates in Appendix A. Besides, we have publicized our source code. These resources should be sufficient to reproduce results of the paper.
234
+
235
+ # ACKNOWLEDGEMENT
236
+
237
+ We thank the anonymous reviewers for their comments. This work was supported in part by the CMU-Portugal MAIA Project, a Baidu PhD Fellowship for Junxian He, and a CMU Presidential Fellowship for Chunting Zhou.
238
+
239
+ # REFERENCES
240
+
241
+ Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
242
+
243
+ Elad Ben Zaken, Shauli Ravfogel, and Yoav Goldberg. Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models. arXiv e-prints, pp. arXiv–2106, 2021.
244
+
245
+ Ondˇrej Bojar, Rajen Chatterjee, Christian Federmann, Yvette Graham, Barry Haddow, Matthias Huck, Antonio Jimeno Yepes, Philipp Koehn, Varvara Logacheva, Christof Monz, et al. Findings of the 2016 conference on machine translation. In Proceedings of the First Conference on Machine Translation: Volume 2, Shared Task Papers, 2016.
246
+
247
+ Shikha Bordia and Samuel R. Bowman. Identifying and reducing gender bias in word-level language models. In Proceedings of the 2019 NAACL: Student Research Workshop, 2019.
248
+
249
+ Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020.
250
+
251
+ Nicholas Carlini, Florian Tramer, Eric Wallace, Matthew Jagielski, Ariel Herbert-Voss, Katherine Lee, Adam Roberts, Tom Brown, Dawn Song, Ulfar Erlingsson, et al. Extracting training data from large language models. arXiv preprint arXiv:2012.07805, 2020.
252
+
253
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of NAACL, 2019.
254
+
255
+ William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. arXiv preprint arXiv:2101.03961, 2021.
256
+
257
+ Mor Geva, Roei Schuster, Jonathan Berant, and Omer Levy. Transformer feed-forward layers are key-value memories. In Proceedings of EMNLP, 2021.
258
+
259
+ Demi Guo, Alexander M Rush, and Yoon Kim. Parameter-efficient transfer learning with diff pruning. In Proceedings of ACL, 2021.
260
+
261
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Delving deep into rectifiers: Surpassing human-level performance on imagenet classification. In Proceedings of ICCV, 2015.
262
+
263
+ Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for nlp. In Proceedings of ICML, 2019.
264
+
265
+ Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, and Weizhu Chen. LoRA: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021.
266
+
267
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Proceedings of ICLR, 2015.
268
+
269
+ Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of EMNLP, 2021.
270
+
271
+ Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. BART: Denoising sequence-to-sequence pretraining for natural language generation, translation, and comprehension. In Proceedings of ACL, 2020.
272
+
273
+ Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of ACL, 2021.
274
+
275
+ Chin-Yew Lin. ROUGE: A package for automatic evaluation of summaries. In Text Summarization Branches Out, 2004.
276
+
277
+ Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. Pretrain, prompt, and predict: A systematic survey of prompting methods in natural language processing. arXiv preprint arXiv:2107.13586, 2021a.
278
+
279
+ Xiao Liu, Yanan Zheng, Zhengxiao Du, Ming Ding, Yujie Qian, Zhilin Yang, and Jie Tang. GPT understands, too. arXiv:2103.10385, 2021b.
280
+
281
+ Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. RoBERTa: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692, 2019.
282
+
283
+ Yinhan Liu, Jiatao Gu, Naman Goyal, Xian Li, Sergey Edunov, Marjan Ghazvininejad, Mike Lewis, and Luke Zettlemoyer. Multilingual denoising pre-training for neural machine translation. Transactions of the Association for Computational Linguistics, 2020a.
284
+
285
+ Yinhan Liu, Jiatao Gu, Naman Goyal, Xian Li, Sergey Edunov, Marjan Ghazvininejad, Mike Lewis, and Luke Zettlemoyer. Multilingual denoising pre-training for neural machine translation. Transactions of the Association for Computational Linguistics, 8:726–742, 2020b. doi: 10.1162/tacl a 00343. URL https://aclanthology.org/2020.tacl-1.47.
286
+
287
+ Rabeeh Karimi Mahabadi, James Henderson, and Sebastian Ruder. Compacter: Efficient low-rank hypercomplex adapter layers. In Proceedings of NeurIPS, 2021.
288
+
289
+ Shashi Narayan, Shay B. Cohen, and Mirella Lapata. Don’t give me the details, just the summary! Topic-aware convolutional neural networks for extreme summarization. In Proceedings of EMNLP, 2018.
290
+
291
+ Jekaterina Novikova, Ondˇrej Dusek, and Verena Rieser. The E2E dataset: New challenges for ˇ end-to-end generation. In Proceedings of the 18th Annual SIGdial Meeting on Discourse and Dialogue, pp. 201–206, Saarbrucken, Germany, August 2017. doi: 10.18653/v1/W17-5525. ¨
292
+
293
+ Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of ACL, 2002.
294
+
295
+ Matthew E Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke Zettlemoyer. Deep contextualized word representations. In Proceedings of NAACL, 2018.
296
+
297
+ Jonas Pfeiffer, Aishwarya Kamath, Andreas Ruckl ¨ e, Kyunghyun Cho, and Iryna Gurevych. Adapter- ´ Fusion: Non-destructive task composition for transfer learning. In Proceedings of EACL, 2021.
298
+
299
+ Xipeng Qiu, Tianxiang Sun, Yige Xu, Yunfan Shao, Ning Dai, and Xuanjing Huang. Pre-trained models for natural language processing: A survey. Science China Technological Sciences, 2020.
300
+
301
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 2019.
302
+
303
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 2020.
304
+
305
+ Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D Manning, Andrew $\mathrm { ~ Y ~ N ~ g ~ } _ { }$ and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of EMNLP, 2013.
306
+
307
+ Emma Strubell, Ananya Ganesh, and Andrew McCallum. Energy and policy considerations for deep learning in NLP. In Proceedings of ACL, 2019.
308
+
309
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Proceedings of NeurIPS, 2017.
310
+
311
+ Adina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of NAACL, 2018.
312
+
313
+ Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick ´ von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. In Proceedings of EMNLP: System Demonstrations, 2020.
314
+
315
+ Yaoming Zhu, Jiangtao Feng, Chengqi Zhao, Mingxuan Wang, and Lei Li. Serial or parallel? plugable adapter for multilingual machine translation. arXiv preprint arXiv:2104.08154, 2021.
316
+
317
+ # A EXPERIMENTS
318
+
319
+ A.1 SETUPS
320
+
321
+ Table 7: Dataset Statistics of the four tasks.
322
+
323
+ <table><tr><td>Dataset</td><td>#train</td><td>#dev</td><td>#test</td></tr><tr><td>XSum</td><td>204,045</td><td>113,332</td><td>113,334</td></tr><tr><td>WMT16 en-ro</td><td>610,320</td><td>1,999</td><td>1,999</td></tr><tr><td>MNLI</td><td>392,702</td><td>9815</td><td>9832</td></tr><tr><td>SST-2</td><td>67,349</td><td>872</td><td>1,821</td></tr></table>
324
+
325
+ We implement all the parameter-efficient tuning methods using the huggingface transformers library (Wolf et al., 2020). We use BARTLARGE(Lewis et al., 2020) and mBARTLARGE (Liu et al., 2020b) (mBART-cc25) for the summarization and machine translation tasks respectively, and we use RoBERTaBASE (Liu et al., 2019) for MNLI and SST2. BARTLARGE and mBARTLARGE have the same encoder-decoder architectures. mBARTLARGE is pre-trained on 25 languages. We use their public checkpoints from the transformers library in experiments. For MT and classifications tasks, the max token lengths of training data are set to be 150 and 512 respectively. For XSum, we set the max length of source articles to be 512 and the max length of the target summary to be 128. The detailed dataset statistics is present in Table 7. In our summarization experiments, we only use 1600 examples for validation to save time.
326
+
327
+ While we vary the bottleneck dimension within $\{ 1 , 3 0 , 5 1 2 , 1 0 2 4 \}$ as mentioned in $\ S 4 . 1$ , we test bottleneck dimension 1024 only when the modified representation is FFN, because the training of prefix tuning does not fit into 48GB GPU memory when $l = 1 0 2 4$ . While other methods do not have memory issues, we keep the bottleneck dimension of attention modification at most 512 to have a relatively fair comparison with prefix tuning. For LoRA we always tune its scaling hyperparameters $s$ on the dev set.
328
+
329
+ # A.2 TRAINING AND EVALUATION
330
+
331
+ We present some training hyperparameters of parameter-efficient tuning methods in Table 8. For all the tasks, we train with the Adam optimizer (Kingma & Ba, 2015), and use a polynomial learning rate scheduler that linearly decays the learning rate throughout training. We set the warm up steps of learning rate to be 0 for both MT and summarization tasks, and for the classification tasks, learning rate is linearly warmed up from 0 for the first $6 \%$ of the total training steps before decay. For full fine-tuning we set these training hyperparameters following Lewis et al. (2020) (XSum), Liu et al. (2020b) (en-ro), and (Liu et al., 2019) (MNLI and SST2). We also did hyperparameter search in the full fine-tuning case to try to reproduce their results. We set dropout rate to be 0.1 for all the tasks. We use ROUGE-2 and perplexity as the validation metrics for summarization and MT respectively.
332
+
333
+ For MT and text summarization, we use beam search for decoding and set the number of beams to be 6 and 5 following previous work (Li & Liang, 2021; Liu et al., 2020b). The min and max generation lengths for summarization and MT are set to be (10, 60) and (1, 200) respectively.
334
+
335
+ # A.3 OTHER EXPERIMENTAL DETAILS
336
+
337
+ Prefix Tuning: Following Li & Liang (2021), we reparameterize the prefix vectors by a MLP network which is composed of a small embedding matrix and a large feedforward neural network. This is conducive for learning due to the shared parameters across all layers.
338
+
339
+ LoRA: LoRA and adapter employ different parameter initialization methods: LoRA uses a random Kaiming uniform (He et al., 2015) initialization for $W _ { \mathrm { d o w n } }$ and zero for $W _ { \mathrm { u p } }$ (LoRA init), while adapters use the same initialization as BERT (Devlin et al., 2019). We found it beneficial to use the same initialization method as LoRA in scaled PA.
340
+
341
+ Table 8: Training hyperparameters of parameter-efficient tuning methods on the four tasks. lr and ls represents learning rate and label smoothing respectively.
342
+
343
+ <table><tr><td>Tasks</td><td>lr</td><td>batch size</td><td>ls</td><td> max grad norm</td><td> weight decay</td><td> train steps</td></tr><tr><td>XSum</td><td>5e-5</td><td>64 sents</td><td>0.1</td><td>0.1</td><td>0.01</td><td>100K</td></tr><tr><td>enro MT</td><td>5e-5</td><td>16384 tokens</td><td>0.1</td><td>1.0</td><td>0.01</td><td>50K</td></tr><tr><td>MNLI/SST2</td><td>1e-4</td><td>32 sents</td><td>0</td><td>1.0</td><td>0.1</td><td>10 epochs</td></tr></table>
344
+
345
+ # B COMPUTATION OF TUNABLE PARAMETERS
346
+
347
+ Table 9: Number of attention or FFN sublayers in each layer of the pre-trained models.
348
+
349
+ <table><tr><td>BART/mBARTLARGE RoBERTaBASE</td><td></td></tr><tr><td>Nattn</td><td></td></tr><tr><td>Nfn</td><td>1</td></tr></table>
350
+
351
+ Table 10: Number of parameters used at each sub-layer for different methods.
352
+
353
+ <table><tr><td></td><td>Nattn</td><td>N</td></tr><tr><td>Prefix Tuning</td><td>2ld</td><td>一</td></tr><tr><td>Adapter variants</td><td>2rd</td><td>2rd</td></tr><tr><td>LoRA</td><td></td><td>2 × 2rd=4rd 2×(rd+4dr)=10rd</td></tr></table>
354
+
355
+ We compute the number of tunable parameters based on where the tunable module is inserted into and how it is parameterized. The pretrained-models for summarization or MT have an encoderdecoder structure and each has $L$ layers, whereas RoBERTaBASE for classification tasks only has $L$ encoder layers. To simplify the computation of tunable parameters, we compute the sum of parameter used in one encoder layer and one decoder layer as the parameter overhead of one single layer of the pre-trained encoder-decoder model. Each layer has $N _ { \mathrm { a t t n } }$ sub-layers and $N _ { \mathrm { { f f n } } }$ sublayers. For the encoder-decoder models, $N _ { \mathrm { a t t n } } = 3$ : the encoder self-attention, the decoder selfattention and the decoder cross-attention. For the classification tasks, $\mathtt { R o B E R T a } _ { \mathtt { B A S E } }$ only has the encoder self-attention, thus $N _ { \mathrm { a t t n } } ~ = ~ 1$ . We present the number of attention and ffn sub-layers for different pre-trained models in Table 10. For modifications applied at the attention sub-layers, the number of tunable parameters is computed by $| \Theta | _ { \mathrm { a t t n } } = \bar { N } _ { \mathrm { W } } ^ { \mathrm { a t t n } } \times N _ { \mathrm { a t t n } } \times L$ , where $N _ { \mathrm { W } } ^ { \mathrm { a t t n } }$ denotes the number of parameters $W _ { \mathrm { d o w n } }$ or $W _ { \mathrm { u p , } }$ ) used for one attention sub-layer. Similarly, the number of tunable parameters for the FFN sub-layers is computed by $\vert \Theta \vert _ { \mathrm { f f n } } = N _ { \mathrm { W } } ^ { \mathrm { f f n } } \times N _ { \mathrm { f f n } } \times$ $L$ . In Table 10, we show the number of parameters for one sub-layer. As we have explained in $\ S 4 . 4$ , LoRA approximates the update of each weight matrix with a pair of $W _ { \mathrm { d o w n } }$ and $W _ { \mathrm { u p } }$ , thus LoRA typically uses more parameters with the same $r$ as other methods. Finally, the total number of tunable parameters for prefix tuning, adapter variants and LoRA is $| \Theta | = | \Theta | _ { \mathrm { a t t n } } + | \Theta | _ { \mathrm { f n } }$ as applicable. Prompt tuning prepends $l$ tunable vectors at the input layer and uses $l \times d$ number of parameters. Using MBART/BART as an example, we present the number of parameters used by several representative methods throughout our paper in Table 11, where adapter variants include sequential adapter, parallel adapter, scaled adapter and multi-head adapter.
356
+
357
+ Table 11: Number of tunable parameters of various parameter-efficient tuning methods with BART/MBART models $L = 1 2$ ) as an example.
358
+
359
+ <table><tr><td>Method</td><td>number of parameters</td></tr><tr><td>Prompt Tuning</td><td>lxd</td></tr><tr><td>Prefix Tuning (attn)</td><td>2ld×3×12</td></tr><tr><td>Adapter variants (attn)</td><td>2rd×3×12</td></tr><tr><td>Adapter variants (ffn)</td><td>2rd ×2×12</td></tr><tr><td>LoRA (attn)</td><td>4rd×3×12</td></tr><tr><td>LoRA (ffn)</td><td>10rd ×2×12</td></tr><tr><td>MAM Adapter (our proposed model)</td><td>)2ld×3×12+2rd×2×12</td></tr></table>
360
+
361
+ # C FULL RESULTS ON DIFFERENT BOTTLENECK DIMENSIONS
362
+
363
+ Table 12: Performance on the test sets of abstractive summarization (XSum) and WMT EN-RO translation.
364
+
365
+ <table><tr><td>Method</td><td># params (%) XSum (R-1/2/L)</td><td>MTBLEU</td></tr><tr><td colspan="3">Modified Representation: : attention</td></tr><tr><td>Prefix Tuning,r = 200</td><td>3.6 43.40/20.46/35.51 9.2</td><td>35.6</td></tr><tr><td>Prefix Tuning,r = 512</td><td>43.29/20.40/35.37</td><td>35.1</td></tr><tr><td>LoRA,r= 200</td><td>43.09/20.29/35.37</td><td>36.2</td></tr><tr><td>Sequential Adapter,r = 200</td><td>42.01/19.30/34.40</td><td>35.3</td></tr><tr><td>Sequential Adapter,r = 512</td><td>41.05/18.87/33.71</td><td>34.7</td></tr><tr><td>Parallel Adapter,r = 200</td><td>43.58/20.31/35.34</td><td>35.6</td></tr><tr><td>Parallel Adapter,r = 512</td><td>43.99/20.83/35.77</td><td>36.2</td></tr><tr><td colspan="3">Modified Representation: FFN</td></tr><tr><td>LoRA,r = 102</td><td>44.59/21.31/36.25</td><td>36.5</td></tr><tr><td>Sequential Adapter,r = 200</td><td>2.4 43.21/19.98/35.08</td><td>35.6</td></tr><tr><td>Sequential Adapter,r = 512</td><td>6.1 43.72/20.75/35.64</td><td>36.3</td></tr><tr><td>Sequential Adapter,r = 1024</td><td>12.3 43.95/21.00/35.90</td><td>36.7</td></tr><tr><td>Parallel Adapter,r = 200</td><td>2.4 43.93/20.66/35.63</td><td>36.4</td></tr><tr><td>Parallel Adapter,r = 512</td><td>6.1 44.35/20.98/35.98</td><td>37.1</td></tr><tr><td>Parallel Adapter,r = 1024</td><td>12.3 44.53/21.24/36.23</td><td>37.3</td></tr></table>
md/dev/0RTJcuvHtIu/0RTJcuvHtIu.md ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Flexible Diffusion Modeling of Long Videos
2
+
3
+ William Harvey, Saeid Naderiparizi, Vaden Masrani, Christian Weilbach, Frank Wood∗
4
+
5
+ Department of Computer Science University of British Columbia Vancouver, Canada {wsgh,saeidnp,vadmas,weilbach,fwood}@cs.ubc.ca
6
+
7
+ # Abstract
8
+
9
+ We present a framework for video modeling based on denoising diffusion probabilistic models that produces long-duration video completions in a variety of realistic environments. We introduce a generative model that can at test-time sample any arbitrary subset of video frames conditioned on any other subset and present an architecture adapted for this purpose. Doing so allows us to efficiently compare and optimize a variety of schedules for the order in which frames in a long video are sampled and use selective sparse and long-range conditioning on previously sampled frames. We demonstrate improved video modeling over prior work on a number of datasets and sample temporally coherent videos over 25 minutes in length. We additionally release a new video modeling dataset and semantically meaningful metrics based on videos generated in the CARLA autonomous driving simulator.
10
+
11
+ # 1 Introduction
12
+
13
+ Generative modeling of photo-realistic videos is at the frontier of what is possible with deep learning on currently-available hardware. Although related work has demonstrated modeling of short photorealistic videos (e.g. 30 frames [36], 48 frames [6] or 64 frames [16]), generating longer videos that are both coherent and photo-realistic remains an open challenge. A major difficulty is scaling: photorealistic image generative models [4, 8] are already close to the memory and processing limits of modern hardware. A long video is at very least a concatenation of many photorealistic frames, implying resource requirements, long-range coherence notwithstanding, that scale with frame count.
14
+
15
+ Attempting to model such long-range coherence makes the problem harder still, especially because in general every frame can have statistical dependencies on other frames arbitrarily far back in the video. Unfortunately fixed-lag autoregressive models impose unrealistic conditional independence assumptions (the next frame being independent of frames further back in time than the autoregressive lag is problematic for generating videos with long-range coherence). And while deep generative models based on recurrent neural networks (RNN) theoretically impose no such conditional independence assumptions, in practice they must be trained over short sequences [12, 26] or with truncated gradients [31]. Despite this, some RNN-based video generative models have demonstrated longer-range coherence, albeit without yet achieving convincing photorealistic video generation [26, 3, 7, 20, 2].
16
+
17
+ In this work we embrace the fact that finite architectures will always impose conditional independences. The question we ask is: given an explicit limit $K$ on the number of video frames we can jointly model, how can we best allocate these frames to generate a video of length $N > K ?$ One option is to use the previously-described autoregressive model but, if $K = N / 4$ , we could instead follow Ho et al. [16] by training two models: one which first samples every 4th frame in the video, and another which (in multiple stages) infills the remaining frames conditioned on those. To enable efficient exploration of the space of such sampling schemes, we propose a flexible architecture based on the denoising diffusion probabilistic model (DDPM) framework. This can sample any subset of video frames conditioned on observed values of any other subset of video frames. It therefore lets us explore a wide variety of previously untested sampling schemes while being easily repurposed for different generation tasks such as unconditional generation, video completion, and generation of videos of different lengths. Since our model can be flexibly applied to sample any frames given any others we call it a Flexible Diffusion Model, or FDM.
18
+
19
+ ![](images/d3896c398df1e076a51acfb5819f046231ccb319e84ddbaf5049df13dc706653.jpg)
20
+ Figure 1: A long video (25 minutes, or approximately 15 000 frames) generated by FDM for each of CARLA Town01 and MineRL, conditioned on 500 and 250 prior frames respectively. We show blocks of frames from three points within each video, starting from the final observed frame on the left. Blocks are marked with the time elapsed since the last observation and frames within them are one second apart. We observe no degradation in sample quality even after $> 1 5 0 0 0$ frames.
21
+
22
+ Contributions (1) At the highest level, we claim to have concurrently developed one of the first denoising diffusion probabilistic model (DDPM)-based video generative models [16, 40]. To do so we augment a previously-used DDPM image architecture [15, 22] with a temporal attention mechanism including a novel relative (frame) position encoding network. (2) The principal contribution of this paper, regardless, is a “meta-learning” training objective that encourages learning of a video generative model that can (a) be flexibly conditioned on any number of frames (up to computational resource constraints) at any time in the past and future and (b) be flexibly marginalized (to achieve this within computational resource constraints). (3) We demonstrate that our model can be used to efficiently explore the space of resource constrained video generation schemes, leading to improvements over prior work on several long-range video modeling tasks. (4) Finally, we release a new autonomous driving video dataset along with a new video generative model performance metric that captures semantics more directly than the visual quality and comparison metrics currently in widespread use.
23
+
24
+ # 2 Sampling long videos
25
+
26
+ Our goal in this paper is to sample coherent photo-realistic videos v with thousands of frames (see Fig. 1). To sample an arbitrarily long video with a generative model that can sample or condition on only a small number of frames at once, we must use a sequential procedure. The simplest example of this is an autoregressive scheme, an example of which is shown in Fig. 2a for a video completion task. In this example it takes seven stages to sample a complete video, in that we must run the generative model’s sampling procedure seven times. At each stage three frames are sampled conditioned on the immediately preceding four frames. This scheme is appealing for its simplicity but imposes a strong assumption that, given the set of four frames that are conditioned on at a particular stage, all frames that come afterwards are conditionally independent of all frames that came before. This restriction can be partially ameliorated with the sampling scheme shown in Fig. 2b where, in the first three stages, every second frame is sampled and then, in the remaining four stages, the remaining frames are infilled. One way to implement this would be to train two different models operating at the two different temporal resolutions. In the language of Ho et al. [16], who use a similar approach, sampling would be carried out in the first three stages by a “frameskip-2” model and, in the remaining stages, by a “frameskip-1” model. Both this approach and the autoregressive approach are examples of what we call sampling schemes. More generally, we characterize a sampling scheme as a sequence of tuples $[ ( \mathcal { X } _ { s } , \mathcal { Y } _ { s } ) ] _ { s = 1 } ^ { \bar { S } }$ , each containing a vector $\mathcal { X } _ { s }$ of indices of frames to sample and a vector $\mathcal { { D } } _ { s }$ of indices of frames to condition on for stages $s = 1 , \ldots , S$ .
27
+
28
+ Algorithm 1 Sample a video v given a sampling scheme $[ ( \mathcal { X } _ { s } , \mathcal { Y } _ { s } ) ] _ { s = 1 } ^ { S }$ . For unconditional generation, the input v can be a tensor of zeros. For conditional generation, the observed input frames should contain their observed values.
29
+
30
+ ![](images/754ba6c3882c936adc15285b6eb3db96a76d55df22201eb208337df69c833391.jpg)
31
+
32
+ ![](images/600712d51e1e42029bc1b4c4cd2cbf9b83301ebb8fae3df91ba6c5a7c1851508.jpg)
33
+ Figure 2: Sampling schemes to complete a video of length $N = 3 0$ conditioned on the first 10 frames, with access to at most $K = 7$ frames at a time. Each stage $s$ of the sampling procedure is represented by one row in the figure, going from top to bottom. Within each subfigure, one column represents one frame of the video, from frame one on the left to frame 30 on the right. At each stage, the values of frames marked in blue are sampled conditioned on the (observed or previously sampled) values of frames marked in red; frames marked in gray are ignored; and frames marked in white are yet to be sampled. For every sampling scheme, all video frames have been sampled after the final row.
34
+
35
+ Algorithm 1 lays out how such a sampling scheme is used to sample a video. If the underlying generative model is trained specifically to model sequences of consecutive frames, or sequences of regularly-spaced frames, then the design space for sampling schemes compatible with these models is severely constrained. In this paper we take a different approach. We design and train a generative model to sample any arbitrarily-chosen subset of video frames conditioned on any other subset and train it using an entirely novel distribution of such tasks. In short, our model is trained to generate frames for any choice of $\mathcal { X }$ and $\mathcal { V }$ . The only constraint we impose on our sampling schemes is therefore a computational consideration that $| \mathcal { X } _ { s } | + | \mathcal { V } _ { s } | \le K$ for all $s$ but, to generate meaningful videos, any valid sampling scheme must also satisfy two more constraints: (1) all frames are sampled at at least one stage and (2) frames are never conditioned upon before they are sampled.
36
+
37
+ Such a flexible generative model allows us to explore and use sampling schemes like those in Fig. 2c and Fig. 2d. We find in our experiments that the best video sampling scheme is dataset dependent. Accordingly, we have developed methodology to optimize such sampling schemes in a dataset dependent way, leading to improved video quality as measured by the Fréchet Video Distance [33] among other metrics. We now review conditional DDPMs (Section 3), before discussing the FDM’s architecture, the specific task distribution used to train it, and the choice and optimization of sampling schemes in Section 4.
38
+
39
+ # 3 A review of conditional denoising diffusion probabilistic models
40
+
41
+ Denoising diffusion probabilistic models, or DDPMs [28, 15, 22, 30], are a class of generative model for data $\mathbf { x }$ , which throughout this paper will take the form of a 4-dimensional tensor representing multiple video frames. We will describe the conditional extension [32], in which the modeled $\mathbf { x }$ is conditioned on observations $\mathbf { y }$ . DDPMs simulate a diffusion process which transforms $\mathbf { x }$ to noise, and generate data by learning the probabilistic inverse of the diffusion process. The diffusion process happens over timesteps $0 , \ldots , T$ such that $\mathbf { x } _ { 0 } = \mathbf { x }$ is data without noise, $\mathbf { x } _ { 1 }$ has a very small amount of noise added, and so on until $\mathbf { x } _ { T }$ is almost independent of $\mathbf { x } _ { \mathrm { 0 } }$ and approximates a random sample from a unit Gaussian. In the diffusion process we consider, the distribution over $\mathbf { x } _ { t }$ depends only on $\mathbf { x } _ { t - 1 }$ :
42
+
43
+ $$
44
+ \begin{array} { r } { q ( \mathbf x _ { t } | \mathbf x _ { t - 1 } ) = \mathcal N ( \mathbf x _ { t } ; \sqrt { \alpha _ { t } } \mathbf x _ { t - 1 } , ( 1 - \alpha _ { t } ) \mathbf I ) . } \end{array}
45
+ $$
46
+
47
+ Hyperparameters $\alpha _ { 1 } , \ldots , \alpha _ { T }$ are chosen to all be close to but slightly less than 1 so that the amount of noise added at each step is small. The combination of this diffusion process and a data distribution
48
+
49
+ ![](images/3fc8bc3620910017f4fb64feeca7720f8dbd1c2dc54a5bb68290e6287af2087d.jpg)
50
+ Figure 3: Left: Our DDPM iteratively transforms Gaussian noise $\mathbf { x } _ { T }$ to video frames $\mathbf { x } _ { \mathrm { 0 } }$ (shown with blue borders), conditioning on observed frames $\mathbf { y }$ (red borders) at every step. Right: The U-net architecture used within each DDPM step. It computes $\epsilon _ { \theta } ( \mathbf x _ { t } , \mathbf y , t )$ , with which the Gaussian transition $p _ { \theta } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } )$ is parameterized.
51
+
52
+ $q ( \mathbf { x } _ { 0 } , \mathbf { y } )$ (recalling that $\mathbf { x } _ { 0 } = \mathbf { x }$ ) defines the joint distribution
53
+
54
+ $$
55
+ q ( \mathbf x _ { 0 : T } , \mathbf y ) = q ( \mathbf x _ { 0 } , \mathbf y ) \prod _ { t = 1 } ^ { T } q ( \mathbf x _ { t } | \mathbf x _ { t - 1 } ) .
56
+ $$
57
+
58
+ DDPMs work by “inverting” the diffusion process: given values of $\mathbf { x } _ { t }$ and $\mathbf { y }$ a neural network is used to parameterize $p _ { \theta } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } , \mathbf { y } )$ , an approximation of $q ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } , \mathbf { y } )$ . This neural network lets us draw samples of $\mathbf { x } _ { \mathrm { 0 } }$ by first sampling $\mathbf { x } _ { T }$ from a unit Gaussian (recall that the diffusion process was chosen so that $q ( \mathbf { x } _ { T } )$ is well approximated by a unit Gaussian), and then iteratively sampling $\mathbf { x } _ { t - 1 } \sim p _ { \theta } ( \cdot | \mathbf { x } _ { t } , \mathbf { y } )$ for $t = T , T - 1 , \dots , 1$ . The joint distribution of sampled $\mathbf { x } _ { \mathrm { 0 : } T }$ given $\mathbf { y }$ is
59
+
60
+ $$
61
+ p _ { \theta } ( \mathbf { x } _ { 0 : T } | \mathbf { y } ) = p ( \mathbf { x } _ { T } ) \prod _ { t = 1 } ^ { T } p _ { \theta } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } , \mathbf { y } )
62
+ $$
63
+
64
+ where $p ( \mathbf { x } _ { T } )$ is a unit Gaussian that does not depend on $\theta$ . Training the conditional DDPM therefore involves fitting $p _ { \theta } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } , \mathbf { y } )$ to approximate $q ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } , \mathbf { y } )$ for all choices of $t$ , $\mathbf { x } _ { t }$ , and $\mathbf { y }$ .
65
+
66
+ Several observations have been made in recent years which simplify the learning of $p _ { \theta } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } , \mathbf { y } )$ . Sohl-Dickstein et al. [28] showed that when $\alpha _ { t }$ is close to 1, $p _ { \theta } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } )$ is approximately Gaussian [28]. Furthermore, Ho et al. [15] showed that this Gaussian’s variance can be modeled well with a non-learned function of $t$ , and that a good estimate of the Gaussian’s mean can be obtained from a “denoising model” as follows. Given data $\mathbf { x } _ { \mathrm { 0 } }$ and unit Gaussian noise $\epsilon$ , the denoising model (in the form of a neural network) is fed “noisy” data $\mathbf { x } _ { t } : = \sqrt { \tilde { \alpha } _ { t } } \mathbf { x } _ { 0 } + \sqrt { 1 - \tilde { \alpha } _ { t } } \epsilon$ and trained to recover $\epsilon$ via a mean squared error loss. The parameters $\begin{array} { r } { \tilde { \alpha } _ { t } : = \prod _ { i = 1 } ^ { t } \alpha _ { i } } \end{array}$ are chosen to ensure that the marginal distribution of $\mathbf { x } _ { t }$ given $\mathbf { x } _ { \mathrm { 0 } }$ is $q ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 } )$ as derived from Eq. (1). Given a weighting function $\lambda ( t )$ , the denoising loss is
67
+
68
+ $$
69
+ \mathcal { L } ( \theta ) = \mathbb { E } _ { q ( \mathbf { x } _ { 0 } , \mathbf { y } , \epsilon ) } \left[ \sum _ { t = 1 } ^ { T } \lambda ( t ) | | \epsilon - \epsilon _ { \theta } ( \mathbf { x } _ { t } , \mathbf { y } , t ) | | _ { 2 } ^ { 2 } \right] \quad \mathrm { w i t h } \quad \mathbf { x } _ { t } = \sqrt { \tilde { \alpha } _ { t } } \mathbf { x } _ { 0 } + \sqrt { 1 - \tilde { \alpha } _ { t } } \epsilon .
70
+ $$
71
+
72
+ The mean of $p _ { \theta } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } , \mathbf { y } )$ is obtained from the denoising model’s output $\epsilon _ { \theta } ( \mathbf x _ { t } , \mathbf y , t )$ as $\begin{array} { r } { \frac { 1 } { \alpha _ { t } } \mathbf { x } _ { t } - \frac { 1 - \alpha _ { t } } { \sqrt { 1 - \tilde { \alpha } _ { t } } } \epsilon _ { \theta } \big ( \mathbf { x } _ { t } , \mathbf { y } , t \big ) } \end{array}$ . If the weighting function $\lambda ( t )$ is chosen appropriately, optimising Eq. (4) is equivalent to optimising a lower-bound on the data likelihood under $p _ { \theta }$ . In practice, simply setting $\lambda ( t ) : = 1$ for all $t$ can produce more visually compelling results in the image domain [15].
73
+
74
+ In our proposed method, as in Tashiro et al. [32], the shapes of $\mathbf { x } _ { \mathrm { 0 } }$ and $\mathbf { y }$ sampled from $q ( \cdot )$ vary. This is because we want to train a model which can flexibly adapt to e.g. varying numbers of observed frames. To map Eq. (4) to this scenario, note that both $\mathbf { x } _ { \mathrm { 0 } }$ and $\mathbf { y }$ implicitly contain information about which frames in the video they represent (via the index vectors $\mathcal { X }$ and $\mathcal { V }$ introduced in the previous section). This information is used inside the neural network $\epsilon _ { \theta } ( \mathbf x _ { t } , \mathbf y , t )$ so that interactions between frames can be conditioned on the distance between them (as described in the following section) and also to ensure that the sampled noise vector $\epsilon$ has the same shape as $\mathbf { x } _ { \mathrm { 0 } }$ .
75
+
76
+ $: \mathcal { X } : = \{ \} ; \mathcal { Y } : = \{ \}$
77
+ 2: while True do
78
+ 3: $n _ { \mathrm { g r o u p } } \sim$ UniformDiscrete $( 1 , K )$
79
+ 4: $s _ { \mathrm { g r o u p } } \sim \mathrm { L o g U n i f o r m } ( 1 , ( N - 1 ) / n _ { \mathrm { g r o u p } } )$
80
+ 5: $x _ { \mathrm { g r o u p } } \sim \mathrm { U n i f o r m } ( 0 , N - ( n _ { \mathrm { g r o u p } } - 1 ) \cdot s _ { \mathrm { g r o u p } } )$
81
+ 6: ogroup ∼ Bernoulli(0.5)
82
+ 7: $\tilde { \mathcal { G } } : = \{ \lfloor x _ { \mathrm { g r o u p } } + s _ { \mathrm { g r o u p } } \cdot i \rfloor | i \in \{ 0 , \ldots , n _ { \mathrm { g r o u p } } - 1 \} \} \backslash \mathcal { X } \backslash \mathcal { Y }$
83
+ 8: if $| \mathcal { X } | + | \mathcal { Y } | + | \mathcal { G } | > K$ then
84
+ 9: return set2vector $( \mathcal { X } )$ , set2vector $( { \mathcal { V } } )$
85
+ 10: else if $| \mathcal { X } | = 0$ or $o _ { \mathrm { g r o u p } } = 0$ then
86
+ 11: $\mathcal { X } : = \mathcal { X } \cup \mathcal { G }$
87
+ 12: else
88
+ 13: $y : = \mathcal { y } \cup \mathcal { G }$
89
+
90
+ ![](images/5026656df62c5d1435c78fbe9221db88072c7b53140f572331883e0731269e40.jpg)
91
+ Figure 4: Left: Samples from $u ( \mathcal { X } , \mathcal { Y } )$ with video length $N = 3 0$ and limit $K = 1 0$ on the number of sampled indices. Each row shows one sample and columns map to frames, with frame 1 on the left and frame $N$ on the right. Blue and red denote latent and observed frames respectively. All other frames are ignored and shown as white. Right: Pseudocode for drawing these samples. The while loop iterates over a series of regularly-spaced groups of latent variables. Each group is parameterized by: the number of indices in it, $n _ { \mathrm { g r o u p } }$ ; the spacing between indices in it, $s _ { \mathrm { g r o u p } }$ ; the position of the first frame in it, $x _ { \mathrm { g r o u p } }$ , and an indicator variable for whether this group is observed, $O _ { \mathrm { { g r o u p } } }$ (which is ignored on line 10 if $\mathcal { X }$ is empty to ensure that the returned value of $\mathcal { X }$ is never empty). These quantities are sampled in a continuous space and then discretized to make a set of integer coordinates on line 7. The process repeats until a group is sampled which, if added to $\mathcal { X }$ or $\mathcal { V }$ , will cause the number of frames to exceed $K$ . That group is then discarded and $\mathcal { X }$ and $\mathcal { V }$ are returned as vectors. The FDM’s training objective forces it to work well for any $( \mathcal { X } , \mathcal { Y } )$ pair from this broad distribution.
92
+
93
+ # 4 Training procedure and architecture
94
+
95
+ Training task distribution Different choices of latent and observed indices $\mathcal { X }$ and $\mathcal { V }$ can be regarded as defining different conditional generation tasks. In this sense, we aim to learn a model which can work well on any task (i.e. any choice of $\mathcal { X }$ and $\mathcal { V }$ ) and so we randomly sample these vectors of indices during training. We do so with the distribution $u ( \mathcal { X } , \mathcal { Y } )$ described in Fig. 4. This provides a broad distribution covering many plausible test-time use cases while still providing sufficient structure to improve learning (see ablation in Section 6 and more details in Appendix C). To cope with constrained computational resources, the distribution is designed such that $\left| \mathcal { X } \right| + \left| \mathcal { V } \right|$ is upper-bounded by some pre-specified $K$ . Sampling from $q ( \mathbf { x } _ { 0 } , \mathbf { y } )$ in Eq. (4) is then accomplished by randomly selecting both a full training video $\mathbf { v }$ and indices $\mathcal { X } , \mathcal { Y } \sim u ( \cdot , \cdot )$ . We then extract the specified frames $\mathbf { x } = \mathbf { v } [ \mathcal { X } ]$ and $\mathbf { y } = \mathbf { v } [ \mathcal { V } ]$ (where we use $\mathbf { v } [ \mathcal { X } ]$ to denote the concatenation of all frames in $\mathbf { v }$ with indices in $\mathcal { X }$ and and $\mathbf { v } [ \mathcal { V } ]$ similarly).
96
+
97
+ Architecture DDPM image models [15, 22] typically use a U-net architecture [24]. Its distinguishing feature is a series of spatial downsampling layers followed by a series of upsampling layers, and these are interspersed with convolutional res-net blocks [14] and spatial attention layers. Since we require an architecture which operates on 4-D video tensors rather than 3-D image tensors we add an extra frame dimension to its input, output and hidden state, resulting in the architecture shown on the right of Fig. 3. We create the input to this architecture as a concatenation $\mathbf x _ { t } \oplus \mathbf y$ , adding an extra input channel which is all ones for observed frames and all zeros for latent frames. For RGB video, the input shape is therefore ( $K$ , image height, image width, 4). Since the output should have the same shape as $\mathbf { x } _ { t }$ we only return outputs corresponding to the latent frames, giving output shape $\vert \mathcal { X } \vert$ , image height, image width, 3). We run all layers from the original model (including convolution, resizing, group normalization, and spatial attention) independently for each of the $K$ frames. To allow communication between the frames, we add a temporal attention layer after each spatial attention layer, described in more detail in the appendix. The spatial attention layer allows each spatial location to attend to all other spatial locations within the same frame, while the temporal attention layer allows each spatial location to attend to the same spatial location across all other frames. This combination of a temporal attention layer with a spatial attention layer is sometimes referred to as factorized attention [32, 16]. We found that, when using this architecture in conjunction with our meta-learning approach, performance could be improved by using a novel form of relative position encoding [27, 38]. This is included in our released source code but we leave its exposition to the supplementary material.
98
+
99
+ Training batch padding Although the size $| \mathcal { X } \oplus \mathcal { Y } |$ of index vectors sampled from our training distribution is bounded above by $K$ , it can vary. To fit examples with various sizes of index vectors into the same batch, one option would be to pad them all to length $K$ with zeros and use masks so that the zeros cannot affect the loss. This, however, would waste computation on processing tensors of zeros. We instead use this computation to obtain a lower-variance loss estimate by processing additional data with “training batch padding”. This means that, for training examples where $| x \oplus y | < K$ , we concatenate frames uniformly sampled from a second video to increase the length along the frame-dimension to $K$ . Masks are applied to the temporal attention mechanisms so that frames from different videos cannot attend to eachother and the output for each is the same as that achieved by processing the videos in different batches.
100
+
101
+ Sampling schemes Before describing the sampling schemes we explore experimentally, we emphasize that the relative performance of each is dataset-dependent and there is no single best choice. A central benefit of FDM is that it can be used at test-time with different sampling schemes without retraining. Our simplest sampling scheme, Autoreg, samples ten consecutives frames at each stage conditioned on the previous ten frames. Long-range is similar to Autoreg but conditions on only the five most recent frames as well as five of the original 36 observed frames. Hierarchy-2 uses a multi-level sampling procedure. In the first level, ten evenly spaced frames spanning the non-observed portion of the video are sampled (conditioned on ten observed frames). In the second level, groups of consecutive frames are sampled conditioned on the closest past and future frames until all frames have been sampled. Hierarchy-3 adds an intermediate stage where several groups of variables with an intermediate spacing between them are sampled. We include adaptive hierarchy-2, abbreviated Ad. hierarchy-2, as a demonstration of a sampling scheme only possible with a model like FDM. It samples the same frames at each stage as Hierarchy-2 but selects which frames to condition on adaptively at test-time with a heuristic aimed at collecting the maximally diverse set of frames, as measured by the pairwise LPIPS distance [41] between them.
102
+
103
+ Optimizing sampling schemes An appealing alternative to the heuristic sampling schemes described in the previous paragraph would be to find a sampling scheme that is, in some sense, optimal for a given model and video generation/completion task. While it is unclear how to tractably choose which frames should be sampled at each stage, we suggest that the frames to condition on at each stage can be chosen by greedily optimizing the diffusion model loss which, as mentioned in Section 3, is closely related to the data log-likelihood. Given a fixed sequence of frames to sample at each stage $[ \mathcal { X } _ { s } ] _ { s = 1 } ^ { S }$ we select $\mathcal { \partial } _ { s }$ for each $s$ to minimize Eq. (4). This is estimated using a set of 100 training videos and by iterating over 10 evenly-spaced values of $t$ (which reduced variance relative to random sampling of $t$ ). See the appendix for further details. We create two optimized sampling schemes: one with the same latent indices as Autoreg, and one with the same latent indices as Hierarchy-2. We call the corresponding optimized schemes Opt. autoreg and Opt. hierarchy-2.
104
+
105
+ # 5 CARLA Town01 Dataset
106
+
107
+ In addition to our methodological contributions, we propose a new video-modeling dataset and benchmark which provides an interpretable measure of video completion quality. The dataset consists of videos of a car driving with a first-person view, produced using the CARLA autonomous driving simulator [9]. All 408 training and 100 test videos (of length 1000 frames and resolution $1 2 8 \times 1 2 8 )$ ) are produced within a single small town, CARLA’s Town01. As such, when a sufficiently expressive video model is trained on this dataset it memorizes the layout of the town and videos sampled from the model will be recognisable as corresponding to routes travelled within the town. We train a regression model in the form of a neural network which maps with high accuracy from any single rendered frame to $( x , y )$ coordinates representing the car’s position. Doing so allows us to plot the routes corresponding to sampled videos (see left of Fig. 5) and compute semantically-meaningful yet quantitative measures of the validity of these routes. Specifically, we compute histograms of speeds, where each speed is estimated by measuring the distance between the regressed locations for frames spaced ten apart (1 second at the dataset’s frame rate). Sampled videos occasionally “jump” between disparate locations in the town, resulting in unrealistically large estimated speeds. To measure the frequency of these events for each method, we compute the percentage of our point-speed estimates that exceed a threshold of $1 0 \mathrm { m / s }$ (the dataset was generated with a maximum simulated speed of $\mathrm { 3 m / s }$ ). We report this metric as the outlier percentage (OP). After filtering out these outliers, we compute the Wasserstein distance (WD) between the resulting empirical distribution and that of the original dataset, giving a measure of how well generated videos match the speed of videos in the dataset. We release the CARLA Town 01 dataset along with code and our trained regression model to allow future comparisons.2
108
+
109
+ ![](images/91d03113bf431ff2ce8593f9dcf8c30de45d678fc436461bb3511e1f415c4d07.jpg)
110
+ Figure 5: Left: Map of the town featured in the CARLA Town01 dataset. We visualize two video completions by FDM by showing coordinates output by our regressor (discussed in Section 5) for each frame. Those corresponding to the initial 36 observed frames are shown in red and those for the 964 sampled frames are shown in blue. Right: For each completion, we show one of the initially observed frames followed by four of the sampled frames (at positions chosen to show the progression with respect to visible landmarks and marked by black dots on the map). The town’s landmarks are usually sampled with high-fidelity, which is key to allowing the regressor to produce a coherent trajectory on the left. However there are sometimes failures: a blue square near the top-right of the map shows where the video model “jumped” to a wrong location for a single frame.
111
+
112
+ # 6 Experiments
113
+
114
+ We perform our main comparisons on the video completion task. In keeping with Saxena et al. [26], we condition on the first 36 frames of each video and sample the remainder. We present results on three datasets: GQN-Mazes [10], in which videos are 300 frames long; MineRL Navigate [13, 26] (which we will from now on refer to as simply MineRL), in which videos are 500 frames long; and the CARLA Town01 dataset we release, for which videos are 1000 frames long. We train FDM in all cases with the maximum number of represented frames $K = 2 0$ . We host non-cherry-picked video samples (both conditional and unconditional) from FDM and all baselines online3.
115
+
116
+ Comparison of sampling schemes The relative performance of different sampling schemes varies significantly between datasets as shown in Table 1. We report Fréchet Video Distances (FVDs) [33], a measure of how similar sampled completions are to the test set, on all datasets. In addition on GQN-Mazes we we report the accuracy metric [26], which classifies videos based on which rooms are visited and measures how often a completion is given the same class as the corresponding test video. For CARLA Town01 we report the previously described percentage outliers (PO) and Wasserstein distance (WD) metrics.
117
+
118
+ ![](images/20181a2ed912845712556e621993f86259d7ed3f838de77c7ab7cd3878c59243.jpg)
119
+ Figure 6: Speed distributions measured from sampled and ground-truth dataset videos.
120
+
121
+ We can broadly consider the aforementioned sampling schemes as either being in the “autoregressive” family (Autoreg and Long-range) or in the “hierarchical”
122
+
123
+ Table 1: Evaluation on video completion with various modes of our method along with several baselines from the literature. Error bars denote the standard error computed with 5 random seeds. Higher is better for the accuracy metric [26] and lower is better for all other metrics shown.
124
+
125
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Sampling scheme</td><td colspan="2">GQN-Mazes</td><td>MineRL</td><td colspan="3">CARLA Town01</td></tr><tr><td>FVD</td><td> Accuracy</td><td>FVD</td><td>FVD</td><td>WD</td><td>OP</td></tr><tr><td>CWVAE [26]</td><td>CWVAE</td><td>837±8</td><td>82.6± 0.5</td><td>1573±5</td><td>1161</td><td>0.666</td><td>44.4</td></tr><tr><td>TATS [11]</td><td>TATS</td><td>163 ± 2.6</td><td>77.0± 0.8</td><td>807±14</td><td>329</td><td>1.648</td><td>42.4</td></tr><tr><td>VDM [16]</td><td>VDM</td><td>66.7 ± 1.5</td><td>77.8± 0.5</td><td>271±8.8</td><td>169</td><td>0.501</td><td>16.9</td></tr><tr><td rowspan="5">FDM (ours)</td><td>Autoreg</td><td>86.4± 5.2</td><td>69.6 ± 1.3</td><td>281±10</td><td>222</td><td>0.579</td><td>0.51</td></tr><tr><td>Long-range</td><td>64.5 ± 1.9</td><td>77.0 ± 1.4</td><td>267 ±4.0</td><td>213</td><td>0.653</td><td>0.47</td></tr><tr><td>Hierarchy-2</td><td>53.1 ± 1.1</td><td>82.8± 0.7</td><td>275±7.7</td><td>120</td><td>0.318</td><td>3.28</td></tr><tr><td>Hierarchy-3</td><td>53.7 ± 1.9</td><td>83.8 ± 1.1</td><td>311± 6.8</td><td>149</td><td>0.363</td><td>4.53</td></tr><tr><td>Ad. hierarchy-2</td><td>55.0 ± 1.4</td><td>83.2 ± 1.3</td><td>316 ±8.9</td><td>117</td><td>0.311</td><td>3.44</td></tr></table>
126
+
127
+ family (the remainder). Those in the hierarchical family achieve significantly better FVDs [33] on GQN-Mazes. Our samples in the appendix suggest that this is related to the autoregressive methods “forgetting” the colors of walls after looking away from them for a short time. In contrast, for MineRL the autoregressive methods tend to achieve the best FVDs. This may relate to the fact that trajectories in MineRL tend to travel in straight lines through procedurally-generated “worlds”[13, 26], limiting the number of long-range dependencies. Finally on CARLA Town01 we notice qualitatively different behaviours from our autoregressive and hierarchical sampling schemes. The hierarchical sampling schemes have a tendency to occasionally lose coherence and “jump” to different locations in the town. This is reflected by higher outlier percentages (OP) in Table 1. On the other hand the autoregressive schemes often stay stationary for unrealistically long times at traffic lights. This is reflected in the histogram of speeds in Fig. 6, which has a larger peak around zero than the ground truth. The high variance of the sampling scheme’s relative performance over different datasets points to a strength of our method, which need only be trained once and then used to explore a variety of sampling schemes. Furthermore, we point out that the best FVDs in Table 1 on all datasets were obtained using sampling schemes that could not be implemented using models trained in prior work, or over evenly spaced frames.
128
+
129
+ Comparison with baselines The related work most relevant to ours is the concurrent work of Ho et al. [16], who model 64-frame videos using two trained DDPMs. The first is a “frameskip-4” model trained to generate every fourth frame and the second is a “frameskip-1” model trained on sequences of nine consecutive frames and used to “fill in” the gaps between frames generated in the first stage. To compare against this approach, which we denote VDM, we train both a “frameskip-4” and a “frameskip-1” model with architectures identical to our own.4 Since VDM requires two trained DDPMs, we train it for more GPU-hours than FDM despite the fact that FDM is meta-learning over a far broader task distribution. We also compare against TATS [11], which embeds videos into a discrete latent space before modelling them with a transformers, and the clockwork VAE (CWVAE) [26], a VAE-based model specifically designed to maintain long-range dependencies within video.
130
+
131
+ Both the diffusion-based methods, FDM and VDM, achieve significantly higher FVD scores than TATS and CWVAE. This may point toward the utility of diffusion models in general for modeling images and video. Table 1 also makes clear the main benefit of FDM over VDM: although there is no sampling scheme for FDM which always outperforms VDM, there is at least one sampling scheme that outperforms it on each dataset. This speaks to the utility of learning a flexible model like FDM that allows different sampling schemes to be experimented with after training.
132
+
133
+ Optimized sampling schemes As mentioned in Section 4, another advantage of FDM is that it makes possible a model- and dataset-specific optimization procedure to determine on which frames to condition. Table 2 shows the results when this procedure is used to create sampling schemes for different datasets. In the first row we show results where the latent frames are fixed to be those of the Autoreg sampling scheme, and in the second row the latent frames are fixed to match those of Hierarchy-2. On two of the three datasets the best results in Table 1 are improved upon, showing the utility of this optimization procedure.
134
+
135
+ Table 2: FVD scores for our sampling schemes with observed indices optimized offline as described in Section 4. We mark with an asterisk $( ^ { * } )$ the eight numbers which improve on the corresponding non-optimized sampling schemes and highlight in bold those that are better than any in Table 1.
136
+
137
+ <table><tr><td></td><td colspan="2">GQN-Mazes</td><td>MineRL</td><td colspan="3">CARLA Town01</td></tr><tr><td>Sampling scheme</td><td>FVD</td><td>Accuracy</td><td>FVD</td><td>FVD</td><td>WD</td><td>OP</td></tr><tr><td> Opt. autoreg</td><td>53.6±1.2*</td><td>80.2±1.2*</td><td>257±6.8*</td><td>146*</td><td>0.452*</td><td>0.65</td></tr><tr><td>Opt. hierarchy-2</td><td>51.1 ± 1.3*</td><td>84.6±0.7*</td><td>320 ± 7.0</td><td>124</td><td>0.349</td><td>4.11*</td></tr></table>
138
+
139
+ Comparison with training on a single task Training a network with our distribution over training tasks could be expected to lead to worse performance on a single task than training specifically for that task. To test whether this is the case, we train an ablation of FDM with training tasks exclusively of the type used in our Autoreg sampling scheme, i.e. “predict ten consecutive frames given the previous ten.” Tested with the Autoreg sampling scheme, it obtained an FVD of 82.0 on GQN-Mazes and 234 on MineRL. As expected given the specialization to a single task, this is better than when FDM is run with the Autoreg sampling scheme (obtaining FVDs of 86.4 and 281 respectively).
140
+
141
+ Ablation on training task distribution To test how important our proposed structured training distribution is to FDM’s performance, we perform an ablation with a different task distribution that samples $\mathcal { X }$ and $\mathcal { V }$ from uniform distributions instead of our proposed structured task distribution We provide full details in the appendix, but report here that switching away form our structured training distribution made the FVD scores worse on all five tested sampling schemes on both GQN-Mazes and MineRL. The reduction in the average FVD was $3 1 \%$ on GQN-Mazes and $5 2 \%$ on MineRL. This implies that our structured training distribution has a significant positive effect.
142
+
143
+ # 7 Related work
144
+
145
+ Some related work creates conditional models by adapting the sampling procedure of an unconditional DDPM [30, 18, 21, 16]. These approaches require approximations and the more direct approach that we use (explcitly training a conditional DDPM) was shown to have benefits by Tashiro et al. [32]. We consider further comparison of these competing approaches to be outside the focus of this work, which is on modeling a small portion of video frames at a time, essentially performing marginalization in addition to conditioning.
146
+
147
+ There are a number of approaches in the literature which use VAEs rather than DDPMs for video modelling. Babaeizadeh et al. [2] use a VAE model which predicts frames autoregressively conditioned on a global time-invariant latent variable. A related approach by Denton and Fergus [7] also uses a VAE with convolutional LSTM architectures in both the encoder and decoder. Unlike Babaeizadeh et al. [2] the prior is learned and a different latent variable is sampled for each frame. Babaeizadeh et al. [3] use a VAE with one set of latent variables per frame and inter-frame dependencies tracked by a two-layer LSTM. Their architecture intentionally overfits to the training data, which when coupled with image augmentations techniques achieves SOTA on various video prediction tasks. Kim et al. [20] use a variational RNN [5] with a hierarchical latent space that includes binary indicator variables which specify how the video is divided into a series of subsequences. Both Villegas et al. [35] and Wichers et al. [37] target long-term video prediction using a hierarchical variational LSTM architecture, wherein high-level features such as landmarks are predicted first, then decoded into low-level pixel space. The two approaches differ in that Villegas et al. [35] requires ground truth landmark labels, while [37] removes this dependence using an unsupervised adversarial approach. Fully GAN-based video models have also been proposed [1, 6] but generally suffer from “low quality frames or low number of frames or both” [1].
148
+
149
+ # 8 Discussion
150
+
151
+ We have defined and empirically explored a new method for generating photorealistic videos with long-range coherence that respects and efficiently uses fixed, finite computational resources. Our approach outperforms prior work on long-duration video modeling as measured by quantitative and semantically meaningful metrics and opens up several avenues for future research. For one, similar to using DDPMs for image generation, our method is slow to sample from (it takes approximately 16 minutes to generate a 300 frame video on a GPU). Ideas for making sampling faster by decreasing the number of integration steps [25, 29, 39] could be applied to our video model.
152
+
153
+ On a different note, consider the datasets on which our artifact was trained. In each there was a policy for generating the sequences of actions that causally led to the frame-to-frame changes in camera pose. In MineRL the video was generated by agents that were trained to explore novel Minecraft worlds to find a goal block approximately 64 meters away [13]. The CARLA data was produced by a camera attached to an agent driven by a low level proportional–integral–derivative controller following waypoints laid down by a high level planner that was given new, random location goals to drive to intermittently. In both cases our video model had no access to either the policy or the specific actions taken by these agents and, so, in a formal sense, our models integrate or marginalize over actions drawn from the stochastic policy used to generate the videos in the first place. Near-term future work could involve adding other modalities (e.g. audio) to FDM as well as explicitly adding actions and rewards, transforming our video generative model into a vision-based world model in the reinforcement learning sense [17, 19]. Furthermore, we point out that FDM trained on CARLA Town01 is in theory capable of creating 100-second videos conditioned on both the first and final frame. Doing so can be interpreted as running a “visual” controller which proposes a path between a current state and a specified goal. Preliminary attempts to run in FDM in this way yielded inconsistent results but we believe that this could be a fruitful direction for further investigation.
154
+
155
+ # Acknowledgments
156
+
157
+ We would like to thank Inverted AI, and especially Alireza Morsali, for generating the CARLA Town01 dataset. We acknowledge the support of the Natural Sciences and Engineering Research Council of Canada (NSERC), the Canada CIFAR AI Chairs Program, and the Intel Parallel Computing Centers program. Additional support was provided by UBC’s Composites Research Network (CRN), and Data Science Institute (DSI). This research was enabled in part by technical support and computational resources provided by WestGrid (www.westgrid.ca), Compute Canada (www.computecanada.ca), and Advanced Research Computing at the University of British Columbia (arc.ubc.ca). WH acknowledges support by the University of British Columbia’s Four Year Doctoral Fellowship (4YF) program.
158
+
159
+ # References
160
+
161
+ [1] Nuha Aldausari, Arcot Sowmya, Nadine Marcus, and Gelareh Mohammadi. Video generative adversarial networks: a review. ACM Computing Surveys (CSUR), 55(2):1–25, 2022.
162
+ [2] Mohammad Babaeizadeh, Chelsea Finn, Dumitru Erhan, Roy H Campbell, and Sergey Levine. Stochastic variational video prediction. arXiv preprint arXiv:1710.11252, 2017.
163
+ [3] Mohammad Babaeizadeh, Mohammad Taghi Saffar, Suraj Nair, Sergey Levine, Chelsea Finn, and Dumitru Erhan. Fitvid: Overfitting in pixel-level video prediction. arXiv preprint arXiv:2106.13195, 2021.
164
+ [4] Rewon Child. Very deep vaes generalize autoregressive models and can outperform them on images. arXiv preprint arXiv:2011.10650, 2020.
165
+ [5] Junyoung Chung, Kyle Kastner, Laurent Dinh, Kratarth Goel, Aaron C Courville, and Yoshua Bengio. A recurrent latent variable model for sequential data. Advances in neural information processing systems, 28, 2015.
166
+ [6] Aidan Clark, Jeff Donahue, and Karen Simonyan. Adversarial video generation on complex datasets. arXiv preprint arXiv:1907.06571, 2019. [7] Emily Denton and Rob Fergus. Stochastic video generation with a learned prior. In International conference on machine learning, pages 1174–1183. PMLR, 2018. [8] Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34, 2021.
167
+ [9] Alexey Dosovitskiy, German Ros, Felipe Codevilla, Antonio Lopez, and Vladlen Koltun. Carla: An open urban driving simulator. In Conference on robot learning, pages 1–16. PMLR, 2017.
168
+ [10] SM Ali Eslami, Danilo Jimenez Rezende, Frederic Besse, Fabio Viola, Ari S Morcos, Marta Garnelo, Avraham Ruderman, Andrei A Rusu, Ivo Danihelka, Karol Gregor, et al. Neural scene representation and rendering. Science, 360(6394):1204–1210, 2018.
169
+ [11] Songwei Ge, Thomas Hayes, Harry Yang, Xi Yin, Guan Pang, David Jacobs, Jia-Bin Huang, and Devi Parikh. Long video generation with time-agnostic vqgan and time-sensitive transformer. arXiv preprint arXiv:2204.03638, 2022.
170
+ [12] Audrunas Gruslys, Rémi Munos, Ivo Danihelka, Marc Lanctot, and Alex Graves. Memoryefficient backpropagation through time. Advances in Neural Information Processing Systems, 29, 2016.
171
+ [13] William H Guss, Brandon Houghton, Nicholay Topin, Phillip Wang, Cayden Codel, Manuela Veloso, and Ruslan Salakhutdinov. Minerl: A large-scale dataset of minecraft demonstrations. arXiv preprint arXiv:1907.13440, 2019.
172
+ [14] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. arxiv 2015. arXiv preprint arXiv:1512.03385, 2015.
173
+ [15] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
174
+ [16] Jonathan Ho, Tim Salimans, Alexey Gritsenko, William Chan, Mohammad Norouzi, and David J Fleet. Video diffusion models. arXiv preprint arXiv:2204.03458, 2022.
175
+ [17] Maximilian Igl, Luisa Zintgraf, Tuan Anh Le, Frank Wood, and Shimon Whiteson. Deep variational reinforcement learning for pomdps. In International Conference on Machine Learning, pages 2117–2126. PMLR, 2018.
176
+ [18] Zahra Kadkhodaie and Eero P Simoncelli. Solving linear inverse problems using the prior implicit in a denoiser. arXiv preprint arXiv:2007.13640, 2020.
177
+ [19] Lukasz Kaiser, Mohammad Babaeizadeh, Piotr Milos, Blazej Osinski, Roy H Campbell, Konrad Czechowski, Dumitru Erhan, Chelsea Finn, Piotr Kozakowski, Sergey Levine, et al. Modelbased reinforcement learning for atari. arXiv preprint arXiv:1903.00374, 2019.
178
+ [20] Taesup Kim, Sungjin Ahn, and Yoshua Bengio. Variational temporal abstraction. Advances in Neural Information Processing Systems, 32, 2019.
179
+ [21] Gautam Mittal, Jesse Engel, Curtis Hawthorne, and Ian Simon. Symbolic music generation with diffusion models. arXiv preprint arXiv:2103.16091, 2021.
180
+ [22] Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In International Conference on Machine Learning, pages 8162–8171. PMLR, 2021.
181
+ [23] Adam Paszke, Sam Gross, Soumith Chintala, Gregory Chanan, Edward Yang, Zachary DeVito, Zeming Lin, Alban Desmaison, Luca Antiga, and Adam Lerer. Automatic differentiation in pytorch. In NIPS-W, 2017.
182
+ [24] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computer-assisted intervention, pages 234–241. Springer, 2015.
183
+ [25] Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. arXiv preprint arXiv:2202.00512, 2022.
184
+
185
+ [26] Vaibhav Saxena, Jimmy Ba, and Danijar Hafner. Clockwork variational autoencoders. Advances in Neural Information Processing Systems, 34, 2021.
186
+
187
+ [27] Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. arXiv preprint arXiv:1803.02155, 2018.
188
+
189
+ [28] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pages 2256–2265. PMLR, 2015.
190
+
191
+ [29] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020.
192
+
193
+ [30] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456, 2020.
194
+
195
+ [31] Corentin Tallec and Yann Ollivier. Unbiasing truncated backpropagation through time. arXiv preprint arXiv:1705.08209, 2017.
196
+
197
+ [32] Yusuke Tashiro, Jiaming Song, Yang Song, and Stefano Ermon. Csdi: Conditional score-based diffusion models for probabilistic time series imputation. Advances in Neural Information Processing Systems, 34, 2021.
198
+
199
+ [33] Thomas Unterthiner, Sjoerd van Steenkiste, Karol Kurach, Raphael Marinier, Marcin Michalski, and Sylvain Gelly. Towards accurate generative models of video: A new metric & challenges. arXiv preprint arXiv:1812.01717, 2018.
200
+
201
+ [34] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
202
+
203
+ [35] Ruben Villegas, Dumitru Erhan, Honglak Lee, et al. Hierarchical long-term video prediction without supervision. In International Conference on Machine Learning, pages 6038–6046. PMLR, 2018.
204
+
205
+ [36] Dirk Weissenborn, Oscar Täckström, and Jakob Uszkoreit. Scaling autoregressive video models. arXiv preprint arXiv:1906.02634, 2019.
206
+
207
+ [37] Nevan Wichers, Ruben Villegas, Dumitru Erhan, and Honglak Lee. Hierarchical Long-term Video Prediction without Supervision. June 2018. doi: 10.48550/arXiv.1806.04768.
208
+
209
+ [38] Kan Wu, Houwen Peng, Minghao Chen, Jianlong Fu, and Hongyang Chao. Rethinking and improving relative position encoding for vision transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10033–10041, 2021.
210
+
211
+ [39] Zhisheng Xiao, Karsten Kreis, and Arash Vahdat. Tackling the generative learning trilemma with denoising diffusion GANs. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\equiv$ JprM0p-q0Co.
212
+
213
+ [40] Ruihan Yang, Prakhar Srivastava, and Stephan Mandt. Diffusion probabilistic modeling for video generation. arXiv preprint arXiv:2203.09481, 2022.
214
+
215
+ [41] Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 586–595, 2018.
216
+
217
+ # Checklist
218
+
219
+ 1. For all authors...
220
+
221
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
222
+ (b) Did you describe the limitations of your work? [Yes]
223
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]
224
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
225
+
226
+ 2. If you are including theoretical results...
227
+
228
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
229
+
230
+ 3. If you ran experiments...
231
+
232
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes]
233
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
234
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
235
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See appendix.
236
+
237
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
238
+
239
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
240
+ (b) Did you mention the license of the assets? [Yes]
241
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
242
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
243
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
244
+
245
+ 5. If you used crowdsourcing or conducted research with human subjects...
246
+
247
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
248
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
249
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/0U0C2pXfTZl/0U0C2pXfTZl.md ADDED
@@ -0,0 +1,467 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SLASH: EMBRACING PROBABILISTIC CIRCUITS INTO NEURAL ANSWER SET PROGRAMMING
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ The goal of combining the robustness of neural networks and the expressivity of symbolic methods has rekindled the interest in Neuro-Symbolic AI. Recent advancements in Neuro-Symbolic AI often consider specifically-tailored architectures consisting of disjoint neural and symbolic components, and thus do not exhibit desired gains that can be achieved by integrating them into a unifying framework. We introduce SLASH – a novel deep probabilistic programming language (DPPL). At its core, SLASH consists of Neural-Probabilistic Predicates (NPPs) and logical programs which are united via answer set programming. The probability estimates resulting from NPPs act as the binding element between the logical program and raw input data, thereby allowing SLASH to answer task-dependent logical queries. This allows SLASH to elegantly integrate the symbolic and neural components in a unified framework. We evaluate SLASH on the benchmark data of MNIST addition as well as novel tasks for DPPLs such as missing data prediction and set prediction with state-of-the-art performance, thereby showing the effectiveness and generality of our method.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ In recent years, Neuro-Symbolic AI approaches to learning (Hudson & Manning, 2019; d’Avila Garcez et al., 2019; Jiang & Ahn, 2020; d’Avila Garcez & Lamb, 2020), which integrates low-level perception with high-level reasoning by combining data-driven neural modules with logic-based symbolic modules, has gained traction. This combination of sub-symbolic and symbolic systems has been shown to have several advantages for various tasks such as visual question answering and reasoning (Yi et al., 2018), concept learning (Mao et al., 2019) and improved properties for explainable and revisable models (Ciravegna et al., 2020; Stammer et al., 2021).
12
+
13
+ Rather than designing specifically tailored Neuro-Symbolic architectures, where often the neural and symbolic modules are disjoint and trained independently (Yi et al., 2018; Mao et al., 2019; Stammer et al., 2021), deep probabilistic programming languages (DPPLs) provide an exciting alternative (Bingham et al., 2019; Tran et al., 2017; Manhaeve et al., 2018; Yang et al., 2020). Specifically, DPPLs integrate neural and symbolic modules via a unifying programming framework with probability estimates acting as the “glue” between separate modules allowing for reasoning over noisy, uncertain data and, importantly, joint training of the modules. Additionally, prior knowledge and biases in the form of logical rules can easily be added with DPPLs, rather than creating implicit architectural biases, thereby integrating neural networks into downstream logical reasoning tasks.
14
+
15
+ Object-centric deep learning has recently brought forth several exciting avenues of research by introducing inductive biases to neural networks to extract objects from visual scenes in an unsupervised manner (Zhang et al., 2019; Burgess et al., 2019; Engelcke et al., 2020; Greff et al., 2019; Lin et al., 2020; Locatello et al., 2020; Jiang & Ahn, 2020). We refer to Greff et al. (2020) for a detailed overview. A motivation for this specific line of investigation, which notably has been around for a longer period of time (Fodor & Pylyshyn, 1988; Marcus, 2019), is that objects occur as natural building blocks in human perception and possess advantageous properties for many cognitive tasks, such as scene understanding and reasoning. With a DPPL, these advancements can be improved by integrating the previously mentioned components into the DPPL’s programming framework and further adding constraints about objects and their properties in form of logical statements e.g. about color singularity, rather than implicitly enforcing this via one hot encodings.
16
+
17
+ ![](images/fbc474f94d8a2574e5362c4b2e3c3d61cc7e2bb6baf0aac66d0dc2840ab2de17.jpg)
18
+ Figure 1: SLASH Attention illustrated for a visual reasoning task. SLASH with Neural-Probabilistic Predicates consisting of a slot attention encoder and Probabilistic Circuits (PCs) realised via EiNets. The slot encoder is shared over all NPPs. Each triangle in the figure represents a single EiNet that gives us a joint distribution at the root node. Thus, each PC learns the joint distribution over slot encodings, $z ^ { i }$ , and object attributes, $C$ , of a specific category, e.g. color attributes. Via targeted queries to the NPPs, one can obtain task-related probabilities, e.g. conditional probabilities for the task of set prediction. Given the probability estimates from the NPP(s) and a SLASH program, containing a set of facts and logical statements about the world, the probability of the truth value of a task-related query are computed via answer set programming. The entire system, including the neural and probabilistic modules, are finally trained end-to-end via a single loss function.
19
+
20
+ We propose SLASH – a novel DPPL that, similar to the punctuation symbol, can be used to efficiently combine several paradigms into one. Specifically, SLASH represents a scalable programming language that seamlessly integrates probabilistic logical programming with neural representations and tractable probabilistic estimations. Fig. 1 shows an example instantiation of SLASH, termed SLASH Attention, for object-centric set prediction. SLASH consists of several key building blocks. Firstly, it makes use of Neural-Probabilistic Predicates (NPPs) for probability estimation. NPPs consist of neural and/or probabilistic circuit (PC) modules and act as a unifying term, encompassing the neural predicates of DeepProbLog and NeurASP, as well as purely probabilistic predicates. In this work, we introduce a much more powerful “flavor” of NPPs that consist jointly of neural and PC modules, taking advantage of the power of neural computations together with true density estimation of PCs. Depending on the underlying task one can thus ask a range of queries to the NPP, e.g. sample an unknown, desired variable, but also query for conditional class probabilities. Example NPPs consisting of a slot attention encoder and several PCs are depicted in Fig. 1 for the task of set prediction. The slot encoder is shared across all NPPs, whereas the PC of each NPP models a separate category of attributes. In this way, each NPP models the joint distribution over slot encodings and object attribute values, such as the color of an object. By querying the NPP, one can obtain task-related probability estimations, such as the conditional attribute probability.
21
+
22
+ The second component of SLASH is the logical program, which consists of a set of facts and logical statements defining the state of the world of the underlying task. For example, one can define the rules for when an object possesses a specific set of attributes (cf. Fig. 1). Thirdly, an ASP module is used to combine the first two components. Given a logical query about the input data, the logical program and the probability estimates obtained from the NPP(s), the ASP module produces a probability estimate about the truth value of the query, stating, e.g., how likely it is for a specific object in an image to be a large, dark red triangle. In contrast to query evaluation in Prolog (Colmerauer & Roussel, 1993; Clocksin & Mellish, 1981) which may lead to an infinite loop, many modern answer set solvers use Conflict-Driven-Clause-Learning (CDPL) which, in principle, always terminates.
23
+
24
+ Training in SLASH is performed efficiently in a batch-wise and end-to-end fashion, by integrating the parameters of all modules, neural and probabilistic, into a single loss term. SLASH thus allows a simple, fast and effective integration of sub-symbolic and symbolic computations. In our experiments, we investigate the advantages of SLASH in comparison to SOTA DPPLs on the benchmark task of MNIST-Addition (Manhaeve et al., 2018). We hereby show SLASH’s increased scalability regarding computation time, as well as SLASH’s ability to handle incomplete data via true probabilistic density modelling. Next, we show that SLASH Attention provides superior results for set prediction in terms of accuracy and generalization abilities compared to a baseline slot attention encoder. With our experiments, we thus show that SLASH is a realization of “one system – two approaches” (Bengio, 2019), that can successfully be used for performing various tasks and on a variety of data types.
25
+
26
+ We make the following contributions: (1) We introduce neural-probabilistic predicates, efficiently integrating answer set programming with probabilistic inference via our novel DPPL, SLASH. (2) We successfully train neural, probabilistic and logic modules within SLASH for complex data structures end-to-end via a simple, single loss term. (3) We show that SLASH provides various advantages across a variety of tasks and data sets compared to state-of-the-art DPPLs and neural models.
27
+
28
+ # 2 NEURO-SYMBOLIC LOGIC PROGRAMMING
29
+
30
+ Neuro-Symbolic AI can be divided into two lines of research, depending on the starting point. Both, however, have the same final goal: to combine low-level perception with logical constraints and reasoning.
31
+
32
+ A key motivation of Neuro-Symbolic AI (d’Avila Garcez et al., 2009; Mao et al., 2019; Hudson & Manning, 2019; d’Avila Garcez et al., 2019; Jiang & Ahn, 2020; d’Avila Garcez & Lamb, 2020) is to combine the advantages of symbolic and neural representations into a joint system. This is often done in a hybrid approach where a neural network acts as a perception module that interfaces with a symbolic reasoning system, e.g. (Mao et al., 2019; Yi et al., 2018). The goal of such an approach is to mitigate the issues of one type of representation by the other, e.g. using the power of symbolic reasoning systems to handle the generalizability issues of neural networks and on the other hand handle the difficulty of noisy data for symbolic systems via neural networks. Recent work has also shown the advantage of Neuro-Symbolic approaches for explaining and revising incorrect decisions (Ciravegna et al., 2020; Stammer et al., 2021). Many of these previous works, however, train the sub-symbolic and symbolic modules separately.
33
+
34
+ Deep Probabilistic Programming Languages (DPPLs) are programming languages that combine deep neural networks with probabilistic models and allow a user to express a probabilistic model via a logical program. Similar to Neuro-Symbolic architectures, DPPLs thereby unite the advantages of different paradigms. DPPLs are related to earlier works such as Markov Logic Networks (MLNs) (Richardson & Domingos, 2006). Thereby, the binding link is the Weighted Model Counting (WMC) introduced in $\mathrm { L P ^ { M L N } }$ (Lee & Wang, 2016). Several DPPLs have been proposed by now, among which are Pyro (Bingham et al., 2019), Edward (Tran et al., 2017), DeepProbLog (Manhaeve et al., 2018), and NeurASP (Yang et al., 2020).
35
+
36
+ To resolve the scalability issues of DeepProbLog, which use Sentential Decision Diagrams (SDDs) (Darwiche, 2011) as the underlying data structure to evaluate queries, NeurASP (Yang et al., 2020), offers a solution by utilizing Answer Set Programming (ASP) (Dimopoulos et al., 1997; Soininen & Niemelä, 1999; Marek & Truszczynski, 1999; Calimeri et al., 2020). In this way, NeurASP changes the paradigm from query evaluation to model generation, i.e. instead of constructing an SDD or similar knowledge representation system, NeurASP generates a set of all possible solutions (one model per solution) and estimates the probability for the truth value of each of these solutions. Of those DPPLs that handle learning in a relational, probabilistic setting and in an end-to-end fashion, all of these are limited to estimating only conditional class probabilities.
37
+
38
+ # 3 THE SLASH FRAMEWORK
39
+
40
+ In this section, we introduce our novel DPPL, SLASH. Before we dive into the details of this, it is necessary to first introduce Neural-Probabilistic Predicates, for which we require an understanding of Probabilistic Circuits. Finally, we will present the learning paradigm of SLASH.
41
+
42
+ The term probabilistic circuit (PC) (Choi et al., 2020) represents a unifying framework that encompasses all computational graphs which encode probability distributions and guarantee tractable probabilistic modelling. These include Sum-Product Networks (SPNs) (Poon & Domingos, 2011) which are deep mixture models represented via a rooted directed acyclic graphs with a recursively defined structure.
43
+
44
+ ![](images/fe12c632ab68913a19fb5c0639cac79765cabf16e331224edc0cd2c84bb8eebe.jpg)
45
+
46
+ (a) NPPs come in various flavors depending on the data and underlying task.
47
+
48
+ ![](images/deaa2f06b12c44d64f5ac8f226a3fdb61c0d8bba50b15128cddc5ccafbad3205.jpg)
49
+ (b) Minimal SLASH program and query for set prediction.
50
+ Figure 2: (a) Depending on the data set and underlying task, SLASH requires a suitable NeuralProbabilistic Predicate (NPP) that computes query-dependent probability estimates. An NPP can be composed of neural and probabilistic modules, or (depicted via slash symbol) only one of these two. (b) A minimal SLASH program and query for the set prediction task, here only showing the NPP that models the color category per object. For the full program, we refer to the Appendix.
51
+
52
+ # 3.1 NEURAL-PROBABILISTIC PREDICATES
53
+
54
+ Previous DPPLs, DeepProbLog (Manhaeve et al., 2018) and NeurASP (Yang et al., 2020), introduced the Neural Predicate as an annotated-disjunction or as a propositional atom, respectively, to acquire conditional class probabilities, $P ( C | X )$ , via the softmax function at the output of an arbitrary DNN. As mentioned in the introduction, this approach has certain limitations concerning inference capabilities. To resolve this issue, we introduce Neural-Probabilisitic Predicates (NPPs).
55
+
56
+ Formally, we denote with
57
+
58
+ $$
59
+ n p p \left( h ( x ) , [ v _ { 1 } , . . . , v _ { n } ] \right)
60
+ $$
61
+
62
+ a Neural-Probabilistic Predicate $h$ . Thereby, (i) npp is a reserved word to label an NPP, (ii) $h$ a symbolic name of either a PC, NN or a joint of a PC and NN (cf. Fig. 2a), e.g., color_attr is the name of an NPP of Fig. 2b. Additionally, (iii) $x$ denotes a “term” and (iv) $v _ { 1 } , \ldots , v _ { n }$ are placeholders for each of the $n$ possible outcomes of $h$ . For example, the placeholders for color_attr are the color attributes of an object (Red, Blue, Green, etc.).
63
+
64
+ An NPP abbreviates an arithmetic literal of the form $c = v$ with $c \in \{ h ( x ) \}$ and $v \in \{ v _ { 1 } , \ldots , v _ { n } \}$ . Furthermore, we denote with $\Pi ^ { n p p }$ a set of NPPs of the form stated in (Eq. 1) and $r ^ { n p p }$ the set of all rules $c = v$ of one NPP, which denotes the possible outcomes, obtained from an NPP in $\Pi ^ { n p p }$ , e.g. $r ^ { c o l o r \_ a t t r } = \{ c = R e d , c = B l u e , c = G r \bar { e } e n , . . . \}$ for the example depicted in Fig. 2b.
65
+
66
+ Rules of the form $n p p ( h ( x ) , [ v _ { 1 } , \ldots , v _ { n } ] ) B o d y$ are used as an abbreviation for application to multiple entities, e.g. multiple slots for the task of set prediction (cf. Fig. 2b). Hereby, Body of the rule is identified by $\top$ (tautology, true) or $\perp$ (contradiction, false) during grounding. Rules of the form $H e a d \gets B o d y$ with $r ^ { n p p }$ appearing in Head are prohibited for $\Pi ^ { n p p }$ .
67
+
68
+ In this work, we largely make use of NPPs that contain probabilistic circuits (specifically SPNs) which allow for tractable density estimation and modelling of joint probabilities. In this way, it is possible to answer a much richer set of probabilistic queries, i.e. $P ( X , C )$ , $P ( X | C )$ and $P ( \bar { C } | X )$ .
69
+
70
+ In addition to this, we introduce the arguably more interesting type of NPP that combines a neural module with a PC. Hereby, the neural module learns to map the raw input data into an optimal latent representation, e.g. object-based slot representations. The PC, in turn, learns to model the joint distribution of these latent variables and produces the final probability estimates. This type of NPP nicely combines the representational power of neural networks with the advantages of PCs in probability estimation and query flexibility.
71
+
72
+ For making the different probabilistic queries distinguishable in a SLASH program, we introduce the following notation. We denote a given variable with $^ +$ and the query variable with −. E.g., within the running example of set prediction $\cdot e f .$ Fig. 1 and 2b), with the query color_attr $\cdot ( + X , - C )$ one is asking for $P ( C | X )$ . Similarly, with color_attr $( - X , + C )$ one is asking for $P ( X | C )$ and, finally, with color_attr $( - X , - C )$ for $P ( X , C )$ .
73
+
74
+ To summarize, an NPP can consist of neural and/or probabilistic modules and produces querydependent probability estimates. Due to the flexibility of its definition, the term NPP contains the predicates of previous works (Manhaeve et al., 2018; Yang et al., 2020), but also more interesting predicates discussed above. The specific “flavor” of an NPP should be chosen depending on what type of probability estimation is required (cf. Fig 2a). Lastly, NPPs have the unified loss function of the negative log-likelihood:
75
+
76
+ $$
77
+ L _ { N P P } : = - \log L H ( x , \hat { x } ) = \sum _ { i = 1 } ^ { n } L H ( x _ { i } , \hat { x } _ { i } ) = - \sum _ { i = 1 } ^ { n } x _ { i } \cdot \log ( P _ { \xi } ^ { ( X , C ) } ( x _ { i } ) ) = - \sum _ { i = 1 } ^ { n } \log ( P _ { \xi } ^ { ( X , C ) } )
78
+ $$
79
+
80
+ whereby we are assuming the data to be i.i.d., ground truth $x _ { i }$ to be the all-ones vector, $\xi$ to be the parameters of the NPP and $P _ { \xi } ^ { ( X , C ) }$ are the predictions ${ \hat { x } } _ { i }$ obtained from the PC encoded in the NPP.
81
+
82
+ # 3.2 THE SLASH LANGUAGE AND SEMANTICS
83
+
84
+ Fig. 1 presents an illustration of SLASH, exemplified for the task of set prediction, with all of its key components. Having introduced the NPPs previously, which produce probability estimates, we now continue in the pipeline on how to use these probability estimates for answering logical queries. We begin by formally defining a SLASH program.
85
+
86
+ Definition 1. A SLASH program Π is the union of $\Pi ^ { a s p }$ , $\Pi ^ { n p p }$ . Therewith, $\Pi ^ { a s p }$ is the set of propositional rules (standard rules from ASP-Core-2 (Calimeri et al., 2020)), and $\Pi ^ { n p p }$ is a set of Neural-Probabilistic Predicates of the form stated in Eq. 1.
87
+
88
+ Fig. 2b depicts a minimal SLASH program for the task of set prediction, exemplifying a set of propositional rules and neural predicates. Similar to NeurASP, SLASH requires ASP and as such adopts its syntax to most part. We therefore now address integrating our NPPs into an ASP compatible form to obtain the success probability for the logical query given all possible solutions. Thus, we define SLASH’s semantics. For SLASH to translate the program $\Pi$ to the ASP-solver’s compatible form, the rules (Eq. 1) will be rewritten to the set of rules:
89
+
90
+ $$
91
+ 1 \{ h ( x ) = v _ { 1 } ; \ldots ; h ( x ) = v _ { n } \} 1
92
+ $$
93
+
94
+ The ASP-solver should understand this as “Pick exactly one rule from the set”. After the translation is done, we can ask an ASP-solver for the solutions for $\Pi$ . We denote a set of ASP constraints in the $\mathrm { f o r m } \gets B o d y$ , as queries $Q$ (annotation). and each of the solutions with respect to $Q$ as a potential solution, $I$ , (referred to as stable model in ASP). With $I | _ { r ^ { n _ { P } p } }$ we denote the projection of the $I$ onto $r ^ { n p p }$ , $N u m ( I | _ { r ^ { n p p } } , \Pi ) \ -$ – the number of the possible solutions of the program $\Pi$ agreeing with $I | _ { r ^ { n p p } }$ on $r ^ { n p p }$ . Because we aim to calculate the success probability of the query $Q$ , we formalize the probability of a potential solution $I$ beforehand.
95
+
96
+ Definition 2. We specify the probability of the potential solution, $I$ , for the program $\Pi$ as the product of the probabilities of all atoms $c = v$ in $I | _ { r ^ { n p p } }$ divided by the number of potential solutions of $\Pi$ agreeing with I|rnpp on rnpp:
97
+
98
+ $$
99
+ P _ { \Pi } ( I ) = \left\{ \begin{array} { l l } { \frac { \prod _ { c = v \in { I \vert _ { r } n p p } } P _ { \Pi } ( c = v ) } { N u m ( I \vert _ { r ^ { n p p } } , \Pi ) } , } & { i f I i s a p o t e n t i a l s o l u t i o n o f \Pi , } \\ { 0 , } & { o t h e r w i s e . } \end{array} \right.
100
+ $$
101
+
102
+ Therefore, the probability of a query can be defined as follows.
103
+
104
+ Definition 3. The probability of the query $Q$ given the set of possible solutions $I$ is defined as
105
+
106
+ $$
107
+ P _ { \Pi } ( Q ) : = \sum _ { I \ v { = } Q } P _ { \Pi } ( I ) .
108
+ $$
109
+
110
+ Thereby, $I \models Q$ reads as $^ { * } I$ satisfies $Q$ ”. The probability of the set of queries $\mathbf { Q } = \{ Q _ { 1 } , \ldots , Q _ { l } \}$ is defined as the product of the probability of each. I.e.
111
+
112
+ $$
113
+ P _ { \Pi } \left( \mathbf { Q } \right) : = \prod _ { Q _ { i } \in \mathbf { Q } } P _ { \Pi } ( Q _ { i } ) = \prod _ { Q _ { i } \in \mathbf { Q } } \sum _ { I \ v { | } = Q } P _ { \Pi } ( I ) .
114
+ $$
115
+
116
+ # 3.3 PARAMETER LEARNING IN SLASH
117
+
118
+ We denote with $\Pi ( \pmb \theta )$ the SLASH program under consideration, thereby $\pmb \theta$ is the set of the parameters associated with Π. Further, making the i.i.d. assumption of the query set $\mathbf { Q }$ , we follow Manhaeve et al. (2018) and Skryagin et al. (2020), and use the learning from entailment setting. That is, the training examples are logical queries that are known to be true in the SLASH program $\Pi ( \theta )$ . The goal is now to learn the parameters $\pmb \theta$ of the SLASH program $\Pi ( \pmb \theta )$ so that the observed queries are most likely.
119
+
120
+ To this end, we employ the negative log-likelihood and the cross-entropy of the observed queries $P _ { \mathrm { { I I } } ( \theta ) } ( Q _ { i } )$ and their predicted probability value $P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i } } )$ , assuming the NPPs are fixed: $L _ { E N T } : =$
121
+
122
+ $$
123
+ - \log L H \left( \log ( P _ { \Pi ( \theta ) } ( \mathbf { Q } ) ) , P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { \mathbf { Q } } ) \right) = - \sum _ { j = 1 } ^ { m } \log ( P _ { \Pi ( \theta ) } ( Q _ { i j } ) ) \cdot \log \left( P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i j } } ) \right) .
124
+ $$
125
+
126
+ This loss function aims at maximizing the estimated success probability. We remark that the defined loss function is true regardless of the NPP’s form (NN with Softmax, PC or PC jointly with NN). The only difference will be the second term, i.e. $P ^ { ( C | X _ { \mathbf { Q } } ) } ( x _ { \mathbf { Q } } )$ or $P ^ { ( X _ { \mathbf { Q } } | C ) } ( x _ { \mathbf { Q } } ) )$ depending on the NPP and task. Furthermore, we assume that for the set of queries $\mathbf { Q }$ holds
127
+
128
+ $$
129
+ P _ { \Pi ( \pmb \theta ) } ( Q ) > 0 \quad \forall Q \in { \bf Q } .
130
+ $$
131
+
132
+ In accordance with the semantics, we seek to reward the right solutions $v = c$ and penalize wrong ones $v \neq c$ . Referring to the probabilities in $r ^ { n p p }$ (the set of logical rules denoting NPPs, see Def. 2) as $\mathbf { p }$ , one can compute their gradients w.r.t. $\pmb { \theta }$ via backpropagation as
133
+
134
+ $$
135
+ \sum _ { Q \in { \bf Q } } \frac { \partial \log \left( P _ { \Pi ( \pmb \theta ) } ( Q ) \right) } { \partial \pmb \theta } = \sum _ { Q \in { \bf Q } } \frac { \partial \log \left( P _ { \Pi ( \pmb \theta ) } ( Q ) \right) } { \partial { \bf p } } \times \frac { \partial { \bf p } } { \partial \pmb \theta } .
136
+ $$
137
+
138
+ The term $\textstyle { \frac { \partial \mathbf { p } } { \partial \theta } }$ can now be computed as usual via backward propagation through the NPPs (see Eq. 13 in the appendix for details). By letting $p$ to be the label of the probability of an atom $c = v$ in $r ^ { n p p }$ and denoting $P _ { \Pi ( \pmb { \theta } ) } ( c = v )$ , the term $\frac { \partial \log \left( P _ { \mathrm { I I } ( \pmb { \theta } ) } ( Q ) \right) } { \partial \mathbf { p } }$ follows from NeurASP (Yang et al., 2020) as
139
+
140
+ $$
141
+ \frac { \partial \log \left( P _ { \Pi ( \theta ) } ( Q ) \right) } { \partial \mathbf { p } } = \frac { I \underset { I : I \mid = Q } { \sum } \frac { P _ { \Pi ( \theta ) } ( I ) } { P _ { \Pi ( \theta ) } ( c = v ) } - \underset { I : I , v ^ { \prime } \mid = Q } { \sum } \frac { P _ { \Pi ( \theta ) } ( I ) } { P _ { \Pi ( \theta ) } ( c = v ^ { \prime } ) } } { \underset { I : I \mid = Q } { \sum } P _ { \Pi ( \theta ) } ( I ) } .
142
+ $$
143
+
144
+ This is sensible. For instance, if a query to be true is not likely to be entailed, the gradient is positive. Putting everything together, the final loss function is
145
+
146
+ $$
147
+ { \cal L } _ { S L A S H } = { \cal L } _ { N P P } + { \cal L } _ { E N T }
148
+ $$
149
+
150
+ and we perform training using coordinate descent, i.e., we train the NPPs, the train the program with fixed NPPs, train the NPPs with the program fixed, and so on.
151
+
152
+ In hindsight, rather than requiring a novel loss function for each individual task and data set, with SLASH, it is possible to simply incorporate the specific requirements into the logic program. The training loss, however, remains the same. We refer to the Appendix A for further details, including the derivation of the total loss gradient.
153
+
154
+ # 4 EMPIRICAL RESULTS
155
+
156
+ The advantage of SLASH lies in the efficient integration of neural, probabilistic and symbolic computations. To emphasize this, we conduct a variety of experimental evaluations.
157
+
158
+ Experimental Details. We use two benchmark data sets, namely MNIST (LeCun et al., 1998b) for the task of MNIST-Addition and a variant of the ShapeWorld data set (Kuhnle & Copestake, 2017) for
159
+
160
+ Table 1: MNIST Addition Results. Test accuracy corresponds to the percentage of correctly classified test images. (a) Test accuracies in percent for the MNIST Addition task with various DPPLs, including SLASH with an NPP that models the joint probabilities (SLASH (PC)) and one that models only conditional probabilities (SLASH (DNN)). (b) Test accuracies in percent for the MNIST Addition task with missing data, comparing DeepProbLog with SLASH (PC). The amount of missing data was varied between $50 \%$ and $9 7 \%$ of the pixels per image.
161
+
162
+ (a) Baseline MNIST Addition.
163
+
164
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Test Acc. (%)</td></tr><tr><td rowspan=1 colspan=1>DeepProbLog</td><td rowspan=1 colspan=1>98.49±0.18</td></tr><tr><td rowspan=1 colspan=1>NeurASP</td><td rowspan=1 colspan=1>98.21 ± 0.30</td></tr><tr><td rowspan=1 colspan=1>SLASH (PC)</td><td rowspan=1 colspan=1>95.39 ± 0.29</td></tr><tr><td rowspan=1 colspan=1>SLASH (DNN)</td><td rowspan=1 colspan=1>98.74±0.21</td></tr></table>
165
+
166
+ (b) Missing data MNIST Addition.
167
+
168
+ <table><tr><td rowspan=1 colspan=2>DeepProbLog</td><td rowspan=1 colspan=1>SLASH (PC)</td></tr><tr><td rowspan=1 colspan=1>50%</td><td rowspan=1 colspan=1>97.73 ± 0.12</td><td rowspan=1 colspan=1>97.67±0.12</td></tr><tr><td rowspan=1 colspan=1>80%</td><td rowspan=1 colspan=1>76.07 ± 18.38</td><td rowspan=1 colspan=1>96.72士0.05</td></tr><tr><td rowspan=1 colspan=1>90%</td><td rowspan=1 colspan=1>69.15 ± 29.15</td><td rowspan=1 colspan=1>94.85士0.38</td></tr><tr><td rowspan=1 colspan=1>97%</td><td rowspan=1 colspan=1>32.46 ± 22.48</td><td rowspan=1 colspan=1>82.57士4.66</td></tr></table>
169
+
170
+ object-centric set prediction. For all experiments we present the average and the standard deviation over five runs with different random seeds for parameter initialization.
171
+
172
+ For ShapeWorld experiments, we generate a data set we refer to as ShapeWorld4. Images of ShapeWorld4 contain between one and four objects, with each object consisting of four attributes: a color (red, blue, green, gray, brown, magenta, cyan or yellow), a shade (bright, or dark), a shape (circle, triangle or square) and a size (small or big). Thus, each object can be created from 84 different combinations of attributes. Fig. 1 depicts an example image.
173
+
174
+ We measure performance via classification accuracies in the MNIST-Addition task. In our ShapeWorld4 experiments, we present the average precision. We refer to appendix B for the SLASH programs and queries of each experiment, and appendix C for a detailed description of hyperparameters and further details.
175
+
176
+ Evaluation 1: SLASH outperforms SOTA DPPLs in MNIST-Addition. The task of MNISTAddition (Manhaeve et al., 2018) is to predict the sum of two MNIST digits, presented only as raw images. During test time, however, a model should classify the images directly. Thus, although a model does not receive explicit information about the depicted digits, it must learn to identify digits via indirect feedback on the sum prediction.
177
+
178
+ We compare the test accuracy after convergence between the three DPPLs: DeepProbLog (Manhaeve et al., 2018), NeurASP (Yang et al., 2020) and SLASH, using a probabilistic circuit (PC) or a deep neural network (DNN) as NPP. Notably, the DNN used in SLASH (DNN) is the LeNet5 model (LeCun et al., 1998a) of DeepProbLog and NeurASP. We note that when using the PC as NPP, we have also extracted conditional class probabilities $P ( C | X )$ , by marginalizing the class variables $C$ to acquire the normalization constant $P ( X )$ from the joint $P ( X , C )$ , and calculating $P ( X | C )$ .
179
+
180
+ The results can be seen in Tab. 1a. We observe that training SLASH with a DNN NPP produces SOTA accuracies compared to DeepProbLog and NeurASP, confirming that SLASH’s batch-wise loss computation leads to improved performances. We further observe that the test accuracy of SLASH with a PC NPP is slightly below the other DPPLs, however we argue that this may be since a PC, in comparison to a DNN, is learning a true mixture density rather than just conditional probabilities. The advantages of doing so will be investigated in the next experiments. Note that, optimal architecture search for PCs, e.g. for computer vision, is an open research question.These evaluations show SLASH’s advantages on the benchmark MNIST-Addition task. Additional benefits will be made clear in the following experiments.
181
+
182
+ Evaluation 2: Handling Missing Data with SLASH. SLASH offers the advantage of its flexibility to use various kinds of NPPs. Thus, in comparison to previous DPPLs, one can easily integrate NPPs into SLASH that perform joint probability estimation. For this evaluation, we consider the task of MNIST-Addition with missing data. We trained SLASH (PC) and DeepProbLog with the MNIST-Addition task with images in which a percentage of pixels per image has been removed. It is important to mention here that whereas DeepProbLog handles the missing data simply as background pixels, SLASH (PC) specifically models the missing data as uncertain data by marginalizing the denoted pixels at inference time. We use DeepProbLog here representative of DPPLs without true density estimation.
183
+
184
+ (a) ShapeWorld4 and ShapeWorld4 CoGenT Test Avg.Precision
185
+ Figure 3: ShapeWorld4 Experiments. (a) Converged test average precision scores for the set prediction task with ShapeWorld4 (top) and ShapeWorld4 CoGenT (bottom). (b) Test average precision scores for set prediction with ShapeWorld4 over the training epochs. In these experiments we compared a baseline slot encoder versus SLASH Attention with slot attention and PC-based NPPs. For the CoGenT experiments, a model is trained on one training set and tested on two separate test conditions. The Condition A test set contains attribute compositions which were also seen during training. The Condition B test set contains attribute compositions which were not seen during training, e.g. yellow circles were not present in the training set, but present in Condition B test set.
186
+
187
+ <table><tr><td></td><td>Slot Att.</td><td>SLASH Att.</td></tr><tr><td>Test Set</td><td>ShapeWorld4 90.24 ± 0.93</td><td>95.58 ± 0.61</td></tr><tr><td></td><td>CoGenT</td><td></td></tr><tr><td>Test Cond. A</td><td>90.37 ± 2.19</td><td>96.85 ± 0.43</td></tr><tr><td>Test Cond.B</td><td>27.15 ± 2.36</td><td>40.58 ± 1.99</td></tr></table>
188
+
189
+ ![](images/0eaf19403876aa7fbb58219357ca9c041a53e7685ffb819aff2c0d5f28605742.jpg)
190
+ (b) Test Avg.Precision over Training Epochs
191
+
192
+ The results can be seen in Tab. 1b for $5 0 \%$ , $8 0 \%$ , $9 0 \%$ and $9 7 \%$ missing pixels per image. We observe that at $5 0 \%$ , DeepProbLog and SLASH produce almost equal accuracies. With $8 0 \%$ percent missing pixels, there is a substantial difference in the ability of the two DPPLs to correctly classify images, with SLASH being very stable. By further increasing the percentage of missing pixels, this difference becomes even more substantial with SLASH still reaching a $8 2 \%$ test accuracy even when $9 7 \%$ of the pixels per image are missing, whereas DeepProbLog degrades to an average of $3 2 \%$ test accuracy. We further note that SLASH, in comparison to DeepProbLog, produces largely reduced standard deviations over runs.
193
+
194
+ Thus, by utilizing the power of true density estimation SLASH, with an appropriate NPP, can produce more robust results in comparison to other DPPLs. Further, we refer to Appendix D, which contains results of additional experiments where training is performed with the full MNIST data set whereas only the test set entails different rates of missing pixels.
195
+
196
+ Evaluation 3: Improved Concept Learning via SLASH. We show that SLASH can be very effective for the complex task of set prediction, which previous DPPLs have not tackled. We revert to the ShapeWorld4 data set for this setting. For set prediction, a model is trained to predict the discrete attributes of a set of objects in an image (cf. Fig. 1 for an example ShapeWorld4 image). The difficulty for the model lies therein that it must match an unordered set of corresponding attributes (with varying number of entities over samples) with its internal representations of the image.
197
+
198
+ The slot attention module introduced by Locatello et al. (2020) allows for an attractive object-centric approach to this task. Specifically, this module represents a pluggable, differentiable module that can be easily added to any architecture and, through a competitive softmax-based attention mechanism, can enforce the binding of specific parts of a latent representation into permutation-invariant, taskspecific vectors, called slots.
199
+
200
+ In our experiments, we wish to show that by adding logical constraints to the training setting, one can improve the overall performances and generalization properties of such a model. For this, we train SLASH with NPPs as depicted in Fig. 1 consisting of a shared slot encoder and separate PCs, each modelling the mixture of latent slot variables and the attributes of one category, e.g. color. For ShapeWorld4, we thereby have altogether four NPPs. SLASH is trained via queries of the kind exemplified in Fig. 7 in the Appendix. We refer to this configuration as SLASH Attention.
201
+
202
+ We compare SLASH Attention to a baseline slot attention encoder using an MLP and Hungarian loss for predicting the object properties from the slot encodings as in Locatello et al. (2020). The results of these experiments can be found in Fig. 3a (top). We observe that the average precision after convergence on the held-out test set with SLASH Attention is greatly improved to that of the baseline model. Additionally, in Fig. 3b we observe that SLASH Attention reaches the average precision value of the baseline model in much fewer number of epochs. Thus, we can summarize that adding logical knowledge in the training procedure via SLASH can greatly improve the capabilities of a neural module for set prediction.
203
+
204
+ Evaluation 4: Improved Compositional Generalization with SLASH. To test the hypothesis that SLASH Attention possesses improved generalization properties in comparison to the baseline model, we ran experiments on a variant of ShapeWorld4 similar to the CLEVR Compositional Generalization Test (CoGenT) (Johnson et al., 2017). The goal of CoGenT is to investigate a model’s ability to handle novel combinations of attributes that were not seen during training.
205
+
206
+ For this purpose, we established two conditions within a ShapeWorld4 CoGenT data set: Condition (A) – the training and test data set contains squares with the colors gray, blue, brown, or yellow, triangles with the colors red, green, magenta, or cyan and circles of all colors. Condition (B) – the training set is as in Condition (A). However, the test set contains squares with the colors red, green, magenta, or cyan, triangles with the colors gray, blue, brown, or yellow and circles of all colors. The goal is to investigate how well a model can generalize that, e.g., also squares can have the color red, although never having seen evidence for this during training.
207
+
208
+ The resulting average precision test scores are presented in Fig. 3a (bottom). We observe that, even though the SLASH Program used for this experiment was not explicitly written to handle composition generalization, SLASH Attention shows greatly improved generalization capabilities. This can be seen in the approx. $1 3 \%$ higher average precision scores on the Condition (B) test set in comparison to the baseline model. Importantly, this trend still holds even when subtracting the higher precision scores observed in Condition (A).
209
+
210
+ To summarize our findings from the experiments on set prediction: we observe that adding prior knowledge in the form of logical constraints via SLASH can greatly improve a neural module in terms of performance and generalizability. On a side note: training neural networks for novel tasks, often involves defining explicit loss functions, e.g. Hungarian loss for set prediction. In contrast with SLASH, no matter the choice of NPP and underlying task, the training loss remains the same. Task-related requirements simply need to be added as lines of code to the SLASH program. This additionally highlights SLASH’s versatility and flexibility.
211
+
212
+ Summary of all Empirical Results. All empirical results together demonstrate that the flexibility of SLASH is highly beneficial and can easily outperform state-of-the-art: one can freely combine what is required to solve the underlying task — (deep) neural networks, PCs, and logic. Particularly, the results indicate the potential of integrating PCs via SLASH into DPPLs.
213
+
214
+ # 5 CONCLUSION AND FUTURE WORK
215
+
216
+ We introduce SLASH, a novel DPPL that integrates neural computations with tractable probability estimates and logical statements. The key ingredient of SLASH to achieve this are Neural-Probabilistic Predicates (NPPs) that can be flexibly constructed out of neural and/or probabilistic circuit modules based on the data and underlying task. With these NPPs, one can produce task-specific probability estimates. The details and additional prior knowledge of a task are neatly encompassed within a SLASH program with only few lines of code. Finally, via Answer Set Programming and Weighted Model Counting, the logical SLASH program and probability estimates from the NPPs are combined to estimate the truth value of a task-specific query. Our experiments show the power and efficiency of SLASH, improving upon previous DPPLs in the benchmark MNIST-Addition task in terms of performance, efficiency and robustness. Importantly, by integrating a SOTA slot attention encoder into NPPs and adding few logical constraints, SLASH demonstrates improved performances and generalizability in comparison to the pure slot encoder for the task of object-centric set prediction; a setting no DPPL has tackled yet. This shows the great potential of DPPLs to elegantly combine logical reasoning with neural computations and uncertainty estimates.
217
+
218
+ Interesting avenues for future work include benchmarking SLASH on additional data types and tasks. One should explore unsupervised and weakly supervised learning using logic with SLASH and investigate how far logical constraints can help unsupervised object discovery. In direct alignment with our work, one should also investigate image generation via the beneficial feature of PCs to generate random samples. Actually, it should be possible to generate images that encapsulate logical knowledge bases. This is important to move from data-rich to knowledge-rich AI.
219
+
220
+ # ETHICS STATEMENT
221
+
222
+ With our work, we have shown that one can add prior knowledge and logical constraints to the training of learning systems. We postulate that SLASH can therefore additionally be used to identify and remove biases or undesirable behavior, by adding constraints within the SLASH program. We observe that this feature, however, also has the potential danger to be used in the opposite way, e.g. explicitly adding bias and discriminatory factors to a system. To the best of our knowledge, our study does not raise any ethical, privacy or conflict of interest concerns.
223
+
224
+ # REPRODUCIBILITY STATEMENT
225
+
226
+ An official, curated GitHub repository will be made public with the final version, containing the code of SLASH, as well as scripts to reproduce the experiments and generate data sets. In addition to this, architectural details and hyperparameters are included in the appendix. Preliminary code will be uploaded upon submission. Lastly, details on the evaluation metrics and relevant data sets are given in the main text as well as appendix.
227
+
228
+ # REFERENCES
229
+
230
+ Yoshua Bengio. From System 1 Deep Learning to System 2 Deep Learning. Invited talk NeurIPS, 2019. URL https://www.youtube.com/watch?v $=$ T3sxeTgT4qc.
231
+
232
+ Eli Bingham, Jonathan P. Chen, Martin Jankowiak, Fritz Obermeyer, Neeraj Pradhan, Theofanis Karaletsos, Rohit Singh, Paul A. Szerlip, Paul Horsfall, and Noah D. Goodman. Pyro: Deep universal probabilistic programming. Journal of Machine Learning Research, pp. 28:1–28:6, 2019.
233
+
234
+ Christopher P. Burgess, Loïc Matthey, Nicholas Watters, Rishabh Kabra, Irina Higgins, Matthew Botvinick, and Alexander Lerchner. Monet: Unsupervised scene decomposition and representation. CoRR, 2019.
235
+
236
+ Francesco Calimeri, Wolfgang Faber, Martin Gebser, Giovambattista Ianni, Roland Kaminski, Thomas Krennwallner, Nicola Leone, Marco Maratea, Francesco Ricca, and Torsten Schaub. Asp-core-2 input language format. Theory and Practice of Logic Programming, pp. 294–309, 2020.
237
+
238
+ YooJung Choi, Antonio Vergari, and Guy Van den Broeck. Probabilistic circuits: A unifying framework for tractable probabilistic models. Technical report, Technical report, 2020.
239
+
240
+ Gabriele Ciravegna, Francesco Giannini, Marco Gori, Marco Maggini, and Stefano Melacci. Humandriven FOL explanations of deep learning. In IJCAI, pp. 2234–2240, 2020.
241
+
242
+ W. F. Clocksin and Chris Mellish. Programming in Prolog. 1981.
243
+
244
+ Alain Colmerauer and Philippe Roussel. The birth of prolog. In HOPL-II, pp. 37–52, 1993.
245
+
246
+ Adnan Darwiche. SDD: A new canonical representation of propositional knowledge bases. In IJCAI, pp. 819–826, 2011.
247
+
248
+ Artur d’Avila Garcez and Luís C. Lamb. Neurosymbolic AI: the 3rd wave. CoRR, 2020.
249
+
250
+ Artur S. d’Avila Garcez, Luís C. Lamb, and Dov M. Gabbay. Neural-Symbolic Cognitive Reasoning. Cognitive Technologies. 2009.
251
+
252
+ Artur S. d’Avila Garcez, Marco Gori, Luís C. Lamb, Luciano Serafini, Michael Spranger, and Son N. Tran. Neural-symbolic computing: An effective methodology for principled integration of machine learning and reasoning. FLAP, pp. 611–632, 2019.
253
+
254
+ Yannis Dimopoulos, Bernhard Nebel, and Jana Koehler. Encoding planning problems in nonmonotonic logic programs. In ECP, Lecture Notes in Computer Science, pp. 169–181, 1997.
255
+
256
+ Martin Engelcke, Adam R. Kosiorek, Oiwi Parker Jones, and Ingmar Posner. GENESIS: generative scene inference and sampling with object-centric latent representations. In ICLR, 2020.
257
+
258
+ Jerry A Fodor and Zenon W Pylyshyn. Connectionism and cognitive architecture: A critical analysis. Cognition, pp. 3–71, 1988.
259
+
260
+ Klaus Greff, Raphaël Lopez Kaufman, Rishabh Kabra, Nick Watters, Christopher Burgess, Daniel Zoran, Loic Matthey, Matthew Botvinick, and Alexander Lerchner. Multi-object representation learning with iterative variational inference. In ICML, pp. 2424–2433, 2019.
261
+
262
+ Klaus Greff, Sjoerd van Steenkiste, and Jürgen Schmidhuber. On the binding problem in artificial neural networks. CoRR, 2020.
263
+
264
+ Drew A. Hudson and Christopher D. Manning. Learning by abstraction: The neural state machine. In NeurIPS, pp. 5901–5914, 2019.
265
+
266
+ Jindong Jiang and Sungjin Ahn. Generative neurosymbolic machines. In NeurIPS, 2020.
267
+
268
+ Justin Johnson, Bharath Hariharan, Laurens van der Maaten, Li Fei-Fei, C. Lawrence Zitnick, and Ross B. Girshick. CLEVR: A diagnostic dataset for compositional language and elementary visual reasoning. In CVPR, pp. 1988–1997, 2017.
269
+
270
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR 2015, 2015.
271
+
272
+ Alexander Kuhnle and Ann A. Copestake. Shapeworld - A new test methodology for multimodal language understanding. CoRR, 2017.
273
+
274
+ Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. pp. 2278–2324, 1998a.
275
+
276
+ Yann LeCun, Corinna Cortes, and Christopher J.C. Burges. THE MNIST DATABASE of handwritten digits, 1998b. URL http://yann.lecun.com/exdb/mnist/.
277
+
278
+ Joohyung Lee and Yi Wang. Weighted rules under the stable model semantics. In KR, pp. 145–154, 2016.
279
+
280
+ Zhixuan Lin, Yi-Fu Wu, Skand Vishwanath Peri, Weihao Sun, Gautam Singh, Fei Deng, Jindong Jiang, and Sungjin Ahn. SPACE: unsupervised object-oriented scene representation via spatial attention and decomposition. In ICLR, 2020.
281
+
282
+ Francesco Locatello, Dirk Weissenborn, Thomas Unterthiner, Aravindh Mahendran, Georg Heigold, Jakob Uszkoreit, Alexey Dosovitskiy, and Thomas Kipf. Object-centric learning with slot attention. In NeurIPS, 2020.
283
+
284
+ Robin Manhaeve, Sebastijan Dumancic, Angelika Kimmig, Thomas Demeester, and Luc De Raedt. Deepproblog: Neural probabilistic logic programming. pp. 3753–3763, 2018.
285
+
286
+ Jiayuan Mao, Chuang Gan, Pushmeet Kohli, Joshua B. Tenenbaum, and Jiajun Wu. The neurosymbolic concept learner: Interpreting scenes, words, and sentences from natural supervision. In ICLR, 2019.
287
+
288
+ Gary F Marcus. The algebraic mind: Integrating connectionism and cognitive science. 2019.
289
+
290
+ Victor W. Marek and Miroslaw Truszczynski. Stable models and an alternative logic programming paradigm. In The Logic Programming Paradigm - A 25-Year Perspective, Artificial Intelligence, pp. 375–398. 1999.
291
+
292
+ Robert Peharz, Steven Lang, Antonio Vergari, Karl Stelzner, Alejandro Molina, Martin Trapp, Guy Van den Broeck, Kristian Kersting, and Zoubin Ghahramani. Einsum networks: Fast and scalable learning of tractable probabilistic circuits. In ICML, pp. 7563–7574, 2020.
293
+
294
+ Hoifung Poon and Pedro M. Domingos. Sum-product networks: A new deep architecture. In UAI, pp. 337–346, 2011.
295
+
296
+ Matthew Richardson and Pedro M. Domingos. Markov logic networks. Machine Learning, pp. 107–136, 2006.
297
+
298
+ Arseny Skryagin, Karl Stelzner, Alejandro Molina, Fabrizio Ventola, and Kristian Kersting. Splog: Sum-product logic. In ProbProg, 2020.
299
+
300
+ Timo Soininen and Ilkka Niemelä. Developing a declarative rule language for applications in product configuration. In PADL, Lecture Notes in Computer Science, pp. 305–319, 1999.
301
+
302
+ Wolfgang Stammer, Patrick Schramowski, and Kristian Kersting. Right for the right concept: Revising neuro-symbolic concepts by interacting with their explanations. In CVPR, pp. 3619–3629, 2021.
303
+
304
+ Dustin Tran, Matthew D. Hoffman, Rif A. Saurous, Eugene Brevdo, Kevin Murphy, and David M. Blei. Deep probabilistic programming. In ICLR, 2017.
305
+
306
+ Zhun Yang, Adam Ishay, and Joohyung Lee. NeurASP: Embracing neural networks into answer set programming. In IJCAI, pp. 1755–1762, 2020.
307
+
308
+ Kexin Yi, Jiajun Wu, Chuang Gan, Antonio Torralba, Pushmeet Kohli, and Josh Tenenbaum. Neuralsymbolic VQA: disentangling reasoning from vision and language understanding. In NeurIPS, pp. 1039–1050, 2018.
309
+
310
+ Yan Zhang, Jonathon S. Hare, and Adam Prügel-Bennett. Deep set prediction networks. In NeurIPS, pp. 3207–3217, 2019.
311
+
312
+ # A APPENDIX A – DETAILS ON PARAMETER LEARNING
313
+
314
+ In the Appendix, we want to discuss details on parameter learning in SLASH. Since we use coordinate descent for training SLASH we present the derivative of each component of the loss function defined in equation 10 since while optimization, one component has to be kept fixed.
315
+
316
+ We start with the gradient of the NPP loss function $L _ { N P P }$ i.e. the negative log-likelihood, defined in equation 2
317
+
318
+ $$
319
+ \begin{array} { c } { { \displaystyle { \frac { \partial } { \partial \xi } } L _ { N P P } = { \frac { \partial } { \partial x _ { Q _ { i } } } \cdot \frac { \partial x _ { Q _ { i } } } { \partial \xi } } L _ { N P P } = { \frac { \partial x _ { Q _ { i } } } { \partial \xi } } \left( - { \sum _ { i = 1 } ^ { n } } { \frac { \partial } { \partial x _ { Q _ { i } } } \log \left( P _ { \xi } ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i } } ) \right) } \right) } } \\ { { \displaystyle { = \frac { \partial x _ { Q _ { i } } } { \partial \xi } } \left( - { \sum _ { i = 1 } ^ { n } } { \frac { 1 } { \left( P _ { \xi } ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i } } ) \right) } } \frac { \partial } { \partial x _ { Q _ { i } } } \left( P _ { \xi } ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i } } ) \right) \right) } } \end{array}
320
+ $$
321
+
322
+ Here, we remark tha t ∂xQi∂ξ will be carried out by back-propagation and the expression after it is the initial gradient.
323
+
324
+ Next, we derive the gradient of the logical entailment loss function $\mathit { L } _ { \mathit { E N T } }$ , as defined in equation 7. One estimates the gradient as follows
325
+
326
+ $$
327
+ \frac { 1 } { n } \frac { \partial } { \partial p } L _ { E N T } \ge - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \frac { \partial \log ( P _ { \Pi ( \theta ) } ( Q _ { i } ) ) } { \partial p } \cdot \log \bigl ( P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i } } ) \bigr ) ,
328
+ $$
329
+
330
+ whereby
331
+
332
+ • $X _ { \mathbf { Q } }$ is the set of random variables associated with the set of the queries $\mathbf { Q }$ ,
333
+ • $x _ { Q _ { i } }$ is a training sample, a realization of the set of random variables $X _ { \mathbf { Q } }$ associated with the particular query $Q _ { i }$ ,
334
+ • $P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i } } )$ is the probability of the realization $x _ { Q _ { i } }$ estimated by the NPP modelling the joint over the set $X _ { \mathbf { Q } }$ and $C$ – the set of classes (the domain of the NPP),
335
+ • $\log ( P _ { \Pi ( \theta ) } ( Q _ { i } ) )$ – the probability of the query $Q _ { i }$ under the program $\Pi ( \theta )$ calculated by SLASH (for the reference see the equation (5)),
336
+ • and ∂ log(PΠ(θ)(Qi)) is the gradient as defined in Eq.9.
337
+
338
+ We begin with the definition of the cross-entropy for two vectors $y _ { i }$ and $\hat { y } _ { i }$ :
339
+
340
+ $$
341
+ H ( y _ { i } , \hat { y } _ { i } ) : = \sum _ { j = 1 } ^ { m } y _ { i j } \cdot \log \left( \frac { 1 } { \hat { y } _ { i j } } \right) = \sum _ { j = 1 } ^ { m } \left( y _ { i j } \cdot \underbrace { \log ( 1 ) } _ { = 0 } - y _ { i j } \cdot \log ( \hat { y } _ { i j } ) \right) = - \sum _ { j = 1 } ^ { m } y _ { i j } \cdot \log ( \hat { y } _ { i j } ) .
342
+ $$
343
+
344
+ Hereafter we substitute
345
+
346
+ $$
347
+ y _ { i } = \log ( P _ { \Pi ( \theta ) } ( Q _ { i } ) ) \qquad \mathrm { ~ a n d ~ } \qquad \hat { y } _ { i } = P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i } } )
348
+ $$
349
+
350
+ and obtain
351
+
352
+ $$
353
+ \bar { \cal I } ( y _ { i } , \hat { y } _ { i } ) = \cal H \left( \log ( P _ { \Pi ( \theta ) } ( Q _ { i } ) ) , P ^ { ( X _ { \mathbf { Q } } , { \cal C } ) } ( x _ { Q _ { i } } ) \right) = - \sum _ { j = 1 } ^ { m } \log ( P _ { \Pi ( \theta ) } ( Q _ { i j } ) ) \cdot \log \Big ( P ^ { ( X _ { \mathbf { Q } } , { \cal C } ) } ( x _ { Q _ { i j } } ) \Big ) .
354
+ $$
355
+
356
+ We remark that $m$ represent the number of classes defined in the domain of an NPP. Now, we differentiate the equation (11) with the respect to $p$ depicted as in Eq. 9 to be the label of the probability of an atom $c = v$ in $r ^ { n p p }$ , denoting $P _ { \Pi ( \pmb { \theta } ) } ( c = v )$ . Since differentiation is linear, the product rule is applicable directly:
357
+
358
+ $$
359
+ \begin{array} { c } { \displaystyle \frac { \partial } { \partial p } H \left( y _ { i } , \hat { y } _ { i } \right) = - \sum _ { j = 1 } ^ { m } \left[ \frac { \partial \log \left( P _ { \Pi ( \theta ) } ( Q _ { i j } ) \right) } { \partial p } \cdot \log \left( P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i j } } ) \right) \right. } \\ { \displaystyle \left. + \log ( P _ { \Pi ( \theta ) } ( Q _ { i j } ) ) \cdot \frac { \partial \log \left( P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i j } } ) \right) } { \partial p } \right] . } \end{array}
360
+ $$
361
+
362
+ We do not wish to consider the latter term of $\begin{array} { r } { \log ( P _ { \mathrm { { I I } } ( \theta ) } ( Q _ { i } ) ) \cdot \frac { \partial \log \left( P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i } } ) \right) } { \partial p } } \end{array}$ because it represents the rescaling and to keep the first since SLASH procure $\frac { \partial \log ( P _ { \Pi ( \theta ) } ( Q _ { i } ) ) } { \partial p }$ following Eq. 9. To achieve this, we estimate equation from above downwards as
363
+
364
+ $$
365
+ \frac { \partial } { \partial p } H \left( y _ { i } , \hat { y } _ { i } \right) \geq - \sum _ { j = 1 } ^ { m } \frac { \partial \log ( P _ { \Pi ( \theta ) } ( Q _ { i j } ) ) } { \partial p } \cdot \log \left( P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i j } } ) \right) .
366
+ $$
367
+
368
+ Furthermore, let us recall that under i.i.d assumption we obtain from the definition of likelihood
369
+
370
+ $$
371
+ L H ( y , \hat { y } ) = \prod _ { i = 1 } ^ { n } L H ( y _ { i } , \hat { y } _ { i } ) ,
372
+ $$
373
+
374
+ and following the negative likelihood coupled with the knowledge that the log-likelihood of $y _ { i }$ is the log of a particular entry of $\hat { y } _ { i }$
375
+
376
+ $$
377
+ \begin{array} { c } { { { \cal L } _ { E N T } = - \displaystyle \log { \cal L } H ( y , \hat { y } ) = - \sum _ { i = 1 } ^ { n } \log { \cal L } H ( y _ { i } , \hat { y } _ { i } ) = - \sum _ { i = 1 } ^ { n } \sum _ { j = 1 } ^ { m } y _ { i j } \cdot \log ( \hat { y } _ { i j } ) = } } \\ { { \displaystyle \sum _ { i = 1 } ^ { n } \left[ - \sum _ { j = 1 } ^ { m } y _ { i j } \cdot \log ( \hat { y } _ { i j } ) \right] = \sum _ { i = 1 } ^ { n } H ( y _ { i } , \hat { y } _ { i } ) . } } \end{array}
378
+ $$
379
+
380
+ Finally, we obtain the following estimate applying inequality (12)
381
+
382
+ $$
383
+ \frac { 1 } { n } \frac { \partial } { \partial p } L _ { E N T } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \frac { \partial } { \partial p } H ( y _ { i } , \hat { y } _ { i } ) \geq - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \frac { \partial \log \left( P _ { \mathrm { { I I } } ( \theta ) } ( Q _ { i } ) \right) } { \partial p } \cdot \log \left( P ^ { ( X _ { \mathbf { Q } } , C ) } ( x _ { Q _ { i } } ) \right)
384
+ $$
385
+
386
+ Also, we note that the mathematical transformations listed above hold for any type of NPP and the task dependent queries (NN with Softmax, PC or PC jointly with NN). The only difference will be the second term, i.e., $\log ( P ^ { ( C | X _ { \mathbf { Q } } ) } ( x _ { Q _ { i j } } ) )$ or $\log ( P ^ { ( \bar { X } _ { \mathbf { Q } } | C ) } \bar { ( x _ { Q _ { i j } } ) } )$ depending on the NPP and task. The NPP in a form of a single PC modeling the joint over $X _ { \mathbf { Q } }$ and $C$ was depicted to be the example. With that, the derivation of gradients for both loss functions 2 and 7 is complete, and the training is carried out by coordinated descent.
387
+
388
+ Backpropagation for joint NN and PC NPPs: If within the SLASH program, $\Pi ( \pmb \theta )$ , the NPP forwards the data tensor through a NN first, i.e., the NPP models a joint over the NN’s output variables by a PC, then we rewrite (8) to
389
+
390
+ $$
391
+ \sum _ { i = 1 } ^ { n } { \frac { \partial \log \left( P _ { \Pi ( \theta ) } ( Q _ { i } ) \right) } { \partial \theta } } = \sum _ { i = 1 } ^ { n } { \frac { \partial \log \left( P _ { \Pi ( \theta ) } ( Q _ { i } ) \right) } { \partial \mathbf { p } } } \times { \frac { \partial \mathbf { p } } { \partial \theta } } \times { \frac { \partial \theta } { \partial \gamma } } .
392
+ $$
393
+
394
+ Thereby, $\gamma$ is the set of the NN’s parameters and $\frac { \partial \pmb { \theta } } { \partial \gamma }$ is computed by the backward propagation through the NN.
395
+
396
+ # B APPENDIX B – SLASH PROGRAMS
397
+
398
+ Here, the interested reader will find the SLASH programs which we compiled for our experiments. Figure 4 presents the one for the MNIST Addition task, Figure 6 – for the set prediction task with slot attention encoder and the subsequent CoGenT test. Note the use of the $" + "$ and “-” notation for indicating whether a random variable is given or being queried for.
399
+
400
+ # Define images img(i1). img(i2). 3 # Define Neural-Probabilistic Predicate 4 npp(digit(X), [0,1,2,3,4,5,6,7,8,9]) :- img(X). 5 # Define the addition of digits given two images and the resulting sum 6 addition(A, B, N) :- digit $\mathrm { \Omega } + \tt { A }$ , -N1), digit( $+ \mathtt { B }$ , -N2), $\mathrm { ~ N ~ } = \mathrm { ~ N ~ 1 ~ } + \mathrm { ~ N ~ 2 ~ }$ .
401
+
402
+ # Is 7 the sum of the digits in img1 and img2? 2 :- addition(image_id1, image_id2, 7)
403
+
404
+ ![](images/5d942cadea3c1d2f75797d835c60baf51150bd1a4748aee77f10460fe3c0d331.jpg)
405
+ Figure 4: SLASH Program for MNIST addition. The same program was used for the training with missing data.
406
+ Figure 5: Example SLASH Query for MNIST addition. The same type of query was used for the training with missing data
407
+ Figure 6: SLASH Program for ShapeWorld4. The same program was used for the CoGenT experiments.
408
+
409
+ # Does object o1 have the attributes red, circle, bright, small? :- has_attributes(o1, red, circle, bright, small)
410
+
411
+ Figure 7: Example SLASH Query for ShapeWorld4 experiments. In other words, this query corresponds to asking SLASH: “Is object 1 a small, bright red circle?”.
412
+
413
+ # C APPENDIX C – EXPERIMENTAL DETAILS
414
+
415
+ # C.1 SHAPEWORLD4 GENERATION
416
+
417
+ The ShapeWorld4 and ShapeWorld4 CoGenT data sets were generated using the original scripts of (Kuhnle & Copestake, 2017) (https://github.com/AlexKuhnle/ShapeWorld). The exact scripts will be added together with the SLASH source code.
418
+
419
+ # C.2 AVERAGE PRECISION COMPUTATION (SHAPEWORLD4)
420
+
421
+ For the baseline slot encoder experiments on ShapeWorld4 we measured the average precision score as in Locatello et al. (2020). In comparison to the baseline slot encoder, when applying SLASH Attention, however, we handled the case of a slot not containing an object, e.g. only background variables, differently. Whereas Locatello et al. (2020) add an additional binary identifier to the multi-label ground truth vectors, we have added a background (bg) attribute to each category (cf. Fig. 6). A slot is thus considered to be empty (i.e. not containing an object) if each NPP returns the maximal conditional probability for the $b g$ attribute.
422
+
423
+ As the ShapeWorld4 prediction task only included discrete object properties both for Slot Attention as well as for SLASH Attention the distance threshold for the average precision computation was infinity (thus corresponding to no threshold).
424
+
425
+ # C.3 MODEL DETAILS
426
+
427
+ For those experiments using NPPs with PC we have used Einsum Networks (EiNets) for implementing the probabilistic circuits. EiNets are a novel implementation design for SPNs introduced by Peharz et al. (2020) that minimize the issue of computational costs that initial SPNs had suffered. This is accomplished by combining several arithmetic operations via a single monolithic einsum-operation.
428
+
429
+ For all experiments, the ADAM optimizer (Kingma & Ba, 2015) with $\beta 1 = 0 . 9$ and $\beta 2 = 0 . 9 9 9$ $\epsilon = 1 e - 8$ and no weight decay was used.
430
+
431
+ MNIST-Addition Experiments For the MNIST-Addition experiments, we ran the DeepProbLog and NeurASP programs with their original configurations, as stated in (Manhaeve et al., 2018) and (Yang et al., 2020), respectively. For the SLASH MNIST-Addition experiments, we have used the same neural module as in DeepProbLog and NeurASP, when training SLASH with the neural NPP (SLASH (DNN)) represented in Tab. 2. When using a PC NPP (SLASH (PC)) we have used an EiNet with the Poon-Domingos (PD) structure (Poon & Domingos, 2011) and normal distribution for the leafs. The formal hyperparameters for the EiNet are depicted in Tab. 3.
432
+
433
+ The learning rate and batch size for the DNN were 0.005 and 100, for DeepProbLog, NeurASP and SLASH (DNN). For the EiNet, these were 0.01 and 100.
434
+
435
+ Table 2: Neural module – LeNet5 for MNIST-Addition experiments.
436
+
437
+ <table><tr><td>Type</td><td>Size/Channels</td><td>Activation</td><td>Comment</td></tr><tr><td>Encoder</td><td>-</td><td>二</td><td>-</td></tr><tr><td>Conv 5 x 5</td><td>1x28x28</td><td>1</td><td>stride 1</td></tr><tr><td>MaxPool2d</td><td>6x24x24</td><td>ReLU</td><td>kernel size 2, stride 2</td></tr><tr><td>Conv 5 x 5</td><td>6x12x12</td><td>1</td><td>stride 1</td></tr><tr><td>MaxPool2d</td><td>16x8x8</td><td>ReLU</td><td>kernel size 2,stride 2</td></tr><tr><td>Classifier</td><td>1</td><td>-</td><td>-</td></tr><tr><td>MLP</td><td>16x4x4,120</td><td>ReLU</td><td>-</td></tr><tr><td>MLP</td><td>120,84</td><td>ReLU</td><td>-</td></tr><tr><td>MLP</td><td>84,10</td><td>1</td><td>Softmax</td></tr></table>
438
+
439
+ ShapeWorld4 Experiments For the baseline slot attention experiments with the ShapeWorld4 data set we have used the architecture presented in Tab. 4. For further details on this, we refer to the original work of Locatello et al. (2020). The slot encoder had a number of 4 slots and 3 attention iterations over all experiments.
440
+
441
+ Table 3: Probabilistic Circuit module – EiNet for MNIST-Addition experiments.
442
+
443
+ <table><tr><td>Variables</td><td>Width</td><td>Height</td><td>Number of Pieces</td><td>Class count</td></tr><tr><td>784</td><td>28</td><td>28</td><td>[4,7,28]</td><td>10</td></tr></table>
444
+
445
+ Table 4: Baseline slot encoder for ShapeWorld4 experiments.
446
+
447
+ <table><tr><td>Type</td><td>Size/Channels</td><td>Activation</td><td>Comment</td></tr><tr><td>Conv 5 x 5</td><td>32</td><td>ReLU</td><td>stride 1</td></tr><tr><td>Conv 5 x 5</td><td>32</td><td>ReLU</td><td>stride 1</td></tr><tr><td>Conv 5 x 5</td><td>32</td><td>ReLU</td><td>stride 1</td></tr><tr><td>Conv 5 x 5</td><td>32</td><td>ReLU</td><td>stride 1</td></tr><tr><td>Position Embedding</td><td>1</td><td>二</td><td>-</td></tr><tr><td>Flatten</td><td>axis: [0, 1,2 x 3]</td><td>-</td><td>flatten x, y pos.</td></tr><tr><td>Layer Norm</td><td>二</td><td>-</td><td>二</td></tr><tr><td>MLP (per location)</td><td>32</td><td>ReLU</td><td>二</td></tr><tr><td>MLP (per location)</td><td>32</td><td>-</td><td>二</td></tr><tr><td>SlotAttentionModule</td><td>32</td><td>ReLU</td><td>二</td></tr><tr><td>MLP</td><td>32</td><td>ReLU</td><td></td></tr><tr><td>MLP</td><td>16</td><td>Sigmoid</td><td>二 1</td></tr></table>
448
+
449
+ For the SLASH Attention experiments with ShapeWorld4 we have used the same slot encoder as in Tab. 4, however, we replaced the final MLPs with 4 individual EiNets with Poon-Domingos structure (Poon & Domingos, 2011). Their hyperparameters are represented in Tab. 5.
450
+
451
+ Table 5: Probabilistic Circuit module – EiNet for ShapeWorld4 experiments.
452
+
453
+ <table><tr><td>EiNet</td><td>Variables</td><td>Width</td><td>Height</td><td>Number ofPieces</td><td>Class count</td></tr><tr><td>Color</td><td>32</td><td>8</td><td>4</td><td>[4]</td><td>9</td></tr><tr><td>Shape</td><td>32</td><td>8</td><td>4</td><td>[4]</td><td>4</td></tr><tr><td>Shade</td><td>32</td><td>8</td><td>4</td><td>[4]</td><td>3</td></tr><tr><td>Size</td><td>32</td><td>8</td><td>4</td><td>[4]</td><td>3</td></tr></table>
454
+
455
+ The learning rate and batch size for SLASH Attention were 0.01 and 512, for ShapeWorld4 and ShapeWorld4 CoGenT. The learning rate for the baseline slot encoder were 0.0004 and 512.
456
+
457
+ # D APPENDIX D - ADDITIONAL RESULTS ON MNIST ADDITION
458
+
459
+ Table 6: Additional MNIST Addition Results. Test accuracy corresponds to the percentage of correctly classified test images. Both models (DeepProbLog and SLASH (PC)) were trained on the full MNIST data, but tested on images with missing pixels. Test accuracies are presented in percent. The amount of missing data was varied between $50 \%$ and $9 7 \%$ of the pixels per image.
460
+
461
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>DeepProbLog</td><td rowspan=1 colspan=1>SLASH (PC)</td></tr><tr><td rowspan=1 colspan=1>50%</td><td rowspan=1 colspan=1>79.94 ± 7.2</td><td rowspan=1 colspan=1>72.2 ± 12.15</td></tr><tr><td rowspan=1 colspan=1>80%</td><td rowspan=1 colspan=1>31.6± 6.08</td><td rowspan=1 colspan=1>44.2± 8.23</td></tr><tr><td rowspan=1 colspan=1>90%</td><td rowspan=1 colspan=1>16.94 ± 1.76</td><td rowspan=1 colspan=1>29.6± 5.77</td></tr><tr><td rowspan=1 colspan=1>97%</td><td rowspan=1 colspan=1>12.33 ± 0.47</td><td rowspan=1 colspan=1>17.6 ± 2.97</td></tr></table>
462
+
463
+ In addition to the setting considered in Evaluation 2, we adjusted the settings for the MNIST Addition task with missing data into the following way.
464
+
465
+ Training was performed with the full MNIST data set, however the test data set contained different rates of missing pixels. Whereas using an NPP with a PC allows, among other things, to compute marginalization “out of the box” without requiring an update to the architecture or a retraining, this is not so trivial for purely neural-based predicates as in DeepProbLog. Thus, we allowed SLASH (PC) to marginalize over the missing pixels, where this was not directly possible for DeepProbLog.
466
+
467
+ The results can be seen in Tab. 6 for $5 0 \%$ , $8 0 \%$ , $9 0 \%$ and $9 7 \%$ of missing pixels per image in the test set. We observe that at $5 0 \%$ , DeepProbLog outperforms SLASH by a small margin. For all other rates, we observe that SLASH (PC) reaches significantly higher test accuracies than DeepProbLog. However, we remark that in this setting, SLASH produces larger standard deviations in comparison to DeepProbLog. These results indicate that the conclusions, drawn in the main part of our work, remain true also in this setting of handling missing data.
md/dev/0YXmOFLb1wQ/0YXmOFLb1wQ.md ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MOTIFEXPLAINER: A MOTIF-BASED GRAPH NEURAL NETWORK EXPLAINER
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ We consider the explanation problem of Graph Neural Networks (GNNs). Most existing GNN explanation methods identify the most important edges or nodes but fail to consider substructures, which are more important for graph data. One method considering subgraphs tries to search all possible subgraphs and identifies the most significant ones. However, the subgraphs identified may not be recurrent or statistically important for interpretation. This work proposes a novel method, named MotifExplainer, to explain GNNs by identifying important motifs, which are recurrent and statistically significant patterns in graphs. Our proposed motif-based methods can provide better human-understandable explanations than methods based on nodes, edges, and regular subgraphs. Given an instance graph and a pre-trained GNN model, our method first extracts motifs in the graph using domain-specific motif extraction rules. Then, a motif embedding is encoded by feeding motifs into the pre-trained GNN. Finally, we employ an attention-based method to identify the most influential motifs as explanations for the prediction results. The empirical studies on both synthetic and real-world datasets demonstrate the effectiveness of our method.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Graph neural networks (GNNs) have shown capability in solving various challenging tasks in graph fields, such as node classification, graph classification, and link prediction. Although many GNNs models (Kipf & Welling, 2016; Gao et al., 2018; Xu et al., 2018; Gao & Ji, 2019; Liu et al., 2020) have achieved state-of-the-art performances in various tasks, they are still considered black boxes and lack sufficient knowledge to explain them. Inadequate interpretation of GNN decisions severely hinders the applicability of these models in critical decision-making contexts where both predictive performance and interpretability are critical. A good explainer allows us to debate GNN decisions and shows where algorithmic decisions may be biased or discriminated against. In addition, we can apply precise explanations to other scientific research like fragment generation. A fragment library is a key component in drug discovery, and accurate explanations may help its generation.
12
+
13
+ Several methods have been proposed to explain GNNs, divided into instance-level explainers and model-level explainers. Most existing instance-level explainers such as GNNExplainer (Ying et al., 2019), PGExplainer (Luo et al., 2020), Gem (Lin et al., 2021), and ReFine (Wang et al., 2021) produce an explanation to every graph instance. These methods explain pre-trained GNNs by identifying important edges or nodes but fail to consider substructures, which are more important for graph data. The only method that considers subgraphs is SubgraphX (Yuan et al., 2021), which searches all possible subgraphs and identifies the most significant one. However, the subgraphs identified may not be recurrent or statistically important, which raises an issue on the application of the produced explanations. For example, fragment-based drug discovery (FBDD)(Erlanson et al., 2004) has been proven to be powerful for developing potent small-molecule compounds. FBDD is based on fragment libraries, containing fragments or motifs identified as relevant to the target property by domain experts. Using a motif-based GNN explainer, we can directly identify relevant fragments or motifs that are ready to be used when generating drug-like lead compounds in FBDD.
14
+
15
+ In addition, searching and scoring all possible subgraphs is time-consuming and inefficient. We claim that using motifs, recurrent and statistically important subgraphs, to explain GNNs can provide a more intuitive explanation than methods based on nodes, edges, or subgraphs.
16
+
17
+ This work proposes a novel GNN explanation method named MotifExplainer, which can identify significant motifs to explain an instance graph. In particular, our method first extracts motifs from a given graph using domain-specific motif extraction rules based on domain knowledge. Then, motif embeddings of extracted motifs are generated by feeding motifs into the target GNN model. After that, an attention model is employed to select relevant motifs based on attention weights. These selected motifs are used as an explanation for the target GNN model on the instance graph. To our knowledge, the proposed method represents the first attempt to apply the attention mechanism to explain the GNN from the motif-level perspective. We evaluate our method using both qualitative and quantitative experiments. The experiments show that our MotifExplainer can generate a better explanation than previous GNN explainers. In addition, the efficiency studies demonstrate the efficiency advantage of our methods in terms of a much shorter training and inference time.
18
+
19
+ # 2 PROBLEM FORMULATION
20
+
21
+ This section formulates the problem of explanations on graph neural networks. Let $G _ { i } = \{ V , E \} \in$ $\mathcal { G } = \{ G _ { 1 } , G _ { 2 } , . . . , G _ { i } , . . . , \bar { G _ { N } } \}$ denotes a graph where $V = \{ v _ { 1 } , v _ { 2 } , . . . , v _ { i } , . . . v _ { n } \}$ is the node set of the graph and $E$ is the edge set. $G _ { i }$ is associated with a $d$ -dimensional set of node features $\pmb { X } = \{ \pmb { x } _ { 1 } , \pmb { x } _ { 2 } , . . . , \pmb { x } _ { i } , . . . , \pmb { x } _ { n } \}$ , where $\pmb { x } _ { i } \in \mathbb { R } ^ { d }$ is the feature vector of node $v _ { i }$ . Without loss of generality, we consider the problem of explaining a GNN-based downstream classification task. For a node classification task, we associate each node $v _ { i }$ of a graph $G$ with a label $y _ { i }$ , where $y _ { i } \in Y =$ $\{ l _ { 1 } , . . . , l _ { c } \}$ and $c$ is the number of classes. For a graph classification task, each graph $G _ { i }$ is assigned a corresponding label.
22
+
23
+ # 2.1 BACKGROUND ON GRAPH NEURAL NETWORKS
24
+
25
+ Most Graph Neural Networks (GNNs) follow a neighborhood aggregation learning scheme. In a layer $\ell$ , GNNs contain three steps. First, a GNN first calculates the messages that will be transferred between every node pair. A message for a node pair $( v _ { i } , v _ { j } )$ can be represented by a function $\theta ( \cdot ) : b _ { i j } ^ { \ell } = \theta ( { \pmb x } _ { i } ^ { \ell - 1 } , { \pmb x } _ { j } ^ { \ell - 1 } , { \pmb e } _ { i j } )$ , where $e _ { i j }$ is the edge feature vector, $\pmb { x } _ { i } ^ { \ell - 1 }$ and ${ \pmb x } _ { i } ^ { \ell - 1 }$ are the node features of $v _ { i }$ and $v _ { j }$ at the previous layer, respectively. Second, for each node $v _ { i }$ , GNN aggregates all messages from its neighborhood ${ \mathcal { N } } _ { i }$ using an aggregation function ${ \boldsymbol { \phi } } ( \cdot ) : { \mathbf { } } { \mathbf { } } { \mathbf { } } B _ { i } ^ { \ell } = \phi \left( \{ b _ { i j } ^ { \ell } | v _ { j } \in \mathcal { N } _ { i } \} \right)$ . Finally, the GNN combine the aggregated message $B _ { i } ^ { \ell }$ with node $v _ { i }$ ’s feature representation from previous layer ${ \pmb x } _ { i } ^ { \ell - 1 }$ , and use a non-linear activation function to obtain the representation for node $v _ { i }$ at layer $l : { \bf x } _ { i } ^ { \ell } = f ( { \bf x } _ { i } ^ { \ell - 1 } , B _ { i } ^ { \ell } )$ . Formally, a $\ell$ -th GNN layer can be represented by
26
+
27
+ $$
28
+ \begin{array} { r } { \pmb { x } _ { i } ^ { \ell } = f ( \pmb { x } _ { i } ^ { \ell - 1 } , \phi ( \{ \theta ( \pmb { x } _ { i } ^ { l - 1 } , \pmb { x } _ { j } ^ { l - 1 } , \pmb { e } _ { i j } ) \} \vert \ v _ { j } \in \mathcal { N } _ { i } \} ) ) . } \end{array}
29
+ $$
30
+
31
+ # 2.2 GRAPH NEURAL NETWORK EXPLANATIONS
32
+
33
+ In a GNN explanation task, we are given a pre-trained GNN model, which can be represented by $\Psi ( \cdot )$ and its corresponding dataset $\mathcal { D }$ . The task is to obtain an explanation model $\bar { \Phi } ( \cdot )$ that can provide a fast and accurate explanation for the given GNN model. Most existing GNN explanation approaches can be categorized into two branches: instance-level methods and model-level methods. Instance-level methods can provide an explanation for each input graph, while model-level methods are input-independent and analyze graph patterns without input data. Following previous works (Luo et al., 2020; Yuan et al., 2021; Lin et al., 2021; Wang et al., 2021; Bajaj et al., 2021), we focus on instance-level methods with explanations using graph sub-structures. Also, our approach is modelagnostic. In particular, given an input graph, our explanation model can generate a subgraph that is the most important to the outcomes of a pre-trained GNN on any downstream graph-related task, such as graph classification tasks.
34
+
35
+ # 3 MOTIF-BASED GRAPH NEURAL NETWORK EXPLAINER
36
+
37
+ Most existing GNN explainers (Ying et al., 2019; Luo et al., 2020) identify the most important nodes or edges. SubgraphX (Yuan et al., 2021) is the first work that proposed a method to explain GNN models by generating the most significant subgraph for an input graph. However, the subgraphs
38
+
39
+ ![](images/6d14148f15b68a87cc3e622f062fd47ac08fb5f38b3b6f2ee99652f13478b8ec.jpg)
40
+ Figure 1: An illustration of the proposed MotifExplainer on graph classification tasks. Given a graph, we first extract motifs based on extraction rules. Then, motif embedding is generated for each motif by feeding it into the pre-trained GNN feature extractor. After that, we employ an attention layer that uses graph embedding as the query and motif embedding as keys and values, resulting in a new graph embedding. Finally, the loss is computed based on the new and the original predictions.
41
+
42
+ identified by SubgraphX may not be recurrent or statistically important. This section proposes a novel GNN explanation method, named MotifExplainer, to explain GNN models based on motifs.
43
+
44
+ # 3.1 FROM SUBGRAPH TO MOTIF EXPLANATION
45
+
46
+ Unlike explanation on models for text and image tasks, a graph has non-grid topology structure information, which needs to be considered in an explanation model. Given an input graph and a trained GNN model, most existing GNN explainers such as GNNExplainer (Ying et al., 2019) and PGExplainer (Luo et al., 2020) identify important edges and construct a subgraph containing all those edges as the explanation of the input graph. However, these models ignore the interactions between edges or nodes and implicitly measure the essence of substructures. To address this limitation, SubgraphX (Yuan et al., 2021) proposed to employ subgraphs for GNN explanation. It explicitly evaluates subgraphs and considers the interaction between different substructures. However, it does not use domain knowledge like motif information when generating the subgraphs.
47
+
48
+ A motif can be regarded as a simple subgraph of a complex graph, which repeatedly appears in graphs and is highly related to the function of the graph. Motifs have been extensively studied in many fields, like biochemistry, ecology, neurobiology, and engineering (Milo et al., 2002; ShenOrr et al., 2002; Alon, 2007; 2019) and are proved to be important. A subgraph identified without considering domain knowledge can be ineffective for downstream tasks like fragment library generation in FBDD. Thus, it is desirable to introduce statistically important motif information to a more human-understandable GNN explanation. In addition, subgraph-based explainers like SubgraphX need to handle a large searching space, which leads to efficiency issues when generating explanations for dense or large scale graphs. In contrast, the number of the extracted motifs can be constrained by well-designed motif extraction rules, which means that using motifs as explanations can significantly reduce the search space. Another limitation of SubgraphX is that it needs to pre-determine a maximum number of nodes for its searching space. As the number of nodes in graphs varies greatly, it is hard to set a proper number for searching subgraphs. A large number will tremendously increase the computational resources, while a small number can limit the power of the explainer. To address the limitations of subgraph-based explainers, we propose a novel method that explicitly select important motifs as an explanation for a given graph. Compared to explainers based on subgraphs, our method generates explanations with motifs, which are statistically important and more human-understandable.
49
+
50
+ # 3.2 MOTIF EXTRACTION
51
+
52
+ This section introduces domain-specific motif extraction rules.
53
+
54
+ <table><tr><td>Algorithm1MotifExplainerfor graphclassification tasks</td><td></td></tr><tr><td>Input: a set of graphs G, labels for graphs Y = {y1,.,yi,., yn}, a pre-trained GNN 亚(), a pre-trained classifier $(-), motif extraction rule R</td><td rowspan="3"></td></tr><tr><td>Initialization: initial a trainable weight matrix W for graph Gi in g do Graph embedding j = 亚(Gi)</td></tr><tr><td>Create motif list M = {m1,., mj,.,mt} based on extraction rule R Generate motif embedding for each motif mj = 亚(mj) Obtain an output score for each motif sj = mj · W . h Train an attention weight for each motif αj = exp(sj)</td></tr></table>
55
+
56
+ Domain knowledge. When working with data from different domains, motifs are extracted based on specific domain knowledge. For example, in biological networks, feed-forward loop, bifan, singleinput, and multi-input motifs are popular motifs, which have shown to have different properties and functions (Alon, 2007; Mangan & Alon, 2003; Gorochowski et al., 2018). For graphs or networks in the engineering domain, the three-node feedback loop (Leite & Wang, 2010) and four-node feedback loop motifs (Piraveenan et al., 2013) are important in addition to the feed-forward loop and bifan motifs. Motifs have also been shown to be important in computational Chemistry (Yu & Gao, 2022). The structures of these motifs are illustrated in Appendix C.
57
+
58
+ Extraction methods. For molecule datasets, we can use sophisticated decomposition methods like RECAP (Lewell et al., 1998) and BRICS (Degen et al., 2008) algorithms to extract motifs. For other datasets that do not have mature extraction methods like biological networks and social networks, inspired by related works on graph feature representation learning (Yu & Gao, 2022; Bouritsas et al., 2022), we propose a general extraction method in Appendix B that only considers cycles and edges as motifs, which can cover most popular network motifs. Our methods can be easily applied to other domains by changing the motif extraction rules accordingly.
59
+
60
+ Computational graph. We define the computational graph of a given graph based on different tasks. The computational graph includes all nodes and edges contributing to the prediction. Since most GNNs follow a neighborhood-aggregation scheme, the computational graph usually depends on the architecture of GNNs, such as the number of layers. In graph classification tasks, all nodes and edges contribute to the final prediction. Thus, a graph itself is its computational graph in graph classification tasks. For node classification tasks, a target node’s computational graph is the $L$ -hop subgraph centered on the target node, where $L$ is the number of GNN layers. Here, we only consider motifs in the computational graph since those outside it are irrelevant to the predictions.
61
+
62
+ Motif extraction. Given a graph $G$ , we extract all motifs based on the motif extraction method. If a motif has been extracted from the graph, it is added to a motif list $\mathcal { M }$ . After searching the whole graph, there may be edges not in any motif. We regard each of them as a one-edge motif and add them to the motif list to retain the integrity of the graph information. At last, we can obtain the motif list $\mathcal { M } = [ m _ { 1 } , m _ { 2 } , . . . , m _ { t } ]$ in $G$ .
63
+
64
+ # 3.3 MOTIF EMBEDDING
65
+
66
+ After extracting motifs $\mathcal { M }$ from a given graph, we encode the feature representations for each motif. Given a pre-trained GNN model, we split it into two parts: a feature extractor $\Psi ( \cdot )$ and a classifier $\xi ( \cdot )$ . The feature extractor $\Psi ( \cdot )$ generates an embedding for the prediction target. In particular, $\Psi ( \cdot )$ outputs graph embeddings in graph classification tasks, and outputs node embeddings in node classification tasks. The motif embedding is obtained in a graph classification task by feeding all motif node embeddings into a readout function. While in a node classification task, motif embedding encodes the influence of the motif on the node embedding of the target node. Thus, we feed the target node $k$ and a motif $m _ { j } \in { \mathcal { M } }$ as a subgraph into the GNN feature extractor $\Psi ( \cdot )$ and use the resulting target node embedding of $k$ as the embedding of the motif. To ensure the connectivity of the subgraph, we keep edges from the target node to the motif and mask features of irrelevant nodes.
67
+
68
+ # 3.4 GNN EXPLANATION FOR GRAPH CLASSIFICATION TASKS
69
+
70
+ This section introduces how to generate an explanation for a pre-trained GNN model in a graph classification task. We split the pre-trained GNN model into a feature extractor $\Psi ( \cdot )$ and a classifier $\xi ( \cdot )$ . Given a graph $G$ , its original graph embedding $^ { h }$ is computed as $h = \Psi ( G )$ . The prediction $y$ is computed by $y = \xi ( h )$ .
71
+
72
+ Based on the given graph, our method extracts a motif list from it and generates motif embedding $M = [ \pmb { m } _ { 1 } , \pmb { m } _ { 2 } , \dots , \pmb { m } _ { t } ]$ using the pre-trained feature extractor $\Psi ( \cdot )$ . Since the original graph embedding is directly related to the predictions, we identify the most important motifs by investigating relationships between the original graph embedding and motif embeddings. To this end, we employ an attention layer, which uses the original graph embedding $h = \Psi ( G )$ as query and motif embedding $M$ as keys and values. The output of the attention layer is considered as a new graph embedding $h ^ { \prime }$ . We interpret the attentions scores as the strengths of relationships between the prediction and motifs. Thus, highly relevant motifs will contribute more to the new graph embedding. By feeding the new graph embedding $\mathbf { { } } h ^ { \prime }$ into the pre-trained graph classifier $\xi ( \cdot )$ , a new prediction $y ^ { \prime } = \xi ( h ^ { \prime } )$ is obtained. The loss based on $y$ and $y ^ { \prime }$ evaluates the contribution of selected motifs to the final prediction, which trains the attention layer such that important motifs are selected to produce similar predictions to the original graph embedding. Formally, this explanation process can be represented as
73
+
74
+ $$
75
+ \begin{array} { r l } & { \boldsymbol { h } = \boldsymbol { \Psi } ( G ) , \boldsymbol { y } = \boldsymbol { \xi } ( \boldsymbol { h } ) , } \\ & { \boldsymbol { M } = [ m _ { 1 } , m _ { 2 } , \ldots , m _ { t } ] = \mathop { \bf M o t i f E x t r a c t o r } ( G ) , } \\ & { \boldsymbol { M } = [ m _ { 1 } , m _ { 2 } , \ldots , m _ { t } ] = [ \boldsymbol { \Psi } ( m _ { i } ) ] _ { i = 1 } ^ { t } , } \\ & { \boldsymbol { h } ^ { \prime } = \mathrm { A t t n } ( \boldsymbol { h } , \boldsymbol { M } , \boldsymbol { M } ) , } \\ & { \boldsymbol { y } ^ { \prime } = \boldsymbol { \xi } ( \boldsymbol { h } ^ { \prime } ) , } \\ & { \mathrm { l o s s } = \boldsymbol { f } ( \boldsymbol { y } , \boldsymbol { y } ^ { \prime } ) , } \end{array}
76
+ $$
77
+
78
+ where Attn is an attention layer and $f$ is a loss function. After training, we use the attention scores to identify important motifs. To our knowledge, our work first attempts to use the attention mechanism for GNN explanation. We want to mention that attention mechanism is only a tool for selecting important motifs. Any other methods that can identify relevances between two feature vectors can be applied in our model. In addition, attention scores are only used in training, while we have other metrics for evaluation.
79
+
80
+ During testing, we use a threshold $\sigma / t$ to select important motifs, where $\sigma$ is a hyper-parameter and $t$ is the number of motifs extracted. The explanation includes the motifs whose attention scores are larger than the threshold. Algorithm 1 describes our GNN explanation method on graph classification tasks. In addition, we provide an illustration of the proposed MotifExplainer in Figure 1.
81
+
82
+ # 3.5 GNN EXPLANATION FOR NODE CLASSIFICATION TASKS
83
+
84
+ This section introduces how to generate an explanation for a node classification task. Given a graph $G$ and a target node $v _ { i }$ , we first construct a computational graph for $v _ { i }$ , which is an $L$ -hop subgraph as described in Section 3.2. Then we extract motifs from the computational graph and generate motif embedding for each motif using the feature extractor $\Psi ( \cdot )$ . To keep the connectivity between a target node and a motif, we keep the shortest path between each node in the motif and the target node in an explanation graph. To reduce the impact of nodes on the path, we set irrelevant nodes’ features to zero. After that, the proposed MotifExplainer employs an attention layer to identify important motifs. The attention layer for node classification tasks is similar to the one for graph classification tasks, except that the query is the embedding of the target node. A node embedding is generated by feeding the whole graph into the feature extractor $\Psi ( \cdot )$ . The target node’s output feature vector $\boldsymbol { h } _ { i }$ is used as the query vector in the attention layer, which outputs the new node embedding $ { \boldsymbol { h } } _ { i } ^ { \prime }$ . Similarly, the new prediction $y ^ { \prime } = \xi ( h _ { i } ^ { \prime } )$ is obtained by feeding $ { \boldsymbol { h } } _ { i } ^ { \prime }$ into the pre-trained classifier. We use a threshold $\sigma / t$ during testing to identify important motifs as an explanation. Algorithm 2 in the appendix describes the details of the MotifExplainer on node classification tasks. Formally, the different parts from Section 3.4 are represented as
85
+
86
+ $$
87
+ \begin{array} { r l } & { \pmb { h } = \Psi ( G ) _ { i } , y = \xi ( \pmb { h } ) , } \\ & { G _ { c } = \mathrm { C o m p u t a t i o n G r a p h } ( G , v _ { i } ) , } \\ & { M = [ m _ { 1 } , m _ { 2 } , \dotsc , m _ { t } ] = \mathrm { M o t i f E x t r a c t o r } ( G _ { c } ) . } \end{array}
88
+ $$
89
+
90
+ Then, Eq. (3 - 6) are applied to compute loss for training the attention layer.
91
+
92
+ # 4 EXPERIMENTAL STUDIES
93
+
94
+ We conduct experiments to evaluate the proposed methods on both real-world and synthetic datasets.
95
+
96
+ # 4.1 DATASETS AND EXPERIMENTAL SETTINGS
97
+
98
+ We evaluate the proposed methods using different downstream tasks on seven datasets to demonstrate the effectiveness of our model. The statistic and properties of seven datasets are summarized in Appendix D. The details are introduced below.
99
+
100
+ Datasets. MUTAG (Kazius et al., 2005; Riesen & Bunke, 2008) is a chemical compound dataset containing 4,337 molecule graphs. Each graph can be categorized into mutagen and non-mutagen.
101
+
102
+ PTC (Kriege & Mutzel, 2012) is a collection of 344 chemical compounds reporting the carcinogenicity for rats.
103
+
104
+ NCI1 (Wale et al., 2008) is a balanced subset of datasets of chemical compounds screened for activity against non-small cell lung cancer and ovarian cancer cell lines respectively.
105
+
106
+ PROTEINS (Dobson & Doig, 2003) is a protein dataset classified as enzymatic or non-enzymatic.
107
+
108
+ IMDB-BINARY (Yanardag & Vishwanathan, 2015) is a movie collaboration dataset that consists of the ego-networks of 1,000 actors/actresses who played roles in movies in IMDB.
109
+
110
+ BA-2Motifs (Luo et al., 2020) is a synthetic graph classification dataset. It contains 800 graphs, and each graph is generated from a Barabasi-Albert (BA) base graph.
111
+
112
+ BA-Shapes (Ying et al., 2019) is a synthetic node classification dataset. It contains a single base BA graph with 300 nodes.
113
+
114
+ Experimental settings. Our experiments adopt a simple GNN model and focus on explanation results. More details of settings can be found in Appendix B. We compare our MotifExplainer model with several state-of-the-art baselines: GNNExplainer, SubgraphX, PGExplainer, and ReFine. We also build a model that uses the same attention layer as MotifExplainer but assigns weights to edges instead of motifs. Noted that all methods are compared in a fair setting. During prediction, we use $\sigma = 1$ to control the size of selected motifs. Unlike other methods, we do not explicitly set a fixed number for selected edges as explanations, enabling maximum flexibility and capability when selecting important motifs.
115
+
116
+ Evaluation metrics. A fundamental criterion for explanations is that they must be humanexplainable, which means the generated explanations should be easy to understand. Taking the BA-2Motif as an example, a graph label is determined by the house structure attached to a base BA graph. A good explanation of GNNs on this dataset should highlight the house structure. To this end, we perform qualitative analysis to evaluate the proposed method.
117
+
118
+ Even though qualitative analysis/visualizations can provide insight into whether an explanation is reasonable for human beings, this assessment is not entirely dependable due to the lack of ground truth in real-world datasets. Thus, we employ three quantitative evaluation metrics to evaluate our explanation methods. We use the Accuracy metric to evaluate models for synthesis datasets with ground truth. Here, we use the same settings as GNNExplainer and PGExplainer. In particular, we regard edges inside ground truth motifs as positive edges and edges outside motifs as negative.
119
+
120
+ An explainer aims to answer a question that when a trained GNN predicts an input, which part of the input makes the greatest contribution. To this end, the explanation selected by an explainer must be unique and discriminative. Intuitively, the explanation obtained by the explainer should obtain similar prediction results as the original graph. Also, the explanation is in a reasonable size. Thus, following (Yuan et al., 2020b), we use Fidelity and Sparsity metrics to evaluate the proposed method on real-world datasets. In particular, the Fidelity metric studies the prediction change by keeping important input features and removing unimportant features. The Sparsity metric measures the proportion of edges selected by explanation methods. Formally, they are computed by
121
+
122
+ ![](images/16beb6c4c038eb29a29ad4d73ecec61c1befb520e3927c88890cac4b63c9dd24.jpg)
123
+ Figure 2: Visualization of explanation results from different explanation models on three datasets. The generated explanations are highlighted by green and bold edges. Three rows are results on the MUTAG dataset, the BA-Shape dataset, and the BA-2Motif dataset, respectively. We only show the motif-related edges for two synthetic datasets to save space.
124
+
125
+ $$
126
+ \begin{array} { r l } & { \mathrm { F i d e l i t y } = \displaystyle \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \left( \Psi ( G _ { i } ) _ { y _ { i } } - \Psi ( G _ { i } ^ { p _ { i } } ) _ { y _ { i } } \right) , } \\ & { \mathrm { S p a r s i t y } = \displaystyle \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \left( 1 - \frac { | p _ { i } | } { | G _ { i } | } \right) , } \end{array}
127
+ $$
128
+
129
+ where $p _ { i }$ is an explanation for an input graph $G _ { i }$ . $| p _ { i } |$ and $| G _ { i } |$ denote the number of edges in the explanation, and the number in the original input graph, respectively.
130
+
131
+ # 4.2 QUALITATIVE RESULTS
132
+
133
+ In this section, we visually compare the explanations of our model with those of state-of-the-art explainers. Some results are illustrated in Figure 2, with generated explanations highlighted. We report the visualization results of the MUTAG dataset in the first row. Unlike BA-Shape and BA2Motif, MUTAG is a real-world dataset and does not have ground truth for explanations. We need to leverage domain knowledge to analyze the generated explanations. In particular, carbon rings with chemical groups $\mathrm { N H _ { 2 } }$ or $\mathrm { N O _ { 2 } }$ tend to be mutagenic. As mentioned by PGExplainer, carbon rings appear in both mutagen and non-mutagenic graphs. Thus, the chemical groups $\mathrm { N H _ { 2 } }$ and $\mathrm { N O _ { 2 } }$ are more important and considered as the ground truth for explanations. From the results, our MotifExplainer can accurately identify $\mathrm { N H _ { 2 } }$ and $\mathrm { N O _ { 2 } }$ in a graph while other models can not. PGExplainer identifies some extra unimportant edges. SubgraphX produces subgraphs as explanations that are neither motifs nor human-understandable. Our proposed GNN explainer can consider motif information and generate better explanations on molecular graphs. Note that neither $\mathrm { N H _ { 2 } }$ nor $\mathrm { N O _ { 2 } }$ is explicitly included in our motif extraction rules. The explanation is generated by identifying bonds in these groups, which means that our method can be used to find motifs.
134
+
135
+ We show the visualization results of the BA-Shape dataset in the second row of Figure 2. In this dataset, a node’s label depends on its location as described in Section 4.1. Thus, an explanation generated by an explainer for a target node should be the motif. We consider the selected edges on the motif to be positive and those not on the motif negative. From the results, our MotifExplainer can accurately mark the motif as the explanation. However, other models select a part of the motif or include extra non-motif edges. The third row of Figure 2 shows the visualization results on the BA-2Motif dataset, which is also a synthetic dataset. From Section 4.1, a graph’s label is determined by the motif attached to the base graph: the five nodes house-like motif or the five nodes cycle motif.
136
+
137
+ Table 1: Results on quantitative studies for different explanation methods. Note that since the Sparsity cannot be fully controlled, we report Fidelity scores under similar Sparsity levels. For two synthetic datasets BA-Shape and BA-2Motif, we report accuracy. $S$ is the sparsity value. $K$ is the maximum number of edges required by baseline models. Our MotifExplainer does not need this required hyper-parameter. The best performances on each dataset are shown in bold.
138
+
139
+ <table><tr><td></td><td>MUTAG S=0.7</td><td>PTC S=0.7</td><td>NCI1 S=0.7</td><td>PROTEINS IMDB S=0.7</td><td>S=0.7</td><td>BA-2Motif K=5</td><td>BA-Shape K=5</td></tr><tr><td>GNNExplainer</td><td>0.260</td><td>0.441</td><td>0.365</td><td>0.453</td><td>0.365</td><td>0.742</td><td>0.925</td></tr><tr><td>PGExplainer</td><td>0.241</td><td>0.388</td><td>0.402</td><td>0.521</td><td>0.225</td><td>0.926</td><td>0.963</td></tr><tr><td>SubgraphX</td><td>0.287</td><td>0.227</td><td>0.303</td><td>0.021</td><td>0.167</td><td>0.774</td><td>0.874</td></tr><tr><td>ReFine</td><td>0.221</td><td>0.349</td><td>0.409</td><td>0.435</td><td>0.127</td><td>0.932</td><td>0.954</td></tr><tr><td>MotifExplainer</td><td>0.031</td><td>0.129</td><td>0.115</td><td>-0.030</td><td>0.101</td><td>1.0</td><td>1.0</td></tr></table>
140
+
141
+ Thus, we treat all edges in these two motifs to be positive and the rest of edges to be negative. From the results, we can see that our MotifExplainer can precisely identify both the house-like motif and the cycle motif in a graph without including non-motif edges. While other models select edges far from the motif. More qualitative analysis results are reported in Appendix F.
142
+
143
+ # 4.3 QUANTITATIVE RESULTS
144
+
145
+ This section shows evaluations of our methods using seven datasets. We report the Fidelity score under the same Sparsity value on five real-world dataset and accuracy on the other two synthetic datasets. More Fidelity scores on real-world dataset are shown in Appendix E. The results are summarized in Table 1. From the results, our MotifExplainer consistently outperforms previous state-of-the-art models on all seven datasets under Sparsity value equals to 0.7 . Note that our method achieves $100 \%$ accuracy on two synthetic datasets and at least $2 . 6 \%$ to $1 9 . 0 \%$ improvements on the real-world datasets, demonstrating our model’s effectiveness.
146
+
147
+ Our model can maintain good performances when Sparsity is high. In particular, in the case of high Sparsity, the explanation contains a very limited number of edges, which shows that our model can identify the most important structures for GNN explanations. Using motifs as basic explanation units, our model can preserve the characteristics of motifs and the connectivity of edges.
148
+
149
+ # 4.4 THRESHOLD STUDIES
150
+
151
+ Our MotifExplainer uses a threshold $\sigma$ to select important motifs as explanations during inference. Since $\sigma$ is an important hyper-parameter, we conduct experiments to study its impact using Sparsity and Fi
152
+
153
+ Table 2: The study of threshold.
154
+
155
+ <table><tr><td>Threshold σ</td><td>1.0</td><td>1.2</td><td>1.5</td><td>1.7</td><td>2.0</td></tr><tr><td>Sparsity</td><td>0.4</td><td>0.5</td><td>0.6</td><td>0.7</td><td>0.8</td></tr><tr><td>Fidelity</td><td>0.025</td><td>0.053</td><td>0.054</td><td>0.031</td><td>0.028</td></tr></table>
156
+
157
+ delity metrics. The performances of MotifExplainer using different $\sigma$ values on the MUTAG dataset are summarized in Table 2. Here, we vary the $\sigma$ value from 1.0 to 2.0 to cover a reasonable range. We can observe that when the threshold is larger, the Sparsity of explanations increases, and the performances in terms of Fidelity gradually decrease. This is expected since fewer motifs selected will be selected when the threshold becomes larger. Thus, the size of explanations becomes smaller, and the Sparsity value becomes larger. Note that even when the Sparsity reaches a high value of 0.8, our model can still perform well. This shows that our model can accurately select the most important motifs as explanations, demonstrating the advantage of using motifs as GNN explanations.
158
+
159
+ # 4.5 ABLATION STUDIES
160
+
161
+ Our MotifExplainer employs an attention model to score and select the most relevant motifs to explain a given graph. To demonstrate the effectiveness of using motifs as basic explanation units, we build a new model named AttnExplainer that uses
162
+
163
+ Table 3: Results for AttnExplainer and MotifExplainer on three datasets. $K { = } 5$ for two synthetic datasets.
164
+
165
+ <table><tr><td></td><td>MUTAG</td><td>BA-2Motif</td><td>BA-Shape</td></tr><tr><td>AttnExplainer</td><td>0.166</td><td>0.934</td><td>0.955</td></tr><tr><td>MotifExplainer</td><td>0.031</td><td>1.0</td><td>1.0</td></tr></table>
166
+
167
+ edges as basic explanation units and apply an attention model to select relevant edges as explana
168
+
169
+ tions. We compare our MotifExplainer with AttnExplainer on three datasets: BA-Shape, BA-2Motif, MUTAG. The results are summarized in Table 3, appendix E. From the results, our model can consistently outperform AttnExplainer. This is because motifs can better obtain structural information than edges by using motif as the basic unit for explanation.
170
+
171
+ # 4.6 EFFICIENCY STUDIES
172
+
173
+ We study the efficiency of our proposed model in terms of the training time and the inference time. For models that need to be trained, such as PGExplainer and ReFine, training and evaluation processes are separate. We report training and inference time separately. In our proposed method, the training time includes three parts: motif extraction, motif embedding construction, and the training of the attention model. For models that do not require training, their training time will be 0. For each model, we run it on the MUTAG dataset and show the averaging time consumed to obtain explanations for each graph. Table 4 shows the comparison results with four state-of-the-art GNN explanation models: MotifExplainer, SubgraphX, PGExplainer, GNNExplainer, and ReFine. From the results, our model has the shortest inference time among models. Compared to PGExplainer and ReFine, our model requires significantly less training time. From this point, the proposed method is efficient and feasible in real-world applications.
174
+
175
+ Table 4: Results on efficiency studies.
176
+
177
+ <table><tr><td>Method</td><td>Inference</td><td>Training</td></tr><tr><td>GNNExplainer</td><td>24.3s</td><td>0s</td></tr><tr><td>PGExplainer</td><td>0.03s</td><td>740s</td></tr><tr><td>SubgraphX</td><td>96.7s</td><td>0s</td></tr><tr><td>ReFine</td><td>0.83s</td><td>946s</td></tr><tr><td>MotifExplainer</td><td>0.02s</td><td>363s</td></tr></table>
178
+
179
+ # 5 RELATED WORK
180
+
181
+ The research on GNN explainability is mainly divided into two categories: instance-level explanation and model-level explanation. Instance-level GNN explanation can also be divided into four directions, namely gradients/features-based methods, surrogate methods, decomposition methods, and perturbation-based methods. Gradients/features-based methods use gradients or hidden feature map values as the approximations of an importance score of an input. Recently, several methods have been employed to explain GNNs like SA (Baldassarre & Azizpour, 2019), CAM (Pope et al., 2019), Grad-CAM (Pope et al., 2019). The basic idea of surrogate methods is using a simple and explainable surrogate model to approximate the predictions of GNNs. Several methods have been introduced recently, such as GraphLime (Huang et al., 2020) and PGM-Explainer (Vu & Thai, 2020). Decomposition methods like GNN-LRP (Schnake et al., 2020) and DEGREE (Feng et al., 2021) measure the importance of input features by decomposing original predictions into several terms. The last method is the perturbation-based method. Along this direction, GNNExplainer (Ying et al., 2019) learns soft masks for edges and node features to generate an explanation via mask optimization. PGExplainer (Luo et al., 2020) learns approximated discrete masks for edges by using domain knowledge. SubgraphX (Yuan et al., 2021) employs Monte Carlo Tree Search algorithm to search possible subgraphs and uses Shapley value to measure the importance of subgraphs and choose a subgraph as the explanation. ReFine (Wang et al., 2021) proposes an idea of generating multigrained explanations. There are also some reinforcement learning based explainers (Shan et al., 2021; Wang et al., 2022). Model-level explanation methods aim to find the general insights and high-level information. So far, there is only one model-level explainer: XGNN (Yuan et al., 2020a). XGNN trains a generator and generates a graph as explanation to maximize a target prediction.
182
+
183
+ # 6 CONCLUSION
184
+
185
+ This work proposes a novel model-agnostic motif-based GNN explainer to explain GNNs by identifying important motifs, which are recurrent and statistically significant patterns in graphs. Our proposed motif-based methods can provide better human-understandable explanations than methods based on nodes, edges, and regular subgraphs. Given a graph, We first extract motifs from a graph using motif extraction rules based on domain knowledge. Then, motif embedding for each motif is generated using the feature extractor from a pre-trained GNN. After that, we train an attention model to select the most relevant motifs based on attention weights and use these selected motifs as an explanation for the input graph. Experimental results show that our MotifExplainer can significantly improve explanation performances from quantitative and qualitative aspects.
186
+
187
+ # REFERENCES
188
+
189
+ Uri Alon. Network motifs: theory and experimental approaches. Nature Reviews Genetics, 8(6): 450–461, 2007.
190
+
191
+ Uri Alon. An introduction to systems biology: design principles of biological circuits. CRC press, 2019.
192
+
193
+ Mohit Bajaj, Lingyang Chu, Zi Yu Xue, Jian Pei, Lanjun Wang, Peter Cho-Ho Lam, and Yong Zhang. Robust counterfactual explanations on graph neural networks. Advances in Neural Information Processing Systems, 34, 2021.
194
+
195
+ Federico Baldassarre and Hossein Azizpour. Explainability techniques for graph convolutional networks. arXiv preprint arXiv:1905.13686, 2019.
196
+
197
+ Giorgos Bouritsas, Fabrizio Frasca, Stefanos P Zafeiriou, and Michael Bronstein. Improving graph neural network expressivity via subgraph isomorphism counting. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
198
+
199
+ Jorg Degen, Christof Wegscheid-Gerlach, Andrea Zaliani, and Matthias Rarey. On the art of compil-¨ ing and using’drug-like’chemical fragment spaces. ChemMedChem: Chemistry Enabling Drug Discovery, 3(10):1503–1507, 2008.
200
+
201
+ Paul D Dobson and Andrew J Doig. Distinguishing enzyme structures from non-enzymes without alignments. Journal of molecular biology, 330(4):771–783, 2003.
202
+
203
+ Daniel A Erlanson, Robert S McDowell, and Tom O’Brien. Fragment-based drug discovery. Journal of medicinal chemistry, 47(14):3463–3482, 2004.
204
+
205
+ Qizhang Feng, Ninghao Liu, Fan Yang, Ruixiang Tang, Mengnan Du, and Xia Hu. Degree: Decomposition based explanation for graph neural networks. In International Conference on Learning Representations, 2021.
206
+
207
+ Hongyang Gao and Shuiwang Ji. Graph u-nets. In international conference on machine learning, pp. 2083–2092. PMLR, 2019.
208
+
209
+ Hongyang Gao, Zhengyang Wang, and Shuiwang Ji. Large-scale learnable graph convolutional networks. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 1416–1424, 2018.
210
+
211
+ Thomas E Gorochowski, Claire S Grierson, and Mario Di Bernardo. Organization of feed-forward loop motifs reveals architectural principles in natural and engineered networks. Science advances, 4(3):eaap9751, 2018.
212
+
213
+ Qiang Huang, Makoto Yamada, Yuan Tian, Dinesh Singh, Dawei Yin, and Yi Chang. Graphlime: Local interpretable model explanations for graph neural networks. arXiv preprint arXiv:2001.06216, 2020.
214
+
215
+ Jeroen Kazius, Ross McGuire, and Roberta Bursi. Derivation and validation of toxicophores for mutagenicity prediction. Journal of medicinal chemistry, 48(1):312–320, 2005.
216
+
217
+ Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
218
+
219
+ Nils Kriege and Petra Mutzel. Subgraph matching kernels for attributed graphs. arXiv preprint arXiv:1206.6483, 2012.
220
+
221
+ Maria Conceic¸ao A Leite and Yunjiao Wang. Multistability, oscillations and bifurcations in feedback ˜ loops. Mathematical Biosciences & Engineering, 7(1):83, 2010.
222
+
223
+ Xiao Qing Lewell, Duncan B Judd, Stephen P Watson, and Michael M Hann. Recap retrosynthetic combinatorial analysis procedure: a powerful new technique for identifying privileged molecular fragments with useful applications in combinatorial chemistry. Journal of chemical information and computer sciences, 38(3):511–522, 1998.
224
+
225
+ Wanyu Lin, Hao Lan, and Baochun Li. Generative causal explanations for graph neural networks. arXiv preprint arXiv:2104.06643, 2021.
226
+
227
+ Meng Liu, Hongyang Gao, and Shuiwang Ji. Towards deeper graph neural networks. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 338–348, 2020.
228
+
229
+ Dongsheng Luo, Wei Cheng, Dongkuan Xu, Wenchao Yu, Bo Zong, Haifeng Chen, and Xiang Zhang. Parameterized explainer for graph neural network. arXiv preprint arXiv:2011.04573, 2020.
230
+
231
+ Shmoolik Mangan and Uri Alon. Structure and function of the feed-forward loop network motif. Proceedings of the National Academy of Sciences, 100(21):11980–11985, 2003.
232
+
233
+ Ron Milo, Shai Shen-Orr, Shalev Itzkovitz, Nadav Kashtan, Dmitri Chklovskii, and Uri Alon. Network motifs: simple building blocks of complex networks. Science, 298(5594):824–827, 2002.
234
+
235
+ Mahendra Piraveenan, Kishan Wimalawarne, and Dharshana Kasthurirathn. Centrality and composition of four-node motifs in metabolic networks. Procedia Computer Science, 18:409–418, 2013.
236
+
237
+ Phillip E Pope, Soheil Kolouri, Mohammad Rostami, Charles E Martin, and Heiko Hoffmann. Explainability methods for graph convolutional neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10772–10781, 2019.
238
+
239
+ Kaspar Riesen and Horst Bunke. Iam graph database repository for graph based pattern recognition and machine learning. In Joint IAPR International Workshops on Statistical Techniques in Pattern Recognition (SPR) and Structural and Syntactic Pattern Recognition (SSPR), pp. 287–297. Springer, 2008.
240
+
241
+ Thomas Schnake, Oliver Eberle, Jonas Lederer, Shinichi Nakajima, Kristof T Schutt, Klaus-Robert ¨ Muller, and Gr ¨ egoire Montavon. Higher-order explanations of graph neural networks via relevant ´ walks. arXiv preprint arXiv:2006.03589, 2020.
242
+
243
+ Caihua Shan, Yifei Shen, Yao Zhang, Xiang Li, and Dongsheng Li. Reinforcement learning enhanced explainer for graph neural networks. Advances in Neural Information Processing Systems, 34:22523–22533, 2021.
244
+
245
+ Shai S Shen-Orr, Ron Milo, Shmoolik Mangan, and Uri Alon. Network motifs in the transcriptional regulation network of escherichia coli. Nature genetics, 31(1):64–68, 2002.
246
+
247
+ Minh N Vu and My T Thai. Pgm-explainer: Probabilistic graphical model explanations for graph neural networks. arXiv preprint arXiv:2010.05788, 2020.
248
+
249
+ Nikil Wale, Ian A Watson, and George Karypis. Comparison of descriptor spaces for chemical compound retrieval and classification. Knowledge and Information Systems, 14(3):347–375, 2008.
250
+
251
+ Xiang Wang, Yingxin Wu, An Zhang, Xiangnan He, and Tat-Seng Chua. Towards multi-grained explainability for graph neural networks. Advances in Neural Information Processing Systems, 34, 2021.
252
+
253
+ Xiang Wang, Yingxin Wu, An Zhang, Fuli Feng, Xiangnan He, and Tat-Seng Chua. Reinforced causal explainer for graph neural networks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
254
+
255
+ Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018.
256
+
257
+ Pinar Yanardag and SVN Vishwanathan. Deep graph kernels. In Proceedings of the 21th ACM SIGKDD international conference on knowledge discovery and data mining, pp. 1365–1374, 2015.
258
+
259
+ Rex Ying, Dylan Bourgeois, Jiaxuan You, Marinka Zitnik, and Jure Leskovec. Gnnexplainer: Generating explanations for graph neural networks. Advances in neural information processing systems, 32:9240, 2019.
260
+
261
+ Zhaoning Yu and Hongyang Gao. Molecular representation learning via heterogeneous motif graph neural networks. In International Conference on Machine Learning, pp. 25581–25594. PMLR, 2022.
262
+
263
+ Hao Yuan, Jiliang Tang, Xia Hu, and Shuiwang Ji. Xgnn: Towards model-level explanations of graph neural networks. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 430–438, 2020a.
264
+
265
+ Hao Yuan, Haiyang Yu, Shurui Gui, and Shuiwang Ji. Explainability in graph neural networks: A taxonomic survey. arXiv preprint arXiv:2012.15445, 2020b.
266
+
267
+ Hao Yuan, Haiyang Yu, Jie Wang, Kang Li, and Shuiwang Ji. On explainability of graph neural networks via subgraph explorations. arXiv preprint arXiv:2102.05152, 2021.
268
+
269
+ <table><tr><td>Algorithm2 MotifExplainer for node classification tasks</td></tr><tr><td>Input: a graph G, labels for al nodes in the graph Y = {y1,.., yi,.,yn}, a pre-trained GNN 亚(·),a pre-trained classifier $(·),motif extraction rule R</td></tr><tr><td>Initialization: initial a trainable weight matrix W,calculate all node embedding H= {h1,..,hi,...,hn}</td></tr><tr><td>for node vi in the graph G do</td></tr><tr><td>Original node embedding hi ∈ H</td></tr><tr><td>Create motif list M = {m1,.., mj,.., mt} based on extraction rule R For each motif mj, we keep the motif, the target node vi and the edges between them. Then we</td></tr><tr><td>put this subgraph into the pre-trained GNN 亚(·) and get a new node embedding of target node</td></tr><tr><td>Ui as the motif embedding mj Obtain an output score for each motif sj = mj · W · hi</td></tr><tr><td>Train an attention weight for each motif α j = exp(sj)</td></tr><tr><td>exp(sk)</td></tr><tr><td>Acquire an alternative graph embedding h&#x27; = ∑=1. t αkmk</td></tr><tr><td>Output a prediction for the alternative graph embedding yi = ε(h&#x27;) Calculate loss based on yi and yi Update weight W using back-propagation.</td></tr></table>
270
+
271
+ # B A GENERAL MOTIFS EXTRACTION RULE
272
+
273
+ According to section 3.2, we can easily design motif extraction rules based on some domain knowledge. However, if we don’t have relevant domain knowledge or the dataset type is unknown, we need a general way to obtain the motifs. Inspired by graph feature representation learning works on motifs (Bouritsas et al., 2022; Yu & Gao, 2022), we propose a general method to extract the simplest motifs: cycles and edges. In particular, given a graph, we first extract all cycles out of it. Then, all edges that are not inside the cycles are considered motifs. We consider combining cycles with more than two coincident nodes into a motif. Although this method cannot extract complex motifs like single-input and multi-input motifs, it can generate the most important motifs, such as ring structures in biochemical molecules and the feed-forward loop motif. By adopting this simple but general motif extraction method, we can explain a GNN model without any domain knowledge, making our explanation model more applicable. Need to be noted that, even though the motif extraction rule cannot extract single-input and multi-input motifs, these motifs can be implicitly identified by our attention layer. Experiments in the table 1 demonstrate it.
274
+
275
+ # C COMMON MOTIFS IN BIOLOGICAL AND ENGINEERING NETWORKS
276
+
277
+ ![](images/f8bc37f1d648b03b9d94603cb23cb888d3aeb688e65a7bb115a9668bcec43aff.jpg)
278
+ Figure 3: Popular motifs in biological and engineering networks.
279
+
280
+ In this section, Figure 3 show some common motifs in biological and engineering networks introduced in section 3.2.
281
+
282
+ # D DATASETS AND GNN MODELS
283
+
284
+ # D.1 STATISTIC AND PROPERTIES OF DATASETS
285
+
286
+ Table 5: Statistics and properties of three datasets.
287
+
288
+ <table><tr><td></td><td>MUTAG PTC</td><td>NCI1</td><td></td><td>PROTEINS IMDB</td><td>BA-2Motif</td><td>BA-Shape</td></tr><tr><td>#Edges (avg)</td><td>30.77 14.69</td><td>32.30</td><td>72.82</td><td>96.53</td><td>25.48</td><td>4110</td></tr><tr><td># Nodes (avg)</td><td>30.32 14.29</td><td>29.87</td><td>39.06</td><td>19.77</td><td>25.0</td><td>700</td></tr><tr><td># Graphs</td><td>4337 344</td><td>4110</td><td>1113</td><td>1000</td><td>1000</td><td>1</td></tr><tr><td># Classes</td><td>2 2</td><td>2</td><td>2</td><td>2</td><td>2</td><td>4</td></tr></table>
289
+
290
+ # D.2 SETTINGS OF GNN MODELS
291
+
292
+ For the pre-trained GNN, we use a 3-layer GCN as a feature extractor and a 2-layer MLP as a classifier on all datasets. The GCN model is pre-trained to achieve reasonable performances on all datasets. We use Adam optimizer for training. We set the learning rate to 0.01.
293
+
294
+ Real World Datasets We employ a 3-layer GCNs to train all five real world datasets. The input feature dimension is 7 and the output dimensions of different GCN layers are set to 64, 64, 64, respectively. We employ mean-pooling as the readout function and ReLU as the activation function. The model is trained for 170 epochs with a learning rate of 0.01. We study the explanations for the graphs with correct predictions.
295
+
296
+ BA-Shape We use a 3-layer GCNs and an MLP as a classifier to train the BA-Shape dataset. The hidden dimensions of different GCN layers are set to 64, 64, 64, respectively. We employ ReLU as the activation function. The model is trained for 300 epochs with a learning rate of 0.01. The validation accuracy of the pre-trained model can achieve $1 0 0 \%$ . We study the explanations for the whole dataset.
297
+
298
+ BA-2Motif We use a 3-layer GCNs and an MLP as a classifier to train the BA-2Motif dataset. The hidden dimensions of different GCN layers are set to 64, 64, 64, respectively. We employ mean-pooling as the readout function and ReLU as the activation function. The model is trained for 300 epochs with a learning rate of 0.01. The validation accuracy of the pre-trained model can be $1 0 0 \%$ , which means the model can perfectly generate the distribution of the dataset. We study the explanations for the whole dataset.
299
+
300
+ # D.3 EXPERIMENT ENVIRONMENT SETTINGS
301
+
302
+ We conduct experiments using one Nvidia 2080Ti GPU on an AMD Ryzen 7 3800X 8-Core CPU. Our implementation environment is based on Python 3.9.7, Pytorch 1.10.1, CUDA 10.2, and Pytorch-geometric 2.0.3.
303
+
304
+ # E MORE QUANTITATIVE RESULTS
305
+
306
+ Table 6: Quantitative results on MUTAG dataset. $S$ is the sparsity value. $K$ is the maximum number of edges required by baseline models. The best performances on each dataset are shown in bold.
307
+
308
+ <table><tr><td rowspan="2"></td><td colspan="5">MUTAG (Fidelity)</td></tr><tr><td>S=0.4</td><td>S=0.5</td><td>S=0.6</td><td>S=0.7</td><td>S=0.8</td></tr><tr><td rowspan="4">GNNExplainer PGExplainer SubgraphX ReFine</td><td>0.153</td><td>0.184</td><td>0.219</td><td>0.260</td><td>0.307</td></tr><tr><td>0.133</td><td>0.154</td><td>0.194</td><td>0.241</td><td>0.297</td></tr><tr><td>0.214</td><td>0.233</td><td>0.254</td><td>0.287</td><td>0.376</td></tr><tr><td>0.075</td><td>0.124</td><td>0.180</td><td>0.221</td><td>0.311</td></tr><tr><td rowspan="2">AttnExplainer MotifExplainer</td><td>0.085</td><td>0.111</td><td>0.133</td><td>0.166</td><td>0.182</td></tr><tr><td>0.025</td><td>0.053</td><td>0.054</td><td>0.031</td><td>0.028</td></tr></table>
309
+
310
+ Table 7: Quantitative results on PTC and NCI1 dataset. $S$ is the sparsity value. $K$ is the maximum number of edges required by baseline models. The best performances on each dataset are shown in bold.
311
+
312
+ <table><tr><td rowspan="2"></td><td colspan="3">PTC (Fidelity)</td><td colspan="3">NCI (Fidelity)</td></tr><tr><td>S=0.6</td><td>S=0.7</td><td>S=0.8</td><td>S=0.6</td><td>S=0.7</td><td>S=0.8</td></tr><tr><td>GNNExplainer</td><td>0.3835</td><td>0.4406</td><td>0.4947</td><td>0.3612</td><td>0.3653</td><td>0.3648</td></tr><tr><td>PGExplainer</td><td>0.3653</td><td>0.3886</td><td>0.3917</td><td>0.4013</td><td>0.4029</td><td>0.4045</td></tr><tr><td>ReFine</td><td>0.3268</td><td>0.3499</td><td>0.3575</td><td>0.4028</td><td>0.4093</td><td>0.4115</td></tr><tr><td>SubgraphX</td><td>0.2062</td><td>0.2274</td><td>0.2643</td><td>0.1697</td><td>0.3036</td><td>0.4075</td></tr><tr><td>MotifExplainer</td><td>0.1162</td><td>0.1299</td><td>0.2256</td><td>0.1002</td><td>0.1154</td><td>0.1297</td></tr></table>
313
+
314
+ Table 8: Quantitative results on PROTEINS and IMDB-B dataset. $S$ is the sparsity value. $K$ is the maximum number of edges required by baseline models. The best performances on each dataset are shown in bold.
315
+
316
+ <table><tr><td rowspan="2"></td><td colspan="2">PROTEINS (Fidelity)</td><td colspan="3">IMDB-B (Fidelity)</td></tr><tr><td>S=0.6</td><td>S=0.7 S=0.8</td><td>S=0.6</td><td>S=0.7</td><td>S=0.8</td></tr><tr><td>GNNExplainer</td><td>0.4558</td><td>0.4535 0.4947</td><td>0.1577</td><td>0.3653</td><td>0.3098</td></tr><tr><td>PGExplainer</td><td>0.5215</td><td>0.5214 0.5207</td><td>0.1801</td><td>0.2253</td><td>0.2784</td></tr><tr><td>ReFine</td><td>0.3399</td><td>0.4354 0.4974</td><td>0.0952</td><td>0.1278</td><td>0.1829</td></tr><tr><td>SubgraphX</td><td>0.0138</td><td>0.0211 0.0398</td><td>0.1342</td><td>0.1671</td><td>0.1955</td></tr><tr><td>MotifExplainer</td><td>-0.0140</td><td>-0.0300 -0.0558</td><td>0.0757</td><td>0.1011</td><td>0.1125</td></tr></table>
317
+
318
+ # F VISUALIZATION OF EXPLANATION
319
+
320
+ In this section, we report more visualization of explanation on MUTAG dataset in Figure 4. MUTAG is a real-world dataset, and it is more complex than synthetic datasets. Thus, visualization of MUTAG can better represent how different explainer works.
321
+
322
+ ![](images/f400b0b3a962c90388877cdd94d1b308f3c55ad9a6b7ae826341bb88468c7421.jpg)
323
+ Figure 4: Popular motifs in biological and engineering networks.
md/dev/0c2SbGJ3Lt/0c2SbGJ3Lt.md ADDED
@@ -0,0 +1,432 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TEXTLESS PHRASE STRUCTURE INDUCTION FROM VISUALLY-GROUNDED SPEECH
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ We study phrase structure induction from visually-grounded speech without intermediate text or text pre-trained models. The core idea is to first segment the speech waveform into sequences of word segments, then induce phrase structure based on the inferred segment-level continuous representations. To this end, we present the Audio-Visual Neural Syntax Learner (AV-NSL) that learns non-trivial phrase structure by listening to audio and looking at images, without ever reading text. Experiments on SpokenCOCO, the spoken version of MSCOCO with paired images and spoken captions, show that AV-NSL infers meaningful phrase structures similar to those learned from naturally-supervised text parsing, quantitatively and qualitatively. The findings in this paper extend prior work in unsupervised language acquisition from speech and grounded grammar induction, and manifest one possibility of bridging the gap between the two fields.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Toddlers learn their first language through listening, talking, and interacting with the world through multi-sensory inputs. Different levels of early language acquisition happen without supervisory feedback (Dupoux, 2018): phonetics, phonology, morphology, syntax, semantics, pragmatics. It is therefore crucial to think about learning language, from identifying lower-level phones or words to inducing high-level linguistic structure like grammar, in natural settings.1 To this end, there have been two ongoing efforts in parallel:
12
+
13
+ • Zero-resource speech processing, where speech models are constructed without any textual intermediates, with the goal of mimicking how children learn to speak before learning to read or write. The modeling tasks are constrained to unsupervised learning of subphones, phones, and words (Jansen et al., 2013). • Grammar induction, which aims to learn latent syntactic structures, including constituency trees and dependency trees, with no annotation of syntactic structures as supervision.
14
+
15
+ Notably in recent years, multi-modal induction has emerged as a promising and effective objective for both efforts. In speech, Harwath (2018) proposed to leverage parallel image-speech data to acquire associated words (Harwath & Glass, 2017) and phones (Harwath et al., 2020) from raw waveforms. In syntax induction, Shi et al. (2019) proposed to induce phrase-structure grammar from parallel image-text data. The above observations motivated us to build a computational model that leverages the visual modality to acquire low-level words up to high-level phrase-structure from raw speech waveforms, without any intermediate textual forms or any direct supervision.2
16
+
17
+ In this paper, we present the Audio-Visual Neural Syntax Learner (AV-NSL), an approach toward learning phrase structure from raw speech waveforms without relying on any kind of intermediate textual form or text pre-trained models (Figure 1). In a nutshell, AV-NSL trains a visually-grounded syntax learner directly on a sequence of continuous speech representations given by an audio-visual word segmentation model. We also introduce a self-training process and an unsupervised decoding method to improve the final output of in AV-NSL. To measure the effectiveness of AV-NSL, we compare it to text-based syntax learner VG-NSL (Shi et al., 2019) and further introduce a novel evaluation metric, SAIOU, that accounts for structure differences when the number of tree nodes are mismatched. To validate our design choice of AV-NSL, we construct several baselines and introduce alternative modeling choices, including acoustic compound-PCFG (Kim et al., 2019a). Qualitatively, we provide constituency recall analyses and the visualizations of the inferred word segmentation and tree structures.
18
+
19
+ ![](images/f0d70eacb042ff33533595a02ebee55672bac6319f24de2f807d7ec9aa263d95.jpg)
20
+ Figure 1: We study the process of inducing phrase structure, in the form of constituency parse tree, on unsupervised inferred word segments from raw speech waveform. No intermediate text tokens or ASR is needed. For illustration purpose, here we show the gold parse tree from the given text caption.
21
+
22
+ In summary, we present the first study on inducing phrase structure from visually-grounded speech without relying on text, introducing the AV-NSL model (§3) with comprehensive experiments (§4) and analysis (§5). As a by product, we improve over the previous state of the art in unsupervised word segmentation (§4.4).
23
+
24
+ # 2 RELATED WORK
25
+
26
+ # 2.1 UNSUPERVISED AND DISTANTLY SUPERVISED GRAMMAR INDUCTION
27
+
28
+ Much work has been proposed to induce grammar from different sources of distant supervision, including language modeling (Shen et al., 2018; 2019; Kim et al., 2019a;b), masked language modeling (Drozdov et al., 2019), natural language inference (Li et al., 2019), and, more recently, visual grounding via image-caption matching (Shi et al., 2019; Zhao & Titov, 2020; Hong et al., 2021; Wan et al., 2022, inter alia). There has also been extensive study directly targeting unsupervised constituency parsing (Klein & Manning, 2002; 2004; Bod, 2006; Spitkovsky et al., 2013, inter alia). To the best of our knowledge, existing work on grammar induction from distant supervision has been based almost exclusively on text input. The most relevant work to ours is MMC-PCFG (Zhang et al., 2021), where speech features are treated as an auxiliary input for video-text grammar induction. However, text data and an off-the-shelf automatic speech recognition (ASR) model are required. In contrast to them, AV-NSL induces constituency parse trees from raw speech bypassing text, with distant supervision from parallel audio-visual data.
29
+
30
+ # 2.2 UNSUPERVISED LANGUAGE ACQUISITION FROM SPEECH
31
+
32
+ The earliest work (de Sa, 1994; De Marcken, 1996; Roy & Pentland, 2002) on language acquisition from speech required phonetic lexicon/labels in the process. The idea of spoken term discovery, i.e., discovering repetitive patterns or keywords from unannotated speech, was first addressed by Park & Glass (2007). Thereafter, subsequent work improved upon the original (Zhang & Glass, 2009; Jansen & Van Durme, 2011; McInnes & Goldwater, 2011; Zhang, 2013, inter alia). Other related work has considered tasks like unsupervised word segmentation and unsupervised ASR, sometimes jointly with spoken term discovery (Lee & Glass, 2012; Lee et al., 2015; Kamper et al., 2015; 2017; Kamper & van Niekerk, 2021; Chorowski et al., 2021; Bhati et al., 2021; Kamper, 2022; Algayres et al., 2022) The discovery of lexical units was applied to text-free language modeling (Nguyen et al., 2020; Peng & Harwath, 2022a) and speech generation (Lakhotia et al., 2021; Polyak et al., 2021; Kharitonov et al., 2022). The ZeroSpeech challenges (Versteegh et al., 2015; Dunbar et al., 2017; 2019; 2020; Nguyen et al., 2020) have been a major driving force in the field.
33
+
34
+ Harwath (2018) opened up a new direction in visually grounded language acquisition, showing word-like (Harwath & Glass, 2017) and phone-like (Harwath et al., 2020) units are acquired from speech by analyzing audio-visual retrieval models. Numerous works have studied the characteristics of the linguistic information acquired in visually grounded speech models (Havard et al., 2019; Khorrami & Ras¨ anen, 2021; Olaleye & Kamper, 2021; Wang & Hasegawa-Johnson, 2021; ¨ Mitja Nikolaus, 2022). Peng & Harwath (2022b) shows that clear word segmentation and identification naturally emerge from a visually grounded, self-supervised speech model named VG-HuBERT, by analyzing the model’s self-attention heads. Unlike the above, AV-NSL acquires phrase structure, in the form of constituency parsing on top of unsupervised word segments.
35
+
36
+ # 2.3 SPEECH PARSING AND ITS APPLICATIONS
37
+
38
+ Early work on speech parsing can be traced back to the SParseval toolkit (Roark et al., 2006), for evaluating text parsers given (errorful) ASR output. Tran et al. (2018; 2019); Tran & Ostendorf (2021) explored the use of acoustic-prosodic features for text parsing with auxiliary speech input. Lou et al. (2019) trained a text parser (Kitaev & Klein, 2018) to detect speech disfluencies. In the past, syntax has also been studied in the context of speech prosody (Wagner & Watson, 2010; Kohn ¨ et al., 2018). The most relevant work to ours is Pupier et al. (2022), where a text dependency parser is trained from speech jointly with an ASR model. Moreover, text syntax parsing has been applied to prosody modeling in end-to-end text-to-speech (TTS; Guo et al., 2019; Tyagi et al., 2020; Kaiki et al., 2021). This work builds on top of pre-existing text parsing algorithms or pre-existing phrase structures from text, whereas we study phrase structure acquisition in the absence of text.
39
+
40
+ # 3 METHOD
41
+
42
+ ![](images/1022ab95dbbcbbc5e4f5d65c9b2b1a42eaaa69555b3c232f911b502e0c1cc2d5.jpg)
43
+ Figure 2: Illustration of AV-NSL, which extends VG-NSL (Shi et al., 2019) to audio-visual inputs.
44
+
45
+ Given a set of paired spoken captions and images, the Audio-Visual Neural Syntax Learner (AVNSL) infers phrase structures from subsequences of raw speech segments without relying on text. The basis of AV-NSL is the Visually-Grounded Neural Syntax Learner (VG-NSL) (Shi et al., 2019). VG-NSL learns constituency parse trees by guiding a sequential tree sampling process with textimage matching. To extend VG-NSL to audio-visual inputs, the central challenge is extracting semantically-meaningful word segments from unannotated speech. We break down the problem into a two-step process: (1) obtaining sequences of word segments, and (2) extracting segment-level self-supervised representations. With these simple modifications, AV-NSL learns non-trivial phrase structure without ever reading text, instead by listening to speech and looking at images.
46
+
47
+ # 3.1 BACKGROUND: VISUALLY-GROUNDED NEURAL SYNTAX LEARNER
48
+
49
+ VG-NSL (Shi et al., 2019) is composed of a bottom-up text parser and a text-image embedding matching module. The parser consists of an embedding similarity scoring function score and an embedding cembeddings sively scorin ${ \cal { W } } = \{ w _ { i } ^ { 0 } \} _ { i = 1 } ^ { N }$ nction comof length g adjacent $N$ ne. Given a text caption, den, the parser synthesizes a consmbeddings at each step. At step ed by a sequence of wordtuency parse tree by recur-, VG-NSL (1) evaluates all $t$
50
+
51
+ consecutive pairs of embeddings $\langle w _ { i } ^ { t } , w _ { i + 1 } ^ { t } \rangle$ and assigns a scalar score to each with score, (2) selects a pair $\langle w _ { i ^ { \prime } } ^ { t } , w _ { i ^ { \prime } + 1 } ^ { t } \rangle$ based on the corresponding scores,3 and (3) combines the selected pair of embeddings via combine to form a new phrase embedding for the next step, copying the remaining ones to the next step. In VG-NSL, score is parameterized by a 2-layer ReLU-activated MLP, and combine is defined by the L2-normalized sum of the input embeddings. The resulting tree is inherently binary and there are $N - 1$ combining steps in total, as the tree parser must combine two nodes in each step.
52
+
53
+ The text-image embedding matching module of VG-NSL is based on the standard hinge-based triplet loss (Kiros et al., 2014), where the sentence-based loss is modified to a phrase-based one. Additionally, the loss function is adapted to estimate the visual concreteness of a text span: intuitively, the smaller the loss related to a candidate constituent $c$ , the larger the concreteness of $c$ , and vice versa. The concreteness of a constituent $c$ is defined as
54
+
55
+ $$
56
+ \mathbf { \nabla } \cdot e \left( \mathbf { c } ; \mathbf { i } \right) = \sum _ { \mathbf { c } ^ { \prime } } \left[ \cos \left( \mathbf { i } , \mathbf { c } \right) - \cos \left( \mathbf { i } , \mathbf { c } ^ { \prime } \right) - \delta \right] _ { + } + \sum _ { \mathbf { i } ^ { \prime } } \left[ \cos \left( \mathbf { i } ^ { \prime } , \mathbf { c } \right) - \cos \left( \mathbf { i } ^ { \prime } , \mathbf { c } \right) - \delta \right] _ { + } ,
57
+ $$
58
+
59
+ where c is the vector representation of $c$ ; i is the corresponding vector of the parallel image of $c ; \mathbf { c } ^ { \prime }$ is a candidate constituent from a sentence that is not in parallel with i; $\mathbf { i } ^ { \prime }$ is an image that is not in parallel with $c ; \delta$ is a constant margin. Here, $[ \cdot ] _ { + } : = \operatorname* { m a x } ( \cdot , 0 )$ . Finally, the estimated concreteness scores are passed back to the parser as rewards to the constituents. VG-NSL jointly optimizes the visual-semantic embedding loss, and trains the parser with REINFORCE (Williams, 1992).
60
+
61
+ # 3.2 AUDIO-VISUAL NEURAL SYNTAX LEARNER
62
+
63
+ AV-NSL extends VG-NSL by: (1) incorporating an audio-visual word segmentation model for obtaining sequences of word segments from unannotated speech, (2) jointly optimizing segment-level embeddings along with phrase structure induction, and (3) employing deeper score and combine function parameterization in the parsing module. We empirically found (3) necessary, mainly because speech embeddings are inherently richer, less clean, and semantically more ambiguous than word embeddings. In AV-NSL, score is parameterized by a 4-layer MLP with GELU nonlinearities (Hendrycks & Gimpel, 2016), and combine is a 5-layer MLP with GELUs. On the other hand, such parameterization may cause the text-based sampling procedure to favor sampling the visually-salient words (Shi et al., 2019; Kojima et al., 2020). We describe (1) and (2) in detail as follows.
64
+
65
+ ![](images/6556f77930feb888985877de3fee66012f8b8c7a64af3426d7862217fe5324ef.jpg)
66
+ Figure 3: Example of word segmentation from VG-HuBERT (top). We use the midpoints of adjacent attention boundaries (vertical blue dashed lines) as the word boundaries. We observe that function words are ignored by VG-HuBERT; to account for this, we introduce segment insertion (bottom): short segments are placed in long enough gaps between existing segments, such that function words are recovered. Inserted segments are marked with $\cdot _ { + } \cdot$ . Best viewed in color.
67
+
68
+ Audio-visual word segmentation: AV-NSL leverages VG-HuBERT Peng & Harwath (2022b) for word segmentation (Figure 2; bottom). VG-HuBERT is trained to associate spoken captions with natural images via retrieval training, without any textual supervision. After training, spoken word segmentation emerges via magnitude thresholding the self-attention heads of the model’s audio encoder: at layer $l$ , we threshold each CLS token attention weights over each temporal speech frame token to only show top $p \%$ of the magnitude. In Figure 3, we visualize the attention weights that each speech frame receives from the CLS token. Weights from different attention heads are plotted in different colors, and color transparency represents the magnitude of the attention weights.
69
+
70
+ However, an issue we observed with VG-HuBERT is that they tend to ignore function words such as $\mathbf { \ddot { a } } ^ { , , }$ , “the”, and “of”. While this is less of an issue for word segmentation and identification, it is problematic for our purpose, as the function words are critical for phrase induction. Therefore, we devise a simple heuristic to pick up function words’ segments – segment insertion. We insert a short word segment whenever there is a sufficiently long enough gap of $s$ seconds, and VGHuBERT fails to place an attention segment. See bottom of Figure 3. Since this could introduce false positives (inserting segments where there is no word spoken), we apply unsupervised voice activity detection (Tan et al., 2020) to further restrict segment insertion only in voiced regions. The length of the insertion gap $s$ , the VG-HuBERT segmentation layer $l$ , attention magnitude threshold $p \%$ , and model training snapshots over different random seeds and training steps, are all determined in an unsupervised fashion with minimal Bayes’ risk decoding, introduced in Section 3.4.
71
+
72
+ Speech segment representations: Given the word segments from the audio-visual segmentation model, segment representations are extracted as inputs for the tree sampling module. Ideally, these segments should be semantically-meaningful and mimic word embeddings method is speech discretization that converts the inputs into sequences of d $\mathbf { \bar { \mathit { W } } } = \{ w _ { i } ^ { 0 } \} _ { i = 1 } ^ { N }$ . A naive(Lakhotia et al., 2021). Yet, we are targeting word-level phrase structures, while speech discretization, namely acoustic unit discovery, are sub-phone level, which does not fit into our setup. Different from it, AVNSL is based on continuous segment-level self-supervised representations. Let’s denote the framelevel representation sequence as $R = \{ r _ { j } \} _ { j = 1 } ^ { T }$ , where $T$ is the speech sequence length. Audio-visual word segmentation returns an alignment $\bar { \boldsymbol { A } } ( i ) = \boldsymbol { r } _ { p : q }$ that maps the ith word segment to the $p$ th to $q$ th acoustic frames. The segment-level continuous representation for the ith word is simply,
73
+
74
+ $$
75
+ w _ { i } ^ { 0 } = \sum _ { t \in A ( i ) } \stackrel { } { a _ { i t } } r _ { i t }
76
+ $$
77
+
78
+ where $a _ { i t }$ is the attention weights over the segments specified by $A ( i )$ . By default in AV-NSL, $R$ is the layer representation from VG-HuBERT, and $a _ { i t }$ is the CLS token attention weights over frames within each segment. In some cases, visual grounding is not available in AV-NSL’s word segmentation, e.g. VG-HuBERT is not available. We instead take $R$ as the layer representation from a vanilla HuBERT (Hsu et al., 2021a), and $a _ { i t }$ is parameterized by a hidden layer that is jointly optimized with the tree sampling module. Despite its simplicity, AV-NSL learns meaningful phrase structures on these segment representation sequences.
79
+
80
+ # 3.3 SELF-TRAINING
81
+
82
+ A self-training procedure is introduced for AV-NSL to further improve its parsing capability. Previously, it has been shown that self-training consistently improves the performance of text-based unsupervised constituency parsing. In Shi et al. (2020), the self-training model was based on Benepar (Kitaev & Klein, 2018), a supervised neural constituency parser, which (1) takes a sentence as the input, (2) maps it to word representations, and (3) predicts a score for any constituency parse tree. In the inference stage, the model evaluates all possible tree structures and outputs the highest-scoring one using the CKY algorithm (Kasami, 1966; Younger, 1967; Cocke, 1969).
83
+
84
+ In this work, we introduce s-Benepar, which is based on the original Benepar, except the model input is the segment-level continuous HuBERT representations mean-pooled over unsupervised word segmentation from VG-HuBERT with segment insertion, and model output is AV-NSL’s inferred constituency parse from Section 3.2. We also removed part-of-speech tag prediction as in Benepar, as there is no textual supervision in our setting. To summarize, with paired speech $D _ { A }$ and image $D _ { V }$ data, the training scheme for AV-NSL with self-training is as follows:
85
+
86
+ 1. Train an AV-NSL from audio-visual data $( D _ { A } , D _ { V } )$ and obtain the trained model $M _ { a v }$ .
87
+ 2. Generate parse tree $T _ { 0 }$ with $M _ { a v }$ for $D _ { A }$ . Obtain audio-tree pairs $( D _ { A } , T _ { 0 } )$ . Set $T = T _ { 0 }$ .
88
+ 3. Train an s-Benepar from $( D _ { A } , T )$ and obtain the trained model $M _ { s } ^ { i }$ .
89
+ 4. Generate parse tree $T _ { i }$ with $M _ { s } ^ { i }$ for $D _ { A }$ . Obtain audio-tree pairs $( D _ { A } , T _ { i } )$ . Set $T = T _ { i }$ .
90
+ 5. Go to Step 3 if we have not reached the desirable number of iterations; return $T$ otherwise.
91
+
92
+ We find it helpful to iterate s-Benepar training twice $( i = 2$ ), but the results plateau afterwards.
93
+
94
+ # 3.4 UNSUPERVISED DECODING
95
+
96
+ One key ingredient of AV-NSL is applying minimum Bayes risk (MBR) decoding (Bickel & Li, 1977) as the selection criterion for fully-unsupervised spoken word segmentation and phrasestructure induction.4 Specifically, this is in contrast to all prior unsupervised word segmentation work, in which ground truth word segments from a development set are required for decoding.
97
+
98
+ At a high level, given a loss function $\ell _ { M B R } ( O _ { 1 } , O _ { 2 } )$ between two outputs $O _ { 1 }$ and $O _ { 2 }$ , and a set of $k$ outputs $\mathcal { O } = \{ O _ { 1 } , \ldots , O _ { k } \}$ , we select the optimal output
99
+
100
+ $$
101
+ \hat { O } = \arg \operatorname* { m i n } _ { O ^ { \prime } \in { \mathcal O } } \sum _ { O ^ { \prime \prime } \in { \mathcal O } } \ell _ { M B R } ( O ^ { \prime } , O ^ { \prime \prime } ) .
102
+ $$
103
+
104
+ For word segmentation, we define the loss between two segmentation proposals $ { \boldsymbol { S } } _ { 1 }$ and $S _ { 2 }$ by $\ell _ { M B R } ( S _ { 1 } , S _ { 2 } ) ^ { - } = - \mathrm { M I O U } ( S _ { 1 } , S _ { 2 } )$ , where $\mathrm { { M I O U } } ( \cdot , \cdot )$ denotes the mean intersection over union ratio across all matched pairs of predicted word spans from $S _ { 1 }$ and $S _ { 2 }$ . We match the predicted word spans using the maximum weight matching algorithm (Galil, 1986), where word spans correspond to vertices, and we define edge weights by the temporal overlap between the corresponding spans.
105
+
106
+ For phrase structure induction, we define the loss function between two parse trees $\mathcal { T } _ { 1 }$ and $\mathcal { T } _ { 2 }$ by $\ell _ { M B R } ( \mathcal { T } _ { 1 } , \mathcal { T } _ { 2 } ) = 1 - F _ { 1 } ( \mathcal { T } _ { 1 } , \mathcal { T } _ { 2 } )$ , where $F _ { 1 } ( \cdot , \cdot )$ denotes the $F _ { 1 }$ score between two trees.
107
+
108
+ # 4 EXPERIMENTS
109
+
110
+ # 4.1 SETTING
111
+
112
+ Dataset: All models are evaluated on SpokenCOCO, the spoken version of MSCOCO (Lin et al., 2014) where the text captions are read out by MTurk users (Hsu et al., 2021b). It contains $8 3 \mathrm { k } / 5 \mathrm { k } / 5 \mathrm { k }$ images for training, validation, and test: each image has 5 corresponding spoken captions. SpokenCOCO totals 740h of read speech from $2 . 3 \mathrm { k }$ speakers, with an average utterance duration of about 4 seconds, covering 29K different word types.
113
+
114
+ Preprocessing: For oracle word segmentation, we ran an off-the-shelf English ASR from Montreal Force Aligner (McAuliffe et al., 2017) that was pre-trained on Librispeech and adapted to SpokenCOCO. We removed a few utterances that have mismatches in their ASR transcripts and their text captions. Following Shi et al. (2019), we included trivial spans in tree evaluation. Additionally, we ran an off-the-shelf English parser (Kitaev & Klein, 2018) on the ASR transcript (normalized text with punctuation removed) to generate the oracle trees for SpokenCOCO.
115
+
116
+ # 4.2 BASELINES AND TOPLINES
117
+
118
+ AV-NSL segments speech waveforms into word segments, then learns phrase structures on top of the learned segments. Both segmentation and structure induction are fully-unsupervised and visuallygrounded. To help us examine the role of each component in AV-NSL, we therefore further construct the following baselines and toplines. Their full descriptions are in Appendix A.1.
119
+
120
+ Trivial tree structures: Following (Shi et al., 2019), we include baselines without linguistic information: random binary trees, left-branching binary trees, and right-branching binary trees.
121
+
122
+ AV-cPCFG: We train compound probabilistic context free grammar (cPCFG) (Kim et al., 2019a) on word-level discrete speech tokens. Similar to AV-NSL, word segments and segment representations are based on VG-HuBERT. Different from AV-NSL, the segment representations are discretized via kmeans to obtain word-level discrete indices. In short, AV-cPCFG leverages visual cues only for segmentation and segment representations, but not for phrase structure induction.
123
+
124
+ DPDP-cPCFG: Instead of training cPCFG on audio-visual word segments and audio-visual segment representations, DPDP-cPCFG does not rely on any visual grounding throughout. Instead, DPDP (Kamper, 2022) and vanilla HuBERT representations are used. As in AV-cPCFG, kmeans is used for word-level discretization.
125
+
126
+ Oracle AV-NSL: To remove the uncertainty of unsupervised word segmentation, we directly train AV-NSL on top of oracle word segmentation via force alignment.
127
+
128
+ # 4.3 EVALUATION METRIC
129
+
130
+ Word segmentation. We use the standard word boundary prediction metrics (precision, recall and F1), which are calculated by comparing the temporal position between inferred word boundaries and force aligned word boundaries. In particular, following Peng & Harwath (2022b), when an inferred boundary is located within $\pm 2 0 m s$ of a force aligned boundary, we declare a successful prediction.
131
+
132
+ Parsing. For parsing with oracle word segmentation, we use EVALB to calculate the $F _ { 1 }$ score between the predicted and ground-truth parse trees.5 For parsing with inferred word segmentation, due to the mismatch in the number of nodes between the predicted and ground-truth parse trees, we introduce the structured average intersection-over-union ratio (SAIOU) as an additional metric.
133
+
134
+ SAIOU takes both word segmentation quality and temporal overlap between induced constituents into consutterance $\mathcal { T } _ { 1 } = \{ c _ { 1 , i } = ( \ell _ { 1 , i } , \dot { r } _ { 1 , i } ) \} _ { i = 1 } ^ { n _ { 1 } }$ pa t id $\mathcal { T } _ { 2 } = \{ c _ { 2 , j } = ( \ell _ { 2 , j } , r _ { 2 , j } ) \} _ { j = 1 } ^ { n _ { 2 } }$ s over the same speech, represented by a set of constituency tempthe constituents in l boand d, $\ell$ $r$ ignmen, where $\mathcal { T } _ { 1 }$ $\mathcal { T } _ { 2 }$ $\begin{array} { r } { \hat { \mathcal { A } } = \arg \operatorname* { m a x } _ { \nu a l i d \mathcal { A } } \sum _ { i = 1 } ^ { n _ { 1 } } \sum _ { j = 1 } ^ { n _ { 2 } } \mathcal { A } _ { i , j } \mathrm { I o U } ( c _ { 1 , i } , c _ { 2 , j } ) } \end{array}$ $A _ { i , j } = 1$ denotes $c _ { 1 , i }$ aligns with $c _ { 2 , j }$ , and $A _ { i , j } = 0$ otherwise; $\operatorname { I o U } ( \cdot , \cdot )$ denotes the intersection-over-union ratio between two spans. A valid alignment $\mathcal { A }$ is one that satisfies the following conditions:
135
+
136
+ 1. Any constituent may be aligned with up to 1 constituent in the other tree;
137
+
138
+ 2. For any pair of $i$ and $j$ where $A _ { i , j } = 1$ ,
139
+
140
+ • Any descendant of $c _ { 1 , i } , c _ { 1 , k }$ , may either align to a descendant of $c _ { 2 , j }$ or be left unaligned;
141
+ • Any ancestor of $c _ { 1 , i } , c _ { 1 , k ^ { \prime } }$ , may either align to a ancestor of $c _ { 2 , j }$ or be left unaligned;
142
+ • Any descendant of $c _ { 2 , j } , c _ { 2 , p }$ , may either align to a descendant of $c _ { 1 , i }$ or be left unaligned;
143
+ • Any ancestor of $c _ { 2 , j } , c _ { 2 , p ^ { \prime } }$ , may either align to a ancestor of $c _ { 1 , i }$ or be left unaligned.
144
+
145
+ Given the optimal alignment $\hat { A }$ , we calculate the structured average IOU between $\mathcal { T } _ { 1 }$ and $\mathcal { T } _ { 2 }$ by
146
+
147
+ $$
148
+ \operatorname { S A I o U } ( \mathcal { T } _ { 1 } , \mathcal { T } _ { 2 } ) = \frac { 2 } { n _ { 1 } + n _ { 2 } } \left( \sum _ { i = 1 } ^ { n _ { 1 } } \sum _ { j = 1 } ^ { n _ { 2 } } \hat { A } _ { i , j } \mathrm { I o U } ( c _ { 1 , i } , c _ { 2 , j } ) \right) .
149
+ $$
150
+
151
+ # 4.4 UNSUPERVISED WORD SEGMENTATION
152
+
153
+ We validate our decision of adopting VG-HuBERT to extract word-like units from raw speech waveforms for later phrase structure parsing. In particular, we investigate two questions: (1) How does segment insertion affect word segmentation performance? (2) how does MBR-based VG-HuBERT compare to supervised selected VG-HuBERT?
154
+
155
+ In Table 1, in addition to VG-HuBERT, we also list a speech-only word segmentation algorithm DPDP (Kamper, 2022). Note that audio-visual model VG-HuBERT significantly outperform DPDP. For question (1), by comparing the third row and the fourth row, as expected we see that performing segment insertion improves recall and hurts precision, and slightly improves F1. For question (2), by comparing the fourth row and the fifth row (second to last row), we see that MBR selection actually leads to better performance than supervised selection. The final MBR selection we adopted is based on the last row, where we first performed MBR selection on SpokenCOCO val set on all 405 candidates, and subsequently chose the 10 most selected combinations to perform another round of MBR decoding. Getting the top 10 most selected combinations does not require knowing the performance on segmentation, and therefore this process is still completely unsupervised. The reason for doing 2 iterations of MBR is because performing MBR on 405 candidates on SpokenCOCO training set is estimated to take 2 months, and MBR on 10 candidates can be done in 5 days. Comparing the last two rows, we observe that two iterations of MBR does not lead to worse results.
156
+
157
+ # 4.5 UNSUPERVISED PHRASE STRUCTURE INDUCTION
158
+
159
+ We quantitatively show that AV-NSL learns meaningful phrase structure given word segments. First, Table 2 is the main result of the fully-unsupervised AV-NSL on SpokenCOCO, evaluated with SAIOU. The best performing AV-NSL is based on our improved VG-HuBERT with MBR top 10 selection for word segmentation, attention-weighted mean-pool over VG-HuBERT layers as the segment representations, and another MBR decoding over all phrase structure induction hyperparameters. Comparing AV-NSL against AV-cPCFG and AV-cPCFG against DPDP-cPCFG, we empirically show the necessity of training AV-NSL on continuous segment representation instead of discretized speech tokens, and the effectiveness of visual-grounding in our overall model design.
160
+
161
+ Table 1: Word Segmentation Performance on SpokenCOCO validation set. Out. Sel. denotes output selection methods, and #Sel. Cand. denotes the number of candidate models to be selected. MBR (2iter) means we first run MBR on all 405 candidates, and then run MBR again on the $1 0 \ \mathrm { m o s t }$ selected candidates. Our improved VG-HuBERT with MBR achieves the best boundary $F _ { 1 }$ .
162
+
163
+ <table><tr><td>Method</td><td>Insertion</td><td>Out. Sel.</td><td>#Sel. Cand.</td><td>Precision</td><td>Recall</td><td>F1</td></tr><tr><td>DPDP (Kamper,2022)</td><td></td><td>supervised</td><td></td><td>17.37</td><td>9.00</td><td>11.85</td></tr><tr><td>VG-HuBERT (Peng &amp; Harwath,2022b)</td><td></td><td>supervised</td><td></td><td>36.19</td><td>27.22</td><td>31.07</td></tr><tr><td rowspan="3">Improved VG-HuBERT (Ours)</td><td></td><td>supervised</td><td></td><td>34.34</td><td>29.85</td><td>31.94</td></tr><tr><td></td><td>MBR</td><td>405</td><td>33.83</td><td>34.37</td><td>34.10</td></tr><tr><td>√</td><td>MBR (2iter)</td><td>405→10</td><td>33.31</td><td>34.90</td><td>34.09</td></tr></table>
164
+
165
+ Table 2: Fully-unsupervised phrase structure induction results on SpokenCOCO. The best overall number and the best number produced by neural models are in boldface. Full table in Appendix 7.
166
+
167
+ <table><tr><td colspan="3">Model</td><td rowspan="2">Output Selection</td><td rowspan="2">SAIoU</td></tr><tr><td>Syntax Induction</td><td>Segmentation</td><td>Seg.Representation (continuous/discrete)</td></tr><tr><td>Right-Branching</td><td>VG-HuBERT+MBR10</td><td></td><td></td><td>0.546</td></tr><tr><td>Right-Branching</td><td>DPDP</td><td></td><td></td><td>0.478</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o (continuous)</td><td>MBR</td><td>0.516</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT10,11,12 (continuous)</td><td>MBR</td><td>0.521</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+4k km (discrete)</td><td>last ckpt.</td><td>0.499</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+8k km (discrete)</td><td>last ckpt.</td><td>0.481</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+2k km (discrete)</td><td>last ckpt.</td><td>0.465</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+2k km (discrete)</td><td>last ckpt.</td><td>0.426</td></tr></table>
168
+
169
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Segmentation</td><td rowspan="2">Seg. Representation</td><td colspan="3">tree target</td><td rowspan="2">Output Selection</td><td rowspan="2">SAIoU</td></tr><tr><td>train</td><td>val</td><td>test</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT2</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.538</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT6</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.538</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT2,4,6.8,10,12</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>MBR</td><td>0.536</td></tr></table>
170
+
171
+ Table 3: Single round self-training in Section 3.3 improves the best AV-NSL from Table 2. We train s-Benepar on the trees from fully-unsupervised AV-NSL. Full table in Appendix 8.
172
+
173
+ Secondly, Table 3 shows that our proposed self-training with s-Benepar complements AV-NSL. Generally, a single round of self-training improves the SAIOU, and our best s-Benepar improves the best AV-NSL from 0.521 to 0.538. Thirdly, Table 4 isolates phrase structure induction from word segmentation quality with oracle AV-NSL. Different from Table 2, since there is no mismatch in the number of tree nodes, we can adopt $F _ { 1 }$ evaluation. With proper segment-level representations, unsupervised oracle AV-NSL matches or out-performs text-based VG-NSL. Similar to Tabel 3, selftraining with s-Benepar on oracle AV-NSL trees further improves the syntax induction results, almost matching that of right-branching tree. Last but not least, perhaps surprisingly, right-branching trees (RBT) on the given word segmentation reach the best SAIOU and $F _ { 1 }$ scores. We note that the rightbranching approach highly aligns with the head-initial property of English (Baker, 2001), especially in our setting where all punctuation marks were removed; thus, it is nontrivial for AV-NSL to reach the performance on par with RBT without inductive biases favoring any specific type of trees.
174
+
175
+ # 5 ANALYSES
176
+
177
+ Unsupervised Constituent Recall: Following Shi et al. (2019), we show the recall of specific types of constituents (Table 5). While VG-NSL benefits from the head-initial (HI) bias, where abstract words are encouraged to appear in the beginning of a constituent, it is worth noting that AV-NSL outperforms all variations of VG-NSL, without inductive biases favoring any specific types of trees.
178
+
179
+ Table 4: Phrase structure induction with oracle segmentation given. Full table in Appendix 9.
180
+
181
+ <table><tr><td colspan="2">Model</td><td rowspan="2">Output Selection</td><td rowspan="2">F1</td></tr><tr><td>Syntax Induction</td><td>Seg.Representation</td></tr><tr><td>Random</td><td></td><td></td><td>32.77</td></tr><tr><td>Left-Branching</td><td></td><td></td><td>24.56</td></tr><tr><td>Right-Branching VG-NSL</td><td></td><td>Supervised</td><td>57.39 53.11</td></tr><tr><td></td><td>word embeddings</td><td></td><td></td></tr><tr><td>oracle AV-NSL</td><td>log-Mel spectrogram</td><td>Supervised</td><td>42.01</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2</td><td>Supervised</td><td>55.51</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2</td><td>MBR</td><td>54.99</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2,4,6,8,10,12,24</td><td>MBR</td><td>55.96</td></tr><tr><td>oracle AV-NSL →s-Benepar</td><td>HuBERT2</td><td>MBR</td><td>57.24</td></tr><tr><td>oracle AV-NSL →s-Benepar</td><td>HuBERT12</td><td>MBR</td><td>57.33</td></tr></table>
182
+
183
+ Ablation Study: We present two ablations to examine the effectiveness of high-quality word segmentation and visual representation (Table 6). We train AV-NSL with the following modifications:
184
+
185
+ 1. Fix the visual representations, but replace oracle segmentation with naive uniform word segmentation, where the number of words in each caption is given (uniform AV-NSL).
186
+ 2. Fix the oracle word segmentation, but replace visual embeddings with random images, where each pixel is independently sampled from a uniform distribution.
187
+
188
+ We observe that there are significant performance drops in both settings, comparing to the AV-NSL trained with oracle segmentation and high-quality visual representation. This set of results complement Table 2, stressing that precise word segmentation and high-quality visual representations are both necessary for phrase structure induction from speech. Furthermore, we provide tree structure and word segmentation visualizations for qualitative analysis in the Appendix.
189
+
190
+ Table 6: Top rows: performance of AV-NSL with word segmentation in various quality and high-quality visual embeddings. Bottom rows: performance of AV-NSL with visual embeddings in various quality and highquality word segmentation. DINO: a selfsupervised model that produces high-quality visual representations (Caron et al., 2021).
191
+
192
+ Table 5: Recall of specific typed phrases, including noun phrases (NP), verb phrases (VP), prepositional phrases (PP) and adjective phrases (ADJP), and overall $F _ { 1 }$ score, evaluated on the SpokenCOCO test split. The VG-NSL numbers are taken from (Shi et al., 2019). AV-NSL here are trained on oracle segmentation with vanilla HuBERT as the layer representations.
193
+
194
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">F1</td><td colspan="4">Constituent Recall</td></tr><tr><td>NP</td><td>VP</td><td>PP</td><td>ADJP</td></tr><tr><td>VG-NSL (Shi et al.,2019)</td><td>50.4</td><td>79.6</td><td>26.2</td><td>42.0</td><td>22.0</td></tr><tr><td>VG-NSL + HI</td><td>53.3</td><td>74.6</td><td>32.5</td><td>66.5</td><td>21.7</td></tr><tr><td>VG-NSL + HI+ FastText</td><td>54.4</td><td>78.8</td><td>24.4</td><td>65.6</td><td>22.0</td></tr><tr><td>oracle AV-NSL</td><td>55.6</td><td>55.5</td><td>68.1</td><td>66.6</td><td>22.1</td></tr></table>
195
+
196
+ <table><tr><td colspan="2">Model</td><td rowspan="2">Visual</td><td rowspan="2">F1</td></tr><tr><td>Syntax Induction</td><td>Seg.Repre.</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT10</td><td>ResNet101</td><td>50.50</td></tr><tr><td>uniform AV-NSL</td><td>HuBERT10</td><td>ResNet101</td><td>36.62</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2</td><td></td><td>55.71</td></tr><tr><td></td><td></td><td>DINO</td><td></td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2</td><td>random</td><td>31.23</td></tr></table>
197
+
198
+ # 6 CONCLUSION
199
+
200
+ In recent years, there have been fruitful progresses in multi-modal induction for zero-resource speech processing and grammar induction respectively. The idea of leveraging the visual modality to learn language competence, either lexicon units from speech or syntactic structure from text, is an attractive approach for modeling human language acquisition. Our study contributes to both lines of research, by presenting an unifying framework that learns phrase structure from visually-grounded speech, without any text. We show that our proposed model, AV-NSL, infers meaningful constituency parse trees on top of continuous word segment representations, both quantitatively and qualitatively. To justify our modeling design choices, we construct several baselines and introduce a novel evaluation metric. We envision our research as the first of many in textless structure learning.
201
+
202
+ # ETHICS STATEMENT
203
+
204
+ This work is scientific at its core, as the goal is to study the process of grammar induction from speech with visual grounding. The data used in this work is also publicly available. One potential concern is that the data and experiments are based on English, which does not represent the global human population. However, we believe that our proposed method is general enough to be applied to other spoken languages when the data is available, because we do not use any language specific speech processing techniques, and we do not have any built-in bias within the models.
205
+
206
+ # REPRODUCIBILITY STATEMENT
207
+
208
+ AV-NSL code, s-Benepar code, and SAIOU evaluation code will be made publicly available. AVNSL code is based on the VG-NSL codebase. s-Benepar code is based on the Benepar codebase. SpokenCOCO is publicly available to download. All models are trained on a single GPU. We also included as many experimental details as we can in the main content of the paper and in Appendix A.2.
209
+
210
+ # REFERENCES
211
+
212
+ Robin Algayres, Tristan Ricoul, Julien Karadayi, Hugo Laurenc¸on, Salah Zaiem, Abdelrahman Mohamed, Benoˆıt Sagot, and Emmanuel Dupoux. Dp-parse: Finding word boundaries from raw speech with an instance lexicon. arXiv preprint arXiv:2206.11332, 2022.
213
+
214
+ Mark C Baker. The atoms of language. Basic Books, 2001.
215
+
216
+ Saurabhchand Bhati, Jesus Villalba, Piotr ´ Zelasko, Laureano Moro-Velazquez, and Najim Dehak. ˙ Segmental contrastive predictive coding for unsupervised word segmentation. Interspeech, 2021.
217
+
218
+ Peter J Bickel and Bo Li. Mathematical statistics. In Test. Citeseer, 1977.
219
+
220
+ Rens Bod. An all-subtrees approach to unsupervised parsing. COLING-ACL, 2006.
221
+
222
+ Mathilde Caron, Hugo Touvron, Ishan Misra, Herve J ´ egou, 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.
223
+
224
+ Jan Chorowski, Grzegorz Ciesielski, Jarosław Dzikowski, Adrian Łancucki, Ricard Marxer, Ma- ´ teusz Opala, Piotr Pusz, Paweł Rychlikowski, and Michał Stypułkowski. Aligned contrastive predictive coding. Interspeech, 2021.
225
+
226
+ John Cocke. Programming languages and their compilers: Preliminary notes. New York University, 1969.
227
+
228
+ Carl De Marcken. Unsupervised language acquisition. PhD thesis, Massachusetts Institute of Technology, 1996.
229
+
230
+ Virginia R de Sa. Learning classification with unlabeled data. NeurIPS, 1994.
231
+
232
+ Andrew Drozdov, Pat Verga, Mohit Yadav, Mohit Iyyer, and Andrew McCallum. Unsupervised latent tree induction with deep inside-outside recursive autoencoders. NAACL-HLT, 2019.
233
+
234
+ Ewan Dunbar, Xuan Nga Cao, Juan Benjumea, Julien Karadayi, Mathieu Bernard, Laurent Besacier, Xavier Anguera, and Emmanuel Dupoux. The zero resource speech challenge 2017. ASRU, 2017.
235
+
236
+ Ewan Dunbar, Robin Algayres, Julien Karadayi, Mathieu Bernard, Juan Benjumea, Xuan-Nga Cao, Lucie Miskic, Charlotte Dugrain, Lucas Ondel, Alan W Black, et al. The zero resource speech challenge 2019: Tts without t. Interspeech, 2019.
237
+
238
+ Ewan Dunbar, Julien Karadayi, Mathieu Bernard, Xuan-Nga Cao, Robin Algayres, Lucas Ondel, Laurent Besacier, Sakriani Sakti, and Emmanuel Dupoux. The zero resource speech challenge 2020: Discovering discrete subword and word units. Interspeech, 2020.
239
+
240
+ Emmanuel Dupoux. Cognitive science in the era of artificial intelligence: A roadmap for reverseengineering the infant language-learner. Cognition, 173:43–59, 2018.
241
+
242
+ Zvi Galil. Efficient algorithms for finding maximum matching in graphs. ACM Comput. Surv., 18 (1):23–38, mar 1986. ISSN 0360-0300. doi: 10.1145/6462.6502. URL https://doi.org/ 10.1145/6462.6502.
243
+
244
+ Haohan Guo, Frank K Soong, Lei He, and Lei Xie. Exploiting syntactic features in a parsed tree to improve end-to-end tts. Interspeech, 2019.
245
+
246
+ David Harwath and James R Glass. Learning word-like units from joint audio-visual analysis. ACL, 2017.
247
+
248
+ David Harwath, Wei-Ning Hsu, and James Glass. Learning hierarchical discrete linguistic units from visually-grounded speech. ICLR, 2020.
249
+
250
+ David Frank Harwath. Learning spoken language through vision. PhD thesis, Massachusetts Institute of Technology, 2018.
251
+
252
+ William N. Havard, Jean-Pierre Chevrot, and Laurent Besacier. Word recognition, competition, and activation in a model of visually grounded speech. In CoNLL, 2019.
253
+
254
+ Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
255
+
256
+ Yining Hong, Qing Li, Song-Chun Zhu, and Siyuan Huang. Vlgrammar: Grounded grammar induction of vision and language. ICCV, 2021.
257
+
258
+ Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, Ruslan Salakhutdinov, and Abdelrahman Mohamed. Hubert: Self-supervised speech representation learning by masked prediction of hidden units. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 29:3451–3460, 2021a.
259
+
260
+ Wei-Ning Hsu, David Harwath, Christopher Song, and James Glass. Text-free image-to-speech synthesis using learned segmental units. ACL, 2021b.
261
+
262
+ Aren Jansen and Benjamin Van Durme. Efficient spoken term discovery using randomized algorithms. ASRU, 2011.
263
+
264
+ Aren Jansen, Emmanuel Dupoux, Sharon Goldwater, Mark Johnson, Sanjeev Khudanpur, Kenneth Church, Naomi Feldman, Hynek Hermansky, Florian Metze, Richard Rose, et al. A summary of the 2012 jhu clsp workshop on zero resource speech technologies and models of early language acquisition. ICASSP, 2013.
265
+
266
+ Nobuyoshi Kaiki, Sakriani Sakti, and Satoshi Nakamura. Using local phrase dependency structure information in neural sequence-to-sequence speech synthesis. In 2021 24th Conference of the Oriental COCOSDA International Committee for the Co-ordination and Standardisation of Speech Databases and Assessment Techniques (O-COCOSDA), pp. 206–211. IEEE, 2021.
267
+
268
+ Herman Kamper. Word segmentation on discovered phone units with dynamic programming and self-supervised scoring. arXiv preprint arXiv:2202.11929, 2022.
269
+
270
+ Herman Kamper and Benjamin van Niekerk. Towards unsupervised phone and word segmentation using self-supervised vector-quantized neural networks. Interspeech, 2021.
271
+
272
+ Herman Kamper, Aren Jansen, and Sharon Goldwater. Fully unsupervised small-vocabulary speech recognition using a segmental bayesian model. In Sixteenth Annual Conference of the International Speech Communication Association, 2015.
273
+
274
+ Herman Kamper, Aren Jansen, and Sharon Goldwater. A segmental framework for fullyunsupervised large-vocabulary speech recognition. Computer Speech & Language, 46:154–174, 2017.
275
+
276
+ Tadao Kasami. An efficient recognition and syntax-analysis algorithm for context-free languages. Coordinated Science Laboratory Report no. R-257, 1966.
277
+
278
+ Eugene Kharitonov, Ann Lee, Adam Polyak, Yossi Adi, Jade Copet, Kushal Lakhotia, Tu-Anh Nguyen, Morgane Riviere, Abdelrahman Mohamed, Emmanuel Dupoux, et al. Text-free prosody- \` aware generative spoken language modeling. ACL, 2022.
279
+
280
+ Khazar Khorrami and Okko Johannes Ras¨ anen. Can phones, syllables, and words emerge as ¨ side-products of cross-situational audiovisual learning? - a computational investigation. ArXiv, abs/2109.14200, 2021.
281
+
282
+ Yoon Kim, Chris Dyer, and Alexander M Rush. Compound probabilistic context-free grammars for grammar induction. ACL, 2019a.
283
+
284
+ Yoon Kim, Alexander M Rush, Lei Yu, Adhiguna Kuncoro, Chris Dyer, and Gabor Melis. Unsuper- ´ vised recurrent neural network grammars. NAACL-HLT, 2019b.
285
+
286
+ Ryan Kiros, Ruslan Salakhutdinov, and Richard S Zemel. Unifying visual-semantic embeddings with multimodal neural language models. arXiv preprint arXiv:1411.2539, 2014.
287
+
288
+ Nikita Kitaev and Dan Klein. Constituency parsing with a self-attentive encoder. In ACL, 2018.
289
+
290
+ Dan Klein and Christopher D Manning. A generative constituent-context model for improved grammar induction. ACL, 2002.
291
+
292
+ Dan Klein and Christopher D Manning. Corpus-based induction of syntactic structure: Models of dependency and constituency. ACL, 2004.
293
+
294
+ Arne Kohn, Timo Baumann, and Oskar D ¨ orfler. An empirical analysis of the correlation of syntax ¨ and prosody. Interspeech, 2018.
295
+
296
+ Noriyuki Kojima, Hadar Averbuch-Elor, Alexander M Rush, and Yoav Artzi. What is learned in visually grounded neural syntax acquisition. ACL, 2020.
297
+
298
+ Shankar Kumar and William Byrne. Minimum Bayes-risk decoding for statistical machine translation. In Proceedings of the Human Language Technology Conference of the North American Chapter of the Association for Computational Linguistics: HLT-NAACL 2004, pp. 169–176, Boston, Massachusetts, USA, May 2 - May 7 2004. Association for Computational Linguistics. URL https://aclanthology.org/N04-1022.
299
+
300
+ Kushal Lakhotia, Eugene Kharitonov, Wei-Ning Hsu, Yossi Adi, Adam Polyak, Benjamin Bolte, Tu-Anh Nguyen, Jade Copet, Alexei Baevski, Abdelrahman Mohamed, et al. On generative spoken language modeling from raw audio. Transactions of the Association for Computational Linguistics, 9:1336–1354, 2021.
301
+
302
+ Chia-ying Lee and James Glass. A nonparametric bayesian approach to acoustic model discovery. ACL, 2012.
303
+
304
+ Chia-ying Lee, Timothy J O’donnell, and James Glass. Unsupervised lexicon discovery from acoustic input. Transactions of the Association for Computational Linguistics, 3:389–403, 2015.
305
+
306
+ Bowen Li, Lili Mou, and Frank Keller. An imitation learning approach to unsupervised parsing. ACL, 2019.
307
+
308
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ´ European conference on computer vision, pp. 740–755. Springer, 2014.
309
+
310
+ Paria Jamshid Lou, Yufei Wang, and Mark Johnson. Neural constituency parsing of speech transcripts. NAACL-HLT, 2019.
311
+
312
+ Jana M Mason. When do children begin to read: An exploration of four year old children’s letter and word reading competencies. Reading Research Quarterly, pp. 203–227, 1980.
313
+
314
+ Michael McAuliffe, Michaela Socolof, Sarah Mihuc, Michael Wagner, and Morgan Sonderegger. Montreal forced aligner: Trainable text-speech alignment using kaldi. Interspeech, 2017.
315
+
316
+ Fergus McInnes and Sharon Goldwater. Unsupervised extraction of recurring words from infantdirected speech. In Proceedings of the Annual Meeting of the Cognitive Science Society, volume 33, 2011.
317
+
318
+ Grzegorz Chrupała Mitja Nikolaus, Afra Alishahi. Learning english with peppa pig. TACL, 2022.
319
+
320
+ Letitia Naigles. Children use syntax to learn verb meanings. Journal of child language, 17(2): 357–374, 1990.
321
+
322
+ Tu Nguyen, Maureen de Seyssel, Patricia Roz’e, Morgane Riviere, Evgeny Kharitonov, Alexei \` Baevski, Ewan Dunbar, and Emmanuel Dupoux. The zero resource speech benchmark 2021: Metrics and baselines for unsupervised spoken language modeling. Self-Supervised Learning for Speech and Audio Processing NeurIPS Workshop, 2020.
323
+
324
+ Kayode Olaleye and Herman Kamper. Attention-based keyword localisation in speech using visual grounding. In Interspeech, 2021.
325
+
326
+ Alex S Park and James R Glass. Unsupervised pattern discovery in speech. IEEE Transactions on Audio, Speech, and Language Processing, 16(1):186–197, 2007.
327
+
328
+ Puyuan Peng and David Harwath. Self-supervised representation learning for speech using visual grounding and masked language modeling. Self-Supervised Learning for Speech and Audio Processing Workshop at AAAI, 2022a.
329
+
330
+ Puyuan Peng and David Harwath. Word discovery in visually grounded, self-supervised speech models. Interspeech, 2022b.
331
+
332
+ Adam Polyak, Yossi Adi, Jade Copet, Eugene Kharitonov, Kushal Lakhotia, Wei-Ning Hsu, Abdelrahman Mohamed, and Emmanuel Dupoux. Speech resynthesis from discrete disentangled self-supervised representations. Interspeech, 2021.
333
+
334
+ Adrien Pupier, Maximin Coavoux, Benjamin Lecouteux, and Jer´ ome Goulian. End-to-end depen- ˆ dency parsing of spoken french. In Interspeech, 2022.
335
+
336
+ Brian Roark, Mary Harper, Eugene Charniak, Bonnie Dorr, Mark Johnson, Jeremy G Kahn, Yang Liu, Mari Ostendorf, John Hale, Anna Krasnyanskaya, et al. Sparseval: Evaluation metrics for parsing speech. LREC, 2006.
337
+
338
+ Deb K Roy and Alex P Pentland. Learning words from sights and sounds: A computational model. Cognitive science, 26(1):113–146, 2002.
339
+
340
+ Yikang Shen, Zhouhan Lin, Chin-Wei Huang, and Aaron Courville. Neural language modeling by jointly learning syntax and lexicon. ICLR, 2018.
341
+
342
+ Yikang Shen, Shawn Tan, Alessandro Sordoni, and Aaron Courville. Ordered neurons: Integrating tree structures into recurrent neural networks. ICLR, 2019.
343
+
344
+ Freda Shi, Daniel Fried, Marjan Ghazvininejad, Luke Zettlemoyer, and Sida I Wang. Natural language to code translation with execution. arXiv preprint arXiv:2204.11454, 2022.
345
+
346
+ Haoyue Shi, Jiayuan Mao, Kevin Gimpel, and Karen Livescu. Visually grounded neural syntax acquisition. ACL, 2019.
347
+
348
+ Haoyue Shi, Karen Livescu, and Kevin Gimpel. On the role of supervision in unsupervised constituency parsing. In EMNLP. Association for Computational Linguistics, 2020.
349
+
350
+ Valentin I. Spitkovsky, Hiyan Alshawi, and Daniel Jurafsky. Breaking out of local optima with count transforms and model recombination: A study in grammar induction. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pp. 1983–1995, Seattle, Washington, USA, October 2013. Association for Computational Linguistics. URL https: //aclanthology.org/D13-1204.
351
+
352
+ Zheng-Hua Tan, Najim Dehak, et al. rvad: An unsupervised segment-based robust voice activity detection method. Computer speech & language, 59:1–21, 2020.
353
+
354
+ Trang Tran and Mari Ostendorf. Assessing the use of prosody in constituency parsing of imperfect transcripts. Interspeech, 2021.
355
+
356
+ Trang Tran, Shubham Toshniwal, Mohit Bansal, Kevin Gimpel, Karen Livescu, and Mari Ostendorf. Parsing speech: a neural approach to integrating lexical and acoustic-prosodic information. NAACL-HLT, 2018.
357
+
358
+ Trang Tran, Jiahong Yuan, Yang Liu, and Mari Ostendorf. On the role of style in parsing speech with neural models. Interspeech, 2019.
359
+
360
+ Shubhi Tyagi, Marco Nicolis, Jonas Rohnke, Thomas Drugman, and Jaime Lorenzo-Trueba. Dynamic prosody generation for speech synthesis using linguistics-driven acoustic embedding selection. Interspeech, 2020.
361
+
362
+ Maarten Versteegh, Roland Thiolliere, Thomas Schatz, Xuan Nga Cao, Xavier Anguera, Aren Jansen, and Emmanuel Dupoux. The zero resource speech challenge 2015. ISCA, 2015.
363
+
364
+ Michael Wagner and Duane G Watson. Experimental and theoretical advances in prosody: A review. Language and cognitive processes, 25(7-9):905–945, 2010.
365
+
366
+ Bo Wan, Wenjuan Han, Zilong Zheng, and Tinne Tuytelaars. Unsupervised vision-language grammar induction with shared structure modeling. ICLR, 2022.
367
+
368
+ Liming Wang and Mark Hasegawa-Johnson. A translation framework for visually grounded spoken unit discovery. In ACSSC, 2021.
369
+
370
+ Ronald J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning, 8(3-4):229–256, 1992. URL https://link.springer.com/ content/pdf/10.1007/BF00992696.pdf.
371
+
372
+ Daniel H Younger. Recognition and parsing of context-free languages in time n3. Information and control, 10(2):189–208, 1967.
373
+
374
+ Hao Zhang and Daniel Gildea. Efficient multi-pass decoding for synchronous context free grammars. In Proceedings of ACL-08: HLT, pp. 209–217, Columbus, Ohio, June 2008. Association for Computational Linguistics. URL https://aclanthology.org/P08-1025.
375
+
376
+ Songyang Zhang, Linfeng Song, Lifeng Jin, Kun Xu, Dong Yu, and Jiebo Luo. Video-aided unsupervised grammar induction. NAACL-HLT, 2021.
377
+
378
+ Yaodong Zhang. Unsupervised speech processing with applications to query-by-example spoken term detection. PhD thesis, Massachusetts Institute of Technology, 2013.
379
+
380
+ Yaodong Zhang and James R Glass. Unsupervised spoken keyword spotting via segmental dtw on gaussian posteriorgrams. ASRU, 2009.
381
+
382
+ Yanpeng Zhao and Ivan Titov. Visually grounded compound pcfgs. EMNLP, 2020.
383
+
384
+ # A APPENDIX
385
+
386
+ A.1 BASELINES
387
+
388
+ AV-cPCFG: We train compound probabilistic context free grammar (cPCFG) (Kim et al., 2019a) on word-level discrete speech tokens. Similar to AV-NSL, word segments are obtained from VGHuBERT with segment insertion, and segment representations are extracted from VG-Hubert layer 10 with CLS attention weighted mean-pool. Different from AV-NSL, the segment representations are discretized via kmeans to obtain word-level discrete indices. Because the discretization is wordlevel instead of phone-level, we swept the number of kmeans cluster over $\left\{ 1 \mathrm { k } , 2 \mathrm { k } , 4 \mathrm { k } , 8 \mathrm { k } , 1 2 \mathrm { k } , 1 6 \mathrm { k } , \right.$ , $2 0 \mathrm { k } \}$ , which corresponds to the dictionary size in cPCFG. In summary, AV-cPCFG leverages visual cues only for segmentation and segment representations, but not for phrase structure induction.
389
+
390
+ DPDP-cPCFG: Instead of training cPCFG on audio-visual word segments and audio-visual segment representations, DPDP-cPCFG does not rely on any visual grounding throughout. Instead, DPDP (Kamper, 2022), a recent speech-only word segmentation algorithm, and vanilla HuBERT representations mean-pooled over DPDP segments are used. We swept through HuBERT layer {2, 4, 6, 8, 10, 12}. As in AV-cPCFG, kmeans is used for word-level discretization.
391
+
392
+ oracle AV-NSL: To remove the uncertainty of unsupervised word segmentation, we directly train AV-NSL on top of oracle word segmentation via force alignment. The segment representations are based on learnable attention pooling over vanilla HuBERT layer $\{ 2 , 4 , 6 , 8 , 1 0 , 1 2 \}$ representations. We also tried log Mel spectrograms and HuBERT-L 300M to examine the effectiveness of different input representations. One note is that simpler score and combine parametrization suffices here6.
393
+
394
+ # A.2 HYPERPARAMETERS
395
+
396
+ For VG-HuBERT, we run MBR selection on the combination of insertion gap $\{ 0 . 1 , 0 . 2 , 0 . 3 \}$ seconds, segmentation layer $\{ 9 , 1 0 , 1 1 \}$ , attention magnitude threshold at top $\{ 3 0 \% , 2 0 \% , 1 0 \% \}$ , three training random seeds, and model snapshots at training step 20k, 30k, 40k, 50k, 60k. This gives 405 combinations in total.
397
+
398
+ # A.3 FULL RESULTS TABLE
399
+
400
+ # A.4 WORD SEGMENTATION VIZ
401
+
402
+ We show more examples of word segmentation generated by our improved VG-HuBERT in Figure 4. Segments marked with $" + "$ are inserted segments, and vertical blue dotted lines are inferred word boundaries.
403
+
404
+ # A.5 VISUALIZATION OF INDUCED TREES
405
+
406
+ We visualize the induced trees in Figure 5.
407
+
408
+ Table 7: Fully-unsupervised phrase structure induction results evaluated with SAIOU.
409
+
410
+ <table><tr><td colspan="3">Model</td><td rowspan="2">Output Selection</td><td rowspan="2">SAIoU</td></tr><tr><td>Syntax Induction</td><td>Segmentation</td><td>Seg.Representation (continuous/discrete)</td></tr><tr><td>Right-Branching</td><td>VG-HuBERT+MBR10</td><td></td><td></td><td>0.546</td></tr><tr><td>Right-Branching</td><td>DPDP</td><td></td><td></td><td>0.478</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o (continuous)</td><td>MBR</td><td>0.516</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT11 (continuous)</td><td>MBR</td><td>0.498</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT12 (continuous)</td><td>MBR</td><td>0.492</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT10,11,12 (continuous)</td><td>MBR</td><td>0.521</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+1k km (discrete)</td><td>last ckpt.</td><td>0.454</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+2k km (discrete)</td><td>last ckpt.</td><td>0.444</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+4k km (discrete)</td><td>last ckpt.</td><td>0.499</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+8k km (discrete)</td><td>last ckpt.</td><td>0.481</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+12k km (discrete)</td><td>last ckpt.</td><td>0.473</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+16k km (discrete)</td><td>last ckpt.</td><td>0.471</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+20k km (discrete)</td><td>last ckpt.</td><td>0.454</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+1k km (discrete)</td><td>last ckpt.</td><td>0.434</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+2k km (discrete)</td><td>last ckpt.</td><td>0.465</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+4k km (discrete)</td><td>last ckpt.</td><td>0.444</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+8k km (discrete)</td><td>last ckpt.</td><td>0.387</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+12k km (discrete)</td><td>last ckpt.</td><td>0.447</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+16k km (discrete)</td><td>last ckpt.</td><td>0.360</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+1k km (discrete)</td><td>last ckpt.</td><td>0.403</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+2k km (discrete)</td><td>last ckpt.</td><td>0.426</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+4k km (discrete)</td><td>last ckpt.</td><td>0.415</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+8k km (discrete)</td><td>last ckpt.</td><td>0.367</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+12k km (discrete)</td><td>last ckpt.</td><td>0.415</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+16k km (discrete)</td><td>last ckpt.</td><td>0.414</td></tr></table>
411
+
412
+ Table 8: Self-training results evaluated with SAIOU.
413
+
414
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Segmentation</td><td rowspan="2">Seg.Representation</td><td colspan="3">tree target</td><td rowspan="2">Output Selection</td><td rowspan="2">SAIoU</td></tr><tr><td>train</td><td>val</td><td>test</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT2</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.538</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT4</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.536</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT6</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.538</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT8</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.532</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT10</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.537</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT12</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.536</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT2,4,6,8,10,12</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>MBR</td><td>0.536</td></tr></table>
415
+
416
+ Table 9: Phrase structure induction with oracle segmentation given results evaluated with $F _ { 1 }$ .
417
+
418
+ <table><tr><td colspan="3">Model</td><td rowspan="2">Output Selection</td><td rowspan="2">F1</td></tr><tr><td>Syntax Induction</td><td>Segmentation</td><td>Seg.Representation</td></tr><tr><td>Random</td><td>oracle</td><td></td><td></td><td>32.77</td></tr><tr><td>Left-Branching</td><td>oracle</td><td></td><td></td><td>24.56</td></tr><tr><td>Right-Branching</td><td>oracle</td><td></td><td></td><td>57.39</td></tr><tr><td>VG-NSL</td><td></td><td>word embeddings</td><td>Supervised</td><td>53.11</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>log-Mel spectrogram</td><td>Supervised</td><td>42.01</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>Supervised</td><td>55.51</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT-L24</td><td></td><td>54.63</td></tr><tr><td></td><td></td><td></td><td>Supervised</td><td></td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>MBR</td><td>54.99</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT4</td><td>MBR</td><td>53.25</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT6</td><td>MBR</td><td>53.46</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT8</td><td>MBR</td><td>53.14</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT10</td><td>MBR</td><td>36.67</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT12</td><td>MBR</td><td>48.51</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT-L24</td><td>MBR</td><td>54.39</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2,4,6,8,10,12</td><td>MBR</td><td>55.56</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2,4,6,8,10,12,24</td><td>MBR</td><td>55.96</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>AV-NSL →s-Benepar</td><td>oracle</td><td>HuBERT2</td><td>MBR</td><td>57.24</td></tr><tr><td>AV-NSL→s-Benepar</td><td>oracle</td><td>HuBERT4</td><td>MBR</td><td>57.08</td></tr><tr><td>AV-NSL→s-Benepar</td><td>oracle</td><td>HuBERT6</td><td>MBR</td><td>56.81</td></tr><tr><td>AV-NSL →s-Benepar</td><td>oracle</td><td>HuBERT8</td><td>MBR</td><td>56.94</td></tr><tr><td>AV-NSL→s-Benepar</td><td>oracle</td><td>HuBERT10</td><td>MBR</td><td>57.16</td></tr><tr><td>AV-NSL →s-Benepar</td><td>oracle</td><td>HuBERT12</td><td>MBR</td><td>57.33</td></tr></table>
419
+
420
+ Table 10: Recall of specific typed phrases, and overall $F _ { 1 }$ score, evaluated on the SpokenCOCO test split. VG-NSL numbers are taken directly from (Shi et al., 2019). AV-NSL here are trained on oracle segmentation with vanilla HuBERT as the layer representations.
421
+
422
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">F1</td><td colspan="4">Constituent Recall</td></tr><tr><td>NP</td><td>VP</td><td>PP</td><td>ADJP</td></tr><tr><td>VG-NSL (Shi et al.,2019)</td><td>50.4</td><td>79.6</td><td>26.2</td><td>42.0</td><td>22.0</td></tr><tr><td>VG-NSL + HI</td><td>53.3</td><td>74.6</td><td>32.5</td><td>66.5</td><td>21.7</td></tr><tr><td>VG-NSL +HI+FastText</td><td>54.4</td><td>78.8</td><td>24.4</td><td>65.6</td><td>22.0</td></tr><tr><td>AV-NSL (oracle seg.+ HuBERT2)</td><td>55.6</td><td>55.5</td><td>68.1</td><td>66.6</td><td>22.1</td></tr><tr><td>AV-NSL (oracle seg.+HuBERT4)</td><td>53.7</td><td>57.4</td><td>56.8</td><td>61.3</td><td>21.3</td></tr><tr><td>AV-NSL (oracle seg.+HuBERT6)</td><td>53.9</td><td>59.4</td><td>55.4</td><td>59.3</td><td>21.2</td></tr><tr><td>AV-NSL (oracle seg.+HuBERT8)</td><td>53.9</td><td>56.0</td><td>58.0</td><td>64.9</td><td>22.5</td></tr><tr><td>AV-NSL (oracle seg.+HuBERT10)</td><td>50.6</td><td>55.8</td><td>48.1</td><td>57.0</td><td>20.5</td></tr><tr><td>AV-NSL (oracle seg. + HuBERT12)</td><td>49.0</td><td>62.5</td><td>34.4</td><td>45.0</td><td>17.4</td></tr></table>
423
+
424
+ Table 11: Top rows: Impact of segmentation quality for AV-NSL with number of words segments known in advance. Bottom rows: Impact of visual embedding for AV-NSL
425
+
426
+ <table><tr><td colspan="3">Model</td><td rowspan="2">Visual Embedding</td><td rowspan="2">F1</td></tr><tr><td>Syntax Induction</td><td>Segmentation</td><td>Seg.Representation</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>ResNet101</td><td>55.51</td></tr><tr><td>AV-NSL</td><td>uniform</td><td>HuBERT2</td><td>ResNet101</td><td>48.97</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT10</td><td>ResNet101</td><td>50.50</td></tr><tr><td>AV-NSL</td><td>uniform</td><td>HuBERT10</td><td>ResNet101</td><td>36.62</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>DINO</td><td>55.71</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>random</td><td>31.23</td></tr></table>
427
+
428
+ ![](images/6eafec723763f1955cfa3db3f2fc4b4dc5b5264e53948ae6cd47f58566a414d3.jpg)
429
+ Figure 4: Examples of attention segments generated by VG-HuBERT. Inserted segments are marked with $" + "$ . Vertical blue dotted lines are inferred word boundaries.
430
+
431
+ ![](images/b9ba5c7f7252344a82826fa03c2de12600f34bc8ecb7e8a39029ac2f4d17e2ae.jpg)
432
+ Figure 5: Visualization of an example produced by AV-NSL (best viewed in color). Top (red and green): the ground-truth parse tree; bottom (blue and yellow): the generated parse tree. In each tree, a parent segment adjacently covers its two children segments.
md/dev/0gouO5saq6K/0gouO5saq6K.md ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Multi-Game Decision Transformers
2
+
3
+ Kuang-Huei Lee∗ Ofir Nachum∗ Mengjiao Yang Lisa Lee
4
+
5
+ # Daniel Freeman Winnie Xu Sergio Guadarrama Ian Fischer
6
+
7
+ Eric Jang Henryk Michalewski Igor Mordatch∗
8
+
9
+ Google Research
10
+
11
+ # Abstract
12
+
13
+ A longstanding goal of the field of AI is a method for learning a highly capable, generalist agent from diverse experience. In the subfields of vision and language, this was largely achieved by scaling up transformer-based models and training them on large, diverse datasets. Motivated by this progress, we investigate whether the same strategy can be used to produce generalist reinforcement learning agents. Specifically, we show that a single transformer-based model – with a single set of weights – trained purely offline can play a suite of up to 46 Atari games simultaneously at close-to-human performance. When trained and evaluated appropriately, we find that the same trends observed in language and vision hold, including scaling of performance with model size and rapid adaptation to new games via fine-tuning. We compare several approaches in this multi-game setting, such as online and offline RL methods and behavioral cloning, and find that our Multi-Game Decision Transformer models offer the best scalability and performance. We release the pre-trained models and code to encourage further research in this direction.1
14
+
15
+ # 1 Introduction
16
+
17
+ Building large-scale generalist models that solve many tasks by training on massive task-agnostic datasets has emerged as a dominant approach in natural language processing [18, 12], computer vision [19, 6], and their intersection [61, 4]. These models can adapt to new tasks (such as translation [63, 78]), make use of unrelated data (such as using high-resource language to improve translations of low-resource languages [17]), or even incorporate new modalities by projecting images into language space [46, 75]. The success of these methods largely derives from a combination of scalable model architectures [77], an abundance of unlabeled task-agnostic data, and continuous improvements in high performance computing infrastructure. Crucially, scaling laws [38, 31] indicate that performance gains due to scale have not yet reached a saturation point.
18
+
19
+ In this work, we argue that a similar progression is possible in the field of reinforcement learning, and take initial steps toward scalable methods that produce highly capable generalist agents. In contrast to vision and language domains, reinforcement learning has seen advocacy for the use of smaller models [16, 49, 8] and is usually either used to solve single tasks, or multiple tasks within the same environment. Importantly, training across multiple environments – with very different dynamics, rewards, visuals, and agent embodiments – has been studied less significantly.
20
+
21
+ ![](images/d4902c2fa4802fa58587f8fd9eb9ac51f6a1cadded1853aa04414ec7e5d40d9c.jpg)
22
+ Figure 1: Aggregates of human-normalized scores (Inter-Quartile Mean) across 41 Atari games. Grey bars are single-game specialist models while blue are generalists. Single-game BCQ [21] results are from Gulcehre et al. [25]. Multi-game models are all trained on a dataset [1] with inter-quartile mean human-normalized score of $101 \%$ , which Multi-Game DT notably exceeds.
23
+
24
+ Specifically, we investigate whether a single model – with a single set of parameters – can be trained to act in multiple environments from large amounts of expert and non-expert experience. We consider training on a suite of 41 Atari games [9, 25] for their diversity, informally asking “Can models learn something universal from playing many video games?”. To train this model, we use only the previously-collected trajectories from Agarwal et al. [1], but we evaluate our agent interactively. We are not striving for mastery or efficiency that game-specific agents can offer, as we believe we are still in early stages of this research agenda. Rather, we investigate whether the same trends observed in language and vision hold for large-scale generalist reinforcement learning agents.
25
+
26
+ We find that we can train a single agent that achieves $126 \%$ of human-level performance simultaneously across all games after training on offline expert and non-expert datasets (see Figure 1). Furthermore, we see similar trends that mirror those observed in language and vision: rapid finetuning to never-before-seen games with very little data (Section 4.5), a scaling relationship between performance and model size (Section 4.4), and faster training progress for larger models (Appendix G).
27
+
28
+ Notably, not all existing approaches to multi-environment training work well. We investigate several approaches, including treating the problem as offline decision transformer-based sequence modeling [14, 35], online RL [53], offline temporal difference methods [42], contrastive representations [56], and behavior cloning [60]. We find that decision transformer based models offer the best performance and scaling properties in the multi-environment regime. However, to permit training on both expert and non-expert trajectories, we find it is necessary to use a guided generation technique from language modeling to generate expert-level actions, which is an important departure from standard decision transformers.
29
+
30
+ Our contributions are threefold: First, we show that it is possible to train a single high-performing generalist agent to act across multiple environments from offline data alone. Second, we show that scaling trends observed in language and vision hold. And third, we compare multiple approaches for achieving this goal, finding that decision transformers combined with guided generation perform the best. It is our hope this study can inspire further research in generalist agents. To aid this, we make our pre-trained models and code publicly available.
31
+
32
+ ![](images/859fd1e48bffed07eace755fe2651e3b53451866eb9af087b83af8821ec21d62.jpg)
33
+ Figure 2: An overview of the training and evaluation setup. We observe expert-level game-play in the interactive setting after offline learning from trajectories ranging from beginner to expert.
34
+
35
+ # 2 Related Work
36
+
37
+ A generalist agent for solving a variety of environments has been a goal for artificial intelligence (AI) researchers since the inception of AI as a field of study [50]. This same reason motivated the introduction of the Atari suite (the Arcade Learning Environment, or ALE) as a testbed for learning algorithms [10]; in their own words, the ALE is for “empirically assessing agents designed for general competency.” While the celebrated deep $Q$ -learning [52] and actor critic [54] agents were among the first to use a single algorithm for all games, they nevertheless required separate training and hyperparameters for each game agent. Later works have demonstrated the ability to learn a single neural network agent on multiple Atari games simultaneously, either online [20] or via policy distillation [59, 67]. The aim of our work is similar – to learn a single agent for playing multiple Atari games – with a focus on offline learning. We demonstrate results with human-level competency on up to 46 games, which is unseen in the literature.
38
+
39
+ A closely related setting is learning to solve multiple tasks within the same or similar environments. For example in the robotics field, existing works propose to use language-conditioned tasks [48, 3, 34], while others posit goal-reaching as a way to learn general skills [51], among other proposals [37, 82]. In this work, we tackle the problem of learning to act in a large collection of environments with distinctively different dynamics, rewards, and agent embodiments. This complicated but important setting requires a different type of generalization that has been studied significantly less.
40
+
41
+ A concurrent work [65] also aims to train a transformer-based generalist agent based on offline data including for the ALE. This work differs from ours in that the offline training data is exclusively near-optimal and it requires prompting by expert trajectories at inference time. In contrast, we extend decision transformers [14] from the Upside-Down RL family [71, 68] to learn from a diverse dataset (expert and non-expert data), predict returns, and pick optimality-conditioned returns. Furthermore, we provide comparisons against existing behavioral cloning, online and offline RL methods, and contrastive representations [80, 56]. Other works that also consider LLM-like sequence modeling for a variety of single control tasks include [66, 84, 35, 23, 57].
42
+
43
+ # 3 Method
44
+
45
+ We consider a decision-making agent that at every time $t$ receives an observation of the world $\mathbf { o } ^ { t }$ , chooses an action $a ^ { t }$ , and receives a scalar reward $r ^ { t }$ . Our goal is to learn a single optimal policy distribution $P _ { \theta } ^ { * } ( a ^ { t } | \mathbf { o } ^ { \le t } , a ^ { < t } , r ^ { < t } )$ with parameters $\theta$ that maximizes the agent’s total future return $\begin{array} { r } { R ^ { t } = \sum _ { k > t } r ^ { k } } \end{array}$ on all the environments we consider.
46
+
47
+ # 3.1 Reinforcement Learning as Sequence Modeling
48
+
49
+ Following [14], we pose the problem of offline reinforcement learning as a sequence modeling problem where we model the probability of the next sequence token $x _ { i }$ conditioned on all tokens prior to it: $P _ { \theta } ( x _ { i } | x _ { < i } )$ , similar to contemporary decoder-only sequence models [12, 15, 62]. The sequences we consider have the form:
50
+
51
+ $$
52
+ x = \langle . . . , { \bf o } _ { 1 } ^ { t } , . . . , { \bf o } _ { M } ^ { t } , \hat { R } ^ { t } , a ^ { t } , r ^ { t } , . . . \rangle
53
+ $$
54
+
55
+ where $t$ represents a time-step, $M$ is the number of image patches per observation (which we further discuss in Section 3.2), and $\hat { R } ^ { t }$ is the agent’s target return for the rest of the sequence. Such a sequence order respects the causal structure of the environment decision process. Figure 3 presents an overview of our model architecture.
56
+
57
+ Returns, actions, and rewards are tokenized (See Section 3.2 for details), and we train the model to predict the next return, action, and reward discrete token in a sequence via standard cross-entropy loss. The sequence we consider is different from Chen et al. [14], which has $\langle . . . , \hat { R } ^ { t } , \mathbf { o } ^ { t } , a ^ { t } , . . . \rangle$ . Our design allows predicting the return distribution and sampling from it, instead of relying on a user to manually select an expert-level return at inference time (See Section 3.4).
58
+
59
+ Predicting future value and rewards have been shown to be useful objectives for learning better representations in artificial reinforcement learning agents [47, 69, 44] and important signals for representation learning in humans [5]. Thus, while we may not directly use all of the predicted quantities, the task of predicting them encourages structure and representation learning of our environments. In this work, we do not attempt to predict future observations due to their non-discrete nature and the additional model capacity that would be required to generate images. However, building image-based forward prediction models of the environment has been shown to be a useful representation objective for RL [28, 27, 29]. We leave it for future investigation.
60
+
61
+ ![](images/59cf36da87bbfa95815ac554a9c04cd09962815a6dc82b5a4da632ac733bf60b.jpg)
62
+ Figure 3: An overview of our decision transformer architecture.
63
+
64
+ # 3.2 Tokenization
65
+
66
+ To generate returns, actions, and rewards via multinomial distributions similarly to language generation, we convert these quantities to discrete tokens. Actions $a$ are already discrete quantities in the environments we consider. We convert scalar rewards to ternary quantities $\{ - 1 , 0 , + 1 \}$ , and uniformly quantize returns into a discrete range shared by all our environments.2
67
+
68
+ Inspired by the simplicity and effectiveness of transformer architectures for processing images [19], we divide each observation image into a collection of $M$ patches3 (see Figure 3). Each patch is additively combined with a trainable position encoding and linearly projected into the input token embedding space. We experimented with using image tokenizations coming from a convolutional network, but did not find it to have a significant benefit and omitted it for simplicity.
69
+
70
+ We chose our tokenization scheme with simplicity in mind, but many other schemes are possible. While all our environments use a shared action space, varying action spaces when controlling different agent morphologies can still be tokenized using methods of [33, 43, 26]. And while we used uniform quantization to discretize continuous quantities, more sophisticated methods such as VQ-VAE [76] can be used to learn more effective discretizations.
71
+
72
+ # 3.3 Training Dataset
73
+
74
+ To train the model, we use an existing dataset of Atari trajectories (with quantized returns) introduced in [1]. The dataset contains trajectories collected from the training progress of a DQN agent [53]. Following [25], we select 46 games where DQN significantly outperforms a random agent. 41 games are used for training and 5 games are held out for out-of-distribution generalization experiments.
75
+
76
+ We chose 5 held-out games representing different categories including Alien and MsPacman (maze based), Pong (ball tracking), SpaceInvaders (shoot vertically), and StarGunner (shoot horizontally), to ensure out-of-distribution generalization can be evaluated on different types of games.
77
+
78
+ For each of 41 games, we use data from 2 training runs, each containing roll-outs from 50 policy checkpoints, in turn each containing 1 million environment steps. This totals 4.1 billion steps. Using the tokenization scheme in previous sections, the dataset contains almost 160 billion tokens.
79
+
80
+ As the dataset contains agent behaviors at all stages of learning, it contains both expert and non-expert behaviors. We do not perform any special filtering, curation, or balancing of the dataset. The motivation to train on such data instead of expert-only behaviors is twofold: Firstly, sub-optimal behaviors are more diverse than optimal behaviors and may still be useful for learning representations of the environment and consequences of poor decisions. Secondly, it may be difficult to create a single binary criteria for optimality as it is typically a graded quantity. Thus, instead of assuming only task-relevant expert behaviors, we train our model on all available behaviors, yet generate expert behavior at inference time as described in the next section.
81
+
82
+ # 3.4 Expert Action Inference
83
+
84
+ As described above, our training datasets contain a mix of expert and non-expert behaviors, thus directly generating actions from the model imitating the data is unlikely to consistently produce expert behavior (as we confirm in Section 4.7). Instead, we want to control action generation to consistently produce actions of highly-rewarding behavior. This mirrors the problem of discriminator-guided generation in language models, for which a variety of methods have been proposed [40, 79, 58].
85
+
86
+ We propose an inference-time method inspired by [40] and assume a binary classifier $P ( \mathbf { e x p e r t } ^ { t } | . . . )$ that identifies whether or not the behavior is expert-level before taking an action at time $t$ . Following Bayes’ rule, the distribution of expert-level returns at time $t$ is then:
87
+
88
+ $$
89
+ P ( \mathrm { e x p e r t } ^ { t } | R ^ { t } , \ldots ) \propto \exp ( \kappa ( R ^ { t } - R _ { l o w } ) / ( R _ { h i g h } - R _ { l o w } ) )
90
+ $$
91
+
92
+ where $R _ { l o w }$ is the return lower bound and $R _ { h i g h }$ is the return upper bound. Similarly to [70, 73, 74, 39], we define a binary classifier to be proportional to future return with inverse temperature $\kappa ^ { 4 }$ :
93
+
94
+ $$
95
+ P ( { \mathrm { e x p e r t } } ^ { t } | R ^ { t } , \ldots ) \equiv \exp ( \kappa R ^ { t } )
96
+ $$
97
+
98
+ This results in a simple auto-regressive procedure where we first sample high-but-plausible target returns $R ^ { t }$ according to log-probability $\log P _ { \theta } ( R ^ { t } | \ldots ) + \kappa ( R ^ { t } - R _ { l o w } ) / ( R _ { h i g h } ^ { - } - \dot { R } _ { l o w } )$ , and then sample actions according to $P _ { \theta } ( a ^ { t } | R ^ { t } , . . . )$ . See Figure 4 for an illustration of this procedure and Appendix B.3 for implementation details. It can be seen as a variation of return-conditioned policies [41, 71, 14] that automatically generates expert-level (but likely) returns at every timestep, instead of manually fixing them for the duration of the episode.
99
+
100
+ ![](images/2f572e1921eab720c534e59f8a71678e6f42ac165680d516909beb9fb93535b7.jpg)
101
+ Figure 4: An illustration of our expert-level return and action sampling procedure. $P _ { \theta } ( R | . . . )$ and $\bar { P _ { \theta } ( a | R . . . ) }$ are the distributions learned by the sequence model.
102
+
103
+ Importantly, this formulation only affects the inference procedure of the model – training is entirely unaffected and can rely on standard next-token prediction frameworks and infrastructure. While we chose this formulation for its simplicity, controllable generation is an active area of study and we expect other more effective methods to be introduced in the future. As such, our contribution is to point out a connection between problems of controllable generation in language modeling and optimality conditioning in control.
104
+
105
+ # 4 Experiments
106
+
107
+ We formulate our experiments to answer a number of questions that are addressed in following sections:
108
+
109
+ • How do different online and offline methods perform in the multi-game regime? • How do different methods scale with model size? • How effective are different methods at transfer to novel games?
110
+
111
+ • Does multi-game decision transformer improve upon training data? • Does expert action inference (Section 3.4) improve upon behavioral cloning? • Does training on expert and non-expert data bring benefits over expert-only training?
112
+
113
+ We also consider whether there are benefits to specifically using the transformer architecture in Appendix D, and qualitatively explore the attention behavior of these models in Appendix H.
114
+
115
+ # 4.1 Setup
116
+
117
+ Model Variants and Scaling. We base our decision transformer (DT) configuration on GPT-2 [12] as summarized in Appendix B.1. We report results for DT-200M (a Multi-Game DT with 200M parameters) if not specified otherwise. Other smaller variants are DT-40M and DT-10M. We set sequence length to 4 game frames for all experiments, which results in sequences of 156 tokens.
118
+
119
+ Training and Fine-tuning. We train all Multi-Game DT models on TPUv4 hardware and the Jaxline (Babuschkin et al. [7]) framework for 10M steps using the LAMB optimizer [81] with a $3 \cdot 1 0 ^ { - 4 }$ learning rate, 4000 steps linear warm-up, no weight decay, gradient clip 1.0, $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 9 9$ , and batch size 2048. For fine-tuning on novel games, we train for 100k steps with a $1 0 ^ { - 4 }$ learning rate, $1 0 ^ { - 2 }$ weight decay and batch size of 256 instead. Both regimes used image augmentations as described in Appendix B.5.
120
+
121
+ Metrics. We measure performance on individual Atari games by human normalized scores (HNS) [53], i.e. $( \mathrm { s c o r e - s c o r e } _ { \mathrm { r a n d o m } } ) / ( \mathrm { s c o r e } _ { \mathrm { h u m a n } } \mathrm { - s c o r e } _ { \mathrm { r a n d o m } } )$ , or DQN-normalized scores, i.e. normalizing by the best DQN scores seen in the training dataset instead of using human scores. To create an aggregate comparison metric across all games, we use inter-quartile mean (IQM) of humannormalized scores across all games, following evaluation best practices proposed in [2]. Due to the prohibitively long training times, we only evaluated one training seed. We additionally report median aggregate metric in Appendix E.
122
+
123
+ # 4.2 Baseline Methods
124
+
125
+ BC Our Decision Transformer (Section 3.1) can be reduced to a transformer-based Behavioral Cloning (BC) [60] agent by removing the target return condition and return token prediction. Similar to what we do for Decision Transformer, we also learn BC models at different scales (10M, 40M, 200M parameters) while keeping other configurations unchanged.
126
+
127
+ C51 DQN As a point of comparison for online performance, we use the C51 algorithm [11] which is a variant of deep $Q$ -learning (DQN) but with a categorical loss for minimizing the temporal difference (TD) errors. Following improvements suggested in Hessel et al. [30] as well as our own empirical observations, we use multi-step learning with $n = 4$ . For the single-game experiments, we use the standard convolutional neural network (CNN) used in the implementation of C51 [13]. For the multi-game experiments, we modify the C51 implementation based on a hyperparameter search to use an Impala neural network architecture [20] with three blocks using 64, 128, and 128 channels respectively with a batch size of 128 and update period of 256.
128
+
129
+ CQL For an offline TD-based learning algorithm we use conservative $Q$ -learning (CQL) [42]. Namely, we augment the categorical loss of C51 with a behavioral cloning loss minimizing $- \log \pi _ { Q } ( a | s )$ , where $( s , a )$ is a state-action pair sampled from the offline dataset and $\pi _ { Q } ( \cdot | s ) \bar { = }$ softmax $( Q ( s , \cdot ) )$ . Following the recommendations in Kumar et al. [42] we weight the contribution of the BC loss by 1 when using $100 \%$ of the offline data (multi-game training) and 4 when using $1 \%$ (single-game finetuning). For scaling experiments, we vary the number of blocks and channels in each block of the Impala: the number of blocks and channels is one of (5 blocks, 128 channels) $\approx$ 5M params, (10 blocks, 256 channels) $\approx 3 0 \mathrm { M }$ params, (5 blocks, 512 channels) $\approx 6 0 \mathrm { M }$ params, (10 blocks, 512 channels) $\approx 1 2 0 \mathrm { M }$ params.
130
+
131
+ CPC, BERT, and ACL For rapid adaptation to new games via fine-tuning, we consider representation learning baselines including contrastive predictive coding (CPC) [56], BERT pretraining [18], and attentive contrastive learning (ACL) [80]. All state representation networks are implemented as additional multi-layer perceptrons (MLPs) or transformer layers on top of the Impala CNN used in C51 and CQL baselines. CPC uses two additional MLP layers with 512 units each interleaved with ReLU activation to represent $\phi ( s )$ , which is optimized by maximizing $\phi ( s ) ^ { \top } W \phi ( s ^ { \prime } )$ of true transitions $( s , s ^ { \prime } )$ and minimizing $\phi ( s ) ^ { \top } W \phi ( { \tilde { s } } )$ where $\tilde { s }$ is a state randomly sampled from the batch (including states from other games). For BERT pretraining, we use 2 self-attention layers with 4 attention heads of 256 units each and feed-forward dimension 512, and train $\phi ( s )$ using BERT’s masked self-prediction loss on a trajectory of sequence length 16. ACL shares the same model parametrization as BERT, with the inclusion of action prediction in the pretraining objective.
132
+
133
+ # 4.3 How do different online and offline methods perform in the multi-game regime?
134
+
135
+ We compare different online and offline algorithms in the multi-game regime and their single-game counterparts in Figure 1. We find that single-game specialists are still most performant. Among multigame generalist models, our Multi-Game Decision Transformer model comes closest to specialist performance. Multi-game online RL with non-transformer models comes second, while we struggled to get good performance with offline non-transformer models. We note that our multi-game online C51 DQN median score of $68 \%$ (see Appendix E) which compares similarly to multi-game median Impala score of $70 \%$ , which we calculated from results reported by [20] for our suite of games.
136
+
137
+ We believe the apparent advantage of offline DT compared to online multi-game methods like C51 may be explained in part through classical differences between online and offline settings in RL [45]. Online methods must balance exploration with the ability to learn and generalize from experience, which could be challenging in the multi-game setting, whereas offline DT only needs to learn to distill and generalize from the fixed multi-game experience given to it (collected by specialist DQN agents [1]). Beyond the difference between online and offline, one could also argue that C51 suffers from more training instability than DT due to the use of a temporal difference (TD) loss, which we discuss in the next paragraph.
138
+
139
+ # 4.4 How do different methods scale with model size?
140
+
141
+ In large language and vision models, lowest-achievable training loss typically decreases predictably with increasing model size. Kaplan et al. [38] demonstrated an empirical scaling relationship between the capacity of a language model (NLP terminology for a next-token autoregressive generative model) and its performance (negative log likelihood on held-out data). These trends were verified over many orders of magnitude of model size, ranging from few-million parameter models to hundreds of billion parameter models.
142
+
143
+ ![](images/e46e0219b3208000eeaf756c5c28b6e400f45e9cea6d8e8bf66529595adb08a8.jpg)
144
+
145
+ ![](images/856d3573874fc9658c6d11072bd29711ec7d2381d27d5c7b8f8ecd81467d579e.jpg)
146
+ (b) Scaling of IQM scores for all novel games after fine-tuning DT and CQL.
147
+
148
+ (a) Scaling of IQM scores for all training games with different model sizes and architectures.
149
+
150
+ Figure 5: How model performance scales with model size, on training set games and novel games.
151
+ (Impala) indicates using the Impala CNN architecture.
152
+
153
+ We investigate whether similar trends hold for interactive in-game performance – not just training loss – and show a similar performance scaling trend in Figure 5a. Multi-Game Decision Transformer performance reliably increases over more than an order of magnitude of parameter scaling, whereas the other methods either saturate, or have much slower performance growth.
154
+
155
+ In contrast, in Figures 5a and 5b, we find that CQL does not improve with increased model size, and actually shows a sharp drop in the performance of larger models on the fine-tuning tasks. Temporal Difference (TD) methods suffer greater instability with larger model size in the multi-game setting, leading to this “inverse” scaling. Indeed, our attempts at other objectives closer to pure TD (C51, DQN, DDQN) led to even worse results (which we do not report). We note that similar conclusions about instability with respect to network size have been made by other work [22].
156
+
157
+ We also find that larger models train faster, in the sense of reaching higher in-game performance after observing the same number of tokens. We discuss these results in Appendix G.
158
+
159
+ # 4.5 How effective are different methods at transfer to novel games?
160
+
161
+ Pretraining for rapid adaptation to new games has not been explored widely on Atari games despite being a natural and well-motivated task due to its relevance to how humans transfer knowledge to new games. Nachum and Yang [55] employed pretraining on large offline data and fine-tunining on small expert data for Atari and compared to a set of state representation learning objectives based on bisimulation [24, 83], but their pretraining and fine-tuning use the same game. We are instead interested in the transfer ability of pretrained agents to new games.
162
+
163
+ We hence devise our own evaluation setup by pretraining DT, CQL, CPC, BERT, and ACL on the full datasets of the 41 training games with 100M steps each, and fine-tuning one model per held-out game using $1 \%$ (1M steps) from each game. The $1 \%$ fine-tuning data is uniformly sampled from the 50M step dataset without quality filtering. DT and CQL use the same objective for pretraining and fine-tuning, whereas CPC, BERT, and ACL each use their own pretraining objective and are fine-tuned using the BC objective. All methods are fine-tuned for 100,000 steps, which is much shorter than training any agent from scratch. We additionally include training CQL from scratch on the $1 \%$ held-out data to highlight the benefit of rapid fine-tuning.
164
+
165
+ Fine-tuning performance on the held-out games is shown in Figure 6. Pretraining with the DT objective performs the best across all games. All methods with pretraining outperform training CQL from scratch, which verifies our hypothesis that pretraining on other games should indeed help with rapid learning of a new game. CPC and BERT underperform DT, suggesting that learning state representations alone is not sufficient for desirable transfer performance. While ACL adds an action prediction auxiliary loss to BERT, it showed little effect, suggesting that modeling the actions in the right way on the offline data is important for good transfer performance. Furthermore, we find that fine-tuning performance improves as the DT model becomes larger, while CQL fine-tuning performance is inconsistent with model size (see Figure 5b).
166
+
167
+ ![](images/8feed4f8dab2d4154b17ad0ad18ddbe062a713669275d49fe5827cc63646fd4a.jpg)
168
+ Figure 6: Fine-tuning performance on $1 \%$ of 5 held-out games’ data after pretraining on other 41 games using DT, CQL, CPC, BERT, and ACL. All pretraining methods outperform training CQL from scratch on the $1 \%$ held-out data, highlighting the transfer benefit of pretraining on other games. DT performs the best among all methods considered.
169
+
170
+ # 4.6 Does multi-game decision transformer improve upon training data?
171
+
172
+ We want to evaluate whether decision transformer with expert action inference is capable of acting better than the best demonstrations seen during training. To do this, we look at the top 3 performing decision transformer model rollouts. We use top 3 rollouts instead of the mean across all rollouts to more fairly compare to the best demonstration, rather than an average expert demonstration. We show percentage improvement over best demonstration score for individual games in Figure 7. We see significant improvement over the training data in a number of games.
173
+
174
+ ![](images/e4d7242c79f518d76828f0cc47c08ed6745a8cbb3945686538d16f2332e1bf3b.jpg)
175
+ Figure 7: Percent of improvement of top 3 decision transformer rollouts over the best score in the training dataset. $0 \%$ indicates no improvement. Top-3 metric (instead of mean) is used to more fairly compare to the best – rather than expert average – demonstration score.
176
+
177
+ ![](images/85c346ce0d2068a080918d00dd8d90e9c12adfe4904e722d05fd2641d6b49496.jpg)
178
+ 4.7 Does optimal action inference improve upon behavior cloning?
179
+ Figure 8: Comparison of per-game scores for decision transformer to behavioral cloning. Bars indicate $\pm$ standard deviation around the mean across 16 trials. We show DQN-normalized scores in this figure for better presentations.
180
+
181
+ In Figure 1 we see that IQM performance across all games is indeed significantly improved by generating optimality-conditioned actions. Figure 8 shows the mean and standard deviation of scores across all games. While behavior cloning may sometimes produce highly-rewarding episodes, it is less likely to do so. We find decision transformer outperforms behavioral cloning in 31 out of 41 games.
182
+
183
+ # 4.8 Does training on expert and non-expert data bring benefits over expert-only training?
184
+
185
+ We believe that, comparing to learning from expert demonstrations, learning from large, diverse datasets that include some expert data but primarily non-expert data help learning and improve performance. To verify this hypothesis, we filter our training data [1] from each game by episodic returns and only preserve top $10 \%$ trajectories to produce an expert dataset (see Appendix F for details). We use this expert dataset to train our multi-game decision transformer (DT-40M) and the transformer-based behavioral cloning model (BC-40M). Figure 9 compares these models trained on expert data and our DT-40M trained on all data.
186
+
187
+ We observe that (1) Training only on expert data improves behavioral cloning; (2) Training on full data, including expert and non-expert data, improves Decision Transformer; (3) Decision Transformer with full data outperforms behavioral cloning trained on expert data.
188
+
189
+ ![](images/17c55a7243c390f84dfc606f91fe6c5aab9df04a0808a25838884f8a9c3ee1f5.jpg)
190
+ Figure 9: Comparison of 40M transformer models trained on full data and only expert data.
191
+
192
+ # 5 Conclusion
193
+
194
+ In the quest to develop highly capable and generalist agents, we have made important and measurable progress. Namely, our results exhibit a clear benefit of using large transformer-based models in multi-game domains, and the general trends in these results – performance improvements with larger models and the ability to rapidly fine-tune to new tasks – mirror the successes observed for large-scale vision and language models. Our results also highlight difficulties of online RL algorithms in handling the complexity of multi-game training on Atari. It is interesting to note that our best results are achieved by decision transformers, which essentially learn via supervised learning on sequence data, compared to alternative approaches such as temporal difference learning (more typical in reinforcement learning), policy gradients, and contrastive representation learning. This begs the question of whether online learning algorithms can be modified to be as “data-absorbent” as DT-like methods. While even our best generalist agents at times fall short of performance achieved by agents trained on a single task, this is broadly consistent with related works that have trained single models on many tasks [36, 65]. Still, our best generalist agents are already capable of outperforming the data they are trained on. We believe the trends suggest clear paths for future work – that, with larger models and larger suites of tasks, performance is likely to scale up commensurately.
195
+
196
+ Limitations. We acknowledge reasons for caution in over-generalizing our conclusions. Our results are based largely on performance in the Atari suite, where action and observation spaces are aligned across different games. It is unclear whether offline RL datasets such as Atari are of sufficient scale and diversity that we would see similar performance scaling as observed in NLP and vision benchmarks. Whether we can observe other forms of generalization, such as zero-shot adaptation, as well as whether our conclusions hold for other settings, remains unclear.
197
+
198
+ Societal Impacts. In the current setting, we do not foresee significant societal impact as the models are limited to playing simple video games. We emphasize that our current agents are not intended to interact with humans or be used outside of self-contained game-playing domains. One should exercise increased caution if extending our algorithms and methods to such situations in order to ensure any safety and ethical concerns are appropriately addressed. At the same time, the capability of decision making based on reward feedback – rather than purely imitation of the data – has the potential to be easier to align with human values and goals.
199
+
200
+ # Acknowledgements
201
+
202
+ We would like to thank Oscar Ramirez, Roopali Vij, Sabela Ramos, Rishabh Agarwal, Shixiang (Shane) Gu, Aleksandra Faust, Noah Fiedel, Chelsea Finn, Sergey Levine, John Canny, Kimin Lee, Hao Liu, Ed Chi, and Luke Metz for their valuable contributions and support for this work.
203
+
204
+ # References
205
+
206
+ [1] Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. An optimistic perspective on offline reinforcement learning. In International Conference on Machine Learning, pages 104–114. PMLR, 2020.
207
+ [2] Rishabh Agarwal, Max Schwarzer, Pablo Samuel Castro, Aaron C Courville, and Marc Bellemare. Deep reinforcement learning at the edge of the statistical precipice. Advances in Neural Information Processing Systems, 34, 2021.
208
+ [3] Michael Ahn, Anthony Brohan, Noah Brown, Yevgen Chebotar, Omar Cortes, Byron David, Chelsea Finn, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, et al. Do as i can, not as i say: Grounding language in robotic affordances. arXiv preprint arXiv:2204.01691, 2022.
209
+ [4] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. arXiv preprint arXiv:2204.14198, 2022.
210
+ [5] William H Alexander and Samuel J Gershman. Representation learning with reward prediction errors. arXiv preprint arXiv:2108.12402, 2021.
211
+ [6] Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Luciˇ c, and Cordelia Schmid. Vivit: A ´ video vision transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6836–6846, 2021.
212
+ [7] Igor Babuschkin, Kate Baumli, Alison Bell, Surya Bhupatiraju, Jake Bruce, Peter Buchlovsky, David Budden, Trevor Cai, Aidan Clark, Ivo Danihelka, Claudio Fantacci, Jonathan Godwin, Chris Jones, Tom Hennigan, Matteo Hessel, Steven Kapturowski, Thomas Keck, Iurii Kemaev, Michael King, Lena Martens, Vladimir Mikulik, Tamara Norman, John Quan, George Papamakarios, Roman Ring, Francisco Ruiz, Alvaro Sanchez, Rosalia Schneider, Eren Sezener, Stephen Spencer, Srivatsan Srinivasan, Wojciech Stokowiec, and Fabio Viola. The DeepMind JAX Ecosystem, 2020. URL http://github.com/deepmind.
213
+ [8] Osbert Bastani, Yewen Pu, and Armando Solar-Lezama. Verifiable reinforcement learning via policy extraction. Advances in neural information processing systems, 31, 2018.
214
+ [9] M. G. Bellemare, Y. Naddaf, J. Veness, and M. Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research, 47:253–279, jun 2013.
215
+ [10] Marc G Bellemare, Yavar Naddaf, Joel Veness, and Michael Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research, 47:253–279, 2013.
216
+ [11] Marc G Bellemare, Will Dabney, and Rémi Munos. A distributional perspective on reinforcement learning. In International Conference on Machine Learning, pages 449–458. PMLR, 2017.
217
+ [12] 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.
218
+ [13] Pablo Samuel Castro, Subhodeep Moitra, Carles Gelada, Saurabh Kumar, and Marc G Bellemare. Dopamine: A research framework for deep reinforcement learning. arXiv preprint arXiv:1812.06110, 2018.
219
+ [14] Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Misha Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision transformer: Reinforcement learning via sequence modeling. Advances in neural information processing systems, 34, 2021.
220
+ [15] 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.
221
+ [16] Giuseppe Cuccu, Julian Togelius, and Philippe Cudré-Mauroux. Playing atari with six neurons. arXiv preprint arXiv:1806.01363, 2018.
222
+ [17] Rishabh Dabral, Ganesh Ramakrishnan, Preethi Jyothi, et al. Rudder: A cross lingual video and text retrieval dataset. arXiv preprint arXiv:2103.05457, 2021.
223
+ [18] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
224
+ [19] 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. arXiv preprint arXiv:2010.11929, 2020.
225
+ [20] 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, pages 1407–1416. PMLR, 2018.
226
+ [21] Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pages 2052–2062. PMLR, 2019.
227
+ [22] Hiroki Furuta, Tadashi Kozuno, Tatsuya Matsushima, Yutaka Matsuo, and Shixiang Shane Gu. Coadaptation of algorithmic and implementational innovations in inference-based deep reinforcement learning. Advances in neural information processing systems, 34:9828–9842, 2021.
228
+ [23] Hiroki Furuta, Yutaka Matsuo, and Shixiang Shane Gu. Generalized decision transformer for offline hindsight information matching. arXiv preprint arXiv:2111.10364, 2021.
229
+ [24] Carles Gelada, Saurabh Kumar, Jacob Buckman, Ofir Nachum, and Marc G Bellemare. Deepmdp: Learning continuous latent space models for representation learning. In International Conference on Machine Learning, pages 2170–2179. PMLR, 2019.
230
+ [25] Caglar Gulcehre, Ziyu Wang, Alexander Novikov, Thomas Paine, Sergio Gómez, Konrad Zolna, Rishabh Agarwal, Josh S Merel, Daniel J Mankowitz, Cosmin Paduraru, et al. Rl unplugged: A suite of benchmarks for offline reinforcement learning. Advances in Neural Information Processing Systems, 33:7248–7259, 2020.
231
+ [26] Agrim Gupta, Silvio Savarese, Surya Ganguli, and Li Fei-Fei. Embodied intelligence via learning and evolution. Nature communications, 12(1):1–12, 2021.
232
+ [27] Danijar Hafner, Timothy Lillicrap, Jimmy Ba, and Mohammad Norouzi. Dream to control: Learning behaviors by latent imagination. In International Conference on Learning Representations, 2019.
233
+ [28] Danijar Hafner, Timothy Lillicrap, Ian Fischer, Ruben Villegas, David Ha, Honglak Lee, and James Davidson. Learning latent dynamics for planning from pixels. In International conference on machine learning, pages 2555–2565. PMLR, 2019.
234
+ [29] Danijar Hafner, Timothy P Lillicrap, Mohammad Norouzi, and Jimmy Ba. Mastering atari with discrete world models. In International Conference on Learning Representations, 2020.
235
+ [30] Matteo Hessel, Joseph Modayil, Hado Van Hasselt, Tom Schaul, Georg Ostrovski, Will Dabney, Dan Horgan, Bilal Piot, Mohammad Azar, and David Silver. Rainbow: Combining improvements in deep reinforcement learning. In Thirty-second AAAI conference on artificial intelligence, 2018.
236
+ [31] Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, et al. Training compute-optimal large language models. arXiv preprint arXiv:2203.15556, 2022.
237
+ [32] Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751, 2019.
238
+ [33] Wenlong Huang, Igor Mordatch, and Deepak Pathak. One policy to control them all: Shared modular policies for agent-agnostic control. In International Conference on Machine Learning, pages 4455–4464. PMLR, 2020.
239
+ [34] Eric Jang, Alex Irpan, Mohi Khansari, Daniel Kappler, Frederik Ebert, Corey Lynch, Sergey Levine, and Chelsea Finn. Bc-z: Zero-shot task generalization with robotic imitation learning. In Conference on Robot Learning, pages 991–1002. PMLR, 2022.
240
+ [35] Michael Janner, Qiyang Li, and Sergey Levine. Offline reinforcement learning as one big sequence modeling problem. Advances in neural information processing systems, 34, 2021.
241
+ [36] Lukasz Kaiser, Aidan N Gomez, Noam Shazeer, Ashish Vaswani, Niki Parmar, Llion Jones, and Jakob Uszkoreit. One model to learn them all. arXiv preprint arXiv:1706.05137, 2017.
242
+ [37] Dmitry Kalashnikov, Jacob Varley, Yevgen Chebotar, Benjamin Swanson, Rico Jonschkowski, Chelsea Finn, Sergey Levine, and Karol Hausman. Mt-opt: Continuous multi-task robotic reinforcement learning at scale. arXiv preprint arXiv:2104.08212, 2021.
243
+ [38] Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020.
244
+ [39] Hilbert J Kappen, Vicenç Gómez, and Manfred Opper. Optimal control as a graphical model inference problem. Machine learning, 87(2):159–182, 2012.
245
+ [40] Ben Krause, Akhilesh Deepak Gotmare, Bryan McCann, Nitish Shirish Keskar, Shafiq Joty, Richard Socher, and Nazneen Fatema Rajani. Gedi: Generative discriminator guided sequence generation. arXiv preprint arXiv:2009.06367, 2020.
246
+ [41] Aviral Kumar, Xue Bin Peng, and Sergey Levine. Reward-conditioned policies. arXiv preprint arXiv:1912.13465, 2019.
247
+ [42] Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative $\mathbf { q }$ -learning for offline reinforcement learning. Advances in Neural Information Processing Systems, 33:1179–1191, 2020.
248
+ [43] Vitaly Kurin, Maximilian Igl, Tim Rocktäschel, Wendelin Boehmer, and Shimon Whiteson. My body is a cage: the role of morphology in graph-based incompatible control. arXiv preprint arXiv:2010.01856, 2020.
249
+ [44] Kuang-Huei Lee, Ian Fischer, Anthony Liu, Yijie Guo, Honglak Lee, John Canny, and Sergio Guadarrama. Predictive information accelerates learning in rl. Advances in Neural Information Processing Systems, 33: 11890–11901, 2020.
250
+ [45] Sergey Levine, Aviral Kumar, George Tucker, and Justin Fu. Offline reinforcement learning: Tutorial, review, and perspectives on open problems. arXiv preprint arXiv:2005.01643, 2020.
251
+ [46] Kevin Lu, Aditya Grover, Pieter Abbeel, and Igor Mordatch. Pretrained transformers as universal computation engines. arXiv preprint arXiv:2103.05247, 2021.
252
+ [47] Clare Lyle, Mark Rowland, Georg Ostrovski, and Will Dabney. On the effect of auxiliary tasks on representation dynamics. In International Conference on Artificial Intelligence and Statistics, pages 1–9. PMLR, 2021.
253
+ [48] Corey Lynch and Pierre Sermanet. Language conditioned imitation learning over unstructured data. arXiv preprint arXiv:2005.07648, 2020.
254
+ [49] Horia Mania, Aurelia Guy, and Benjamin Recht. Simple random search provides a competitive approach to reinforcement learning. arXiv preprint arXiv:1803.07055, 2018.
255
+ [50] John McCarthy, Marvin L Minsky, Nathaniel Rochester, and Claude E Shannon. A proposal for the dartmouth summer research project on artificial intelligence, august 31, 1955. AI magazine, 27(4):12–12, 2006.
256
+ [51] Russell Mendonca, Oleh Rybkin, Kostas Daniilidis, Danijar Hafner, and Deepak Pathak. Discovering and achieving goals via world models. Advances in Neural Information Processing Systems, 34, 2021.
257
+ [52] 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.
258
+ [53] Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. nature, 518(7540):529–533, 2015.
259
+ [54] Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International conference on machine learning, pages 1928–1937. PMLR, 2016.
260
+ [55] Ofir Nachum and Mengjiao Yang. Provable representation learning for imitation with contrastive fourier features. Advances in Neural Information Processing Systems, 34, 2021.
261
+ [56] Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
262
+ [57] Pedro A Ortega, Markus Kunesch, Grégoire Delétang, Tim Genewein, Jordi Grau-Moya, Joel Veness, Jonas Buchli, Jonas Degrave, Bilal Piot, Julien Perolat, et al. Shaking the foundations: delusions in sequence models for interaction and control. arXiv preprint arXiv:2110.10819, 2021.
263
+ [58] Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. arXiv preprint arXiv:2203.02155, 2022.
264
+ [59] Emilio Parisotto, Jimmy Lei Ba, and Ruslan Salakhutdinov. Actor-mimic: Deep multitask and transfer reinforcement learning. arXiv preprint arXiv:1511.06342, 2015.
265
+ [60] Dean A Pomerleau. Efficient training of artificial neural networks for autonomous navigation. Neural computation, 3(1):88–97, 1991.
266
+ [61] 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 International Conference on Machine Learning, pages 8748–8763. PMLR, 2021.
267
+ [62] Jack W Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, et al. Scaling language models: Methods, analysis & insights from training gopher. arXiv preprint arXiv:2112.11446, 2021.
268
+ [63] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019.
269
+ [64] Maithra Raghu, Thomas Unterthiner, Simon Kornblith, Chiyuan Zhang, and Alexey Dosovitskiy. Do vision transformers see like convolutional neural networks? Advances in Neural Information Processing Systems, 34:12116–12128, 2021.
270
+ [65] Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, and Nando de Freitas. A generalist agent, 2022. URL https://arxiv.org/abs/2205.06175.
271
+ [66] Machel Reid, Yutaro Yamada, and Shixiang Shane Gu. Can wikipedia help offline reinforcement learning? arXiv preprint arXiv:2201.12122, 2022.
272
+ [67] Andrei A Rusu, Sergio Gomez Colmenarejo, Caglar Gulcehre, Guillaume Desjardins, James Kirkpatrick, Razvan Pascanu, Volodymyr Mnih, Koray Kavukcuoglu, and Raia Hadsell. Policy distillation. arXiv preprint arXiv:1511.06295, 2015.
273
+ [68] Juergen Schmidhuber. Reinforcement learning upside down: Don’t predict rewards–just map them to actions. arXiv preprint arXiv:1912.02875, 2019.
274
+ [69] Julian Schrittwieser, Ioannis Antonoglou, Thomas Hubert, Karen Simonyan, Laurent Sifre, Simon Schmitt, Arthur Guez, Edward Lockhart, Demis Hassabis, Thore Graepel, et al. Mastering atari, go, chess and shogi by planning with a learned model. Nature, 588(7839):604–609, 2020.
275
+ [70] Ross D Shachter. Probabilistic inference and influence diagrams. Operations research, 36(4):589–604, 1988.
276
+ [71] Rupesh Kumar Srivastava, Pranav Shyam, Filipe Mutz, Wojciech Jaskowski, and Jürgen Schmidhuber. ´ Training agents using upside-down reinforcement learning. arXiv preprint arXiv:1912.02877, 2019.
277
+ [72] Jianlin Su, Yu Lu, Shengfeng Pan, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. arXiv preprint arXiv:2104.09864, 2021.
278
+ [73] Emanuel Todorov. Linearly-solvable markov decision problems. Advances in neural information processing systems, 19, 2006.
279
+ [74] Marc Toussaint. Robot trajectory optimization using approximate inference. In Proceedings of the 26th annual international conference on machine learning, pages 1049–1056, 2009.
280
+ [75] Maria Tsimpoukelli, Jacob L Menick, Serkan Cabi, SM Eslami, Oriol Vinyals, and Felix Hill. Multimodal few-shot learning with frozen language models. Advances in Neural Information Processing Systems, 34: 200–212, 2021.
281
+ [76] Aaron van den Oord, Oriol Vinyals, and Koray Kavukcuoglu. Neural discrete representation learning. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pages 6309–6318, 2017.
282
+ [77] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
283
+ [78] Linting Xue, Noah Constant, Adam Roberts, Mihir Kale, Rami Al-Rfou, Aditya Siddhant, Aditya Barua, and Colin Raffel. mt5: A massively multilingual pre-trained text-to-text transformer. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 483–498, 2021.
284
+ [79] Kevin Yang and Dan Klein. Fudge: Controlled text generation with future discriminators. arXiv preprint arXiv:2104.05218, 2021.
285
+ [80] Mengjiao Yang and Ofir Nachum. Representation matters: Offline pretraining for sequential decision making. In International Conference on Machine Learning, pages 11784–11794. PMLR, 2021.
286
+ [81] Yang You, Jing Li, Sashank Reddi, Jonathan Hseu, Sanjiv Kumar, Srinadh Bhojanapalli, Xiaodan Song, James Demmel, Kurt Keutzer, and Cho-Jui Hsieh. Large batch optimization for deep learning: Training bert in 76 minutes. arXiv preprint arXiv:1904.00962, 2019.
287
+ [82] Tianhe Yu, Deirdre Quillen, Zhanpeng He, Ryan Julian, Karol Hausman, Chelsea Finn, and Sergey Levine. Meta-world: A benchmark and evaluation for multi-task and meta reinforcement learning. In Conference on Robot Learning, pages 1094–1100. PMLR, 2020.
288
+ [83] Amy Zhang, Rowan McAllister, Roberto Calandra, Yarin Gal, and Sergey Levine. Learning invariant representations for reinforcement learning without reconstruction. arXiv preprint arXiv:2006.10742, 2020.
289
+ [84] Qinqing Zheng, Amy Zhang, and Aditya Grover. Online decision transformer. arXiv preprint arXiv:2202.05607, 2022.
290
+
291
+ # Checklist
292
+
293
+ 1. For all authors...
294
+
295
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
296
+ (b) Did you describe the limitations of your work? [Yes] See Section 5
297
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 5
298
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
299
+
300
+ 2. If you are including theoretical results...
301
+
302
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
303
+
304
+ 3. If you ran experiments...
305
+
306
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes]
307
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
308
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
309
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
310
+
311
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
312
+
313
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
314
+ (b) Did you mention the license of the assets? [N/A]
315
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
316
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
317
+
318
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
319
+
320
+ 5. If you used crowdsourcing or conducted research with human subjects...
321
+
322
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
323
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
324
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/0sEIBFb4cs/0sEIBFb4cs.md ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PRACTICAL ADVERSARIAL ATTACKS ON BRAIN– COMPUTER INTERFACES
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Deep learning has been widely employed in brain–computer interfaces (BCIs) to decode a subject’s intentions based on recorded brain activities enabling direct interaction with computers and machines. BCI systems play a crucial role in motor rehabilitation and have recently experienced a significant market boost as consumer-grade products. Recent studies have shown that deep learning-based BCIs are vulnerable to adversarial attacks. Failures in such systems might cause medical misdiagnoses, physical harm, and financial damages, hence it is of utmost importance to analyze and understand in-depth, potential malicious attacks to develop countermeasures. In this work, we present the first study that analyzes and models adversarial attacks based on physical domain constraints in EEGbased BCIs. Specifically, we assess the robustness of EEGNet which is the current state-of-the-art network for embedded BCIs. We propose new methods to induce denial-of-service attacks and incorporate domain-specific insights and constraints to accomplish two key goals: (i) create smooth adversarial attacks that are physiologically plausible; (ii) consider the realistic case where the attack happens at the origin of the signal acquisition and it propagates on the human head. Our results show that EEGNet is significantly vulnerable to adversarial attacks with an attack success rate of more than $50 \%$ . With our work, we want to raise awareness and incentivize future developments of proper countermeasures.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Recent work has shown that adversarial perturbations can cause state-of-the-art (SoA) deep learning models to misbehave in various domains including vision (Szegedy et al., 2014; Goodfellow et al., 2015), NLP (Li et al., 2019a; Zhang et al., 2020), speech (Qin et al., 2019; Li et al., 2019b), and biomedicine (Finlayson et al., 2019; Han et al., 2020). Neural networks have been applied in brain–computer interfaces (BCIs) achieving impressive results (Lawhern et al., 2018; Dose et al., 2018). A BCI enables direct interactions with external devices based on brain activities, typically recorded using electroencephalographic (EEG) systems. It can provide a communication pathway for severely paralyzed patients or assist in rehabilitation (Chaudhary et al., 2016). Besides medical applications, recent developments in wearable devices have pushed BCIs towards consumer-grade products to improve life quality (Aricò et al., 2020), e.g., the Interaxon Muse headband for stress relief (Arsalan et al., 2019) or the Emotiv headset for controlling drones (Marin et al., 2020) and ground vehicles (Zhuang et al., 2021). Safety in BCI systems is paramount (Dutta, 2020; Bernal et al., 2021), because a failure would cause misdiagnoses, user frustration, or even danger while driving a wheelchair or controlling a drone, causing physical and financial damages.
12
+
13
+ Zhang & Wu (2019) were the first to show that EEG-based BCIs are vulnerable to adversarial attacks by proposing an unsupervised fast gradient sign method (FGSM) (Goodfellow et al., 2015). More recent work has proposed a more practical attack where a universal adversarial perturbation (UAP) is computed once and can be applied to all EEG trials without learning it for every new input (Liu et al., 2021). Both works assume that the acquired signals are sent to a remote compute engine, e.g., a computer, and the attacker can alter the signals during the transmission by attaching a “jamming” module between the signal preprocessing step and the classifier. Recent developments in smart edge computing (Akmandor & Jha, 2018; Beach et al., 2021) eliminate the need for data transmission, making this attack scenario inapplicable. Novel BCI solutions (Kartsch et al., 2019; Wang et al., 2020) embed the signal processing and classification directly at the sensor edge. A more practical adversarial example has been identified by Meng et al. (2021). It consists of a square-shaped signal that can be added to EEG trials before the preprocessing step. However, the attack is proposed as a backdoor key, which means that the attacker has direct access to the training dataset and pollutes it with adversarial examples, which is improbable if the attacker is not directly involved in the data acquisition or in the training of the classifier. Li et al. (2019b) have shown an attack scenario in the audio domain by considering the on-board edge processing of a wake-word detection system, where an adversarial audio trace is delivered to the environment causing denial-of-service (DoS). No similar studies can be currently found in the BCI domain.
14
+
15
+ Challenges: Designing natural attacks and modeling its propagation. Unlike in audio applications where the signal can simply propagate over-the-air and is sensed by a microphone, extra modeling is required to evaluate the signal propagation in BCIs based on the physical properties of the biological tissues. In this work, rather than assuming a “jamming” module between the preprocessing and the classification steps as in related works, we consider a more realistic and practically applicable attack scenario where the adversarial perturbations are introduced at the source of the data acquisition, as showcased in Figure 6 in Appendix A. This can be achieved, for example, via electromagnetic waves delivered to the environment (Dutta, 2020) or via transcranial current stimulation with electrical current delivered directly to the scalp (Bodranghien et al., 2017; Fertonani et al., 2015), by exploiting wearable devices, such as smart glasses or over-ear headsets (Flowneuroscience, 2021; Marin et al., 2020). The adversarial perturbations translate into electrical signals propagating over the scalp and are sensed by the electrodes in addition to the EEG signals.
16
+
17
+ To guarantee the imperceptibility of the attacks, previous works in BCIs create perturbations that are small in amplitude (Zhang & Wu, 2019; Jiang et al., 2019; Liu et al., 2021), limiting the attack success rate (ASR). Increased perturbation’s amplitude yields higher ASR (Meng et al., 2021), but makes the attack more easily detectable. Moreover, the generated perturbations are square-shaped, which is implausible for biosignals. Han et al. (2020) are the first to observe square-wave artifacts in biosignals’ attacks and propose smooth perturbations for electrocardiograms (ECGs). No similar works have been found for EEGs.
18
+
19
+ This work: Practical attacks on BCI models. To address the above technical challenges, and for analyzing the vulnerability of embedded BCI models in practical scenarios, we design a new attack algorithm that generates smooth adversarial examples based on the signals’ first derivative and model its propagation over the scalp based on a realistic head model by taking into consideration the attack source and the electrical and physical properties of the conducting tissues. This enables the creation of practically effective perturbations, that can be delivered by an external device to attack EEG-based BCIs at the source of signal acquisition. We attack the most energy-efficient network that has been embedded on microcontrollers for smart wearable BCIs called EEGNet (Lawhern et al., 2018; Schneider et al., 2020). It is a resource-friendly convolutional neural network (CNN) and is the SoA in terms of accuracy and energy-efficiency trade-off (Belwafi et al., 2018; Malekmohammadi et al., 2019; Wang et al., 2020; Schneider et al., 2020).
20
+
21
+ We evaluate our methods and show experimental results on BCIs based on the motor imagery (MI) paradigm, which is of special interest among others because it can be asynchronously self-paced without external stimuli (Freer & Yang, 2020). By imagining the movement of different body parts, the decoded intention is translated into control signals. It is widely applied in several BCI applications, such as the control of wheelchairss (Yu et al., 2018), prosthetic armss (Elstob & Secco, 2016), ground vehicles (Zhuang et al., 2021), and in communication (Brumberg et al., 2016). It has been proven to be the most difficult task to be attacked among the most common BCI paradigms (Zhang & Wu, 2019; Meng et al., 2021). We evaluate our methods by “fooling” the victim model to always predict “rest” class. This essentially yields a DoS attack, because resting-state EEG signals are generally interpreted as no subject’s intention decoded, i.e., no control action needs to be taken by the BCI system (Yu et al., 2018). While for healthy subjects it might solely cause user frustration and financial losses, for severely paralyzed patients it can lead to loss of communication and independence. We generalize our methodology to an other MI task of BCI Competition IV-2a dataset and believe that it can be easily adapted to other BCI paradigms.
22
+
23
+ Main contributions. Our main contributions are:
24
+
25
+ • We design a new method to generate smooth adversarial perturbations that are physiologically plausible and imperceptible to the human eye.
26
+
27
+ • We consider a practical scenario where the perturbation is added at the signal acquisition source and model its propagation constrained by the physical properties of the human scalp. • The first study of adversarial perturbations in BCI to consider the practical scenario of smart edge computing and physical signal propagation. We create both local and global perturbations and show that our attacks consistently achieve a success rate of $> 5 0 \%$ in different settings pointing to the significant vulnerability of the SoA embedded EEGNet.
28
+
29
+ We hope that our work raises awareness for potential risks and motivates the future development of appropriate countermeasures.
30
+
31
+ # 2 BACKGROUND
32
+
33
+ # 2.1 CLASSIFICATION IN BCIS
34
+
35
+ We first describe the commonly used approach in BCIs for classification, consisting of a preprocessing step and a classifier. The brain activity is recorded with an EEG device which samples $N _ { c h }$ channels at rate $F _ { s }$ . We define one trial $j$ as $( \mathbf { X } ^ { ( j ) } , y ^ { ( j ) } )$ , where $y ^ { ( j ) } \in \{ 0 , 1 , . . . , N _ { c l } - 1 \}$ is the true label of $N _ { c l }$ MI tasks, and $\mathbf { X } ^ { ( j ) } \in \mathbb { R } ^ { N _ { s } \times N _ { c h } }$ the multi-channel recording defined as
36
+
37
+ $$
38
+ \mathbf { X } ^ { ( j ) } : = \left( \mathbf { x } _ { 0 } ^ { ( j ) } , \mathbf { x } _ { 1 } ^ { ( j ) } , . . . , \mathbf { x } _ { N _ { c h } - 1 } ^ { ( j ) } \right) ,
39
+ $$
40
+
41
+ with $\mathbf { x } _ { i } ^ { ( j ) } \in \mathbb { R } ^ { N _ { s } }$ corresponding to the recording of the $j$ -th trial and the $i$ -th channel containing $N _ { s }$ temporal samples. For simplicity, we denote $\mathbf { X } : = \mathbf { X } ^ { ( j ) }$ and $y : = y ^ { ( j ) }$ .
42
+
43
+ The EEG recordings are often preprocessed with a band-pass filter, e.g., using a Fast Fourier Transform (FFT) filter $h _ { b p } ( \cdot )$ , before being fed to a classifier, yielding
44
+
45
+ $$
46
+ \mathbf { X } _ { b p } = H _ { b p } ( \mathbf { X } ) = \left( h _ { b p } ( \mathbf { x } _ { 0 } ) , h _ { b p } ( \mathbf { x } _ { 1 } ) , . . . , h _ { b p } ( \mathbf { x } _ { N _ { c h } - 1 } ) \right) .
47
+ $$
48
+
49
+ Finally, the preprocessed signal $\mathbf { X } _ { b p }$ is classified with a trainable model $f$ and is mapped to $\mathbf { p } : =$ $f \left( { \bf { X } } _ { b p } \right)$ , where $\mathbf { p } \in \mathbb { R } ^ { N _ { c l } }$ contains the output probabilities, e.g., originating from a softmax activation as final operation in $f$ . The model’s final prediction $\hat { y }$ is the index with the maximum score in $\mathbf { p }$ :
50
+
51
+ $$
52
+ \boldsymbol { \hat { y } } = \boldsymbol { \hat { f } } \left( \mathbf { X } _ { b p } \right) = \underset { y \in \{ 0 , \ldots , N _ { c l } - 1 \} } { \mathrm { a r g m a x } } ~ f \left( \mathbf { X } _ { b p } \right) [ y ] .
53
+ $$
54
+
55
+ # 2.2 INSTANCE-BASED ATTACKS
56
+
57
+ Instance-based attacks try to fool an EEG classifier $f$ to misclassify an EEG signal $\mathbf { X }$ to a targeted class $y _ { t }$ . In this section, we describe the attack directly on the classifier $f$ without considering the preprocessing $H _ { b p }$ ; the inclusion of the preprocessing is described in Section 3.3. We define an adversarial example as any $\mathbf { X } ^ { * } = \mathbf { X } + \mathbf { V } \in \mathbb { R } ^ { N _ { s } \times N _ { c h } }$ such that
58
+
59
+ $$
60
+ \hat { f } \left( \mathbf { X } \right) \neq \hat { f } \left( \mathbf { X } ^ { * } \right) = y _ { t } .
61
+ $$
62
+
63
+ FGSM. The FGSM (Goodfellow et al., 2015) generates an adversarial perturbation $\mathbf { V } \in \mathbb { R } ^ { N _ { s } \times N _ { c h } }$ of magnitude $\epsilon$ which points in the negative direction of a loss function’s gradient:
64
+
65
+ $$
66
+ \mathbf { V } = - \epsilon \cdot \mathrm { s i g n } \left( \nabla _ { \mathbf { X } } \cdot l \left( \mathbf { X } , y _ { t } \right) \right) ,
67
+ $$
68
+
69
+ where the loss function contains the negative log likelihood
70
+
71
+ $$
72
+ l ( \mathbf { X } , y _ { t } ) = - \log \left( { \mathbf { p } } [ y _ { t } ] \right) = - \log \left( f \left( \mathbf { X } \right) [ y _ { t } ] \right) .
73
+ $$
74
+
75
+ As $\mathbf { p }$ is the output of the softmax activation function, equation 6 becomes a cross-entropy loss which maximizes the output $\mathbf { p } [ y _ { t } ]$ while minimizing the remaining outputs.
76
+
77
+ PGD. The projected gradient descent (PGD) (Madry et al., 2018) is a variant of the basic iterative method (Kurakin et al.), generally considered to be more effective than FGSM. PGD aims to find a perturbation by iteratively taking small steps of size $\alpha$ in the gradient’s direction and projecting the resulting perturbation back to the sample’s neighborhood after each iteration. We randomly initialize the attack inside the $L _ { \infty }$ ball of radius $\epsilon$ and update the attack $\mathbf { V } _ { t + 1 }$ for any iteration $t$ with
78
+
79
+ $$
80
+ \mathbf { V } _ { t + 1 } = \mathrm { c l i p } _ { \epsilon } \left( \mathbf { V } _ { t } - \alpha \cdot \mathrm { s i g n } \left( \nabla _ { \mathbf { V } } l \left( \mathbf { X } + \mathbf { V } _ { t } , y _ { t } \right) \right) \right) ,
81
+ $$
82
+
83
+ where $\alpha$ is a step size smaller than $\epsilon$ which decays linearly with each iteration and the function $\mathrm { c l i p } _ { \epsilon } \left( \cdot \right)$ clips the signal at the maximum desired amplitude $\epsilon$ .
84
+
85
+ # 2.3 UNIVERSAL ATTACKS
86
+
87
+ UAPs have been introduced by Moosavi-Dezfooli et al. (2017) in the context of natural images, seeking to find an image-agnostic perturbation that fools the classifier on any input image. In the BCI domain (Liu et al., 2021), we seek to find a perturbation $\mathbf { V } \in \mathbb { R } ^ { N _ { s } \times N _ { c h } }$ such that
88
+
89
+ $$
90
+ \begin{array} { r } { \hat { f } \left( \mathbf { X } + \mathbf { V } \right) \neq \hat { f } \left( \mathbf { X } \right) \mathrm { f o r } ^ { * } \mathrm { m o s t } ^ { * } \mathbf { X } \sim D , } \end{array}
91
+ $$
92
+
93
+ where $D$ is the distribution of the EEG data. The UAP can be determined by optimizing the negative log-likelihood loss with respect to $\mathbf { V }$ using batch gradient descent on the trials in the training set.
94
+
95
+ # 3 MODELING PRACTICAL ATTACKS IN BCI
96
+
97
+ This section is the main contribution of the paper: we present a design of practical DoS attacks on MIBCIs that operates at the source of the signal acquisition. We propose a new method to eliminate the square wave artifacts to generate adversarial examples that are natural and physiologically plausible. The perturbation is emitted by a smart, adversarial device placed close to the ear, e.g., a smart glass or in-ear headphones, and is propagated to the individual EEG electrodes over the scalp’s skin. As can be experimentally observed on measured EEG traces (Merlet et al., 2013; Sazgar & Young, 2019), the same electrical source, e.g., electrocardiographic activities, is sensed by each EEG electrode with different degrees of attenuation and delay. We present a practical propagation model that determines the magnitude and delay for every individual electrode based on the distance along the scalp to the adversarial device. The perturbation is trained end-to-end to fool the classifier to always output “rest,” hence DoS, while respecting the spatial model and the amplitude constraints to remain imperceptible.
98
+
99
+ # 3.1 DESIGN AND ASSESSMENT OF PHYSIOLOGICALLY PLAUSIBLE ATTACKS
100
+
101
+ PGD-designed attacks on EEG tend to form perturbation signals which resemble a square-wave artifact (see Figure 2), an effect that has been observed on ECG data, too (Han et al., 2020). However, EEG signals are of random nature and can be modeled as frequency dependent stationary or nonstationary random processes (Karlekar & Gupta, 2014). To this end, we introduce a new loss term in the PGD optimization such that the perturbation resembles the random nature of EEG signals, which we achieve by promoting signal changes represented in the first order derivative. We estimate the per-channel derivative $\begin{array} { r } { \bar { { \bf V } ^ { \prime } } = ( { \bf v } _ { 0 } ^ { \prime } , { \bf v } _ { 1 } ^ { \prime } , . . . , { \bf v } _ { N _ { c h } - 1 } ^ { \prime } ) \in \mathbb { R } ^ { N _ { s } - 1 \times N _ { c h } } } \end{array}$ using the sample-wise difference:
102
+
103
+ $$
104
+ \begin{array} { r } { \mathbf { v } _ { c } ^ { \prime } [ t ] : = \mathbf { v } _ { c } [ t ] - \mathbf { v } _ { c } [ t - 1 ] \quad t \in \{ 1 , 2 , . . . , N _ { s } - 1 \} , c \in \{ 0 , 1 , . . . , N _ { c h } - 1 \} } \end{array}
105
+ $$
106
+
107
+ The additive loss term is determined by $\begin{array} { r } { l _ { 1 } ( { \bf V } ) = - \frac { \beta } { \epsilon } \sum _ { c = 1 } ^ { N _ { c h } } | | { \bf v } _ { c } ^ { \prime } | | _ { 1 } } \end{array}$ − β PNchc=1 ||v0c||1, where || · ||1 is the \`1-norm,  the maximum perturbation amplitude, and $\beta \geq 0$ a weighting factor. When designing a one-dimensional perturbation, the derivative loss becomes $\begin{array} { r } { l _ { 1 } ( \mathbf { v } ) = - \frac { \beta } { \epsilon } | | \mathbf { v } ^ { \prime } | | } \end{array}$ .
108
+
109
+ Measuring the Plausibility of Attacks None of the previous works have given quantitative measures to assess the physiological plausibility of an EEG adversarial attack. In this work, we propose data-driven measures for quantifying the naturalism of an attack. We compute either the cross correlation, the Euclidian distance, or the cosine similarity between the attacked signal and the original EEG, and average the values over the $N _ { c h }$ channels and over the samples in the dataset.
110
+
111
+ # 3.2 SPATIAL PROPAGATION MODEL
112
+
113
+ So far, a perturbation signal was designed for every individual channel. It is unrealistic for an attacker to perturb the signal for all individual channels simultaneously; hence, we consider a more practical use case where the perturbation signal $\mathbf { v } \in \mathbb { R } ^ { N _ { s } }$ is emitted from one location, e.g., from an adversarial device placed on the left side of the subject or close to the left ear. More specifically, in this study, we assume that the EEG electrode at the position T9 according to the international 10-10 system (Sch), which is the closest to the left ear, senses the largest perturbation. The signal subsequently propagates over the skin to each electrode, which results in an individual magnitude and delay depending on the distance between the adversarial device and the electrode. More formally, we model the sensed perturbation at channel $i$ and time instant $t$ as
114
+
115
+ $$
116
+ h _ { i } ( \mathbf { v } , \lambda _ { m } , \lambda _ { d } ) ( t ) : = m ( l _ { i } , \lambda _ { m } ) \cdot \mathbf { v } \left( t - d ( l _ { i } , \lambda _ { d } ) \right) ,
117
+ $$
118
+
119
+ where $m ( l _ { i } , \lambda _ { m } )$ and $d ( l _ { i } , \lambda _ { d } )$ are the magnitude and the delay respectively, both of which depend on the distance $l _ { i }$ and on characteristic parameters $\lambda _ { m }$ and $\lambda _ { d }$ . We define the resulting multi-channel perturbation $\mathbf { V } \in \mathbb { R } ^ { N _ { s } \times N _ { c h } }$ , which is added to the multi-channel EEG signal, as
120
+
121
+ $$
122
+ \begin{array} { r } { { \bf V } ( \lambda _ { m } , \lambda _ { d } ) = H ( { \bf v } , \lambda _ { m } , \lambda _ { d } ) : = \left( h _ { 0 } ( { \bf v } , \lambda _ { m } , \lambda _ { d } ) , h _ { 1 } ( { \bf v } , \lambda _ { m } , \lambda _ { d } ) , . . . , h _ { N _ { c h } - 1 } ( { \bf v } , \lambda _ { m } , \lambda _ { d } ) \right) . } \end{array}
123
+ $$
124
+
125
+ We estimate the distance $l _ { i }$ between the electrode at position T9 and the remaining, attacked positions using the 10-10 system and a head model with a radius of $8 . 7 \mathrm { c m }$ (Algazi et al., 2001). We decouple the distance-dependent modeling of the magnitude and delay, explained in the following paragraphs.
126
+
127
+ Magnitude. For modeling the magnitude, we assume that the adversarial device injects or induces a current $I$ , yielding a potential $V$ measured near T9. The current propagates over the head surface through the skin to each of the remaining attacked electrodes, which can be modeled as a cylindrical resistor with resistance
128
+
129
+ $$
130
+ R _ { i } = \frac { l _ { i } } { \sigma A } ,
131
+ $$
132
+
133
+ where $\sigma$ is the conductivity of the skin which can be in the range of [0.28, 0.87] Siemens/m (Vorwerk et al., 2019), and $A$ is the area of the skin conductor. The potential at electrode $i$ is $V _ { i } = V - I \cdot R _ { i }$ , and hence the magnitude can be described as
134
+
135
+ $$
136
+ m ( l _ { i } , \lambda _ { m } ) = 1 - \frac { V - V _ { i } } { V } = 1 - \frac { I } { V \sigma A } l _ { i } = 1 - \lambda _ { m } l _ { i } ,
137
+ $$
138
+
139
+ where we further constrain $0 \leq m ( l _ { i } , \lambda _ { m } ) \leq 1$ . The characteristic magnitude parameter $\lambda _ { m }$ represents the complex interplay between input current, voltage, conductivity, and area, covering various attack scenarios. We consider different characteristic magnitude parameters $\lambda _ { m } \in [ 1 , 1 5 ]$ . A large $\lambda _ { m }$ represents cases with large attenuation and limited propagation, i.e., a limited set of neighboring electrodes sense the perturbation. Conversely, a small $\lambda _ { m }$ covers cases with lower attenuation where the perturbation can propagate further and infects all electrodes. We consider also an intermediate case where around half of the electrodes are affected by the attack with $\lambda _ { m } = 5$ . Appendix B provides examples of the magnitude of the spatial propagation on the head model.
140
+
141
+ Delay. The propagation of a signal on the head surface yields a position-dependent phase angle or delay, as shown by experimental measurements of related studies (Plutchik & Hirsch, 1963; Qiao et al., 1994). The delay stems from a combination of resistive and capacitive components that are encountered during the propagation of the signal, which can be modeled as an RC-circuit with resistance $R$ , capacity $C$ , and time constant $\tau = R \cdot C$ that relates to the group delay. Specifically, the contacts between the electrodes and the skin are predominantly capacitive whereas the skin itself is both resistive and capacitive (Kim et al., 2010). As explained in the previous part, an increasing distance between the attacker and the target electrode yields a larger resistance $R$ . As a result, the time constant $\tau$ and the delay increase too.
142
+
143
+ Here, we model a linear distance-delay relation. We rely on a study by Plutchik & Hirsch (1963), which conducted human skin impedance and phase angle measurements by placing electrodes at an approximate distance of $1 0 \mathrm { c m }$ and applying voltages with frequencies in the range $2 { \mathrm { - } } 1 0 0 0 \mathrm { { H z } }$ . When assuming a linear frequency-phase relation in low-frequency region (Qiao et al., 1994), one can derive the group delay to be $2 . 8 \mathrm { m s }$ when considering a measured angle of $1 0 ^ { \circ }$ at $1 0 \mathrm { H z }$ . As those measurements were conducted for only one distance, we extrapolate the delay for the remaining distances using a rectified linear model:
144
+
145
+ $$
146
+ \lambda _ { d } \cdot ( l _ { i } - l _ { 0 } ) > 0 \uparrow d ( l _ { i } , \lambda _ { d } ) = \lambda _ { d } \cdot ( l _ { i } - l _ { 0 } ) + d _ { 0 } : d ( l _ { i } , \lambda _ { d } ) = 0 ,
147
+ $$
148
+
149
+ where $d _ { 0 } = 2 . 8 \mathrm { m s }$ is the delay at distance $l _ { 0 } = 1 0 \mathrm { c m }$ . The delay depends not only on the distance, but also on other parameters such as the electrode-to-skin contact, the humidity of the skin, etc. To this end, we evaluate the propagation of the attack with different characteristic delay parameters $\lambda _ { d } \in \left[ 0 . 1 , 0 . 5 6 3 \right] \mathrm { s / m }$ . With $\lambda _ { d } = 0 . 1$ we cover the cases where very little delay happens, while the largest considered $\lambda _ { d } = 0 . 5 6 3 \mathrm { s / m }$ yields a maximum delay of $0 . 1 \mathrm { s }$ at the farthest electrode T10, which is in alignment with the observed EEG measurements (Merlet et al., 2013; Sazgar & Young, 2019). Similarly to $\lambda _ { m }$ , we showcase also for an intermediate value of $\lambda _ { d } = 0 . 3$ which corresponds to a delay of $0 . 0 5 3 \mathrm { m s }$ at T10.
150
+
151
+ Algorithm 1: Generation of physiologically plausible UAP. input : $\mathbf { X } _ { t r a i n }$ , EEG training samples; $\lambda _ { m } , \lambda _ { d }$ , spatial propagation parameters; $\beta$ , weight of derivative loss term; , maximum perturbation amplitude; $G$ , number of PGD iterations; $E$ , number of epochs output :v, adversarial perturbation 1 $\mathbf { v } \mathcal { U } ( - \epsilon , \epsilon ) \in \mathbb { R } ^ { N _ { s } } ;$ ; // Initialisation 2 for $e \gets 1$ to $E$ do 3 Shuffle $\mathbf { X } _ { t r a i n }$ ; 4 for each batch $\mathbf { B } \in \mathbf { X } _ { t r a i n }$ do 5 $\alpha \frac \epsilon 2$ ; 6 for $g \gets 1$ to $G$ do 7 $\mathbf { \bar { V } } H ( \mathbf { v } , \lambda _ { m } , \lambda _ { d } ) ;$ // Spatial propagation 8 $\begin{array} { r } { \dot { \mathbf { p } } f ( H _ { b p } ( \mathbf { B } + \mathbf { V } ) ) } \end{array}$ ; // Model pass with perturbation 9 $\begin{array} { r } { \mathbf { v } \mathbf { v } - \alpha \cdot \mathrm { s i g n } ( \nabla _ { \mathbf { v } } ( l ( \mathbf { p } , y _ { r e s t } ) - \frac { \beta } { \epsilon } | | \mathbf { v } ^ { \prime } | | _ { 1 } ) ) } \end{array}$ ; // Update w/derivative 10 v ← clip (v); // PGD projection 11 $\alpha { \frac { 0 . 1 - { \frac { \epsilon } { 2 } } } { G } } \cdot g + { \frac { \epsilon } { 2 } }$ ; // Learning rate update 12 end 13 end 14 end
152
+
153
+ # 3.3 ATTACK DESIGN
154
+
155
+ We present practical DoS attacks in BCIs that respect domain constraints such as maximum amplitude, spectral distribution, physiological plausibility, and the spatial propagation of the perturbation. To this end, we formulate a general objective function that contains the spatial propagation, the preprocessing step, and the first order derivative loss term:
156
+
157
+ $$
158
+ \mathcal { L } _ { t o t } \left( \mathbf { X } , \mathbf { v } , \lambda _ { m } , \lambda _ { d } \right) = l \left( H _ { b p } \left( \mathbf { X } + H ( \mathbf { v } , \lambda _ { m } , \lambda _ { d } ) \right) , y _ { r e s t } \right) - \frac { \beta } { \epsilon } | | \mathbf { v } ^ { \prime } | | _ { 1 } ,
159
+ $$
160
+
161
+ where $l ( \cdot , \cdot )$ is the negative log-likelihood loss defined in equation 6 and $\beta { = } 1 \mathrm { e } { - } 6$ is a scalar that weights the contribution of the derivative loss term. We compare different attack scenarios:
162
+
163
+ Instance-based attacks. A perturbation is computed using either FGSM or PGD based on the knowledge of the currently attacked EEG signal $\mathbf { X }$ . FGSM computes the perturbation as stated in equation 5, where the $\epsilon$ defines the perturbation amplitude which is varied between $1 { - } 5 0 \mathrm { m V } .$ Alternatively, we compute the perturbation using PGD with $G { = } 1 0$ iterations, where each iteration consists of a gradient-based update of the perturbation and a projection to the $L _ { \infty }$ ball with radius $\epsilon$ (see equation 7). The update rate $\alpha$ is initialized with $\epsilon / 2$ and linearly decreased with each iteration, reaching a final value of $0 . 1 \mathrm { m V }$ at iteration 10. The PGD computation is restarted 5 times with different initial perturbations, which are drawn from a uniform distribution within the range $[ - \epsilon , + \epsilon ]$ .
164
+
165
+ Universal attacks. A universal perturbation is computed for all the samples in the training data. We optimize the UAP objective function
166
+
167
+ $$
168
+ \operatorname* { m i n } _ { \mathbf { v } } E _ { \mathbf { X } \sim D } \mathcal { L } _ { t o t } \left( \mathbf { X } , \mathbf { v } , \lambda _ { m } , \lambda _ { d } \right) \quad \mathrm { ~ s . t . ~ } | | \mathbf { v } | | _ { \infty } \leq \epsilon
169
+ $$
170
+
171
+ using batched PGD. We pass a batch of 16 samples together with the current perturbation through the preprocessing and classifier, compute the loss function, and update the perturbation based on the negative gradient with consecutive projection to the $L _ { \infty }$ ball with radius $\epsilon$ . This step is repeated $G { = } 1 0$ times before processing the next batch. Overall, the UAP is learned for $E { = } 1 0$ epochs.
172
+
173
+ Propagation model. We distinguish between three use cases of spatial propagation model, where in all cases either an instance-specific attack or a universal attack can be computed: Case 1) Ignore the propagation model: a multi-channel perturbation $\mathbf { V }$ is computed, which attacks each channel individually, replacing the terms $H ( \mathbf { v } , \lambda _ { m } , \lambda _ { d } )$ by $\mathbf { V }$ and $\mathbf { v } ^ { \prime }$ by $\mathbf { V } ^ { \prime }$ in equation 15. Case 2) Consider the propagation model: a single-channel perturbation v is computed and tested with a specific propagation configuration $\lambda _ { m }$ and $\lambda _ { d }$ . Case 3) Consider a use-case where the attacker does not know the spatial propagation model and computes the same perturbation $\mathbf { v }$ for all channels. The actual propagation model is applied during testing to model the real-world signal propagation.
174
+
175
+ ![](images/a1324eec3369ab8d3e852dd7a1f3de592be68aba36ad56c69f815c71827712f0.jpg)
176
+ Figure 1: Performance of random noise, FGSM, PGD, and UAP with and without derivative loss term.
177
+
178
+ Table 1: Plausibility metrics for PGD attack (a) without derivative term, (b) with the derivative loss term, and (c) with a Gaussian kernel (Han et al., 2020). The smaller the cross correlation $\eta$ and the Euclidian distance $\ell _ { 2 }$ - norm, and the higher the cosine similarity $\gamma$ , the more natural the generated attack.
179
+
180
+ <table><tr><td></td><td colspan="3">n[10-3v2]</td><td colspan="3">l2-norm [mV]</td><td colspan="3">γ[%]</td></tr><tr><td>ε[mV]</td><td>(a)</td><td>(b)</td><td>(c)</td><td>(a)</td><td>(b)</td><td>(c)</td><td>(a)</td><td>(b)</td><td>(c)</td></tr><tr><td>1</td><td>3.31</td><td>1.98</td><td>3.42</td><td>20.8</td><td>15.2</td><td>21.2</td><td>99.89</td><td>99.93</td><td>99.89</td></tr><tr><td>5</td><td>16.6</td><td>7.76</td><td>17.3</td><td>99.1</td><td>61.2</td><td>102</td><td>97.99</td><td>99.22</td><td>97.87</td></tr><tr><td>10</td><td>32.5</td><td>12.6</td><td>34.1</td><td>191</td><td>112</td><td>198</td><td>93.82</td><td>97.47</td><td>93.49</td></tr><tr><td>25</td><td>74.9</td><td>27.3</td><td>79.2</td><td>461</td><td>263</td><td>475</td><td>79.61</td><td>90.05</td><td>78.92</td></tr><tr><td>50</td><td>125</td><td>39.0</td><td>135</td><td>823</td><td>462</td><td>855</td><td>64.17</td><td>79.70</td><td>63.06</td></tr></table>
181
+
182
+ ![](images/0be065a5743b1cee7251d7d88da8df12f3001691d68088f221c3d7a7df59ba26.jpg)
183
+ Figure 2: A successful attack (a) without and (b) with derivative loss term (PGD, $\scriptstyle \epsilon = 1 0 \mathrm { m V }$ ). The background traces show the original signal before the preprocessing filter.
184
+
185
+ End-to-end algorithm. We illustrate the algorithmic procedure for designing a physiologically plausible UAP in Algorithm 1. Analogously, the proposed methods of derivative loss term and model propagation are applied with PGD. The hyperparameters $\alpha$ , $\beta$ , the number of PGD iterations and the restarts, the batch size and the number of epochs in UAP are determined based on a cross-validated grid search on the training set.
186
+
187
+ # 4 EXPERIMENTS AND RESULTS
188
+
189
+ We evaluate our methods on the Physionet EEG Motor Movement/Imagery Dataset (Goldberger et al., 2000; Sch) tackling inter-subject challenges, and generalize to subject-specific inter-session dataset IV-2a of BCI Competition (Brunner et al., 2008) (See Appendix C).
190
+
191
+ Dataset. The Physionet dataset contains valid EEG recordings of 105 subjects (Dose et al., 2018) and is publicly available under Open Data Commons Attribution License v1.0. We use the MI recordings that contain tasks of the imagination of left against right fist for $3 \mathrm { s }$ . The EEG trials were recorded with $N _ { c h } { = } 6 4$ channels sampled at $F _ { s } { = } 1 6 0 \mathrm { H z }$ , yielding $N _ { s } { = } 3 { \cdot } 1 6 0 { = } 4 8 0$ samples per trial. Additional baseline runs provide resting-state data, where the subjects did not perform any tasks while having eyes open. Overall, we get a total of 6615 trials with $N _ { c l } { = } 3$ balanced classes “left”, “right”, and “rest.”
192
+
193
+ Training and validation. We train and validate both the classification models and the generated adversarial examples with a 5-fold cross-validation, splitting the dataset into 84 subjects used for training and 21 subjects used for validation to effectively test the model on inter-subject variability. Similar to Wang et al. (2020), which achieved SoA performance on this dataset, the baseline model is trained for 100 epochs using Adam with $\beta _ { 1 } { = } 0 . 9$ , $\beta _ { 2 } { = } 0 . 9 9 9$ , and batch size of 16. The learning rate is 0.01 and decreased by a factor of 10 at epochs 20 and 50, achieving an average accuracy of $7 4 . 7 8 \%$ .
194
+
195
+ ![](images/61e50ae1624936e4724c0a3920f25f9cef6e945f75c78ede3ed08a1fb5c4512d.jpg)
196
+ Figure 3: A successful attack with derivative loss term and spatial constraints $\lambda _ { m } = 1$ and $\lambda _ { d } = 0 . 5 6 3$ (PGD, $\scriptstyle \epsilon = 5 0 \mathrm { m V }$ ). The background traces show the original signal before the preprocessing filter.
197
+
198
+ ![](images/1523c7615753b90b2c8e0e94fb41fcac116f3a3069037a001618243cb754a843.jpg)
199
+ Figure 4: ASR of PGD and UAP in Case 2), i.e., computed with head model (w/HM), and in Case 3), i.e., computed without head model (w/oHM).
200
+
201
+ ![](images/2c2e639cc82a57badda6f507c714534618e64bf003ecf1957433ac239f2e7d18.jpg)
202
+ Figure 5: ASR with the PGD attack propagating from different EEG channels with fixed $\lambda _ { d } { = } 0 . 3$ and variable $\lambda _ { m }$ .
203
+
204
+ An FFT band-pass filter $h _ { b p }$ with a customary passband of $0 . 1 { - } 4 0 \mathrm { H z }$ (Lawhern et al., 2018) is used as preprocessing step in both baseline and attack experiments.To determine the ASR, we compute the ratio between the successfully fooled trials, i.e., trials now classified as “rest”, and the total number of attacked trials, where we only consider the ones initially correctly classified as “left”/“right”.
205
+
206
+ Physiologically plausible attacks. We first analyze the instance-based attacks without considering the propagation model (Case 1), depicted in Figure 1. We compare our methods against random noise with amplitude $\epsilon$ as in (Zhang & Wu, 2019), FGSM that is the same as in (Zhang & Wu, 2019) with targeted scenario, and a UAP designed specifically for EEG (Liu et al., 2021). For both FGSM and PGD, the ASR increases together with the maximum amplitude $\epsilon$ of the perturbation. They always outperform the random noise, with PGD performing slightly better than FGSM. They reach the maximum ASR of $9 9 . 9 7 \%$ with $1 0 \mathrm { m V } .$ The post-attack classification accuracy drops from $7 4 . 7 8 \%$ to $48 \%$ for a perturbation amplitude of $2 \mathrm { m V }$ and to $33 \%$ for $1 0 \mathrm { m V }$ and higher amplitudes. Figure 2a shows the signals of a successful attack using PGD. The adversarial perturbation has a squarewave form which negatively affects the natural shape of the EEG signal. By adding the proposed derivative term, the square-wave artifacts are significantly reduced (2b), making the perturbation more physiologically plausible. When comparing the power spectral density of the original and attacked signals, the attacked signal designed without derivative presents large components in low frequencies, making it more easily detectable. Whereas the attack with derivative loss better resembles the power spectral density of the original signal (see Appendix D). Moreover, the introduction of the derivative term does not degrade the ASR (Figure 1). The quantitative measures between the original and the adversarial samples in Table 1 demonstrate that our proposed method with derivative term generates adversarial samples that are more similar to the original EEG, allowing them to remain imperceptible even with high $\epsilon$ (Appendix D). We reproduce the attacks using a Gaussian kernel as in (Han et al., 2020). After tuning the kernel size and variance of the Gaussian kernel, the method could not improve the plausibility metrics. The inferior performance of the Gaussian kernel could stem from the different nature of the signal: it was originally designed for ECGs which have a pseudo-periodic structure.
207
+
208
+ We extend the application of the derivative term to the UAP attack, while still not considering the propagation model (Case 1). Figure 1 shows a comparison in performance for different values of $\epsilon$ The saturation in ASR is reached with higher $\epsilon$ , i.e., $9 9 . 9 4 \%$ with $5 0 \mathrm { m V } .$ . This is expected since the UAP is a more difficult attack where a single set of perturbations per EEG channel is generated for all the test samples. Likewise in PGD, the ASR does not drop with the addition of the derivative term. We reproduce the UAP proposed by (Liu et al., 2021). Our UAP consistently reaches higher ASR.
209
+
210
+ Spatial Propagation. Finally, we introduce the spatial constraints in the signal propagation over the scalp (Case 2). We consider 9 different scenarios by combining 3 realistic attenuation configurations $\lambda _ { m } \ \in \ \{ 1 , 5 , 1 5 \}$ with 3 delay configurations $\lambda _ { d } \ \in \ \{ 0 . 1 , 0 . 3 , 0 . 5 6 3 \}$ , which capture the range described in Section 3.2. For evaluating the highest achievable attack efficiency, we test a scenario where the attacker is assumed to know the propagation model: the adversarial perturbation is generated and evaluated on fixed spatial parameters $\lambda _ { m }$ and $\lambda _ { d }$ , shown in Figure 4, where the ASR reaches up to $6 9 . 2 \%$ with PGD and $4 5 . 6 \%$ with UAP at $5 0 \mathrm { m V } .$ Figure 3 depicts an example of a successful attack with the highest perturbation amplitude. The introduction of the spatial constraints makes the attack problem harder yielding seldom square distortions. However, the resulting EEG signals still resemble physiological random processes typical of EEGs. Next, we ablate the spatial constraints during generation and test the resulting perturbations on the 9 above-mentioned scenarios (Case 3). The ASR drops significantly, especially for $\lambda _ { m } { = } 5$ and $\lambda _ { m } { = } 1 5$ where the attenuation of the perturbation over the scalp is greater (see Figure 7), and with the global UAP attack, where the attacker does not have access to the attacked EEG signals.
211
+
212
+ Our spatial propagation models allows us to identify the vulnerability of the individual EEG channels. Figure 5 shows the ASR when initiating an attack from a specific channel (T9, T10, etc.) and propagating it to the rest of the head. In the case with the greatest attenuation $\left( \lambda _ { m } = 1 5 \right)$ we find the maximum ASR at the electrode $\mathbf { C } \mathbf { z }$ between the regions of the electrodes C3 and C4, which are the most relevant ones for MI of the left and right hand tasks (Pfurtscheller & Lopes da Silva, 1999). We compute the pre- and post-attack confusion matrices for attacks from T9 and T10 (see Appendix E). When the attack propagates from the left side (T9), more samples with ground-truth label “right” can be fooled to “rest”, while the attacks from the right side (T10) are more effective “left” labels.
213
+
214
+ Overall, our methods successfully generates perturbations resembling natural noise in EEGs, that can be added at the source of the signal acquisition and are propagated over the scalp, creating attacked signals that are physiologically plausible. Similar results have been observed on the BCI Competition IV-2a dataset, shown in Appendix C.
215
+
216
+ # 5 CONCLUSION
217
+
218
+ With the incentive of improving security in BCIs, in this work, we demonstrated that DoS attacks are feasible and effective despite physical domain constraints. Experimental results reveal potential risks of realistic attacks on smart wearable BCIs and incentivize the need for future development of defense mechanisms while designing deep learning models to be embedded in smart wearable BCIs. Our detailed analysis on each EEG channel shows that special attention has to be paid, combined with the findings in neuroscience, to the brain regions that are found responsible for a specific task. In future work, the proposed attacks can cover uncertainty in the propagation model and the timing of the MI activity. Moreover, hardware implementations of such attacks can be created to evaluate the proposed methods in real-world, with the ultimate goal of developing effective countermeasures.
219
+
220
+ # ETHICS STATEMENT
221
+
222
+ The sore goal of this work is to raise awareness of potential adversarial attacks in BCIs and incentivize the development of coutermeasures, especially in the current moment when the BCIs are facing an increasing growth in applications of everyday life. The active development of smart wearable BCIs is introducing a paradigm shift where the processing algorithms are embedded near the data acquisition. While this improves the system security to a certain extend, with this work we have shown that it is not the only and ultimate way to a safe and reliable BCI, since we have shown that BCI systems are vulnerable also to attacks at the signals’ source. We hope that our work sheds light on the fact that practical BCI systems are vulnerable, despite the physical constraints, and motivates the design and development of more reliable and robust BCI systems.
223
+
224
+ # REPRODUCIBLITY
225
+
226
+ A link to a anonymous downloadable source code of this work is submitted as supplementary materials.
227
+
228
+ # REFERENCES
229
+
230
+ BCI2000: A general-purpose brain-computer interface (BCI) system.
231
+
232
+ Ayten Ozge Akmandor and Niraj K. Jha. Smart health care: An edge-side computing perspective. IEEE Consumer Electronics Magazine, 7(1):29–37, 2018.
233
+
234
+ Ralph Algazi, Carlos Avendano, and Richard O Duda. Estimation of a spherical-head model from anthropometry. J. Aud. Eng. Soc., 49, 2001.
235
+
236
+ Pietro Aricò, Nicolina Sciaraffa, and Fabio Babiloni. Brain–computer interfaces: Toward a daily life employment. Brain Sciences, 10(3), 2020.
237
+
238
+ Aamir Arsalan, Muhammad Majid, Amna Rauf Butt, and Syed Muhammad Anwar. Classification of perceived mental stress using a commercially available EEG headband. IEEE Journal of Biomedical and Health Informatics, 23(6):2257–2264, 2019.
239
+
240
+ Christopher Beach, Ertan Balaban, and Alexander J. Casson. Chapter 14 - edge algorithms for wearables: an overview of a truly multi-disciplinary problem. In Edward Sazonov (ed.), Wearable Sensors (Second Edition), pp. 379–414. Academic Press, Oxford, second edition edition, 2021.
241
+
242
+ Kais Belwafi, Olivier Romain, Sofien Gannouni, Fakhreddine Ghaffari, Ridha Djemal, and Bouraoui Ouni. An embedded implementation based on adaptive filter bank for brain–computer interface systems. Journal of Neuroscience Methods, 2018.
243
+
244
+ Sergio López Bernal, Alberto Huertas Celdrán, Gregorio Martínez Pérez, Michael Taynnan Barros, and Sasitharan Balasubramaniam. Security in brain-computer interfaces: State-of-the-art, opportunities, and future challenges. ACM Comput. Surv., 54(1), January 2021.
245
+
246
+ Florian C. A. A. Bodranghien, Margot Langlois Mahe, Serge Clément, and Mario U. Manto. A pilot study on the effects of transcranial direct current stimulation on brain rhythms and entropy during self-paced finger movement using the Epoc helmet. Frontiers in Human Neuroscience, 11:201, 2017.
247
+
248
+ Jonathan S. Brumberg, Jeremy D. Burnison, and Kevin M. Pitt. Using motor imagery to control brain-computer interfaces for communication. In Dylan D. Schmorrow and Cali M. Fidopiastis (eds.), Foundations of Augmented Cognition: Neuroergonomics and Operational Neuroscience, pp. 14–25, Cham, 2016. Springer International Publishing.
249
+
250
+ C Brunner, R Leeb, G R Müller-Putz, A Schlögl, and G Pfurtscheller. BCI competition 2008 - Graz data set A, 2008. URL http://bnci-horizon-2020.eu/database/data-sets.
251
+
252
+ Ujwal Chaudhary, Niels Birbaumer, and Ander Ramos-Murguialday. Brain–computer interfaces for communication and rehabilitation. Nature Reviews Neurology, 12, 08 2016.
253
+
254
+ Hauke Dose, Jakob S. Moller, Sadasivan Puthusserypady, and Helle K. Iversen. A deep learning MI - EEG classification model for BCIs. In 2018 26th European Signal Processing Conference (EUSIPCO), pp. 1676–1679. IEEE, 2018.
255
+
256
+ Anirban Dutta. Brain–computer interface spellers for communication: Why we need to address their security and authenticity. Brain Sciences, 10:139, 03 2020.
257
+
258
+ Daniel Elstob and Emanuele Secco. A low cost EEG based BCI prosthetic using motor imagery. International Journal of Information Technology Convergence and Services, 6:23–36, 02 2016.
259
+
260
+ Anna Fertonani, Clarissa Ferrari, and Carlo Miniussi. What do you feel if I apply transcranial electric stimulation? Safety, sensations and secondary induced effects. Clinical Neurophysiology, 126(11): 2181–2188, 2015.
261
+
262
+ Samuel G. Finlayson, John D. Bowers, Joichi Ito, Jonathan L. Zittrain, Andrew L. Beam, and Isaac S. Kohane. Adversarial attacks on medical machine learning. Science, 363(6433):1287–1289, 2019.
263
+
264
+ Flowneuroscience. Flow tDCS device. https://flowneuroscience.com/, 2021. Accessed: 2021-05-27.
265
+
266
+ Daniel Freer and Guang-Zhong Yang. Data augmentation for self-paced motor imagery classification with C-LSTM. Journal of Neural Engineering, 17, 01 2020.
267
+
268
+ Ary L Goldberger, Luis A N Amaral, Leon Glass, Jeffrey M Hausdorff, Plamen Ch Ivanov, Roger G Mark, Joseph E Mietus, George B Moody, Chung-Kang Peng, and H Eugene Stanley. PhysioBank, PhysioToolkit, and PhysioNet: components of a new research resource for complex physiologic signals. circulation, 101(23):e215–e220, 2000.
269
+
270
+ Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. In Proc. International Conference on Learning Representations, ICLR, 2015.
271
+
272
+ Xintian Han, Yuxuan Hu, Luca Foschini, Larry Chinitz, Lior Jankelson, and Rajesh Ranganath. Deep learning models for electrocardiograms are susceptible to adversarial attack. Nature medicine, 26 (3):360–363, 2020.
273
+
274
+ Xue Jiang, Xiao Zhang, and Dongrui Wu. Active learning for black-box adversarial attacks in EEGbased brain-computer interfaces. In 2019 IEEE Symposium Series on Computational Intelligence (SSCI), pp. 361–368, 2019.
275
+
276
+ Mandar Karlekar and Anubha Gupta. Stochastic modeling of EEG rhythms with fractional gaussian noise. In 2014 22nd European Signal Processing Conference (EUSIPCO), pp. 2520–2524, 2014.
277
+
278
+ Victor Kartsch, Giuseppe Tagliavini, Marco Guermandi, Simone Benatti, Davide Rossi, and Luca Benini. Biowolf: A sub-10-mW 8-channel advanced brain–computer interface platform with a nine-core processor and BLE connectivity. IEEE Transactions on Biomedical Circuits and Systems, 13(5):893–906, 2019.
279
+
280
+ Min Kim, Youngchang Cho, Suk-Tae Seo, Chang-Sik Son, Hee-Joon Park, and Yoon-Nyun Kim. A new method for non-invasive measurement of skin in the low frequency range. Healthcare informatics research, 16:143–8, 09 2010.
281
+
282
+ Alexey Kurakin, Ian J. Goodfellow, and Samy Bengio. Adversarial examples in the physical world. CoRR, abs/1607.02533.
283
+
284
+ Vernon J Lawhern, Amelia J Solon, Nicholas R Waytowich, Stephen M Gordon, Chou P Hung, and Brent J Lance. EEGNet: a compact convolutional neural network for EEG-based brain–computer interfaces. Journal of Neural Engineering, 15(5):056013, 7 2018.
285
+
286
+ Jinfeng Li, Shouling Ji, Tianyu Du, Bo Li, and Ting Wang. Textbugger: Generating adversarial text against real-world applications. In Proc. Network and Distributed System Security Symposium, NDSS. The Internet Society, 2019a.
287
+
288
+ Juncheng Li, Shuhui Qu, Xinjian Li, Joseph Szurley, J. Zico Kolter, and Florian Metze. Adversarial music: Real world audio adversary against wake-word detection system. In Proc. Neural Information Processing Systems (NeurIPS), pp. 11908–11918, 2019b.
289
+
290
+ Zihan Liu, Lubin Meng, Xiao Zhang, Weili Fang, and Dongrui Wu. Universal adversarial perturbations for CNN classifiers in EEG-based BCIs, 2021.
291
+
292
+ Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. In Proc. International Conference on Learning Representations (ICLR), 2018.
293
+
294
+ Alireza Malekmohammadi, Hoda Mohammadzade, Alireza Chamanzar, Mahdi Shabany, and Benyamin Ghojogh. An efficient hardware implementation for a motor imagery brain computer interface system. Scientia Iranica, 26:72–94, 2019.
295
+
296
+ Iuliana Marin, Myssar Jabbar Hammood Al-Battbootti, and Nicolae Goga. Drone control based on mental commands and facial expressions. In 2020 12th International Conference on Electronics, Computers and Artificial Intelligence (ECAI), pp. 1–4, 2020.
297
+
298
+ Lubin Meng, Jian Huang, Zhigang Zeng, Xue Jiang, Shan Yu, Tzyy-Ping Jung, Chin-Teng Lin, Ricardo Chavarriaga, and Dongrui Wu. EEG-based brain-computer interfaces are vulnerable to backdoor attacks, 2021.
299
+
300
+ Isabelle Merlet, Gwénaël Birot, Ricardo Salvador, Behnam Molaee-Ardekani, Abeye Mekonnen, Aureli Soria-Frish, Giulio Ruffini, Pedro C. Miranda, and Fabrice Wendling. From oscillatory transcranial current stimulation to scalp EEG changes: A biophysical and physiological modeling study. PLOS ONE, 8:1–12, 02 2013.
301
+
302
+ Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, Omar Fawzi, and Pascal Frossard. Universal adversarial perturbations. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), July 2017.
303
+
304
+ G. Pfurtscheller and F.H. Lopes da Silva. Event-related EEG/MEG synchronization and desynchronization: basic principles. Clinical Neurophysiology, 110(11):1842–1857, 11 1999.
305
+
306
+ Robert Plutchik and Henry R Hirsch. Skin impedance and phase angle as a function of frequency and current. Science, 141(3584):927–928, 1963.
307
+
308
+ ZG Qiao, L Mørkrid, and NK Vøllestad. Characteristics of phase angle, extrapolated conductance and ion relaxation time in the low-frequency admittance locus plot of human palmar skin. Medical and Biological Engineering and Computing, 32(2):161–167, 1994.
309
+
310
+ Yao Qin, Nicholas Carlini, Ian J. Goodfellow, Garrison W. Cottrell, and Colin Raffel. Imperceptible, robust, and targeted adversarial examples for automatic speech recognition. CoRR, abs/1903.10346, 2019.
311
+
312
+ Mona Sazgar and Michael G. Young. EEG Artifacts, pp. 149–162. Springer International Publishing, Cham, 2019.
313
+
314
+ Tibor Schneider, Xiaying Wang, Michael Hersche, Lukas Cavigelli, and Luca Benini. Q-EEGNet: an energy-efficient 8-bit quantized parallel EEGNet implementation for edge motor-imagery brainmachine interfaces. In 2020 IEEE International Conference on Smart Computing (SMARTCOMP), pp. 284–289, 2020.
315
+
316
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian J. Goodfellow, and Rob Fergus. Intriguing properties of neural networks. In Proc. International Conference on Learning Representations, ICLR, 2014.
317
+
318
+ Johannes Vorwerk, Ümit Aydin, Carsten H Wolters, and Christopher R Butson. Influence of head tissue conductivity uncertainties on EEG dipole reconstruction. Frontiers in neuroscience, 13:531, 2019.
319
+
320
+ Xiaying Wang, Michael Hersche, Batuhan Tömekce, Burak Kaya, Michele Magno, and Luca Benini. An accurate EEGNet-based motor-imagery brain–computer interface for low-power edge computing. In 2020 IEEE International Symposium on Medical Measurements and Applications (MeMeA), pp. 1–6, 2020.
321
+
322
+ Yang Yu, Yadong Liu, Jun Jiang, Erwei Yin, Zongtan Zhou, and Dewen Hu. An asynchronous control paradigm based on sequential motor imagery and its application in wheelchair navigation. IEEE Transactions on Neural Systems and Rehabilitation Engineering, 26(12):2367–2375, 2018.
323
+
324
+ Wei Emma Zhang, Quan Z. Sheng, Ahoud Abdulrahmn F. Alhazmi, and Chenliang Li. Adversarial attacks on deep-learning models in natural language processing: A survey. ACM Trans. Intell. Syst. Technol., 11(3):24:1–24:41, 2020.
325
+
326
+ Xiao Zhang and Dongrui Wu. On the vulnerability of CNN classifiers in EEG-based BCIs. IEEE Transactions on Neural Systems and Rehabilitation Engineering, 27(5):814–825, 2019.
327
+
328
+ Jiayu Zhuang, Keke Geng, and Guodong Yin. Ensemble learning based brain–computer interface system for ground vehicle control. IEEE Transactions on Systems, Man, and Cybernetics: Systems, 51(9):5392–5404, 2021.
329
+
330
+ ![](images/673d5d9efd092b4cc8e800ff6a5738b2621fff65b3be06e0ef50d295cf6a25a4.jpg)
331
+
332
+ Figure 6: Practical adversarial attack scenario in BCIs: a smart device close to the ear emits a perturbation signal which propagates over the head surface to the EEG electrodes.
333
+
334
+ ![](images/38b8a7e8b4be2758df986c7eb0277e6018207129bd99c18ee2f96bd9341afb7e.jpg)
335
+ Figure 7: Magnitude of the spatial propagation for different $\lambda _ { m }$ . The perturbation is emitted from the left side of the head and propagates over the head surface. The leftmost electrode senses the highest magnitude (red), which linearly decreases towards zero (white) with growing propagation distance and $\lambda _ { m }$ . The electrodes which sense the perturbations, i.e., magnitude ${ > } 0$ , are marked with dots. The electrodes T9, C3, C4, and T10 are labeled for reference.
336
+
337
+ # A ATTACK AT THE SOURCE OF SIGNAL ACQUISITION
338
+
339
+ Fig. 6 illustrates the new attack scenario where the perturbation is delivered to the human scalp and propagates to the sensing electrodes at the source of the signal acquisition.
340
+
341
+ # B SPATIAL PROPAGATION MODELS
342
+
343
+ Fig. 7 illustrates the magnitude of signal propagation using different propagation parameters $\lambda _ { m } =$ $\{ 1 , 5 , 1 5 \}$ . A large $\lambda _ { m }$ represents cases with large attenuation and limited propagation (e.g., attack over the air) and a small $\lambda _ { m }$ covers cases with lower attenuation where the perturbation can propagate farther (e.g., a smart glass).
344
+
345
+ # C EXPERIMENTS ON BCI COMPETITION IV-2A
346
+
347
+ Dataset. The IV-2a dataset of the BCI Competition contains recordings from nine different subjects and distinguishes between four classes of imagined movements: left and right hand, both feet, and the tongue. 22 different EEG channels were recorded, sampled at $2 5 0 \mathrm { H z }$ . The data was pre-processed with a bandpass filter between 0.1 and $4 0 \mathrm { H z }$ . Each subject completed two recording session on two different days, where the first session is used for training and the second for testing as per the rules of the competition. Each session contains 288 trials.
348
+
349
+ Training and validation. We train a separate baseline model per subject using Adam optimizer with $\beta _ { 1 } { = } 0 . 9$ and $\beta _ { 2 } { = } 0 . 9 9 9$ , a batch size of 32, and 500 epochs. The learning rate is 0.001 achieving an average accuracy of $7 1 . 7 9 \%$ . This dataset does not contain the rest class. We choose to design an attack that aims to fool the classifier to always predict “tongue.” Moreover, we apply a maximum perturbation amplitude of $\epsilon \in [ 0 . 0 1 , 1 0 ] \mathrm { m V }$ due to the lower signal amplitude encountered in this dataset.
350
+
351
+ Results. Fig. 8 compares the ASR of different attacks without considering the propagation model (Case 1). Generally, a minimal perturbation amplitude of $1 \mathrm { m V }$ and $2 \mathrm { m V }$ suffices to achieve $100 \%$ ASR with PGD and UAP, respectively. The addition of the derivative loss term does not give any performance degradation in terms of the ASR. The average post-attack classification accuracy drops from $7 1 . 7 9 \%$ to $50 \%$ for a perturbation amplitude of $0 . 1 5 \mathrm { m V }$ and $2 4 . 7 \%$ for $0 . 6 \mathrm { m V }$ and higher amplitudes, when PGD with derivative is used.
352
+
353
+ ![](images/2754d89a4671045e54c9d9a042e28c5bfceebb00058d60cea27bd8868f79baae.jpg)
354
+ Figure 8: ASR on BCI Competition IV-2a with random noise, FGSM, PGD, and UAP with and without derivative loss term.
355
+
356
+ Fig. 9 shows the ASR for different propagation parameters $\lambda _ { m }$ and $\lambda _ { d , }$ ) and maximum perturbation amplitudes $\epsilon$ . When considering the head model during the design of the attack (Case 2, w/HM), both PGD and UAP reach significantly higher ASR compared to attacks designed without the consideration of the head model (Case 3, w/oHM).
357
+
358
+ # D PLAUSIBILITY OF ATTACKS
359
+
360
+ This section provides power spectral density plots of original signals and attacked signals with and without the derivative loss term, shown in Figure 10. The power spectral density is determined by computing the magnitude squared Fast Fourier Transform of the signals that were illustrated in Figure 2. The attack designed with the derivative loss term has a similar distribution as the original signal, where as the attack without derivative shows large contributions in the low frequency domain $( < 5 \mathrm { H z } )$ , which were not present in the original signal. These low-frequency components stem from the square-wave shaped attack and can be used as a way to detect the attack; hence, this attack cannot be considered imperceptible.
361
+
362
+ Moreover, Figure 13 shows the attacks with and without derivative loss term with increasing maximum amplitude . We can see that for low amplitudes ( $\mathrm { 1 m V }$ and $5 \mathrm { m V }$ ) the generated attacks with and without derivative still look like EEGs. At $1 0 \mathrm { m V } ,$ the attack generated without derivative presents minor square-wave artifacts, which could be still imperceptible to a non-expert. With $2 5 \mathrm { m V }$ and $5 0 \mathrm { m V } ,$ , the ones generated without derivative have strong and perceptible square-wave displacements, while the ones generated with our proposed method can still be mistaken as real EEG signals. While with the instance-based attacks, it is not necessary to have more than $1 0 \mathrm { m V }$ to get a very high ASR (see Figure 1), with the universal attacks and physical constraints, the ASR increases with increasing perturbation amplitude (see Figure 4).
363
+
364
+ The same observations can be drawn from the plausibility metrics, which have been proposed for the first time in this paper to assess quantitatively the EEG attacks. For example, looking at the cosine similarity $( \gamma )$ in Table 1, without the derivative loss term, $\gamma$ drops to $9 7 . 9 9 \%$ with $\epsilon = 5 \mathrm { m V } ,$ , whereas, with the derivative, $\gamma$ drops to about the same value of $9 7 . 4 7 \%$ with $\epsilon = 1 0 \mathrm { m V } ,$ yielding an increase in ASR from $85 \%$ $\mathrm { 5 m V ) }$ to $9 9 \%$ $\mathrm { 1 0 m V ) }$ shown in Figure 1 with PGD.
365
+
366
+ ![](images/ce3b790a23a18be77d8726d791255034fbb41f1cf3028b470ccdc8576c9d615a.jpg)
367
+ Figure 9: Results on BCI Competition IV-2a. ASR of PGD and UAP in Case 2), i.e., computed with head model (w/HM); and in Case 3), i.e., computed without head model (w/oHM).
368
+
369
+ ![](images/24bbf9586d061f5fa7fa0a1b21aa8350f5c5b44b459c9cb84b74008f7c705ba6.jpg)
370
+ Figure 10: Power spectral density comparison of the attack with and without derivative loss term, as well as the original signal shown in Figure 2.
371
+
372
+ # E CLASSIFICATION CONFUSION MATRICES
373
+
374
+ We analyze the confusion matrices before and after the proposed attack. Fig. 11 shows the confusion matrix of EEGNet on the Physionet dataset before the attack, where all classes can be classified with similar accuracy $( 7 2 . 8 \% - 7 3 . 5 \% )$ . Fig. 12 shows the confusion matrices for three different propagation parameters $( \lambda _ { m } \in \{ 1 , 5 , 1 5 \} )$ and two attack positions (T9 and T10) which correspond to the left and right side of the head. When considering the attacks from the left side, shown in Fig. 12a–12c, more samples with ground-truth label “right” can be fooled to “rest”. This is particularly articulated in largely attenuated propagation model $\lambda _ { m } { = } 1 5 )$ . In a similar vein, attacks coming from the right side of the head (T10) are more effective on data with ground-truth label “left” (Fig. 12d–12f).
375
+
376
+ ![](images/1ea1613670bc55b7d890555d5cc7a5add225bf73d62460f527b51eaf42cf5122.jpg)
377
+ Figure 11: Confusion matrix original EEG predictions on Physionet dataset.
378
+
379
+ ![](images/f736298343192e93d83223443cacb3b79a8f52cbc4fc153ebd24626308f0133e.jpg)
380
+ Figure 12: Confusion matrices for the Physionet dataset after attacking EEGNet with the proposed PGD attack with derivative and considering the spatial propagation. The attack is either performed from the left electrode (T9) or from the right electrode (T10). We consider different magnitude propagation parameters $\lambda _ { m }$ and a constant delay parameter $\lambda _ { d } { = } 0 . 3$ .
381
+
382
+ ![](images/6345909357cc6d546532e1d948e55cd4d914328dd323e1190fe1921adc19c884.jpg)
383
+ Figure 13: A successful PGD attack on Physionet dataset (i) without and (ii) with derivative with different values of maximum amplitude $\epsilon$ .
md/dev/0xiJLKH-ufZ/0xiJLKH-ufZ.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/10uNUgI5Kl/10uNUgI5Kl.md ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # REWARD DESIGN WITH LANGUAGE MODELS
2
+
3
+ Minae Kwon, Sang Michael Xie, Kalesha Bullard†, Dorsa Sadigh Stanford University, DeepMind† {minae, xie, dorsa}@cs.stanford.edu, ksbullard@deepmind.com†
4
+
5
+ # ABSTRACT
6
+
7
+ Reward design in reinforcement learning (RL) is challenging since specifying human notions of desired behavior may be difficult via reward functions or require many expert demonstrations. Can we instead cheaply design rewards using a natural language interface? This paper explores how to simplify reward design by prompting a large language model (LLM) such as GPT-3 as a proxy reward function, where the user provides a textual prompt containing a few examples (few-shot) or a description (zero-shot) of the desired behavior. Our approach leverages this proxy reward function in an RL framework. Specifically, users specify a prompt once at the beginning of training. During training, the LLM evaluates an RL agent’s behavior against the desired behavior described by the prompt and outputs a corresponding reward signal. The RL agent then uses this reward to update its behavior. We evaluate whether our approach can train agents aligned with user objectives in the Ultimatum Game, matrix games, and the DEALORNODEAL negotiation task. In all three tasks, we show that RL agents trained with our framework are well-aligned with the user’s objectives and outperform RL agents trained with reward functions learned via supervised learning. Code and prompts can be found here.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Autonomous agents are becoming increasingly capable with the rise of compute and data. This underscores the importance for human users to be able to control what policies the agents learn and ensure the policies are aligned with their objectives. For instance, imagine training an agent to represent users in a salary negotiation. A working mother fighting for a livable wage may want their agent to be stubborn whereas a new hire looking to develop a good relationship with the company may want their agent to be more versatile.
12
+
13
+ Currently, users specify desired behaviors by 1) designing reward functions or 2) providing large amounts of labeled data. Both approaches are challenging and impractical for different reasons. Designing reward functions is not an intuitive way to specify preferences. For instance, it isn’t straightforward how to write a reward function for a “versatile” negotiator. Furthermore, designing reward functions that balance between different objectives — also known as the “reward design problem” — is notoriously difficult because agents are susceptible to reward hacking (Amodei et al., 2016; Hadfield-Menell et al., 2017). On the other hand, one can learn a reward function from labeled examples. However, that is not possible with a single example; we need large amounts of labeled data to capture the nuances of different users’ preferences and objectives, which has shown to be costly (Zhang et al., 2016). Additionally, both approaches do not generalize well to new users who have different objectives — we would have to re-design our reward functions or re-collect data.
14
+
15
+ Our aim is to create an easier way for users to communicate their preferences, where the interface is more intuitive than crafting a reward function and where they can cheaply specify their preferences with no more than a few examples. To do this, we leverage large language models (LLMs) that are trained on internet-scale text data and have shown an impressive ability to learn in-context from few or zero examples (Brown et al., 2020). Our key insight is that
16
+
17
+ The scale of data that LLMs have been trained on make them great in-context learners and also allows them to capture meaningful commonsense priors about human behavior. Given a few examples or a description demonstrating the user’s objective, an LLM should be able to provide an accurate instantiation of reward values on a new test example, allowing for easier generalization to new objectives.
18
+
19
+ To this end, we explore how to prompt an LLM as a proxy reward function to train RL agents from user inputs. In our approach, the user specifies an objective with a natural language prompt. Objectives can be specified with a few examples when they are difficult to define (such as “versatility”) or as a single phrase when they are well-known concepts (such as “Pareto-optimality”). We use the prompt and the LLM to define a reward function for training an RL agent. The LLM takes the user prompt and a trajectory from an RL episode as input and outputs a score (e.g., “No” or $\ " { } 0 \ " { }$ ) for whether the trajectory satisfies the user’s objective, which we parse as an integer reward for the RL agent (Figure 1).
20
+
21
+ ![](images/4d357745dfacf87e4d77f974ecc34842b5bd5df46781e597ec75dd1e0114449e.jpg)
22
+ Figure 1: Depiction of our framework on the DEALORNODEAL negotiation task. A user provides an example and explanation of desired negotiating behavior (e.g., versatility) before training. During training, (1) we provide the LLM with a task description, a user��s description of their objective, an outcome of an episode that is converted to a string, and a question asking if the outcome episode satisfies the user objective. (2-3) We then parse the LLM’s response back into a string and use that as the reward signal for the Alice the RL agent. (4) Alice updates their weights and rolls out a new episode. (5) We parse the episode outcome int a string and continue training. During evaluation, we sample a trajectory from Alice and evaluate whether it is aligned with the user’s objective.
23
+
24
+ There are two advantages to prompting LLMs as a proxy reward function: (1) we can leverage LLM’s in-context learning abilities and prior knowledge on human behavior so that users only need to provide a handful of example desirable behaviors and (2) users can specify their preferences intuitively using language. On the other hand, a potential disadvantage is that it is unclear how much prompt design will be required for the LLM to reliably infer user intent (see Sec. 5 for a discussion). The goal of this paper is to explore how well LLMs can train objective-aligned agents by providing reward signals, and empirically examine whether we can do so with no more than a few examples. Our contributions are as follows:
25
+
26
+ • We introduce the idea of using LLMs as a proxy reward function.
27
+ • We propose a general RL training framework that leverages this proxy reward and is agnostic to the RL algorithm used.
28
+ • We show that an LLM can more accurately train objective-aligned RL agents by an average of $3 5 \%$ compared the baseline. We use few-shot prompting for the Ultimatum Game and DEALORNODEAL negotiation task as well as zero-shot prompting in Matrix Games.
29
+ • We conduct a pilot study with 10 human users. Users rate our agent to be significantly more aligned with their objective than an agent trained with a different one, $p { < } 0 . 0 0 1$ .
30
+ • We provide further analysis quantifying the amount of user data required for our approach as well as the effect varying prompts has on the LLM’s reward signal accuracy.
31
+
32
+ # 2 RELATED WORK
33
+
34
+ Using Language for Reward Shaping. Recent Reinforcement Learning from Human Feedback (RLHF) works Ouyang et al. (2022); Bai et al. (2022) use LLMs as rewards by fine-tuning them on large amounts of user data. Our work does not fine-tune LLMs but uses in-context learning from only a handful of user data.
35
+
36
+ Several works Goyal et al. (2019); Carta et al. (2022); Mirchandani et al. (2021) shape rewards by training an RL agent to learn and complete intermediate tasks guided by language. In contrast, our framework does not focus on generating subtasks but leverages the in-context learning abilities of an LLM to determine whether an agent’s policy satisfies the higher-level task.
37
+
38
+ RL and Foundation Models. We leverage large language models such as GPT-3 (Brown et al., 2020) to learn a proxy reward function while avoiding the need for many expert demonstrations. Ahn et al. (2022); Huang et al. (2022) use an LLM to provide a plan which guides a robot with reasonable/feasible actions towards a human goal (e.g., with enumerating subtasks). In contrast, our work is different in that we are using an LLM to identify if a behavior satisfies “hard-to-specify” properties of a human’s objective and also offers users more control over how they want their policy to be executed. In the vision domain, Parisi et al. (2022) used pre-trained vision models as a feature extractor for the learned policy, but not to design a reward signal. In a similar spirit of leveraging self-supervised pre-training to design a flexible reward function, Chen et al. (2021) use a broad dataset of human videos and a small dataset of robot videos to train a reward function, which improves generalization to new environments and tasks. The interface for the desired task is a video of the task to be completed, instead of text in our framework, and the domain is restricted to robot tasks. More related works can be found in Sec. A.2.
39
+
40
+ # 3 USING LLMS AS A REWARD SIGNAL
41
+
42
+ Our goal is to use an LLM as a proxy reward function to train objective-aligned RL agents from user inputs. We formalize the task using a Markov Decision Process $\mathcal { M } { = } \langle S , \mathcal { A } , p , \mathcal { R } , \gamma \rangle$ , where $s$ is the state space (e.g., in DEALORNODEAL, the space of representations of utterances in the negotiation so far), $\mathcal { A }$ is the action space (e.g., set of all possible utterances), $p { : } S \times \mathcal { A } \times \mathcal { S } [ 0 , 1 ]$ is the transition probability, and $\gamma$ is the discount factor. Traditionally the reward function maps states and actions to a real number $\mathcal { R } : \mathcal { S } \times \mathcal { A } \mathbb { R }$ In our work, we use an LLM as a proxy reward function that takes in a text prompt and outputs a string. We define $A ^ { * }$ to be the set of all strings, $\rho \in A ^ { * }$ as our text prompt (input to the LLM) and the LLM as a function $L L M { \mathrel { : } } A ^ { * } { \mathrel { \to } } A ^ { * }$ . As illustrated in Fig. 1, the prompt $\rho$ is a concatenation of four components including a string to describe the task $\rho _ { 1 } \in A ^ { * }$ and a user-specified string that describes their objectives using examples or a description, $\rho _ { 2 } \in A ^ { * }$ . Additionally, we include a textual description of states and actions from an RL episode, $\rho _ { 3 }$ , using a parser $f : { \cal S } \times { \cal A } { \cal A } ^ { * }$ . $\rho _ { 3 }$ can describe the final state, final action, a trajectory, or any other representation of the episode. Finally, we include a question $\rho _ { 4 } \in A ^ { * }$ that asks whether the RL agent’s behavior, $\rho _ { 3 }$ , satisfies the user’s objective, $\rho _ { 2 }$ . We define an additional parser $g \colon A ^ { * } \to \{ 0 , 1 \}$ that maps the textual output of $L L M$ to a binary value. We use this as the reward signal. Our framework replaces the traditional reward function with a proxy reward, $L L M$ , and can be used with any RL training algorithm.
43
+
44
+ Our framework is depicted in Fig. 1. Before training, a user specifies $\rho _ { 2 }$ which can be $N$ examples describing their objective or a description of their objective using natural language. In Fig. 1 a user provides an example of their objective: versatile negotiating behavior. During training, we construct a prompt $\rho$ by concatenating a description of the task, the user-specified examples/description, an episode’s outcome, and a question asking if the outcome satisfies the objective. We (1) feed the prompt to the LLM, (2) take its output, and (3) parse it into an integer using function $g$ ; we use a handcrafted, task-specific parser. We use the integer as the reward signal. (4) The RL agent then updates its weights and rolls out an episode. (5) We parse the episode outcome into a string using $f$ and continue training; we also instantiate $f$ as handcrafted, task-specific parser. To evaluate our framework, we sample a trajectory (e.g., a negotiation) from the agent and evaluate whether the trajectory is aligned with the user’s objective (e.g., whether Alice demonstrated versatile negotiating behavior).
45
+
46
+ # 4 EXPERIMENTS
47
+
48
+ In this section we investigate three questions to determine the feasibility and efficacy of our approach: (Q1) Can LLMs produce reward signals that are consistent with user objectives from a few examples (few-shot prompting)? (Q2) When objectives are well-known, can LLMs produce objective-consistent reward signals without any examples (zero-shot prompting)? (Q3) Can LLMs provide objective-aligned reward signals from examples (few-shot prompting) in more complex, longer-horizon domains? We evaluate our approach on three tasks: the Ultimatum Game, 2-player Matrix Games, and the DEALORNODEAL negotiation task (Lewis et al., 2017). We address (Q1) using the Ultimatum Game. We use Matrix Games to address (Q2) because it has well-known solution concepts such as Pareto-optimality. The
49
+
50
+ DEALORNODEAL negotiation task is a longer-horizon domain where the LLM rewards agents for negotiating in a user-specified style; we address (Q3) in this task.
51
+
52
+ In practice, we do not have access to ground truth user reward functions — this is the function that we are trying to approximate. However, for most of our experiments, we assume access to the true reward by constructing user reward functions that humans have been shown to have inspired by prior work. We use the true rewards only to evaluate our framework’s performance. Finally, we include a pilot user study where we evaluate agent performance when we do not have access to the ground truth reward. We use the ‘text-davinci-002’ GPT-3 model with temperature 0 as our LLM and our results are reported across 3 random seeds. Details on how we trained RL agents for each task are in A.4. s
53
+
54
+ Evaluation Metrics. We evaluate our approach using the following metrics across our tasks (task-specific metrics are described within each subsection):
55
+
56
+ Labeling Accuracy. We construct ground-truth reward functions for each domain. We report the mean accuracy of predictions of the reward value during RL training with respect to the ground-truth reward functions. This assesses how effectively the LLM can produce reward signals that are consistent with the user’s objective.
57
+
58
+ RL Agent Accuracy. After RL training, we evaluate the learned policy with respect to the ground truth reward functions. We report the mean accuracy of RL agents.
59
+
60
+ # Baselines.
61
+
62
+ SL (Few-shot baseline). A supervised learning (SL) model trained to predict reward signals using the same examples given to the LLM in our framework. Examples are represented using structured non-text inputs, making it an easier problem for the SL model. This baseline only applies to tasks where we use few-shot prompting (Ultimatum Game, DEALORNODEAL). See A.5 for details on training and model architecture for each task.
63
+
64
+ No Objective (Zero-shot baseline). In our zero-shot task, Matrix Games, we do not use any examples so we do not use SL as a baseline. Instead, we use a No Objective baseline where we prompt the LLM without using the user’s description of their objective to isolate the effect the description has on the LLM’s response.
65
+
66
+ RL trained with Ground Truth Reward Functions. RL agents trained with ground truth reward functions.
67
+ We use this as an oracle.
68
+
69
+ 4.1 ULTIMATUM GAME: TRAINING OBJECTIVE-ALIGNED AGENTS WITH FEW-SHOT PROMPTING
70
+
71
+ When defining a precise objective is difficult, we can instead give a few examples of desired behavior. For instance, in a resource division game like the Ultimatum Game, it may be difficult for a user to specify the exact percentage (such as $3 2 . 4 \%$ ) of resources they would be happy with receiving. Instead it could be easier for a user to give examples of splits that they would be happy with. We explore whether LLMs can produce reward signals that are consistent with user objectives from a few examples in the Ultimatum Game.
72
+
73
+ Task Description. The Ultimatum Game consists of two players, a Proposer and a Responder. A sum of money is endowed to the Proposer and they must propose a way to split the endowment with the Responder. The Responder can accept or reject the proposed split. If the Responder accepts, players receive money as per the split; if the Responder rejects, then both players get nothing. We train an RL agent to play the Responder. The agent learns to reject proposals according to a user’s preferences. The game consists of a single timestep and our RL agents are trained using DQN for 1e4 steps.
74
+
75
+ Ground Truth User Objectives. A rational Responder would accept any proposal, even if it is unfair because getting something is better than getting nothing (in fact, this is a Nash Equilibrium of the game). However, prior work in behavioral economics shows that humans are willing to “punish” the Proposer by rejecting unfair proposals (Vavra et al., 2018). For instance, a student may reject an unfair proposal only if she receives less than $30 \%$ of the endowment whereas a wealthier person may reject if they receive less than $60 \%$ . We experiment with the following preferences:
76
+
77
+ • Low vs High Percentages. Users will reject proposals if they receive less than $( 3 0 \%$ , $6 0 \% \}$ of the endowment.
78
+ • Low vs High Payoffs. Users will reject unfair proposals if they receive less than $\{ \$ 10,4100 \}$ . They accept unfair proposals otherwise.
79
+
80
+ ![](images/5554a8306018ca0c9c21790adcde59541b3517880405b9f852f19fbc9b381a9b.jpg)
81
+ Figure 2: Ultimatum Game, Few-shot. (Top) Accuracy of reward signals provided by LLM and SL during RL training when prompted with/trained on 10 vs 1 example. (Bottom) Corresponding accuracy of RL agents after training. LLM is able to maintain a high accuracy when prompted with a single example followed by an explanation. We do not provide figures of Inequity Aversion because both LLM and SL trivially achieve perfect labeling and RL agent accuracy.
82
+
83
+ • Inequity Aversion (Fehr & Schmidt (2010)). Users will reject proposals if they do not receive exactly $5 0 \%$ of the endowment.
84
+
85
+ Prompt Design. We describe a user’s objective using 10 examples of the Ultimatum Game. An example consists of the proposed split, the Responder’s action, and a “yes/no” label of whether the Responder’s action was desirable or undesirable. These examples do not have explanations and resemble a traditional dataset used for supervised learning. We also experiment with using a single example followed by a short explanation. Importantly, we do not explicitly mention the user’s ground truth objective in the prompt. See Fig. 10 in the Appendix for an example of both types of prompts.
86
+
87
+ Design Procedure. We randomly generated 10 proposed splits used for our prompt and sampled one proposal from the set for our single-example case. For Low vs High Percentages and Low vs High Payoffs, we used the same set of proposals across variants (i.e., same proposals for $30 \%$ and $60 \%$ ) and $( \$ 10$ , $\$ 100)$ ). We also randomly generated 50 proposals used to evaluate the LLM. Due to limited resources when querying GPT-3, we query the model’s responses to the 50 evaluation splits in a batched manner and save them. We then use those responses as the reward signal.
88
+
89
+ # 4.1.1 RESULTS
90
+
91
+ Labeling Accuracy. We evaluated our approach on our test set of 50 proposals over 3 seeds; results are shown in Fig. $\cdot$ . When prompted with 10 examples without explanations, the LLM and SL perform similarly well (see Fig. 2, top row). This result is not surprising, given that the decision boundary for the binary decision tasks is relatively simple to learn with 10 training examples.
92
+
93
+ Instead, if we prompt the LLM with a single example followed by an explanation, it maintains a high accuracy whereas SL trained on the same, single example drops in accuracy. We did not use the explanation as part of input when training SL because it only takes non-textual inputs. This result highlights the advantage of using an LLM over a supervised learning model: they require far fewer examples because they can learn from explanations (Lampinen et al., 2022). We find that explanations are critical, as removing explanations when prompting the LLM with a single example results in a drop in LLM labeling accuracy (avg. drop of $3 1 . 6 7 \%$ ) and a drop in RL agent accuracy (avg. drop of $2 8 . 8 \%$ ).
94
+
95
+ RL Agent Accuracy. The accuracy of the trained RL agents mirror the labeling accuracy.
96
+
97
+ Summary. LLMs are efficient in-context learners. They are able to provide reward signals that are consistent with a user’s objectives from examples — even a single example with an explanation will suffice.
98
+
99
+ 4.2 MATRIX GAMES: TRAINING OBJECTIVE-ALIGNED AGENTS WITH ZERO-SHOT PROMPTING
100
+
101
+ When objectives are well-known concepts such as Pareto-optimality, can we prompt the LLM without giving any examples? We hypothesize that well-known objectives are likely to be in-distribution for LLMs, and thus LLMs may be able to produce objective-aligned reward signals from zero-shot prompting. Since we do not use examples, we do not use a SL baseline. Instead we use a baseline No Objective where we do not mention any objectives and ask the LLM for a reward signal (see example in Fig. 11 in the Appendix). This baseline evaluates whether the LLM can successfully apply its knowledge of each objective.
102
+
103
+ ![](images/6f2f78c08eb7a4cd75c7b78807517333e6a2477ab0ce57631d8946cca7d5e2af.jpg)
104
+ Figure 3: Matrix Games, Zero-shot. (Top) Accuracy of reward signals provided by LLM and a No Objective baseline during RL training. We report results for both regular and scrambled versions of matrix games. (Bottom) Accuracy of RL agents after training.
105
+
106
+ Task Description. We consider two-player normal-form matrix games: Battle of the Sexes, Stag Hunt, Chicken, and Prisoner’s Dilemma. Each matrix game has four joint outcomes (i.e., a tuple of joint actions and rewards) and we address pure strategies in this task. The game consists of a single timestep and our RL agents are trained using DQN for 500 steps.
107
+
108
+ Ground Truth User Objectives. Although (mixed) Nash Equilibria are traditional solution concepts for normal form matrix games, users may prefer a solution for other properties. For instance, in Prisoner’s Dilemma, users may prefer both agents to cooperate because they will maximize total welfare even though it is not a Pure Nash Equilibrium. We experiment with four well-known solution concepts (or objectives):
109
+
110
+ • Total Welfare. Outcomes that achieve the greatest sum of player rewards.
111
+ • Equality. Outcomes that result in equal rewards between players.
112
+ • Rawlsian Fairness. Outcomes that maximize the minimum reward any player receives.
113
+ • Pareto-optimality. Outcomes where the one of the corresponding rewards cannot be improved without lowering the other.
114
+
115
+ Prompt Design. Prompts for each solution concept are shown in Fig. 11 in the Appendix. Due to limited resources with querying GPT-3, we queried GPT-3 in a batched manner and saved the corresponding labels to train our RL agents. Our prompt enumerates the outcomes of a matrix game and then asks the LLM for the outcome(s) that satisfy a solution concept. We do not mention the name of the matrix game in the prompt. As in Kojima et al. (2022), we elicit intermediate reasoning steps by asking the LLM to “think step-by-step” and provide a definition of the solution concept. To prevent any bias the LLM may have towards the order in which the outcomes of a matrix game are presented, we also randomly scramble associations between joint actions and rewards (example shown in Fig. 12 in the Appendix).
116
+
117
+ Design Procedure. We tuned the wording of our prompt (e.g., how to describe the matrix game, whether or not to use chain-of-thought prompting) on the Battle of the Sexes matrix game to find a prompt that gave us accurate results. During evaluation, we kept the structure of our prompt the same for all of the matrix games.
118
+
119
+ # 4.2.1 RESULTS
120
+
121
+ Labeling Accuracy. Given that each game can have many outcomes that satisfy a solution concept, we report the LLM’s accuracy if its response does not include any incorrect outcomes. If the LLM identifies any incorrect outcome, we report a score of 0. The LLM produces more objective-aligned reward signals with zero-shot prompting by applying its knowledge of well-known objectives, improving the labeling accuracy over having no objective by $48 \%$ on average with a regular ordering of matrix game outcomes and $36 \%$ with a scrambled order. Scrambling the order of matrix game outcomes in the prompt lowers accuracy for most solution concepts. We suspect that this is because the matrix games are well-known and likely to have been in the LLM’s training set, where each joint action is usually associated with particular payoffs. Scrambling the associations between joint actions and payoffs could make the matrix game more out-of-distribution for the LLM, and thus lower accuracy.
122
+
123
+ RL Agent Accuracy. Compared to labeling accuracy, it is easier for the resulting RL agents to be accurate because they only need to learn one correct outcome, not all of them. Thus, LLMs that only identify one out of two correct outcomes can still train objective-aligned RL agents. Results are shown on the bottom row of Fig. 3. RL agents trained using rewards from the LLM receive perfect accuracy for Total Welfare and Equality and $7 5 \%$ accuracy for the other two objectives. The baseline receives lower accuracy for all objectives.
124
+
125
+ Does the LLM Correctly Identify Each Objective? As part of our prompt, we ask the LLM to provide a definition of the objective before reasoning about whether an outcome satisfies the objective (see Fig. 11 in the Appendix). Table 2 in the Appendix shows how the LLM defines each objective zero-shot. The LLM is able to successfully recall the definitions for each objective except for Rawlsian Fairness – it gets it partially correct. However, the LLM varies in its ability to reason whether an outcome of a game satisfies the objective, which explains why the LLM does not receive perfect labeling accuracy for all objectives.
126
+
127
+ Summary. An LLM is able to identify well-known objectives and provide objective-aligned reward signals in a zero-shot setting.
128
+
129
+ # 4.3 DEALORNODEAL: TRAINING OBJECTIVE-ALIGNED AGENTS IN MULTI-TIMESTEP TASKS
130
+
131
+ We have shown that an LLM can provide objective-aligned reward signals in single-timestep tasks. In longer horizon tasks we must give trajectories instead of states as examples in our prompts. Longer prompts can be challenging because it is less likely for an LLM to have seen them during training. LLMs also have a recency bias which makes it harder for them to remember context introduced earlier on (Zhao et al., 2021). Can an LLM provide objective-aligned signals in longer horizon tasks? We investigate this question in the DEALORNODEAL negotiation task (Lewis et al., 2017).
132
+
133
+ Task Description. DEALORNODEAL is a long-horizon task with a maximum length of 100 timesteps. An agent Alice must come to an agreement with her partner Bob on the allocation of a set of objects (books, hats, and balls). Agents are shown a context, which includes the counts of each item and their private utilities for each item. In the original task, agents get rewarded based on the agreed upon split and their utilities. If Alice and Bob reach a disagreement, both agents get nothing. We train Alice using on-policy RL by negotiating against a fixed partner model, which we refer to as Bob. See Sec. A.4 for more details on the domain and training.
134
+
135
+ Ground Truth User Objectives. We train Alice to negotiate in different styles. For this experiment, we assume we have access to precise definitions in order to evaluate our models. Importantly, we do not give definitions of each style to the LLM, only examples. We experiment with the following negotiation styles inspired by previous literature Sycara et al. (1997); Caputo et al. (2019):
136
+
137
+ • Versatile. Alice does not suggest the same proposal more than once.
138
+ • Push-Over. Alice gets less points than Bob.
139
+ • Competitive. Alice gets more points than Bob.
140
+ • Stubborn. Alice repeatedly suggests the same proposal.
141
+
142
+ Prompt Design. We describe user objectives using three examples. Each example contains a negotiation between Alice and Bob, a question asking whether Alice negotiated in a particular style, and a yes or no answer followed by a short explanation. For an example, see Fig. 13 in the Appendix.
143
+
144
+ Design Procedure. To create example negotiations, we randomly sampled three negotiation contexts for each objective and trained an RL agent (using the original task reward, without the LLM) to negotiate against $B o b$ in these contexts. We then sampled negotiations from the trained model. We also made sure all three sampled negotiations did not have the same ground truth label. We use a separate set of contexts when training RL agents with an LLM in the loop.
145
+
146
+ # 4.3.1 RESULTS
147
+
148
+ Labeling Accuracy. The top row of Fig. 4 shows that the LLM labels more accurately than SL except for Versatile. For Versatile, both models perform similarly because SL learns to overwhelmingly predict a negative label (avg of $9 6 \%$ negative predictions) and the RL agent showed more negative examples of Versatile behavior (avg. of $7 0 \%$ ground truth negative labels). However, the large portion of negative examples prevents the agent from learning correct behavior as shown in the Versatile plot on the bottom of Fig. 4); here, we get a larger performance gap between the LLM and SL.
149
+
150
+ ![](images/85056cb312e34a15f0e98388facbd4a8fb45226608d6ad7fdb3e5e03152829ba.jpg)
151
+ Figure 4: DEALORNODEAL, Few-shot. (Top) Accuracy of reward signals provided by LLM and SL during RL training. (Bottom) Accuracy of RL agents after training. (Right) Pilot study results. Agents trained with the user’s preferred style were rated as significantly more aligned than an agent trained with the opposite style $p { < } 0 . 0 0 1$ .
152
+
153
+ Table 1: Qualitative results describing negotiations produced by agents trained with LLM.
154
+
155
+ <table><tr><td></td><td>Advantage</td><td>Diversity</td><td>Agreement Rate</td></tr><tr><td>Versatile</td><td>0.17±0.91</td><td>0.99±0.01</td><td>0.98±1.89</td></tr><tr><td>Push-Over</td><td>-2.95±0.64</td><td>0.82±0.26</td><td>1.0±0.0</td></tr><tr><td>Competitive</td><td>2.92±0.64</td><td>0.74±0.25</td><td>0.88±6.5</td></tr><tr><td>Stubborn</td><td>1.36±2.24</td><td>0.52±0.1</td><td>0.82±12.35</td></tr></table>
156
+
157
+ RL Agent Accuracy. Results are shown on bottom row of of Fig. 4. LLM improves RL agent accuracy over SL by $4 6 \%$ on average. Our method approaches the performance of using the true reward; we under perform by an average of $4 \%$ . We remind readers that it is possible to outperform an agent trained with the true reward — especially when the LLM’s labeling accuracy is near-perfect as is the case for Competitive and Stubborn — due to reward hacking or stochasticity during training. For instance, agents trained with the true reward for Competitive end in more disagreements, leading to 0 reward for both agents and a lower accuracy.
158
+
159
+ Is There a Qualitative Difference in Styles? Example negotiations of agents trained with the LLM for each style are shown in Fig. 9 in the Appendix. To measure qualitative differences among styles, we looked at average advantage (Alice’s original task reward - Bob’s original task reward), diversity (percentage of Alice’s utterances that are unique in a negotiation), and agreement rate (percentage of negotiations that end in agreement). The results in Table 1 demonstrate qualitative differences in styles.
160
+
161
+ # 4.3.2 PILOT USER STUDY
162
+
163
+ We conduct a within-subjects pilot user study to determine whether our trained agents can meaningfully align themselves with different user objectives when we do not have access to ground truth objectives and users evaluate agent performance.
164
+
165
+ Method We asked $N { = } 1 0$ users to select a style in which they wanted their agent to negotiate in. We gave them an option to choose from our existing styles (Versatile, Push-Over, Competitive, Stubborn), or come up with their own. Importantly, users did not know how we defined these styles. We then showed users a list of 10 example negotiations generated via selfplay using an RL agent trained with a greedy objective (no particular style). We asked users to select 3 examples (1 positive, 1 negative, and 1 positive or negative) where Alice displayed positive or negative behavior of the user’s chosen style. For each chosen example, we asked users whether Alice demonstrated their chosen style and asked them to provide a ”Yes/No” answer as well as a short explanation. These examples corresponded to unknown, user-specific ground truth reward functions that we did not have access to. We then trained a negotiation agent by incorporating the user-provided examples in the prompt as described in Sec. 3. We also trained an agent to negotiate in the opposite style by flipping the ”Yes/No” labels in the user-provided explanations. We hypothesize that users should perceive a significant difference between these two agents. To evaluate our trained agents, we had both agents negotiate on a set of 10 test negotiations. For each test negotiation, we asked users to rate how well each agent aligned with their chosen style on a scale from 1 (least aligned) to 5 (most aligned).
166
+
167
+ Results Agents trained with the correct style were significantly more aligned (avg. $3 . 7 2 { \pm } 1 . 2 )$ than agents trained with the opposite style (avg. $1 . 5 6 \pm 1 . 0 5 )$ , $p < 0 . 0 0 1$ , see Fig. 4 (right). Users varied in which styles they preferred: 4 users chose styles such as Polite, Push-Over, Considerate and Compromising, 2 users chose Versatile, and 4 users chose styles such as Stubborn, Competitive and Ambitious. These results demonstrate that our framework can produce agents aligned with differently specified objectives by changing the examples in the prompt. Furthermore, these results suggest that our framework can be used when rewards are difficult to define and results are agents with humans.
168
+
169
+ Summary. Our framework can train objective-aligned agents when ground truth rewards are not present in complex, longer-horizon tasks. Agents are able to align the style in which they complete a task as evaluated by automated metrics as well as human users.
170
+
171
+ # 5 ANALYSIS OF DATA EFFICIENCY & PROMPT DESIGN
172
+
173
+ We have shown that we can use an LLM as a proxy reward function to successfully train objective-aligned agents across different tasks. This is a promising result because it represents an important step in enabling human-compatible and value-aligned AI systems. In this section, 1) we further quantify how data efficient our method is and 2) also analyze how robust LLM is to variations of prompt design.
174
+
175
+ 1) How Data-efficient is Our Method? We quantify how much more user data a supervised learning baseline would need in order to achieve the same labeling accuracy as the LLM. Results in the Ultimatum Game demonstrate that 10 labeled examples is enough for an SL model to reach comparable performance, whereas a a single labeled example is not sufficient. In this section, we quantify the amount of data needed for DEALORNODEAL because it is an example of a task where the decision boundary is not as easy to learn as the Ultimatum Game. We train SL by adding additional class-balanced, labeled examples to the original three examples it was trained on. We plot the average labeling accuracy SL achieves when trained on increasingly larger amounts of examples as well as the accuracy LLM achieves with three examples, shown in Fig. 6 in the Appendix. Results show that SL requires on the order of hundreds of more labeled examples in order to be comparably accurate as LLM.
176
+
177
+ 2) How Much Does LLM’s Labeling Accuracy Change When We Vary the Prompt? As with many approaches that use LLMs, a limitation of our approach is that it requires prompt design. We attempt to quantify the effort required for designing prompts as well as determine the feasibility of using nonengineered prompts from humans. We analyze the effect of prompt variation on labeling accuracy in DEALORNODEAL for the Stubborn objective. We vary different parts of the user-specified prompt at a time: the keyword (i.e., replacing “Stubborn” with its synonyms), the example negotiations, and the explanations associated with each example. Fig. 7 provides a summary of our results. See Sec. A.7 for the full results. Results illustrate that an LLM can be quite robust to different prompts — they all outperform SL. Furthermore, the quality of the explanation seems to be the most important in determining LLM accuracy.
178
+
179
+ # 6 LIMITATIONS & FUTURE WORK
180
+
181
+ User Studies. This work takes a first step in determining whether we can use LLMs as proxy rewards.
182
+ Given promising results, we plan on evaluating our approach with a larger user study.
183
+
184
+ Multimodal Foundation Models. Beyond language models, multimodal foundation models such as Flamingo (Alayrac et al., 2022) can enable us to provide more complex environment states to the foundation model through images or other modalities while preserving an intuitive language interface for specifying the user objective.
185
+
186
+ Non-Binary Rewards. Another limitation of our framework is that the LLM only specifies binary rewards. We plan on exploring how we can incorporate the likelihoods that LLMs produce for each word as a non-binary reward signal.
187
+
188
+ # ACKNOWLEDGMENTS
189
+
190
+ This work was supported by NSF Award 1941722, 2125511, 2006388, AFOSR, DARPA YFA Award, ONR, and JP Morgan Faculty Award. We would also like to thank Karl Tuyls, Ian Gemp, Albert Gu, Siddharth Karamcheti, Kanishk Gandhi, and other reviewers for this paper.
191
+
192
+ # REFERENCES
193
+
194
+ Michael Ahn, Anthony Brohan, Noah Brown, Yevgen Chebotar, Omar Cortes, Byron David, Chelsea Finn, Chuyuan Fu, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, Daniel Ho, Jasmine Hsu, Julian Ibarz, Brian Ichter, Alex Irpan, Eric Jang, Rosario Jauregui Ruano, Kyle Jeffrey, Sally Jesmonth, Nikhil J Joshi, Ryan Julian, Dmitry Kalashnikov, Yuheng Kuang, Kuang-Huei Lee, Sergey Levine, Yao Lu, Linda Luu, Carolina Parada, Peter Pastor, Jornell Quiambao, Kanishka Rao, Jarek Rettinghouse, Diego Reyes, Pierre Sermanet, Nicolas Sievers, Clayton Tan, Alexander Toshev, Vincent Vanhoucke, Fei Xia, Ted Xiao, Peng Xu, Sichun Xu, Mengyuan Yan, and Andy Zeng. Do as i can, not as i say: Grounding language in robotic affordances. arXiv, 2022.
195
+
196
+ Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zhitao Gong, Sina Samangooei, Marianne Monteiro, Jacob Menick, Sebastian Borgeaud, Andrew Brock, Aida Nematzadeh, Sahand Sharifzadeh, Mikolaj Binkowski, Ricardo Barreira, Oriol Vinyals, Andrew Zisserman, and Karen Simonyan. Flamingo: a visual language model for few-shot learning. arXiv, 2022.
197
+
198
+ Dario Amodei, Chris Olah, Jacob Steinhardt, Paul Christiano, John Schulman, and Dan Mane. Concrete ´ problems in ai safety. arXiv preprint arXiv:1606.06565, 2016.
199
+
200
+ Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, Tom Henighan, et al. Training a helpful and harmless assistant with reinforcement learning from human feedback. arXiv preprint arXiv:2204.05862, 2022.
201
+
202
+ Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020.
203
+
204
+ Andrea Caputo, Oluremi B Ayoko, Nii Amoo, and Charlott Menke. The relationship between cultural values, cultural intelligence and negotiation styles. Journal of Business Research, 99:23–36, 2019.
205
+
206
+ Thomas Carta, Sylvain Lamprier, Pierre-Yves Oudeyer, and Olivier Sigaud. Eager: Asking and answering questions for automatic reward shaping in language-guided rl. arXiv preprint arXiv:2206.09674, 2022.
207
+
208
+ Annie S. Chen, Suraj Nair, and Chelsea Finn. Learning generalizable robotic reward functions from ”in-the-wild” human videos. ArXiv, abs/2103.16817, 2021.
209
+
210
+ Paul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. Advances in neural information processing systems, 30, 2017.
211
+
212
+ Junyoung Chung, Caglar Gulcehre, KyungHyun Cho, and Yoshua Bengio. Empirical evaluation of gated recurrent neural networks on sequence modeling. arXiv preprint arXiv:1412.3555, 2014.
213
+
214
+ Ernst Fehr and Klaus M Schmidt. On inequity aversion: A reply to binmore and shaked. Journal of economic behavior & organization, 73(1):101–108, 2010.
215
+
216
+ Prasoon Goyal, Scott Niekum, and Raymond J Mooney. Using natural language for reward shaping in reinforcement learning. arXiv preprint arXiv:1903.02020, 2019.
217
+
218
+ Dylan Hadfield-Menell, Smitha Milli, Pieter Abbeel, Stuart J Russell, and Anca Dragan. Inverse reward design. Advances in neural information processing systems, 30, 2017.
219
+
220
+ He He, Derek Chen, Anusha Balakrishnan, and Percy Liang. Decoupling strategy and generation in negotiation dialogues. In Empirical Methods in Natural Language Processing (EMNLP), 2018.
221
+
222
+ Wenlong Huang, P. Abbeel, Deepak Pathak, and Igor Mordatch. Language models as zero-shot planners: Extracting actionable knowledge for embodied agents. In ICML, 2022.
223
+
224
+ Borja Ibarz, Jan Leike, Tobias Pohlen, Geoffrey Irving, Shane Legg, and Dario Amodei. Reward learning from human preferences and demonstrations in atari. Advances in neural information processing systems, 31, 2018.
225
+
226
+ W Bradley Knox, Alessandro Allievi, Holger Banzhaf, Felix Schmitt, and Peter Stone. Reward (mis) design for autonomous driving. arXiv preprint arXiv:2104.13906, 2021.
227
+
228
+ Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. arXiv, 2022.
229
+
230
+ Minae Kwon, Siddharth Karamcheti, Mariano-Florentino Cuellar, and Dorsa Sadigh. Targeted data acquisition for evolving negotiation agents. In International Conference on Machine Learning, pp. 5894–5904. PMLR, 2021.
231
+
232
+ Andrew K Lampinen, Ishita Dasgupta, Stephanie CY Chan, Kory Matthewson, Michael Henry Tessler, Antonia Creswell, James L McClelland, Jane X Wang, and Felix Hill. Can language models learn from explanations in context? arXiv preprint arXiv:2204.02329, 2022.
233
+
234
+ Mike Lewis, Denis Yarats, Yann N. Dauphin, Devi Parikh, and Dhruv Batra. Deal or no deal? end-to-end learning for negotiation dialogues. In Empirical Methods in Natural Language Processing (EMNLP), 2017.
235
+
236
+ Jessy Lin, Daniel Fried, Dan Klein, and Anca Dragan. Inferring rewards from language in context. arXiv preprint arXiv:2204.02515, 2022.
237
+
238
+ Suvir Mirchandani, Siddharth Karamcheti, and Dorsa Sadigh. Ella: Exploration through learned language abstraction. Advances in Neural Information Processing Systems, 34:29529–29540, 2021.
239
+
240
+ Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke E. Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Francis Christiano, Jan Leike, and Ryan J. Lowe. Training language models to follow instructions with human feedback. ArXiv, abs/2203.02155, 2022.
241
+
242
+ Alexander Pan, Kush Bhatia, and Jacob Steinhardt. The effects of reward misspecification: Mapping and mitigating misaligned models. arXiv preprint arXiv:2201.03544, 2022.
243
+
244
+ Simone Parisi, Aravind Rajeswaran, Senthil Purushwalkam, and Abhinav Kumar Gupta. The unsurprising effectiveness of pre-trained vision models for control. In ICML, 2022.
245
+
246
+ Antonin Raffin, Ashley Hill, Adam Gleave, Anssi Kanervisto, Maximilian Ernestus, and Noah Dormann. Stable-baselines3: Reliable reinforcement learning implementations. Journal of Machine Learning Research, 22(268):1–8, 2021. URL http://jmlr.org/papers/v22/20-1364.html.
247
+
248
+ Stephane Ross, Geoffrey Gordon, and Drew Bagnell. A reduction of imitation learning and structured ´ prediction to no-regret online learning. In Proceedings of the fourteenth international conference on artificial intelligence and statistics, pp. 627–635. JMLR Workshop and Conference Proceedings, 2011.
249
+
250
+ Dorsa Sadigh, Anca D. Dragan, S. Shankar Sastry, and Sanjit A. Seshia. Active preference-based learning of reward functions. In Proceedings of Robotics: Science and Systems (RSS), July 2017. doi: 10.15607/RSS.2017.XIII.053.
251
+
252
+ Katia Sycara, Daniel Zeng, et al. Benefits of learning in negotiation. In Proceedings of the AAAI National Conference on Artificial Intelligence. Menlo Park, California, pp. 36–41, 1997.
253
+
254
+ Peter Vavra, Luke J Chang, and Alan G Sanfey. Expectations in the ultimatum game: distinct effects of mean and variance of expected offers. Frontiers in psychology, 9:992, 2018.
255
+
256
+ Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3):229–256, 1992.
257
+
258
+ Jing Zhang, Xindong Wu, and Victor S Sheng. Learning from crowdsourced labeled data: a survey. Artificial Intelligence Review, 46(4):543–576, 2016.
259
+
260
+ Tony Z. Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving fewshot performance of language models. In International Conference on Machine Learning (ICML), 2021.
261
+
262
+ # A APPENDIX0 Tabl
263
+
264
+ # A.1 SUMMARY
265
+
266
+ OF RESULTS: IS IT IS POSSIBLE TO USE LLM AS A PROXY REWARD IN RL TRAINING?
267
+ Figure 5: Average Labeling and RL Agent Accuracy across the different objectives for each task across 3 seeds.
268
+
269
+ <table><tr><td colspan="5">Avg.Labeling Accuracy</td><td colspan="3">Avg.RL Agent Accuracy</td></tr><tr><td></td><td>Zero-shot Baseline (No Obj.)</td><td>Few-shot Baseline (SL)</td><td>Ours</td><td>Zero-shot Baseline (No Obj.)</td><td>Few-shot Baseline (SL)</td><td>Ours</td><td>True Reward</td></tr><tr><td>Ultimatum Game</td><td>-</td><td>0.67 ±0.34</td><td>0.91±0.27</td><td>-</td><td>0.67 ±0.34</td><td>0.9±0.26</td><td>1.0±0.02</td></tr><tr><td>Matrix Games</td><td>0.19 ±0.29</td><td>-</td><td>0.61±0.41</td><td>0.54±0.29</td><td>-</td><td>0.88±0.</td><td>1.0±0.</td></tr><tr><td>DEALORNODEAL</td><td></td><td>0.5± 0.47</td><td>0.9±0.22</td><td></td><td>0.33± 0.42</td><td>0.8±0.33</td><td>0.84 ±0.27</td></tr></table>
270
+
271
+ We provide a summary of results in Fig. 5. The figure depicts the average Labeling and RL Agent Accuracy computed across the different user objectives for each task, across 3 seeds. Overall, our approach is able to produce more objective-aligned reward signals than our baselines. Our approach is also able to produce objective-aligned policies that are close in accuracy to policies trained with the true reward.
272
+
273
+ # A.2 MORE RELATED WORKS
274
+
275
+ Reward Design. Our framework addresses reward design—how to engineer rewards so that they align with our objectives (Amodei et al., 2016). This is challenging because tasks often have conflicting objectives that a human must trade off (Pan et al., 2022). Misspecifying reward functions can lead to reward hacking, or the gaming of specified rewards. Reward hacking has appeared in various domains such as autonomous driving (Knox et al., 2021) and game-playing (Ibarz et al., 2018). We hope to address these challenges by leveraging LLMs and making it easier for humans to specify their objectives.
276
+
277
+ Imitation Learning & Preference-based Learning. Another method of specifying user objectives is to learn them from expert demonstrations (Ross et al., 2011) or preferences Sadigh et al. (2017). These techniques either assume access to large datasets (Christiano et al., 2017) or place restrictive assumptions (such as linearity) about the reward function (Sadigh et al., 2017). Recent work attempts to learn reward functions from language instructions using pragmatic reasoning (Lin et al., 2022). In contrast, our work relies on an LLM’s in-context learning abilities to provide a reward.
278
+
279
+ # A.3 LLM DEFINITION OF OBJECTIVES IN THE MATRIX GAME
280
+
281
+ <table><tr><td rowspan=1 colspan=1>LLMDefns.of ObjectivesTotal welfare is the sum of the rewards of both players.(√)</td></tr><tr><td rowspan=1 colspan=1>Equality of rewards is only possible if both players receive the same reward. (√)</td></tr><tr><td rowspan=1 colspan=1>Rawlsian fairness is defined as the maxmin value of the game, which is theminimum reward that the player could get assuming that the other player ismaximizing their reward. (X)</td></tr><tr><td rowspan=1 colspan=1>An outcome is Pareto-optimal if there is no other outcome that would make one player beter off without making the other player worse off.(√)</td></tr></table>
282
+
283
+ Table 2: Completion of each sentence given by LLM in pink. LLM provides correct definitions for objectives except for Rawlsian Fairness, which is partially correct.
284
+
285
+ # A.4 DETAILS ON RL ENVIRONMENTS AND TRAINING
286
+
287
+ Ultimatum Game. The environment is a single horizon with discrete actions (i.e., accept or reject) and continuous observations (i.e., a proposed split). We train DQN agents using the Stable Baselines3 implementation for 1e4 timesteps with a learning rate of 1e-4 across 3 seeds (Raffin et al., 2021). We instantiate our policy as a MLP with the default parameters used in Stable Baselines3.
288
+
289
+ Parser $g$ . The parser $g$ that transforms the LLM’s output into an integer reward signal is defined using a handcrafted parser. When prompting the LLM, we structure the labels for each example to be in “Yes/No” form which enables the LLM to also reply using the same format. We are then able search for the “Yes” or “No” strings and parse them into a 1 or 0 respectively. In the rare occasion that the LLM does not respond in this form, we skip the episode during RL training and omit the example from our evaluation.
290
+
291
+ Further Analysis on Performance of No Objective Baseline. The average LLM accuracy of a random baseline across the four matrix games are Welfare: 0.125, Equality: 0.125, Rawlsian Fairness: 0.078, Pareto-optimality: 0.172. The No Objective baseline’s performance is close to random as can be verified by comparing the random baseline results with Figure 3 (top row).\* Behaviorally, we observe that No Objective acts like a random baseline: the LLM often hallucinates matrix game rewards and also displays incoherent reasoning when selecting answers.
292
+
293
+ Matrix Game.. The environment is a single horizon with discrete actions (i.e., one of the four joint actions) and no observations. We train DQN agents using the Stable Baselines3 implementation for 500 timesteps with a learning rate of 1e-4 across 3 seeds (Raffin et al., 2021). We instantiate our policy as a MLP with the default parameters used in Stable Baselines3.
294
+
295
+ Parser $g$ . We parse the LLM’s response by hand, since LLM output can be variable in zero-shot settings.
296
+
297
+ DEALORNODEAL. We use a version of the DEALORNODEAL environment used in Kwon et al. (2021). In the environment, the goal is for an agent $A$ to come to an agreement with a partner $B$ on the allocation of a set of objects (books, hats, and balls). During each negotiation, agents receive a context, $c _ { A } = [ i ; u _ { A } ] , c _ { B } =$ $[ i ; u _ { B } ]$ , detailing the count of each item $i$ as well as their private utilities, $u _ { A } , u _ { B }$ . Item counts and utilities are represented as vectors $i \in \{ 1 , . . . , 4 \} ^ { 3 }$ and $u _ { A } , u _ { B } \in \{ 0 , \bar { . . . } , 1 0 \} ^ { 3 }$ and are sampled uniformly.
298
+
299
+ After receiving contexts $c _ { A } , c _ { B }$ , an agent is randomly selected to begin the negotiation. Agents negotiate for $T$ time steps by exchanging coarse dialogue acts $x _ { t }$ at each time step $1 \leq t \leq T$ (He et al., 2018). Rather than negotiate directly in natural language, where the generation problem is hard and can result in degenerate dialogues (He et al., 2018), we use these dialogue acts instead to focus on learning diverse and interpretable strategies.
300
+
301
+ A dialogue act $x _ { t }$ is one of five actions: propose, insist, agree, disagree, or end. The propose and insist acts take allocations of items as arguments $o \ = \ [ o _ { A } ; o _ { B } ]$ where $o _ { A } , o _ { B } \in \{ 1 , . . . , 4 \} ^ { 3 }$ (e.g., propose: books $^ { = 1 }$ , hat $S { = } 2$ , $\mathtt { b a l l s } = 1$ ). When an agent selects end, the conversation terminates and each agent is asked to make their final selection.
302
+
303
+ If agents agree on the final allocation of items, i.e., $o _ { A } + o _ { B } = i$ , agents are awarded points based on their private utilities, $r _ { A } = u _ { A } \cdot o _ { A } , r _ { B } = u _ { B } \cdot o _ { B }$ . If agents do not agree, they receive 0 points. Each agent’s context is constrained so that the agent can receive a maximum of 10 points.
304
+
305
+ Agents are first trained using supervised learning on a dataset of human-human negotiations provided by (Lewis et al., 2017) to predict the next token. We use a learning rate of 1.0 and batch size of 16. We then fine-tune these agents using RL where they optimize the expected reward of each dialogue act using REINFORCE (Williams, 1992). Agents are trained on 250 contexts for 1 epoch with a learning rate of 0.1. We instantiate our policy with four GRUs (Chung et al., 2014). We closely follow the implementation outlined in (Kwon et al., 2021; Lewis et al., 2017), please refer to those papers for more training details.
306
+
307
+ Parser $g$ . The parser $g$ that transforms the LLM’s output into an integer reward signal is defined using a handcrafted parser. When prompting the LLM, we structure the labels for each example to be in “Yes/No” form which enables the LLM to also reply using the same format. We are then able search for the “Yes” or “No” strings and parse them into a 1 or 0 respectively. In the rare occasion that the LLM does not respond in this form, we skip the episode during RL training and omit the example from our evaluation.
308
+
309
+ # A.5 SL MODEL ARCHITECTURE AND TRAINING
310
+
311
+ Ultimatum Game. SL is trained to predict binary labels for a batch of proposed splits. We implemented SL as a multi-layer perceptron (MLP) network that consists of a single hidden layer with depth 32. We also use ReLU activations after our input and hidden layers. We trained the model on the same 10 examples we gave to LLM for 5 epochs with the Adam optimizer. We evaluate the model on the 50 heldout test examples and save the model with the best test accuracy. We show the training and test accuracy for each user objective below:
312
+
313
+ Table 3: Training accuracy for SL on the Ultimatum Game.
314
+
315
+ <table><tr><td></td><td>30%</td><td>60%</td><td>$10</td><td>$100</td><td>Ineq. Aversion</td></tr><tr><td>Train Acc. (10 examples)</td><td>1.0</td><td>1.0</td><td>0.9</td><td>1.0</td><td>1.0</td></tr><tr><td>Train Acc. (1 example)</td><td>1.0</td><td>1.0</td><td>1.0</td><td>1.0</td><td>1.0</td></tr></table>
316
+
317
+ DEALORNODEAL. SL is trained to predict binary labels given a negotiation as input. We closely follow the implementation of a SL model found in (Kwon et al., 2021; Lewis et al., 2017). A negotiation consists of a context, coarse dialogue acts exchanged between Alice and Bob, and the outcome of the negotiation (the final split of items and whether agents agreed or disagreed). Please refer to Sec. A.4 for more details on the environment. We implement SL using a MLP context encoder, MLP outcome encoder, and a GRU ((Chung et al., 2014)) to process the coarse dialogue acts. The MLP encoders consist of an embedding layer followed by a linear layer with a Tanh activation function; we use a hidden size of 64 for the context encoder’s linear layer. We similarly embed each coarse dialogue act before feeding it into the GRU. We use a hidden size of 128 for the GRU. We train SL on the same 3 examples we use in our prompt for LLM. We train for a maximum of 50 epochs using the Adam optimizer. SL received a training accuracy of $1 0 0 \%$ for all of our objectives.
318
+
319
+ # A.6 HOW DATA-EFFICIENT IS OUR METHOD?
320
+
321
+ ![](images/4f6b808338f90d977425b0fd7632117383cc36d585ae233c2534f392778dd388.jpg)
322
+ SL Labeling Accuracy When Trained with # Additional Labeled Examples
323
+ Figure 6: SL requires on the order of hundreds of more labeled examples in order to be comparably accurate to the LLM.
324
+
325
+ A.7 HOW MUCH DOES LLM’S LABELING ACCURACY CHANGE WHEN WE VARY THE PROMPT?
326
+ Effect of Prompt Variation on Labeling Accuracy for Stubborn (N=3, 3 seeds)
327
+ Figure 7: On average, varying the prompt does not have a large impact on the accuracy of the LLM.
328
+
329
+ <table><tr><td>SL</td><td>Ours</td><td>Vary Keyword</td><td>Vary Example Negotiations</td><td>Vary Explanations</td></tr><tr><td>0.58 ± 0.48</td><td>0.97 ± 0.16</td><td>0.91±0.28</td><td>0.93 ±0.28</td><td>0.79 ±0.33</td></tr></table>
330
+
331
+ We analyze the effect of varying prompts on the LLM’s labeling accuracy for the Stubborn negotiating style in DEALORNODEAL. We vary prompts in three ways: we vary the keyword (i.e., replacing “Stubborn” with its synonyms), the example negotiations, and the explanations associated with each example.
332
+
333
+ When varying the keyword, we use the synonyms: “Headstrong”, “Obstinate”, and a less commonly used word, “Froward”. To vary example negotiations, we randomly sample three new negotiations to have counterbalanced labels, all positive labels, or all negative labels. We vary the explanations by coming up with two plausible sets of explanations a user might have given for each example. We also experiment with the scenario where we give no explanations. Results are shown in Fig. 8. Overall, varying prompts do not have a large impact on labeling accuracy — they all outperform the baseline. However, the quality of explanation seems to have the largest impact on labeling accuracy.
334
+
335
+ # A.8 WHAT IS THE IMPORTANCE OF INCLUDING THE TASK DESCRIPTION, $\rho _ { 1 }$ IN THE PROMPT?
336
+
337
+ We experiment with removing $\rho _ { 1 }$ , the task description in the Ultimatum Game with a single example followed by an explanation. Performance increases slightly in LLM labeling accuracy (avg. of $8 \%$ ) and RL agent accuracy (avg. of $9 \%$ ). We run the same experiment in the Ultimatum game in the case of 10 examples with no explanation. Performance drops slightly in LLM labeling accuracy (avg. $4 . 4 \%$ ) and RL agent accuracy (avg. $5 . 3 \%$ ). We conclude that $\rho _ { 1 }$ is not conclusively influential in improving performance in few-shot settings.
338
+
339
+ ![](images/4b26b32a6fb585ccb6d6dedd5628c442fa267f1c69fedf71cf174a571a5c57ce.jpg)
340
+ Figure 8: Varying prompts do not have a large impact on labeling accuracy.
341
+ Figure 9: Example negotiations after Alice is trained with reward signals from LLM in DEALORNODEAL. We illustrate qualitative differences in how Alice negotiates for the same context. $B o b$ is an agent that is trained with supervised learning.
342
+
343
+ # A.9 EXPERIMENTING WITH SMALLER LLM SIZES
344
+
345
+ We experiment with GPT-2, a 1.5B parameter model. We We find that GPT-2 underperforms GPT-3 in both labeling (avg. $1 5 \%$ ) and RL agent accuracy (avg. $4 9 \%$ ). GPT-2 outperforms the SL baseline in labeling accuracy (avg. $2 4 \%$ ), and slightly underperforms the SL baseline for RL agent accuracy (avg. $2 . 7 \%$ ). Results are averaged across styles and seeds. GPT-2 (1.5B) is several orders smaller than GPT-3 (175B), and we expect models larger than GPT-2 to close the gap with GPT-3’s performance.
346
+
347
+ A.10 EXAMPLE NEGOTIATIONS
348
+
349
+ # Context
350
+
351
+ Alice : book=(count:1 value:0) hat=(count:1 value:7) ball=(count:3 value:1) Bob : book=(count:1 value:3) hat=(count:1 value:7) ball=(count:3 value:0)
352
+
353
+ <table><tr><td rowspan=1 colspan=1>Versatile</td></tr><tr><td rowspan=1 colspan=1>Alice : propose: item0=1 item1=1 item2=0Bob :propose: item0=0 item1=1 item2=0Alice : propose: item0=1 item1=0 item2=2Bob :agree</td></tr><tr><td rowspan=1 colspan=1>Agreement!Alice : 2 pointsBob :7 pointsCompetitive</td></tr><tr><td rowspan=1 colspan=1>Alice : propose: item0=1 item1=0 item2=3Bob : propose: item0=1 item1=1 item2=0Alice : insist: item0=0 item1=1 item2=3Bob :agree</td></tr><tr><td rowspan=1 colspan=1>Agreement!Alice : 10 pointsBob :3 points</td></tr></table>
354
+
355
+ <table><tr><td>Push-over</td></tr><tr><td>Alice : propose: item0=1 item1=0 item2=3 Bob :propose: itemO=1 item1=1 item2=0 Alice :agree Agreement! Alice : 3 points</td></tr><tr><td>Bob :10 points Stubborn Alice : propose: item0=0 item1=1 item2=1</td></tr><tr><td>Bob :propose: item0=0 item1=1 item2=0 Alice : propose: item0=0 item1=1 item2=1 Bob : propose: item0=0 item1=1 item2=0 Alice : propose: item0=0 item1=1 item2=1 Bob :propose: item0=0 item1=1 item2=0 Alice : propose: item0=0 item1=1 item2=1 Bob:propose: item0=0 item1=1 item2=0 Alice : propose: item0=0 item1=1 item2=1</td></tr></table>
356
+
357
+ Disagreement?! Alice : 0 (potential 0) Bob : 0 (potential 0)
358
+
359
+ # A.11 EXAMPLE OF PROMPTS USED IN OUR EXPERIMENTS
360
+
361
+ # A.11.1 ULTIMATUM GAME
362
+
363
+ Further Explanation of Our Prompt Selection Process. When constructing our explanations, we encourage the LLM to produce intermediate reasoning steps by using the “Let’s think step by step” template usedUltimatum prompt in Kojima et al. (2022) which has been shown to improve performance.
364
+
365
+ ![](images/29d0ebc7ae13f4da3f5e7cac6aafe08e7307f316a879182340e85c2fc8204951.jpg)
366
+ Figure 10: An example of few-shot prompts used for the Ultimatum Game. We highlight the four parts of each pro
367
+
368
+ # A.11.2 MATRIX GAMES
369
+
370
+ Further Explanation of Our Prompt Selection Process. We found that structuring the outcomes of the game as a multiple choice question improved performance. We also encouraged the LLM to produce intermediate reasoning steps by using the “Let’s think step by step” template used in Kojima et al. (2022) which has been shown to improve performance.Matrix prompt
371
+
372
+ ![](images/29401b78cc06de5d45f4c3a39611eed45b44fbd7d818516e389fa9b1f09d0051.jpg)
373
+ Figure 11: Examples of a zero-shot prompts used for each objective, including the no-objective baseline, in the Matrix Games. Due to limited resources when querying GPT-3, we queried GPT-3 in a batched manner and saved the corresponding labels to train our RL agents. Consequently, we do not have an Episode outcome in our prompts.
374
+
375
+ # A.11.3 DEALORNODEAL
376
+
377
+ Further Explanation of Our Prompt Selection Process. We chose 3 counterbalanced examples from a training set of sample negotiations. This training set was generated via selfplay using an RL agent trained
378
+
379
+ Figure 12: Examples of regular and scrambled outcomes for the Chicken Game (Matrix Game experiments). Scrambling creates new associations between joint actions and joint rewards. We scramble the outcomes in order to remove any bias LLM may have towards the order in which outcomes are normally presented.
380
+
381
+ <table><tr><td>Chicken Game (Regular Order)</td><td>Chicken Game (Scrambled Order)</td></tr><tr><td>We have a two-player game where P1 and P2 can choose one of these options.</td><td>We have a two-player game where P1 and P2 can choose one of these options.</td></tr><tr><td>Options: A.if action1(P1) and action1(P2)=&gt;P1 gets reward of 2, P2 gets reward of 2.</td><td>Options: A. if actionl(P1) and actionl(P2) =&gt;P1 gets reward of 3,P2 gets reward of 1.</td></tr><tr><td>B. if action1(P1) and action2(P2)=&gt;P1 gets reward of 1,P2 gets reward of 3.</td><td>B.if action1(P1) and action2(P2)=&gt;P1 gets reward of 2,P2 gets reward of 2.</td></tr><tr><td>C.if action2(P1) and action1(P2)=&gt;P1 gets reward of 3,P2 gets reward of 1.</td><td>C.if action2(P1) and action1(P2)=&gt;P1 gets reward of 1, P2 gets reward of 3.</td></tr><tr><td>D.if action2(P1) and action2(P2)=&gt;P1 gets reward of 0,P2 gets reward of 0.</td><td>D.if action2(P1)and action2(P2)=&gt;P1 gets reward of 0,P2 gets reward of 0.</td></tr><tr><td></td><td></td></tr><tr><td>Which option(s) are Pareto-optimal? Let&#x27;s think step by step:</td><td>Which option(s) are Pareto-optimal? Let&#x27;s think step by step:</td></tr><tr><td>An outcome is Pareto-optimal if</td><td>An outcome is Pareto-optimal if</td></tr></table>
382
+
383
+ with a greedy reward (no particular style). We chose to complement our examples with simple and succinct explanations.
384
+
385
+ ![](images/46283f58af7f6fc1357e46c8a1d3b0735f3e69152e432c8c5133651396f848ce.jpg)
386
+ Figure 13: Example of a prompt used for DEALORNODEAL.
md/dev/157Usp_kbi/157Usp_kbi.md ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Knowledge Distillation from A Stronger Teacher
2
+
3
+ Tao Huang1,2 Shan You1∗ Fei Wang3 Chen Qian1 Chang Xu2 1SenseTime Research 2School of Computer Science, Faculty of Engineering, The University of Sydney 3University of Science and Technology of China
4
+
5
+ # Abstract
6
+
7
+ Unlike existing knowledge distillation methods focus on the baseline settings, where the teacher models and training strategies are not that strong and competing as state-of-the-art approaches, this paper presents a method dubbed DIST to distill better from a stronger teacher. We empirically find that the discrepancy of predictions between the student and a stronger teacher may tend to be fairly severer. As a result, the exact match of predictions in KL divergence would disturb the training and make existing methods perform poorly. In this paper, we show that simply preserving the relations between the predictions of teacher and student would suffice, and propose a correlation-based loss to capture the intrinsic inter-class relations from the teacher explicitly. Besides, considering that different instances have different semantic similarities to each class, we also extend this relational match to the intra-class level. Our method is simple yet practical, and extensive experiments demonstrate that it adapts well to various architectures, model sizes and training strategies, and can achieve state-of-the-art performance consistently on image classification, object detection, and semantic segmentation tasks. Code is available at: https://github.com/hunto/DIST_KD.
8
+
9
+ # 1 Introduction
10
+
11
+ The advent of automatic feature engineering fuels deep neural networks to achieve remarkable success in a plethora of computer vision tasks, such as image classification [17, 19, 38, 48, 53], object detection [2, 23], and semantic segmentation [5, 54]. In the path of pursuing better performance, current deep learning models generally grow deeper and wider [13, 45]. However, such heavy models are clumsy to deploy in practice due to the limitations of computational and memory resources. For an efficient model with competitive performance to those larger models, knowledge distillation (KD) [16] has been proposed to boost the performance of the efficient model (student) by distilling the knowledge of a larger model (teacher) during training.
12
+
13
+ The essence of knowledge distillation relies on how to formulate and transfer the knowledge from teacher to student. The most intuitive yet effective approach is to match the probabilistic prediction (response) scores between the teacher and student via Kullback–Leibler (KL) divergence [16]. In this way, the student can be guided with more informative signals during training, and is thus expected to have more promising performance than that being trained stand-alone. Besides this vanilla prediction match, other works [11, 14, 34, 41] also investigate the knowledge within intermediate representations to further boost the distillation performance, but this usually induces additional training cost as a consequence. For example, OFD [14] proposes to distill the information via multiple intermediate layers, but requires additional convolutions for feature alignments; CRD [41] introduces a contrastive loss to transfer pair-wise relationships, but it needs to hold a memory bank for all 128-d features of ImageNet images, and produces additional 260M FLOPs of computation cost.
14
+
15
+ ![](images/3c98d691bf1e5ddef9f2ca4076934e2f714fa5c37330374aaa209dc25b59e6bb.jpg)
16
+ Figure 1: Comparisons of KD and our proposed DIST on ImageNet with different teachers. (a) The ResNet-18 students are trained using baseline strategy with different model sizes of the teacher. (b) The ResNet-18 students are trained using different strategies with ResNet-50 teachers.
17
+
18
+ Recently, a few studies [8, 29, 39] have been performed to address the poor learning issue of the student network when the student and teacher model sizes significantly differ. For example, TAKD [29] proposes to reduce the discrepancy of teacher and student by resorting to an additional teaching assistant of moderate model size; DGKD [39] further improves TAKD by densely gathering all the assistant models to guide the student. However, increasing the model size is only one of the popular approaches to have a stronger teacher. There lacks a thorough analysis on the training strategies to derive a stronger teacher and their effect on KD. Most importantly, a generic enough solution is preferred to address the difficulty of KD brought by stronger teachers, rather than struggling to deal with different types of stronger teachers (with larger model size or stronger training strategy) individually.
19
+
20
+ To understand what makes a stronger teacher and their effect on KD, we systematically study the prevalent strategies for designing and training deep neural networks, and show that:
21
+
22
+ • Beyond scaling up the model size, a stronger teacher can also be derived through advanced training strategies, e.g., label smoothing and data augmentation [51]. However, given a stronger teacher, the student’s performance on the vanilla KD could be dropped, even worse than training from scratch without KD, as shown in Figure 1. • The discrepancy between teacher and student tends to get fairly larger when we switch their training strategy to a stronger one (see Figure 2). In this case, an exact recovery of predictions via KL divergence could be challenging and lead to the failure of vanilla KD. • Preserving the relation of predictions between teacher and student is sufficient and effective. When transferring the knowledge from teacher to student, what we really care about is preserving the preference (relative ranks of predictions) by the teacher, instead of recovering the absolute values accurately. Correlation between teacher and student predictions could be favored to relax the exact match of KL divergence and distill the intrinsic relations.
23
+
24
+ In this paper, we thus leverage the Pearson correlation coefficient [33] as a new match manner to replace the KL divergence. In addition, besides the inter-class relations in prediction vector (see Figure 3), with the intuition that different instances have different spectrum of similarities with respect to each class, we also propose to distill the intra-class relations for further boosting the performance as Figure 3. Concretely, for each class, we gather its corresponding predicted probabilities of all instances in a batch, then transfer this relation from teacher to student. Our proposed method (dubbed DIST) is super simple, efficient, and practical, which can be implemented with only several lines of code (see Appendix A.1) and has almost the same training cost as the vanilla KD. As a result, the student can be liberated from the burden of matching the exact output of a strong teacher, but only be guided appropriately to distill those truly informative relations.
25
+
26
+ Extensive experiments are conducted on benchmark datasets to verify our effectiveness on various tasks, including image classification, object detection, and semantic segmentation. Experimental results show that our DIST significantly outperforms vanilla KD and those sophisticatedly-designed state-of-the-art KD methods. For example, with the same baseline settings on ImageNet, our DIST achieves the highest $7 2 . 0 7 \%$ accuracy on ResNet-18. With the stronger strategy, our method obtains $8 2 . 3 \%$ accuracy on the recent transformer Swin-T [27], improving KD by $1 \%$ .
27
+
28
+ ![](images/f3f3dab51630049eab346bb9d566a7028a1d93061af433377c97d78cb92e8c8f.jpg)
29
+ Figure 2: Discrepancy between the predictions of models trained standalone with different strategies on ImageNet validation set. R18B1 represents ResNet-18 trained with strategy B1 for instance. Details of training strategies B1 and B2 refer to Table 1.
30
+
31
+ # 2 Revisiting Prediction Match of KD
32
+
33
+ In vanilla knowledge distillation [16], the knowledge is transferred from a pre-trained teacher model to a student model by minimizing the discrepancy between the prediction scores of the teacher and student models.
34
+
35
+ Formally, with the logits $Z ^ { ( \mathrm { s } ) } \in \mathbb { R } ^ { B \times C }$ and $Z ^ { ( \mathrm { t } ) } \in \mathbb { R } ^ { B \times C }$ of student and teacher networks, where $B$ and $C$ denote batch size and the number of classes, respectively, the vanilla KD loss [16] is represented as
36
+
37
+ $$
38
+ \mathcal { L } _ { \mathrm { K D } } : = \frac { \tau ^ { 2 } } { B } \sum _ { i = 1 } ^ { B } \mathrm { K L } ( Y _ { i , : } ^ { ( \mathrm { t } ) } , Y _ { i , : } ^ { ( \mathrm { s } ) } ) = \frac { \tau ^ { 2 } } { B } \sum _ { i = 1 } ^ { B } \sum _ { j = 1 } ^ { C } Y _ { i , j } ^ { ( \mathrm { t } ) } \log \left( \frac { Y _ { i , j } ^ { ( \mathrm { t } ) } } { Y _ { i , j } ^ { ( \mathrm { s } ) } } \right) ,
39
+ $$
40
+
41
+ where $\mathrm { K L }$ refers to Kullback–Leibler divergence with
42
+
43
+ $$
44
+ Y _ { i , : } ^ { \mathrm { ( s ) } } = s o f t m a x ( Z _ { i , : } ^ { \mathrm { ( s ) } } / \tau ) , \quad Y _ { i , : } ^ { \mathrm { ( t ) } } = s o f t m a x ( Z _ { i , : } ^ { \mathrm { ( t ) } } / \tau ) ,
45
+ $$
46
+
47
+ being the probabilistic prediction vectors, and $\tau$ is the temperature factor to control the softness of logits.
48
+
49
+ In addition to the teacher’s soft targets in Eq.(1), KD [16] stated that it is beneficial to train the student together with ground-truth labels, and the overall training loss is composed of the original classification loss $\mathcal { L } _ { \mathrm { c l s } }$ and KD loss ${ \mathcal { L } } _ { \mathrm { K D } }$ , i.e.,
50
+
51
+ $$
52
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { t r } } = \alpha \mathcal { L } _ { \mathrm { c l s } } + \beta \mathcal { L } _ { \mathrm { K D } } , } \end{array}
53
+ $$
54
+
55
+ where $\mathcal { L } _ { \mathrm { c l s } }$ is usually the cross-entropy loss between the predictions of student network and groundtruth labels, $\alpha$ and $\beta$ are factors for balancing the losses.
56
+
57
+ # 2.1 Catastrophic discrepancy with a stronger teacher
58
+
59
+ As illustrated in Section 1, the effect of a teacher on KD has not been sufficiently investigated, especially when the performance of pre-trained teacher grows stronger, such as with larger model size or being trained with more advanced and competing strategies, e.g., label smoothing, mix-up [51], auto augmentations [9], etc. With this regard, as Figure 2, we train ResNet-18 and ResNet-50 standalone with strategy B1 and strategy $\bar { \mathbf { B } \bar { 2 } }$ , and obtain 4 trained models (R18B1, R18B2, R50B1, and R50B2 with accuracies $6 9 . 7 6 \%$ , $7 3 . 4 \%$ , $7 6 . 1 3 \%$ , and $78 . 5 \%$ , respectively), then compare their discrepancy using KL divergence ( $\mathit { \check { \tau } } = 1$ and $\tau = 4$ ) on the predicted probabilities $\mathbf { Y }$ . We have the following observations:
60
+
61
+ ![](images/2bd1eb75068dbf9263a14589f57b9fc951fe07021affa3ae30f02f0e7cd2010b.jpg)
62
+ Figure 3: Difference between our DIST and existing KD methods. Conventional KD matches the outputs of student $( s \in \mathbb { R } ^ { 5 } )$ ) to teacher $( t \in \mathbb { R } ^ { 5 } )$ ) point-wisely; instance relation methods operate on the feature level and measure the internal correlations (corr.) between instances in student and teacher separately, then transfer the teacher’s correlations to student. Our DIST proposes to maintain the inter-class and intra-class relations between student and teacher. Inter-class relation: correlation between the predicted probabilistic distributions on each instance of teacher and student. Intra-class relation: correlation of the probabilities of all the instances on each class.
63
+
64
+ • The outputs of ResNet-18 do not change much with the stronger strategy compared to ResNet-50. This implies that the representational capacity limits the student’s performance, and it tends to be fairly challenging for the student to exactly match the teacher’s outputs as their discrepancy becomes larger.
65
+ When the teacher and student models are trained with a stronger strategy, the discrepancy between teacher and student would be larger. This indicates that when we adopt KD with a stronger training strategy, the misalignment between KD loss and classification loss would be severer, thus disturbing the student’s training.
66
+
67
+ As a result, the exact match (i.e., the loss reaches the minimal if and only if the teacher and student outputs are exactly identical) with KL divergence seems way too overambitious and demanding since the discrepancy between student and teacher can be considerably huge. Since the exact match can be detrimental with a stronger teacher, our intuition is to develop a relaxed manner for matching the predictions between the teacher and student.
68
+
69
+ # 3 DIST: Distillation from A Stronger Teacher
70
+
71
+ # 3.1 Relaxed match with relations
72
+
73
+ The prediction scores indicate the teacher’s confidence (or preference) over all classes. For a relaxed match of predictions between the teacher and student, we are motivated to consider what we really care about for the teacher’s output. Instead of the exact probabilistic values, actually, during inference, we are only concerned about their relations, i.e., relative ranks of predictions of teacher.
74
+
75
+ In this way, for some metric $d ( \cdot , \cdot )$ with $\mathbb { R } ^ { C } \times \mathbb { R } ^ { C } \mathbb { R } ^ { + }$ , the exact match can be formulated that $d ( { \pmb a } , { \pmb b } ) = 0$ if ${ \pmb a } = { \pmb b }$ for any two prediction vector as $Y _ { i , : } ^ { ( \mathrm { s } ) }$ and $Y _ { i , : } ^ { ( \mathrm { t } ) }$ in the KL divergence of Eq.(1). Then as a relaxed match, we can introduce additional mappings $\phi ( \cdot )$ and $\psi ( \cdot )$ with $\mathbb { R } ^ { C } \to \mathbb { R } ^ { C }$ such that
76
+
77
+ $$
78
+ d ( \phi ( \mathbf { a } ) , \psi ( \pmb { b } ) ) = d ( \mathbf { a } , \pmb { b } ) , \forall \mathbf { a } , \pmb { b }
79
+ $$
80
+
81
+ Therefore, $d ( { \pmb a } , { \pmb b } ) = 0$ does not necessarily require $\textbf { \em a }$ and $^ { b }$ should be exactly the same. Nevertheless, since we care about the relation within $\textbf { \em a }$ or $^ { b }$ , the mappings $\phi$ and $\psi$ should be isotone and do not affect the semantic information and inference result of the prediction vector.
82
+
83
+ With this regard, a simple yet effective choice for the isotone mapping is the positive linear transformation, namely,
84
+
85
+ $$
86
+ d ( m _ { 1 } { \pmb a } + n _ { 1 } , m _ { 2 } { \pmb b } + n _ { 2 } ) = d ( { \pmb a } , { \pmb b } ) ,
87
+ $$
88
+
89
+ where $m _ { 1 }$ $_ { \cdot 1 } , m _ { 2 } , n _ { 1 }$ , and $n _ { 2 }$ are constants with $m _ { 1 } \times m _ { 2 } > 0$ . As a result, this match could be invariant under separate changes in scale and shift for the predictions. Actually, to satisfy the property Eq.(5), we can thus adopt the widely-used Pearson’s distance as the metric, i.e.,
90
+
91
+ $$
92
+ \begin{array} { r } { d _ { \mathrm { p } } ( \pmb { u } , \pmb { v } ) : = 1 - \rho _ { \mathrm { p } } ( \pmb { u } , \pmb { v } ) . } \end{array}
93
+ $$
94
+
95
+ $\rho _ { \mathrm { p } } ( { \pmb u } , { \pmb v } )$ is the Pearson correlation coefficient between two random variables $\textbf { \em u }$ and $\textbf { { v } }$
96
+
97
+ $$
98
+ \rho _ { \mathrm { p } } ( { \pmb u } , { \pmb v } ) : = \frac { \mathrm { C o v } ( { \pmb u } , { \pmb v } ) } { \mathrm { S t d } ( { \pmb u } ) \mathrm { S t d } ( { \pmb v } ) } = \frac { \sum _ { i = 1 } ^ { C } ( u _ { i } - \bar { u } ) ( v _ { i } - \bar { v } ) } { \sqrt { \sum _ { i = 1 } ^ { C } ( u _ { i } - \bar { u } ) ^ { 2 } \sum _ { i = 1 } ^ { C } ( v _ { i } - \bar { v } ) ^ { 2 } } }
99
+ $$
100
+
101
+ where $\operatorname { C o v } ( u , v )$ is the covariance of $\textbf { \em u }$ and $v , { \bar { u } }$ and $\operatorname { S t d } ( { \pmb u } )$ denote the mean and standard derivation of $\textbf { \em u }$ , respectively.
102
+
103
+ In this way, we can define the relation as correlation. More specifically, and the original exact match in vanilla KD [16] can thus be relaxed and replaced by maximizing the linear correlation to preserve the relation of teacher and student on the probabilistic distribution of each instance, which we call inter-class relation. Formally, for each pair of prediction vector ${ Y } _ { i , : } ^ { ( \mathrm { s } ) }$ ) and Y (t)i,: , the inter-relation loss can be formulated as
104
+
105
+ $$
106
+ \mathcal { L } _ { \mathrm { i n t e r } } : = \frac { 1 } { B } \sum _ { i = 1 } ^ { B } d _ { \mathrm { p } } ( Y _ { i , : } ^ { ( \mathrm { s } ) } , Y _ { i , : } ^ { ( \mathrm { t } ) } ) .
107
+ $$
108
+
109
+ Some isotone mappings or metrics can also be used to relax the match as Eq.(4), such as cosine similarity investigated empirically in Section 4.5; other more advanced and delicate choices could be left as future work.
110
+
111
+ # 3.2 Better distillation with intra-relations
112
+
113
+ Besides the inter-class relation, where we transfer the relation of multiple classes in each instance, the prediction scores of multiple instances in each class are also informative and useful. This scores indicate the similarities of multiple instances to one class. For instance, suppose we have three images containing “cat”, “dog”, and “plane”, respectively, and they have three prediction scores on the ‘cat’ class, denoted as $e$ , $f$ , and $g$ . Generally, the picture “cat” should have the largest score to the “cat” class, while the “plane” should have the smallest score since it is inanimate. This relation of $^ { \bullet } e > f > g ^ { , \bullet }$ could also be transferred to the student. Besides, even for the images from the same class, the intrinsic intra-class variance of the semantic similarities is actually also informative. It indicates the prior from the teacher that which one is more reliable to cast in this class.
114
+
115
+ Therefore, we also encourage to distill this intra-relation for better performance. Actually, define prediction matrix Y (s) and Y (t) with each row as Y (si,: ) and Y (t)i,: , then the above inter-relation is to maximize the correlation row-wisely (see Figure 3). In contrast, for intra-relation, the corresponding loss is thus to maximize the correlation column-wisely, i.e.,
116
+
117
+ $$
118
+ \mathcal { L } _ { \mathrm { \mathrm { i n t r a } } } : = \frac { 1 } { C } \sum _ { j = 1 } ^ { C } d _ { \mathrm { p } } ( Y _ { : , j } ^ { ( \mathrm { s } ) } , Y _ { : , j } ^ { ( \mathrm { t } ) } ) .
119
+ $$
120
+
121
+ As a result, the overall training loss $\mathcal { L } _ { \mathrm { t r } }$ can be composed of the classification loss, inter-class KD loss, and intra-class KD loss, i.e.,
122
+
123
+ $$
124
+ \mathcal { L } _ { \mathrm { t r } } = \alpha \mathcal { L } _ { \mathrm { c l s } } + \beta \mathcal { L } _ { \mathrm { i n t e r } } + \gamma \mathcal { L } _ { \mathrm { i n t r a } } ,
125
+ $$
126
+
127
+ where $\alpha , \beta$ , and $\gamma$ are factors for balancing the losses. In this way, via the relation loss, we have endowed the student with freedom more or less to match the teacher network’s output adaptively, thus boosting the distillation performance to a great extent.
128
+
129
+ Table 1: Training strategies on image classification tasks. BS: batch size; $L R$ : learning rate; WD: weight decay; LS: label smoothing; EMA: model exponential moving average; RA: RandAugment [9]; $R E$ : random erasing; CJ: color jitter.
130
+
131
+ <table><tr><td>Strategy</td><td>Dataset</td><td>Epochs</td><td>Total Initial BS</td><td>LR</td><td>Optimizer</td><td>WD</td><td></td><td></td><td>LS EMA LR scheduler</td><td></td><td>Data augmentation</td></tr><tr><td>A1</td><td>CIFAR-100</td><td>240</td><td>64</td><td>0.05</td><td>SGD</td><td>5×10-4</td><td></td><td></td><td></td><td>×0.1 at 150,180,210 epochs crop + flip</td><td></td></tr><tr><td>B1</td><td>ImageNet</td><td>100</td><td>256</td><td>0.1</td><td>SGD</td><td>1×10-4</td><td></td><td>1</td><td>-</td><td>×0.1 every 30 epochs</td><td>crop + flip</td></tr><tr><td>B2</td><td>ImageNet</td><td>450</td><td>768</td><td>0.048</td><td>3RMSProp</td><td>1×10-5</td><td></td><td></td><td></td><td>0.10.9999 ×0.97 every 2.4 epochs</td><td>{Bl} +RA + RE</td></tr><tr><td>B3</td><td>ImageNet</td><td>300</td><td>1024</td><td>5e-4</td><td>AdamW</td><td>5×10-²</td><td>0.1</td><td></td><td>1 cosine</td><td></td><td>{B2} +CJ+ Mixup +CutMix</td></tr></table>
132
+
133
+ Table 2: Evaluation results of baseline settings on ImageNet. We use ResNet-34 and ResNet-50 released by Torchvision [28] as our teacher networks, and follow the standard training strategy (B1). Student (teacher) Teacher Student KD [16] OFD [14] CRD [41] SRRL [47] Review [7] DIST
134
+
135
+ <table><tr><td>ResNet-18 (ResNet-34)</td><td>Top-1 Top-5</td><td>73.31 91.42</td><td>69.76 89.08</td><td>70.66 89.88</td><td>71.08 90.07</td><td>71.17 90.13</td><td>71.73 90.60</td><td>71.61 90.51</td><td>72.07 90.42</td></tr><tr><td>MobileNet (ResNet-50)</td><td>Top-1 Top-5</td><td>76.16 92.86</td><td>70.13 89.49</td><td>70.68 90.30</td><td>71.25 90.34</td><td>71.37 90.41</td><td>72.49 90.92</td><td>72.56 91.00</td><td>73.24 91.12</td></tr></table>
136
+
137
+ # 4 Experiments
138
+
139
+ # 4.1 Experimental settings
140
+
141
+ Training strategies. The training strategies of image classification task are summarized in Table 1. CIFAR-100. For fair comparisons, we use the same training strategies (referred to $A l$ in Table 1) and pretrained models following CRD [41]. ImageNet. B1: for comparisons with previous KD methods, we train our baselines with the same simple training strategy as CRD [41]. B2: to validate the effectiveness of KD methods on modern training strategies, we follow EfficientNet [40] and design a training strategy B2, which can significantly improve the performance compared to B1. B3: the strategy B3 is used for training Swin-Transformers [27], and contains even more stronger data augmentations and regularization.
142
+
143
+ Loss weights. On CIFAR-100 and ImageNet, we set $\alpha = 1$ , $\beta = 2$ , and $\gamma = 2$ in Eq.(10). On object detection and semantic segmentation, these three factors are all equal to 1. For KD [16], we set $\alpha = 0 . 9$ , $\beta = 1$ in Eq.(3), and use a default temperature $\tau = 4$ . Specifically, instead of using $\tau = 1$ on ImageNet, we choose a larger temperature $\tau = 4$ on CIFAR-100, as it is easy to get overfit and the learned probabilistic distribution is sharp on CIFAR-100.
144
+
145
+ # 4.2 Image Classification
146
+
147
+ Baseline results on ImageNet. We first compare our method with prior works using the baseline settings. As shown in Table 2, our DIST significantly outperforms prior KD methods. Note that our method is only conducted on the outputs of models, and has a similar computational cost as KD [16]. Nevertheless, it even achieves better performance compared to those sophisticatedlydesigned methods. For example, CRD [41] needs to preserve a memory bank for all 128-d features of ImageNet images, and produces additional 260M FLOPs of computation cost; SRRL [47] and Review [7] require additional convolutions for feature alignments. The implementation of DIST can be found in Appendix A.1, which is quite simple compared to these methods.
148
+
149
+ Distillation from stronger teacher models. As the stronger teachers come from larger model sizes and stronger strategies, we here first conduct experiments to compare our DIST with the vanilla KD on different scales (model sizes) of ResNets with baseline strategy B1. As shown in Table 3, when the teacher goes larger, the ResNet-18 students perform even worse than that with a medium-sized ResNet-50 teacher. Nevertheless, our DIST shows an upward trend with larger teachers, and the improvements compared to KD also become more significant, indicating that our DIST tackles better on the large discrepancy between the student and larger teacher.
150
+
151
+ Distillation from stronger training strategies. Recently, the performance of models on ImageNet has been significantly improved by the sophisticated training strategies and strong data augmentations (e.g., TIMM [44] achieves $8 0 . 4 \%$ accuracy on ResNet-50 while the baseline strategy B1 only obtains $7 6 . 1 \%$ . However, most of the KD methods still conduct experiments with simple training settings. It is seldomly investigated whether the KD methods are suitable to the advanced strategies. In this way, we conduct experiments with advanced training strategies and compare our method with vanilla KD, instance relation-based RKD [30], and SRRL [47].
152
+
153
+ Table 3: Performance of ResNet-18 and ResNet-34 on ImageNet with different sizes of teachers.
154
+
155
+ <table><tr><td rowspan="2">Student</td><td rowspan="2">Teacher</td><td colspan="4">Top-1 ACC (%)</td></tr><tr><td> student</td><td>teacher</td><td>KD</td><td>DIST</td></tr><tr><td rowspan="4">ResNet-18</td><td>ResNet-34</td><td rowspan="4">69.76</td><td>73.31</td><td>71.21</td><td>72.07 (+0.86)</td></tr><tr><td>ResNet-50</td><td>76.13</td><td>71.35</td><td>72.12 (+0.77)</td></tr><tr><td>ResNet-101</td><td>77.37</td><td>71.09</td><td>72.08 (+0.99)</td></tr><tr><td>ResNet-152</td><td>78.31</td><td>71.12</td><td>72.24 (+1.12)</td></tr><tr><td rowspan="4">ResNet-34</td><td>ResNet-50</td><td rowspan="2">73.31</td><td>76.13</td><td>74.73</td><td>75.06 (+0.33)</td></tr><tr><td>ResNet-101</td><td>77.37</td><td>74.89</td><td>75.36 (+0.47)</td></tr><tr><td>ResNet-152</td><td>78.31</td><td>74.87</td><td>75.42 (+0.55)</td></tr><tr><td></td><td></td><td></td><td></td></tr></table>
156
+
157
+ Table 4: Performance of students trained with strong strategies on ImageNet. The Swin- $T$ is trained with strategy B3 in Table 1, others are trained with B2. †: trained by [44]. ‡: Pretrained on ImageNet-22K.
158
+
159
+ <table><tr><td rowspan="2">Teacher</td><td rowspan="2">Student</td><td colspan="4">Top-1 ACC (%)</td></tr><tr><td>teacher student</td><td>KD[16] RKD[30]</td><td>SRRL [47]</td><td>DIST</td></tr><tr><td rowspan="4">ResNet-50t</td><td>ResNet-18</td><td rowspan="4">80.1</td><td>73.4</td><td>72.6 72.9 71.2</td><td>74.5</td></tr><tr><td>ResNet-34</td><td>76.8</td><td>77.2 76.6 76.7</td><td> 77.8</td></tr><tr><td>MobileNetV2</td><td>73.6</td><td>71.7 73.1 69.2</td><td> 74.4</td></tr><tr><td>EfficientNet-B0</td><td>78.0 77.4</td><td>77.5 77.3</td><td>78.6</td></tr><tr><td rowspan="2">Swin-L</td><td>ResNet-50</td><td rowspan="2">86.3</td><td>78.5</td><td>80.0 78.9 78.6</td><td>80.2</td></tr><tr><td>Swin-T</td><td>81.3 81.5</td><td>81.2 81.5</td><td> 82.3</td></tr></table>
160
+
161
+ We first train traditional CNNs with strong strategies, and also use a strong ResNet-50 with $8 0 . 1 \%$ accuracy trained by [44] as the teacher. As results shown in Table 4, on both similar architectures (ResNet-18, ResNet-34) and dissimilar architectures (MobileNetV2, EfficientNet-B0), our DIST can achieve the best performance. Note that RKD and SRRL can perform worse than training from scratch, especially when the students are small (ResNet-18 and MobileNet) or the architectures of teacher and student are fairly different (ResNet-50 and Swin-L), this might be because they focus on the intermediate features, which can be more challenging for the student to recover teacher’s features compared to predictions.
162
+
163
+ Furthermore, we experiment on the recent state-of-the-art Swin-Transformer [27]. The results show that our DIST gains improvements on even more stronger models and strategies. For example, with Swin-L teacher, our method improves ResNet-50 and Swin-T by $1 . 7 \%$ and $1 . 0 \%$ , respectively.
164
+
165
+ CIFAR-100. The results on CIFAR-100 dataset in Table 5 show that, by distilling on the predicted logits, our method even outperforms those sophisticatedly-designed feature distillation methods.
166
+
167
+ # 4.3 Object Detection
168
+
169
+ We further investigate the effectiveness of DIST on downstream tasks. We conduct experiments on MS COCO object detection dataset [25], and simply leverage our DIST as an additional supervision on the final predictions of classes. Following [37, 52], we use the same standard training strategies and utilize Cascade Mask R-CNN [2] with ResNeXt-101 backbone as the teacher for two-stage student of Faster R-CNN [23] with ResNet-50 backbone; while for one-stage RetinaNet [24] with ResNet-50 backbone, the RetinaNet with ResNeXt-101 backbone is utilized as the teacher.
170
+
171
+ As shown in Table 6, our DIST achieves competitive results on COCO validation set. For comparisons, we train the vanilla KD under the same settings as our DIST, the results show that our DIST significantly outperforms vanilla KD by simply replacing the loss functions. Moreover, by combining
172
+
173
+ Table 5: Evaluation results on CIFAR-100 dataset. The upper and lower models denote teacher and student, respectively.
174
+
175
+ <table><tr><td rowspan="2">Method</td><td colspan="3">Same architecture style</td><td colspan="3">Different architecture style</td></tr><tr><td>WRN-40-2 WRN-40-1</td><td>ResNet-56 ResNet-20</td><td>ResNet-32x4 ResNet-8x4</td><td>ResNet-50 MobileNetV2 ShuffleNetV1 ShuffleNetV2</td><td>ResNet-32x4 ResNet-32x4</td><td></td></tr><tr><td>Teacher</td><td>75.61</td><td>72.34</td><td>79.42</td><td>79.34</td><td>79.42</td><td>79.42</td></tr><tr><td>Student</td><td>71.98</td><td>69.06</td><td>72.50</td><td>64.6</td><td>70.5</td><td>71.82</td></tr><tr><td colspan="7">Feature-based methods</td></tr><tr><td>FitNet [35]</td><td>72.24±0.24 69.21±0.36</td><td></td><td>73.50±0.28</td><td>63.16±0.47</td><td>73.59±0.15</td><td>73.54±0.22</td></tr><tr><td>VID [1]</td><td>73.30±0.13</td><td>70.38±0.14</td><td>73.09±0.21</td><td>67.57±0.28</td><td>73.38±0.09</td><td>73.40±0.17</td></tr><tr><td>RKD [30]</td><td>72.22±0.20</td><td>69.61±0.06</td><td>71.90±0.11</td><td>64.43±0.42</td><td>72.28±0.39</td><td>73.21±0.28</td></tr><tr><td>PKT [31]</td><td>73.45±0.19</td><td>70.34±0.04</td><td>73.64±0.18</td><td>66.52±0.33</td><td>74.10±0.25</td><td>74.69±0.34</td></tr><tr><td>CRD [41]</td><td>74.14±0.22</td><td>71.16±0.17</td><td>75.51±0.18</td><td>69.11±0.28</td><td>75.11±0.32</td><td>75.65±0.10</td></tr><tr><td colspan="7">Logits-based methods</td></tr><tr><td>KD [16]</td><td>73.54±0.20 70.66±0.24 73.33±0.25</td><td></td><td></td><td>67.35±0.32</td><td>74.07±0.19</td><td>74.45±0.27</td></tr><tr><td> DIST</td><td></td><td>74.73±0.24 71.75±0.30 76.31±0.19</td><td></td><td>68.66±0.23</td><td>76.34±0.18</td><td>77.35±0.25</td></tr></table>
176
+
177
+ Table 6: Results on COCO validation set. T: teacher; S: student. \*: We implement KD using $\tau = 1$ and other settings are the same as DIST.
178
+
179
+ <table><tr><td>Method</td><td colspan="5">AP AP50 AP75 APs APM APL</td></tr><tr><td>T: Cascade Mask RCNN-X101</td><td>Two-stage detectors</td><td>45.6 64.1 49.7</td><td>26.2</td><td>49.6 42.1</td><td>60.0 50.3</td></tr><tr><td>S: Faster RCNN-R50 KD [16]* FKD [52]</td><td>38.4 39.7 41.5</td><td>59.0 61.2 62.2</td><td>42.0 43.0 45.1</td><td>21.5 23.2 23.5</td><td>43.3 51.7 45.0 55.3</td></tr><tr><td>CWD [37] DIST DIST + mimic</td><td>41.7 40.4 61.7</td><td>62.0 45.5 43.8</td><td>23.3 23.9</td><td>45.5 44.6 41.8 62.4 45.6 23.4 46.1</td><td>55.5 52.6 55.0</td></tr><tr><td>T: RetinaNet-X101 S:RetinaNet-R50 KD [16]*</td><td>One-stage detectors 41.0 37.2 56.5</td><td>60.944.0 37.4 56.739.6</td><td>39.3 20.4</td><td>23.9 45.2 20.0 40.7 40.4</td><td>54.0 49.7 49.5</td></tr><tr><td>FKD [52] CWD [37]</td><td>39.6 40.8</td><td>558.8 60.4 59.5</td><td>42.1 43.4</td><td>22.7 43.3 22.7 44.5</td><td>52.5 55.3</td></tr><tr><td>DIST DIST + mimic</td><td>39.8 40.1 59.4</td><td>42.5 43.0</td><td>22.0</td><td>43.7 23.2 44.0</td><td>53.0 53.6</td></tr></table>
180
+
181
+ Table 7: Results on Cityscapes val dataset. All models are pretrained on ImageNet.
182
+
183
+ <table><tr><td rowspan=1 colspan=3>Method</td><td rowspan=1 colspan=1>mIoU (%)</td></tr><tr><td rowspan=1 colspan=3>T: DeepLabV3-R101</td><td rowspan=1 colspan=1>78.07</td></tr><tr><td rowspan=1 colspan=3>S: DeepLabV3-R18</td><td rowspan=1 colspan=1>74.21</td></tr><tr><td rowspan=1 colspan=3>SKD [26]</td><td rowspan=3 colspan=1>75.4275.59</td></tr><tr><td rowspan=2 colspan=2>IFVD [43]</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=2 colspan=3>CWD [37]</td></tr><tr><td rowspan=1 colspan=1>75.55</td></tr><tr><td rowspan=1 colspan=3>CIRKD [46]</td><td rowspan=1 colspan=1>76.38</td></tr><tr><td rowspan=1 colspan=3>DIST</td><td rowspan=1 colspan=1>77.10</td></tr><tr><td rowspan=1 colspan=3>S: PSPNet-R18</td><td rowspan=1 colspan=1>72.55</td></tr><tr><td rowspan=1 colspan=3>SKD [26]</td><td rowspan=3 colspan=1>73.2973.7174.36</td></tr><tr><td rowspan=1 colspan=3>IFVD [43]</td></tr><tr><td rowspan=1 colspan=3>CWD [37]</td></tr><tr><td rowspan=1 colspan=3>CIRKD [46]</td><td rowspan=1 colspan=1>74.73</td></tr><tr><td rowspan=1 colspan=3> DIST</td><td rowspan=1 colspan=1>76.31</td></tr></table>
184
+
185
+ DIST with mimic, which minimizes the mean square error between FPN features of teacher and student, we can even outperform the state-of-the-art KD methods designed for object detection.
186
+
187
+ # 4.4 Semantic Segmentation
188
+
189
+ We also perform experiments on semantic segmentation, a challenging dense prediction task. Following [37, 43, 46], we train DeepLabV3 [6] and PSPNet [54] with ResNet-18 backbone on Cityscapes dataset, and adopt our DIST on the predictions of classification head using a teacher with ResNet101 backbone of DeepLabV3. As the results summarized in Table 7, with only the supervision of class predictions, our DIST can significantly outperform existing knowledge distillation methods on semantic segmentation task. For example, our DIST outperforms recent state-of-the-art method CIRKD [46] by $1 . 5 8 \%$ on PSPNet-R18. This demonstrate our effectiveness on relation modeling.
190
+
191
+ # 4.5 Ablation studies
192
+
193
+ Effects of inter-class and intra-class correlations. This paper proposes two types of relations: interclass and intra-class relations. To validate the effectiveness of each relation, we conduct experiments to train students with these relations separately. The results on Table 8 verify that, both inter-class and intra-class relations can outperform the vanilla KD; also, the performance could be further boosted by combining them together.
194
+
195
+ Table 8: Ablation of inter-class and intra-class relations on ImageNet. The student and teacher models are ResNet-18 and ResNet-34, respectively.
196
+
197
+ <table><tr><td>Method</td><td>Inter</td><td>Intra</td><td>ACC (%)</td></tr><tr><td>KD</td><td>-</td><td>1</td><td>71.21</td></tr><tr><td>DIST (KL div.) DIST (KL div.)</td><td>× √</td><td>√ &lt;</td><td>70.61 71.62</td></tr><tr><td>DIST</td><td>√</td><td>×</td><td>71.63</td></tr><tr><td>DIST</td><td>×</td><td>√</td><td>71.55</td></tr><tr><td>DIST</td><td>√</td><td>√</td><td></td></tr><tr><td></td><td></td><td></td><td>72.07</td></tr></table>
198
+
199
+ Effect of intra-class relation in vanilla KD. To investigate the effectiveness of intra-class relation in vanilla KD, we adopt experiments to train our DIST using KL divergence as the relation metric, denoted as $D I S T ( K L { \dot { d } } i \nu . ) ^ { 3 }$ . As the results summarized in Table 8, adding intra-class relation in the vanilla KD can also improve the performance (from $7 1 . 2 1 \%$ to $7 1 . 6 2 \%$ ). However, when the student is trained with intra-class relation only, the improvement of using KL divergence is less significant than using Pearson correlation $7 0 . 6 1 \%$ vs. $7 1 . 5 5 \%$ ), since the means and variances of intra-class distributions could be varied.
200
+
201
+ Effect of training students with KD loss only. Training student with only the KD loss can better reflect the distillation ability and the information richness of supervision signals. As results in Table 9 show that, when the student is trained with only the KD loss, our DIST significantly outperforms the vanilla KD. Without using the ground-truth labels, it can even outperform the standalone training accuracy, which indicates the effectiveness of our DIST in distilling those truly-beneficial relations.
202
+
203
+ Table 9: Comparisons of training KD with or without the classification loss on ImageNet. The student and teacher models are ResNet-18 and ResNet-34, respectively. The original accuracy of ResNet-18 without KD is $6 9 . 7 6 \%$ .
204
+
205
+ <table><tr><td>Method</td><td>w/ cls. loss</td><td>w/o cls. loss</td></tr><tr><td>KD</td><td>71.21</td><td>68.12</td></tr><tr><td>DIST</td><td>72.07</td><td>70.65</td></tr></table>
206
+
207
+ More ablation studies can be found in Section A.3.
208
+
209
+ # 5 Conclusion
210
+
211
+ This paper presents a new knowledge distillation (KD) method named DIST to implement better distillation from a stronger teacher. We empirically study the catastrophic discrepancy problem between the student and a stronger teacher, and propose a relation-based loss to relax the exact match of KL divergence in a linear sense. Our method DIST is simple yet effective in handling strong teachers. Extensive experiments show our superiority in various benchmark tasks. For example, DIST even outperforms state-of-the-art KD methods designed specifically for object detection and semantic segmentation.
212
+
213
+ # Acknowledgements
214
+
215
+ This work was supported in part by the Australian Research Council under Project DP210101859 and the University of Sydney Research Accelerator (SOAR) Prize.
216
+
217
+ # References
218
+
219
+ [1] knowledge transfer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9163–9171, 2019. 8 [2] Z. Cai and N. Vasconcelos. Cascade r-cnn: High quality object detection and instance segmentation. IEEE Transactions on Pattern Analysis and Machine Intelligence, page 1–1, 2019. 1, 7 [3] K. Chandrasegaran, N.-T. Tran, Y. ZHAO, and N. man Cheung. To smooth or not to smooth? on compatibility between label smoothing and knowledge distillation, 2022. 14 [4] H. Chen, Y. Wang, C. Xu, C. Xu, and D. Tao. Learning student networks via feature embedding. IEEE Transactions on Neural Networks and Learning Systems, 32(1):25–35, 2020. 13 [5] L.-C. Chen, G. Papandreou, F. Schroff, and H. Adam. Rethinking atrous convolution for semantic image segmentation. arXiv preprint arXiv:1706.05587, 2017. 1 [6] L.-C. Chen, Y. Zhu, G. Papandreou, F. Schroff, and H. Adam. Encoder-decoder with atrous separable convolution for semantic image segmentation. In Proceedings of the European conference on computer vision (ECCV), pages 801–818, 2018. 8 [7] P. Chen, S. Liu, H. Zhao, and J. Jia. Distilling knowledge via knowledge review. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5008–5017, 2021. 6 [8] J. H. Cho and B. Hariharan. On the efficacy of knowledge distillation. In Proceedings of the IEEE/CVF international conference on computer vision, pages 4794–4802, 2019. 2 [9] E. D. Cubuk, B. Zoph, J. Shlens, and Q. V. Le. Randaugment: Practical automated data augmentation with a reduced search space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, pages 702–703, 2020. 3, 6
220
+ [10] Y. Dodge. The concise encyclopedia of statistics. Springer Science & Business Media, 2008. 13
221
+ [11] S. Du, S. You, X. Li, J. Wu, F. Wang, C. Qian, and C. Zhang. Agree to disagree: Adaptive ensemble knowledge distillation in gradient space. advances in neural information processing systems, 33:12345– 12355, 2020. 1
222
+ [12] J. Gou, B. Yu, S. J. Maybank, and D. Tao. Knowledge distillation: A survey. International Journal of Computer Vision, 129(6):1789–1819, 2021.
223
+ [13] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016. 1
224
+ [14] B. Heo, J. Kim, S. Yun, H. Park, N. Kwak, and J. Y. Choi. A comprehensive overhaul of feature distillation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1921–1930, 2019. 1, 6
225
+ [15] B. Heo, M. Lee, S. Yun, and J. Y. Choi. Knowledge transfer via distillation of activation boundaries formed by hidden neurons. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 3779–3787, 2019.
226
+ [16] G. Hinton, O. Vinyals, and J. Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015. 1, 3, 5, 6, 7, 8, 14
227
+ [17] A. G. Howard, M. Zhu, B. Chen, D. Kalenichenko, W. Wang, T. Weyand, M. Andreetto, and H. Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017. 1
228
+ [18] T. Huang, Z. Li, H. Lu, Y. Shan, S. Yang, Y. Feng, F. Wang, S. You, and C. Xu. Relational surrogate loss learning. In International Conference on Learning Representations, 2022.
229
+ [19] T. Huang, S. You, B. Zhang, Y. Du, F. Wang, C. Qian, and C. Xu. Dyrep: Bootstrapping training with dynamic re-parameterization. arXiv preprint arXiv:2203.12868, 2022. 1
230
+ [20] M. G. Kendall. A new measure of rank correlation. Biometrika, 30(1/2):81–93, 1938. 13
231
+ [21] J. Kim, S. Park, and N. Kwak. Paraphrasing complex network: Network compression via factor transfer. arXiv preprint arXiv:1802.04977, 2018.
232
+ [22] S. Kong, T. Guo, S. You, and C. Xu. Learning student networks with few data. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 4469–4476, 2020.
233
+ [23] T.-Y. Lin, P. Dollár, R. Girshick, K. He, B. Hariharan, and S. Belongie. Feature pyramid networks for object detection. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2117–2125, 2017. 1, 7
234
+ [24] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollár. Focal loss for dense object detection. In Proceedings of the IEEE international conference on computer vision, pages 2980–2988, 2017. 7
235
+ [25] T.-Y. Lin, M. Maire, S. Belongie, J. Hays, P. Perona, D. Ramanan, P. Dollár, and C. L. Zitnick. Microsoft coco: Common objects in context. In European conference on computer vision, pages 740–755. Springer, 2014. 7
236
+ [26] Y. Liu, C. Shu, J. Wang, and C. Shen. Structured knowledge distillation for dense prediction. IEEE transactions on pattern analysis and machine intelligence, 2020. 8
237
+ [27] Z. Liu, Y. Lin, Y. Cao, H. Hu, Y. Wei, Z. Zhang, S. Lin, and B. Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint arXiv:2103.14030, 2021. 3, 6, 7
238
+ [28] S. Marcel and Y. Rodriguez. Torchvision the machine-vision package of torch. In Proceedings of the 18th ACM international conference on Multimedia, pages 1485–1488, 2010. 6
239
+ [29] S. I. Mirzadeh, M. Farajtabar, A. Li, N. Levine, A. Matsukawa, and H. Ghasemzadeh. Improved knowledge distillation via teacher assistant. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 5191–5198, 2020. 2
240
+ [30] W. Park, D. Kim, Y. Lu, and M. Cho. Relational knowledge distillation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3967–3976, 2019. 7, 8, 13, 14
241
+ [31] N. Passalis, M. Tzelepi, and A. Tefas. Probabilistic knowledge transfer for lightweight deep representation learning. IEEE Transactions on Neural Networks and Learning Systems, 32(5):2030–2039, 2020. 8
242
+ [32] A. Paszke, S. Gross, F. Massa, A. Lerer, J. Bradbury, G. Chanan, T. Killeen, Z. Lin, N. Gimelshein, L. Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32:8026–8037, 2019. 13
243
+ [33] K. Pearson. Vii. mathematical contributions to the theory of evolution.—iii. regression, heredity, and panmixia. Philosophical Transactions of the Royal Society of London. Series A, containing papers of a mathematical or physical character, (187):253–318, 1896. 2
244
+ [34] B. Peng, X. Jin, J. Liu, D. Li, Y. Wu, Y. Liu, S. Zhou, and Z. Zhang. Correlation congruence for knowledge distillation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 5007–5016, 2019. 1, 13
245
+ [35] A. Romero, N. Ballas, S. E. Kahou, A. Chassang, C. Gatta, and Y. Bengio. Fitnets: Hints for thin deep nets. arXiv preprint arXiv:1412.6550, 2014. 8
246
+ [36] Z. Shen, Z. Liu, D. Xu, Z. Chen, K.-T. Cheng, and M. Savvides. Is label smoothing truly incompatible with knowledge distillation: An empirical study. In International Conference on Learning Representations, 2020. 14
247
+ [37] C. Shu, Y. Liu, J. Gao, Z. Yan, and C. Shen. Channel-wise knowledge distillation for dense prediction. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 5311–5320, 2021. 7, 8
248
+ [38] K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014. 1
249
+ [39] W. Son, J. Na, J. Choi, and W. Hwang. Densely guided knowledge distillation using multiple teacher assistants. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 9395– 9404, 2021. 2
250
+ [40] M. Tan and Q. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning, pages 6105–6114. PMLR, 2019. 6
251
+ [41] Y. Tian, D. Krishnan, and P. Isola. Contrastive representation distillation. In International Conference on Learning Representations, 2019. 1, 6, 8, 14
252
+ [42] F. Tung and G. Mori. Similarity-preserving knowledge distillation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1365–1374, 2019.
253
+ [43] Y. Wang, W. Zhou, T. Jiang, X. Bai, and Y. Xu. Intra-class feature variation distillation for semantic segmentation. In European Conference on Computer Vision, pages 346–362. Springer, 2020. 8
254
+ [44] R. Wightman, H. Touvron, and H. Jégou. Resnet strikes back: An improved training procedure in timm. arXiv preprint arXiv:2110.00476, 2021. 7
255
+ [45] S. Xie, R. Girshick, P. Dollár, Z. Tu, and K. He. Aggregated residual transformations for deep neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1492–1500, 2017. 1
256
+ [46] C. Yang, H. Zhou, Z. An, X. Jiang, Y. Xu, and Q. Zhang. Cross-image relational knowledge distillation for semantic segmentation. arXiv preprint arXiv:2204.06986, 2022. 8
257
+ [47] J. Yang, B. Martinez, A. Bulat, and G. Tzimiropoulos. Knowledge distillation via softmax regression representation learning. In International Conference on Learning Representations, 2020. 6, 7, 14
258
+ [48] S. You, T. Huang, M. Yang, F. Wang, C. Qian, and C. Zhang. Greedynas: Towards fast one-shot nas with greedy supernet. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1999–2008, 2020. 1
259
+ [49] S. You, C. Xu, C. Xu, and D. Tao. Learning from multiple teacher networks. In Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 1285–1294, 2017.
260
+ [50] S. Zagoruyko and N. Komodakis. Paying more attention to attention: Improving the performance of convolutional neural networks via attention transfer. arXiv preprint arXiv:1612.03928, 2016.
261
+ [51] H. Zhang, M. Cisse, Y. N. Dauphin, and D. Lopez-Paz. mixup: Beyond empirical risk minimization. In International Conference on Learning Representations, 2018. 2, 3
262
+ [52] L. Zhang and K. Ma. Improve object detection with feature-based knowledge distillation: Towards accurate and efficient detectors. In International Conference on Learning Representations, 2020. 7, 8
263
+ [53] X. Zhang, X. Zhou, M. Lin, and J. Sun. Shufflenet: An extremely efficient convolutional neural network for mobile devices. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 6848–6856, 2018. 1
264
+ [54] H. Zhao, J. Shi, X. Qi, X. Wang, and J. Jia. Pyramid scene parsing network. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2881–2890, 2017. 1, 8
265
+
266
+ # Checklist
267
+
268
+ 1. For all authors...
269
+
270
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
271
+ (b) Did you describe the limitations of your work? [Yes] See Appendix.
272
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Appendix.
273
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
274
+
275
+ 2. If you are including theoretical results...
276
+
277
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
278
+
279
+ 3. If you ran experiments...
280
+
281
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Training details are provided in the paper. Training code and logs are released at GitHub: https://github.com/hunto/DIST_KD.
282
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
283
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] Standard deviations on CIFAR-100 are reported.
284
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
285
+
286
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
287
+
288
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
289
+ (b) Did you mention the license of the assets? [Yes]
290
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] Code and training logs are included.
291
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
292
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
293
+
294
+ 5. If you used crowdsourcing or conducted research with human subjects...
295
+
296
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
297
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
298
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/17RDXeF-skZ/17RDXeF-skZ.md ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DOING FAST ADAPTATION FAST: CONDITIONALLY INDEPENDENT DEEP ENSEMBLES FOR DISTRIBUTION SHIFTS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Classifiers in a diverse ensemble capture distinct predictive signals, which is valuable for datasets containing multiple strongly predictive signals. Performing fast adaptation at test time allows us to generalize to distributions where certain signals are no longer predictive, or to avoid relying on sensitive or protected attributes. However, ensemble learning is often expensive, even more so when we need to enforce diversity constraints between the high-dimensional representations of the classifiers. Instead, we propose an efficient and fast method for learning ensemble diversity. We minimize conditional mutual information of the output distributions between classifiers, a quantity which can be cheaply and exactly computed from empirical data. The resulting ensemble contains individually strong predictors that are only dependent because they predict the label. We demonstrate the efficacy of our method on shortcut learning tasks. Performing fast adaptation on our ensemble selects shortcut-invariant models that generalize well to test distributions where the shortcuts are uncorrelated with the label.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Some of the strongest scientific theories are supported by multiple sources of evidence, a principle described by 19th century philosopher William Whewell as “consilience”. Evolution is one such example, having been firmly corroborated by fields ranging from paleontology to genetics. In many real-world applications of machine learning, datasets can similarly contain multiple predictive signals that explain the label well. In these settings, a standard model typically learns from a combination of predictive features (Ross et al., 2018; Kirichenko et al., 2022). Such a model will fail to generalize to distribution shifts that break the correlation between certain signals and the label (Hovy & Søgaard, 2015; Hashimoto et al., 2018; Puli et al., 2022).
12
+
13
+ This shortcoming can be addressed by learning a diverse set or ensemble of classifiers. Such methods typically exploit some notion of independence to learn multiple classifiers that rely on different predictive signals. We can then perform fast adaptation, using a small amount of out-of-distribution (OOD) validation data to select the model that generalizes best. Learning diversity is also beneficial in and of itself: these classifiers are empirically shown to be more human-interpretable than if we were to fit a single model (Ross et al., 2018), possibly because they learn disentangled representations that correspond to natural factors of variation (Shu et al., 2019).
14
+
15
+ The key challenge is quantifying the right notion of diversity. Existing work has exploited concepts like input gradient or parameter orthogonality as a proxy for statistical independence (Teney et al., 2021; Xu et al., 2021). To tackle OOD generalization, which fundamentally requires additional assumptions or data beyond the observed training data (Bareinboim et al., 2022; Scholkopf et al., ¨ 2021), previous work have also assumed access to unlabelled test data and measured disagreement on those examples (Lee et al., 2022; Pagliardini et al., 2022). However, these objectives or assumptions are often prohibitive or unrealistic in real-world settings. For example, group-balanced test data is not always obtainable, e.g. when deploying a pneumonia model to multiple new hospitals whose patient profiles may change over time. Another costly example is enforcing input gradient orthogonality on high-dimensional covariates like images or text, where it can be challenging to avoid learning from orthogonal covariates of the same underlying feature, such as neighboring pixels.
16
+
17
+ To avoid the pitfalls of operating in high-dimensional input or parameter space, a promising line of work instead adopts the information-theoretic perspective and tackles the problem as representation learning. These approaches apply the information bottleneck method and minimize mutual information between the representations learnt by each classifier. Such an objective forces the classifiers to rely on distinctly meaningful features for prediction. Most notably, Pace et al. (2020) and Rame & Cord (2021) minimize mutual information between the classifier representations conditioned on the label. Since any pair of predictors cannot both be accurate while remaining unconditionally independent, the extra conditioning prevents learning weak classifiers. The resulting ensemble contains accurate classifiers that nevertheless rely on distinct predictive signals. The only core assumption is that the underlying predictive signals are themselves conditionally independent.
18
+
19
+ These approaches are conceptually appealing but practically challenging. Mutual information between high-dimensional representations is intractable and must be approximated, either via variational (e.g. Fischer, 2020) or contrastive (e.g. Oord et al., 2018) bounds. Furthermore, such approximations are computationally expensive, a problem that is compounded in the ensemble setting where we wish to train multiple classifiers speedily.
20
+
21
+ We seek to learn ensemble diversity fast and effectively. Our key insight is that it suffices to enforce conditional independence on the output distributions of the classifiers. Our first contribution is proposing conditional mutual information (CMI) between output distributions as the regularizing objective. Assuming conditionally independent predictive signals, enforcing CMI between output distributions also guarantees that the ensemble where separate predictive signals are learnt by separate classifiers is a minimizing solution. Since the output distribution is categorical, CMI can be cheaply and exactly computed from empirical data. In addition, our method avoids using additional sources of data that cannot be found in many real-world domains, such as unlabelled test data or “group” labels for each predictive signal in the dataset. We only permit a small amount of validation data from the test distribution for (1) hyperparameter tuning and (2) selecting the final predictor from our ensemble. We dub our approach as Conditionally Independent Deep Ensembles (CoDE).
22
+
23
+ Our second contribution is evaluating CoDE on benchmark datasets for shortcut learning (Geirhos et al., 2020). Shortcuts are signals that are (i) highly but spuriously correlated to the label in the training distribution, possibly due to biases in data collection or other systematic pre-processing errors (Torralba & Efros, 2011), and (ii) preferentially learnt by a neural network, possibly due to simplicity biases (Shah et al., 2020) or architectural biases (e.g. convolutional neural networks (CNNs) relying on texture over shape (Baker et al., 2018)). An empirical risk minimizing (ERM) model will rely on shortcuts and fail to generalize to test distributions where they are no longer correlated to the label. This is a natural application for our method as the core assumption of conditional independence applies to many such datasets — for example, in natural images, the foreground is typically the label and is thus conditionally independent from the background (shortcut). We show that CoDE effectively recovers an ensemble where the shortcut features and the true signal are learnt by separate classifiers.
24
+
25
+ # 2 PRELIMINARIES: SETUP AND NOTATION
26
+
27
+ In Section 3, we will fully motivate the assumptions behind our model of the data-generating process (DGP). However, we describe it here first to establish key terminology and concepts.
28
+
29
+ Data-Generating Process Let $\mathbf { z }$ denote the set of latent factors that generate the set of observed features $\mathbf { x } \in \mathbb { R } ^ { P }$ . Let $y \in \{ 0 , 1 , \dotsc , K - 1 \}$ denote the label. The data $p _ { e } ( \mathbf { x } , y , \mathbf { z } )$ is generated from a family of distributions indexed by $e$ , the environment. We only consider: (i) a single training environment $\mathbf { \boldsymbol { e } } _ { \mathbf { \lambda } } = t { \boldsymbol { r } } _ { \mathbf { \lambda } } $ ), from which we have access to i.i.d. labelled training examples $D _ { t r } \ = \ \{ { \bf x } _ { i } , y _ { i } \} _ { i = 1 } ^ { N }$ , and (ii) a test environment $\mathit { \Pi } _ { \mathrm { ~ e ~ } } = \mathit { \Pi } _ { t e }$ ), from which we draw unlabelled test examples that our model should perform well on. We also allow access to a small set of labelled validation data $D _ { v a l } = \{ \mathbf { x } _ { i } , y _ { i } \} _ { i = 1 } ^ { N ^ { \prime } }$ from the test environment, which is used only for hyperparameter tuning and ensembling (i.e. constructing the final model from the set of learnt classifiers).
30
+
31
+ We make the following assumptions on the DGP:
32
+
33
+ (i) all label information is encoded by $\mathbf { z }$ , i.e. $p _ { e } ( y | \mathbf { x } , \mathbf { z } ) = p _ { e } ( y | \mathbf { z } )$ for all $e$ (ii) $p _ { e } ( \mathbf { x } | \mathbf { z } ) = p ( \mathbf { x } | \mathbf { z } )$ is invariant across all $e$
34
+
35
+ (iii) $p _ { e } ( { \bf z } ) > 0$ for all $e$ and $\mathbf { z }$
36
+ (iv) $p _ { e } ( y ) > 0$ for all $e$ and $y$
37
+ (v) [Latent Conditional Independence] $z _ { i } \perp \perp z _ { j } \mid y$ for all $e$ and $i , j$
38
+
39
+ Based on these assumptions, we can factorize $p _ { e } ( \mathbf { x } , y , \mathbf { z } )$ as:
40
+
41
+ $$
42
+ p _ { e } ( \mathbf { z } , \mathbf { x } , y ) = p _ { e } ( y ) \left( \prod _ { i = 1 } ^ { L } p _ { e } ( z _ { i } | y ) \right) p ( \mathbf { x } | \mathbf { z } )
43
+ $$
44
+
45
+ Example: ColoredMNIST As introduced in Arjovsky et al. (2019), $y$ is a binary label which determines color $( z _ { 1 } \in \{ \mathrm { r e d } , \mathrm { g r e e n } \} )$ with probability $p _ { c }$ and digit $( z _ { 2 } \in \{ 0 \ – 4 , 5 \ – 9 \} )$ ) with probability $p _ { d }$ . $p _ { c }$ and $p _ { d }$ are independently chosen. In the training distribution, $p _ { c } = 0 . 2 5$ and $p _ { d } = 0 . 1$ , as such, an ERM model will primarily learn from color. $p _ { c }$ and $p _ { d }$ can be arbitrary in the test distribution.
46
+
47
+ Example: Waterbirds As introduced in Sagawa et al. (2019), $y$ is a binary label determining if the image represents a water or land bird. It perfectly determines the foreground $( z _ { 1 } \in \ \left\{ \begin{array} { l l } { \end{array} } \right.$ water bird, land bird}) and is highly but spuriously correlated to the background $( z _ { 2 } \in$ {water, land}) in the training distribution. An ERM model will learn from background features.
48
+
49
+ Group Robustness When $\mathbf { z }$ is discrete, each possible value that $\mathbf { z }$ can take is known as a group. Due to the spurious correlations created by $p _ { t r } ( z _ { i } | y )$ , groups that are highly represented in the training set are called “majority groups”, and poorly-represented groups are “minority groups”. Group robustness refers to the goal of generalizing well on all groups and is one natural way of evaluating if a model has been learning shortcuts. For example, both ColoredMNIST and Waterbirds admits four groups formed by the Cartesian product of $z _ { 1 }$ and $z _ { 2 }$ .
50
+
51
+ Ensembles and Fast Adaptation A classifier $f ( \mathbf { x } ) : = p _ { \theta } ( y | \mathbf { x } )$ is parametrized by $\theta$ and outputs class probabilities. We will use $\hat { y } : = p _ { \theta } ( y )$ to denote the unconditional output distribution. We use the term “ensemble” loosely to refer to a set of or sequentially. (Section 4 clarifies the relations $M$ classifiers to tradition $\{ f _ { m } \} _ { m = 1 } ^ { M }$ that can be learnt joinle methods.) After all $M$ classifiers are learnt, the final model $\theta ^ { * }$ is selected using validation data $D _ { v a l }$ :
52
+
53
+ $$
54
+ \theta ^ { * } = \arg \operatorname* { m i n } _ { \theta _ { m } , m \in \{ 1 , \dots , M \} } \frac { 1 } { N ^ { \prime } } \sum _ { i = 1 } ^ { N ^ { \prime } } \log p _ { \theta _ { m } } ( y _ { i } | \mathbf { x } _ { i } )
55
+ $$
56
+
57
+ This process is referred to as fast adaptation.
58
+
59
+ # 3 CONDITIONALLY INDEPENDENT DEEP ENSEMBLES
60
+
61
+ To motivate our approach and the assumptions made in (1), we first define what it means to learn a diverse ensemble and explain why conditional independence is a sound measure of diversity.
62
+
63
+ # 3.1 DIVERSITY AS CONDITIONAL INDEPENDENCE
64
+
65
+ Diverse classifiers utilize separate predictive signals, intuitively, they predict the “same things for different reasons” (Rame & Cord, 2021). Our setup in Section 2 formalizes this notion of “different reasons” by explicitly defining the latent variable $\mathbf { z }$ , which models the total underlying set of predictive signals that relate $\mathbf { x }$ to $y$ . A classifier that learns a mapping from $\mathbf { x }$ to $y$ can then be interpreted as implicitly inferring $\mathbf { z }$ from $\mathbf { x }$ and learning a mapping from $\mathbf { z }$ to $y$ . We can thus define diverse classifiers that rely on separate predictive signals as learning from separate dimensions or subspaces of $\mathbf { z }$ .
66
+
67
+ To formalize the idea that a classifier $f$ learns using only a subspace of $\mathbf { z }$ , one naive approach might be to define $f$ as relying only on the subspace ${ \mathbf z } _ { [ a ] }$ if and only if (some distribution computed from) $f$ is independent of its complement ${ \mathbf z } \backslash { \mathbf z } _ { [ a ] }$ . This definition is convenient as it suggests that the appropriate objective to learn a diverse ensemble is simply to enforce statistical independence between the classifiers. This follows because two classifiers that rely on overlapping subspaces of $\mathbf { z }$ will necessarily be dependent.
68
+
69
+ However, the definition above assumes that distinct predictive signals (i.e. subspaces of $\mathbf { z }$ ) are themselves unconditionally independent. This is not always true when a dataset contains multiple strongly predictive signals. Dimensions of $\mathbf { z }$ can be dependent by virtue of their correlation to $y$ Classifiers that learn from such signals will similarly be dependent. Shortcut learning is precisely a problem because meaningful and spurious features are highly correlated in the training environment.
70
+
71
+ This conundrum can be resolved by establishing independence of the latent factors with conditioning on $y$ . Doing so is equivalent to assuming that upon knowing the true label, observing one set of features yields no additional information about other features. This is usually a realistic assumption to make. As the Waterbirds example in Section 2 shows, backgrounds and foregrounds are often conditionally independent in the test distributions we care about. This motivates our assumption (v) of latent conditional independence in Section 2, where the individual factors $z _ { i }$ are conditionally independent given $y$ . We formalize this notion of “diversity as conditional independence” below.
72
+
73
+ Definition 3.1. Let $\mathbf { z } _ { [ a ] } : = ( z _ { a _ { 1 } } , \ldots , z _ { a _ { l } } )$ denote some subspace of $\mathbf { z }$ . Let $\hat { h } ( f )$ denote some distribution computed from $f$ . We say $f$ is invariant to ${ \mathbf z } _ { [ a ] }$ if $\hat { h } \perp \perp ( z _ { a _ { 1 } } , \ldots , z _ { a _ { l } } ) | y$ . Let $\mathbf { z } _ { [ i ] }$ be the maximal subset of $\mathbf { z }$ that $f$ is invariant to. Then $f$ is said to rely on $\mathbf { z } _ { - [ i ] } : = \mathbf { z } \backslash \mathbf { z } _ { [ i ] }$ for prediction.
74
+
75
+ Definition 3.2. Let $f$ and $f ^ { \prime }$ be a pair of classifiers that rely on $\mathbf { z } _ { [ i ] }$ and $\mathbf { z } _ { [ i ^ { \prime } ] }$ respectively. $f$ and $f ^ { \prime }$ are said to be diverse if $\mathbf { z } _ { [ i ] } \bigcap _ { . . } \mathbf { z } _ { [ i ^ { \prime } ] } = \emptyset$ . An ensemble $\{ f _ { m } \} _ { m = 1 } ^ { M }$ is diverse if every pair of classifiers $f _ { j } , f _ { k }$ in the ensemble are diverse.
76
+
77
+ It follows immediately from Definition 3.2 that diverse classifiers must themselves be conditionally independent, i.e. $\hat { h } _ { i } \perp \perp \hat { h } _ { j } | y$ . Our training objective for learning a diverse ensemble should therefore enforce conditional independence on all pairs of classifiers:
78
+
79
+ $$
80
+ \begin{array} { l } { \displaystyle \arg \underset { \theta _ { 1 } , \dots , \theta _ { M } } { \operatorname* { m a x } } \sum _ { i = 1 } ^ { N } \sum _ { m = 1 } ^ { M } \log p _ { \theta _ { m } } ( y _ { i } | \mathbf { x } _ { i } ) } \\ { \displaystyle \mathrm { s u b j e c t ~ t o } \hat { h } _ { s } \perp \hat { h } _ { t } \vert y \qquad \forall s , t } \end{array}
81
+ $$
82
+
83
+ We can interpret (3) as follows: the main objective guarantees that the learnt ensemble contains individually strong predictors, whereas the constraint guarantees that each predictor is uninformative of the others when conditioned on the label. Put together, (3) learns classifiers that rely on conditionally independent subspaces of $\mathbf { z }$ and thus provide no additional information about each other. As is typical in machine learning (Krogh & Hertz, 1991; Deb, 2014), we optimize an unconstrained analogue of (3) by expressing the constraint as a regularization term.
84
+
85
+ # 3.2 ENFORCING CONDITIONAL INDEPENDENCE VIA OUTPUT DISTRIBUTIONS
86
+
87
+ It remains for us to decide on the distribution $\hat { h }$ that we constrain, as well as the (unconstrained) regularization objective from (3). These choices are crucial in many ways. Since independence with respect to $\hat { h }$ underpins the notions of invariance and diversity in Definitions 3.1 and 3.2, it must be informative about the underlying predictive signals that a classifier is relying on. Furthermore, $\hat { h }$ and the regularization objective must be tractable.
88
+
89
+ Earlier work such as Pace et al. (2020) and Rame & Cord (2021) choose $\hat { h }$ to be the representations learnt by the classifiers, e.g. by constructing $f = f _ { l } \circ f _ { e }$ as a deep encoder network $f _ { e }$ that is attached to a linear classifier $f _ { l }$ and letting $\hat { h } \ = \ f _ { e } ( \mathbf { x } )$ . As the regularization objective for conditional independence, Rame & Cord (2021) compute pairwise conditional mutual information $\mathcal { C M T } ( f _ { e , s } , f _ { e , t } )$ whereas Pace et al. (2020) compute total correlation $\mathcal { T C } ( f _ { e , 1 } , \dots , f _ { e , M } )$ . Since the encoder representations are high-dimensional, these terms must be approximated.
90
+
91
+ We propose a far simpler and more efficient method. Instead of network representations, we choose $\hat { h }$ to simply be the output distribution $\hat { h } = f ( \mathbf { x } ) = p _ { \boldsymbol { \theta } } ( y | \mathbf { x } )$ of the classifier. Accordingly, our regularization objective is conditional mutual information (CMI) between the output distributions of the classifiers. For any pair of classifiers $f _ { j } , f _ { k }$ , we have:
92
+
93
+ $$
94
+ \mathcal { C M T } ( f _ { s } , f _ { t } ) = \mathbb { E } _ { y } \left[ \mathcal { D } _ { K L } \Big ( p ( f _ { s } , f _ { t } | y ) | | p ( f _ { s } | y ) p ( f _ { t } | y ) \Big ) \right]
95
+ $$
96
+
97
+ CMI is zero iff $f _ { s } \perp \perp f _ { t } | y$ for all values of $y$ . Enforcing conditional independence on the classifiers’ predicted output probabilities rather than underlying representations trades off granularity of the independence constraint for computational efficiency. We believe that this is a valuable trade-off. Since $\hat { y }$ has categorical support, (4) can be cheaply and exactly estimated from training data. As our experiments in Section 5 show, even on a noisier signal like output distributions, enforcing conditional independence is sufficient to learn a diverse ensemble.
98
+
99
+ Even though a diverse ensemble implies pairwise conditionally independent classifiers, the converse is not necessarily true. Mutual information is also zero if one of the classifiers outputs random or constant class probabilities. In particular, optimizing a weighted sum of the cross-entropy term and the CMI term can be challenging — overly weak regularization produces an ensemble that is not diverse, whereas overly strong regularization tends towards solutions containing close-to-random classifiers. Instead, we propose adding another term to regularize for confident predictions:
100
+
101
+ $$
102
+ \mathcal { R } ( f ) = \sum _ { k = 1 } ^ { K } \| p ( \hat { y } | y = k ) - I _ { k } \|
103
+ $$
104
+
105
+ where $I _ { k }$ is the indicator function at $k$ . Put together, the overall loss objective is:
106
+
107
+ $$
108
+ \mathcal { L } ( \{ \theta _ { m } \} _ { m = 1 } ^ { M } ) = \sum _ { i = 1 } ^ { N } \sum _ { m = 1 } ^ { M } \log p _ { \theta _ { m } } ( y _ { i } | \mathbf { x } _ { i } ) + \lambda _ { 1 } \cdot \sum _ { s = 1 } ^ { M } \sum _ { t = 1 } ^ { s - 1 } \mathcal { C } \mathcal { M } \mathcal { Z } ( f _ { s } , f _ { t } ) + \lambda _ { 2 } \cdot \sum _ { m = 1 } ^ { M } \mathcal { R } ( f _ { m } )
109
+ $$
110
+
111
+ where $\lambda _ { 1 }$ and $\lambda _ { 2 }$ are hyperparameters controlling the strength of regularization. A solution that minimizes (6) contains an ensemble where: (i) each classifier is accurate (first term) and confident (third term), and (ii) different classifiers rely on different subspaces of $\mathbf { z }$ for prediction (second term). We name such an ensemble a Conditionally Independent Deep Ensemble (CoDE).
112
+
113
+ # 3.3 CODE: COMPUTATIONAL DETAILS
114
+
115
+ The hyperparameters of the method are $M , \lambda _ { 1 }$ , and $\lambda _ { 2 }$ . Unlike traditional ensembles, $M$ (ensemble size) will typically be small $M = 2$ for all our experiments) since $M$ cannot be larger than the number of conditionally independent predictive signals inherent in the dataset. As is typical for OOD problems, we assume access to validation data from the test environment for hyperparameter tuning.
116
+
117
+ Objective (6) describes the situation where all $M$ classifiers are jointly optimized. Since $M$ is typically small, doing so is not difficult or computationally expensive (as might be with traditional ensembles). An alternative to joint optimization is to learn the classifiers in a sequential fashion. The analogue to (6) becomes:
118
+
119
+ $$
120
+ \mathcal { L } ( \theta _ { m } ) = \sum _ { i = 1 } ^ { N } \log p _ { \theta _ { m } } ( y _ { i } | \mathbf { x } _ { i } ) + \lambda _ { 1 } \cdot \sum _ { s = 1 } ^ { m - 1 } \mathcal { C } \mathcal { M } \mathcal { Z } ( \hat { y } _ { s } , \hat { y } _ { m } ) + \lambda _ { 2 } \cdot \mathcal { R } ( f _ { m } )
121
+ $$
122
+
123
+ Sequential optimization presents a natural way to determine $M$ , as we can terminate the training process when no more predictive classifiers can be learnt. However, it will fail if earlier classifiers in the sequence learn multiple predictive signals. We discuss this further in Section 5.
124
+
125
+ # 4 RELATED WORK
126
+
127
+ Ensemble Methods In statistics, ensembling traditionally refers to combining multiple predictors into a single model that outperforms the individual learners, typically by bagging (Breiman, 1996) or boosting (Schapire, 1990). Diversity in this context refers to minimizing correlation between individual learners, which reduces variance and improve generalization (Kuncheva & Whitaker, 2003). Deep ensembling (Lakshminarayanan et al., 2017) is an analogous approach in deep learning where multiple randomly-initialized networks are trained in parallel, however, they are generally used for the purpose of uncertainty estimation. Unlike these works, we consider diversity specifically in the context of datasets with multiple predictive signals, and learning a diverse ensemble as recovering all such signals for the purpose of OOD generalization.
128
+
129
+ Various Approaches For Learning Diversity As an unsupervised task, diversity refers to learning disentangled representations where natural factors of variation in the dataset are encoded into distinct latent dimensions (Bengio et al., 2013; Higgins et al., 2018); however, recent work has proposed incorporating weak supervision in this process (Locatello et al., 2019; Shu et al., 2019; Brehmer et al., 2022). As a supervised problem without OOD shifts, diversity refers to learning functions that disagree outside training points. Methods in this space have generally made use of input gradients (Ross et al., 2017; 2018) and orthogonality (Mashhadi et al., 2021; Xu et al., 2021). Finally, diversity is considered in the context of distribution shifts — either to improve robustness against adversarial attacks (Pang et al., 2019), to disambiguate between perfectly correlated signals (Lee et al., 2022), or to evade the simplicity bias by learning more complex functions (Pagliardini et al., 2022; Teney et al., 2021). Our work is most closely aligned with this last category. Unlike the approaches above, we exploit information-theoretic measures as our objective.
130
+
131
+ Shortcut Learning and Spurious Correlations Shortcut learning (Geirhos et al., 2020) involves distribution shifts arising from spurious correlations (Buolamwini & Gebru, 2018; Xiao et al., 2020; Moayeri et al., 2022) and neural network biases (architectural or simplicity biases) (Geirhos et al., 2018; Shah et al., 2020; Teney et al., 2021). Methods that tackle distribution shifts must use additional data and/or assumptions. Examples of additional data include having multiple training environments (Arjovsky et al., 2019), counterfactual examples (Teney et al., 2020), access to enough validation data to fine-tune the model (Kirichenko et al., 2022), or group labels (Sagawa et al., 2019; Puli et al., 2022). Examples of additional assumptions include exploiting the lottery ticket hypothesis (Zhang et al., 2021) or treating misclassified training examples by an initial model as a proxy for minority groups (Liu et al., 2021; Zhang et al., 2022). Unlike these methods, we aim to learn all predictive signals in the dataset, rather than performing well on a single test distribution. Furthermore, we use validation data for hyperparameter tuning only, without additional sources of data (e.g. group labels).
132
+
133
+ Information Bottleneck and Conditional Independence The line of work most similar to ours also exploits the information bottleneck method to learn diversity. Sinha et al. (2020) minimizes the mutual information $\mathcal { T } ( \hat { z } _ { s } , \hat { z } _ { t } )$ between learnt representations $\hat { z } _ { m }$ , however, this term is unconditional and will simply learn weak (biased) predictors, as noted in Section 3. Rame & Cord (2021) introduce DICE, which minimizes the conditional term $\mathcal { C } \mathcal { M } \mathcal { I } ( \hat { z } _ { s } , \hat { z } _ { t } )$ . Pace et al. (2020) considers total correlation $\mathcal { T C } ( \hat { z } _ { 1 } , \dots , \hat { z } _ { M } )$ instead of pairwise terms. Unlike CoDE, both of these approaches compute mutual information terms on the high-dimensional representations $\hat { z } _ { m }$ . Their objectives are intractable and must be approximated. For example, DICE requires both variational approximations and a jointly trained adversarial discriminator that learns to distinguish pairwise classifiers. Compared to these approaches, CoDE is by far computationally advantageous as mutual information for categorical output distributions can be computed faster and exactly.
134
+
135
+ # 5 EXPERIMENTS
136
+
137
+ Section 5.1 presents experiments on ColoredMNIST, which is used both to demonstrate the viability of our approach and to highlight pivotal observations and ablations. Section 5.2 then evaluates CoDE on larger benchmark datasets for shortcut learning to show that it scales effectively.
138
+
139
+ # 5.1 COLOREDMNIST
140
+
141
+ Setup As described in Section 2, the original MNIST (LeCun et al., 1998) labels are binarized (0-4, 5-9) and used to generate true labels $y$ with noise $p _ { d }$ . $y$ then generates binary color labels with noise $p _ { c }$ , used to color the image (red or green). As per Arjovsky et al. (2019), we consider two test environments: the training distribution where $p _ { d } = 0 . 2 5$ and $p _ { c } = 0 . 1$ , and the adversarial distribution where $p _ { d } = 0 . 2 5$ but $p _ { c } = 0 . 9$ (hence the shortcut-label correlation is reversed).
142
+
143
+ Evaluation Baselines and Metrics As is standard in existing work, we evaluate predictive accuracy on the training and adversarial distributions. In choosing baselines, we considered the following desiderata for fairness and comprehensiveness: (i) comparing to both ensembling and non-ensembling methods, (ii) amongst ensembling methods, comparing to both conditional independence-based methods and those that do not, and (iii) comparing only to methods that do not require additional sources of data besides validation data for hyperparameter tuning. We chose the following baselines:
144
+
145
+ Table 1: Results on ColoredMNIST. A theoretically ideal classifier relying only on digit (denoted as “Invariant”) will be upper-bounded by the digit-label noise $p _ { d }$ $(7 5 \% )$ , hence any result above $7 5 \%$ is relying on the color shortcut. CoDE has the strongest performance on the adversarial distribution. \*We were unable to reproduce TC-Ensemble on ColoredMNIST, and are citing their results in lieu.
146
+
147
+ <table><tr><td colspan="6">Results on ColoredMNIST</td></tr><tr><td>(pd,Pc)</td><td>Training (0.25, 0.1)</td><td>(0.25, 0.9)</td><td>(0.25, 0.5)</td><td>AdversarialRandom-ColorRandom-Color + Perfect-Digit (0.0, 0.5)</td></tr><tr><td>Invariant</td><td>75</td><td>75</td><td>75</td><td>100</td></tr><tr><td>ERM</td><td>88.6</td><td>15.3</td><td>52.5</td><td>53.4</td></tr><tr><td>JTT</td><td>17.8</td><td>87.9</td><td>52.5</td><td>56.6</td></tr><tr><td>Ortho-Ensemble</td><td>89.8</td><td>11.1</td><td>50.3</td><td>49.2</td></tr><tr><td>TC-Ensemble</td><td>89.1</td><td>69.8*</td><td>-</td><td>-</td></tr><tr><td>CoDE</td><td>70.7</td><td>70.0</td><td>70.8</td><td>91.2</td></tr></table>
148
+
149
+ 1. ERM classifier (ERM): single, standard classifier trained with ERM 2. Just Train Twice (Liu et al., 2021) (JTT): an initial classifier is trained for a limited number of epochs; mis-classified examples are upweighted to train the final classifier 3. Ensembles using input gradient orthogonality (Teney et al., 2021) (Ortho-Ensemble): an ensemble where the regularizing term is the dot product of the two models’ input gradients 4. Ensembles using conditional total correlation (CTC) (Pace et al., 2020) (TC-Ensemble): an ensemble learnt by minimizing CTC over the encoder network’s representation
150
+
151
+ Table 1 shows all results on ColoredMNIST. We discuss the most important findings below.
152
+
153
+ # 1. Enforcing conditional independence on output distributions achieves diversity effectively.
154
+
155
+ Since ColoredMNIST is an artificially-created dataset whose DGP we know satisfy latent conditional independence ${ \overset { \cdot } { p } } _ { c }$ and $p _ { d }$ are independently determined), it is the ideal dataset to evaluate our key claim. Indeed, the strong performance of CoDE shows that it is sufficient to enforce conditional independence on output distributions. The final predictor selected via fast adaptation achieves near-invariant results, suggesting that it has correctly learnt from digit rather than color.
156
+
157
+ # 2. CoDE generalizes to multiple OOD test distributions, without overfitting on any one specific distribution.
158
+
159
+ In Table 1, JTT achieved about $90 \%$ on the adversarial distribution, implying that it overfitted to the adversarial distribution — by learning the opposite shortcut (color) correlation rather than the true signal (digit). This is further confirmed with additional results on two other test environments (Random-Color and Random-Color $^ +$ Perfect-Digit) where $p _ { c } = 0 . 5$ . JTT is close to random on these two environments, suggesting that it is still relying on color as the predictive feature. In contrast, CoDE achieves $91 \%$ when $p _ { d } = 0 . 0$ , suggesting that it has learnt to predict using digit.
160
+
161
+ While concerning, these results are not entirely surprising. A method like JTT did exactly what it was designed to do, which is to minimize classification errors on the adversarial test distribution. Since $p _ { c } = 0 . 1$ , the opposite color correlation is precisely this loss-minimizing function. In contrast, CoDE will not find such a solution because two classifiers that return opposite predictions using the same feature (color) are perfectly correlated, even when conditioned on $y$ .
162
+
163
+ These results highlight the shortcomings of single classifier methods like JTT. Such methods are designed to generalize to a specific test distribution, in general, this does not imply that they have learnt the desired predictive signal — merely that they have learnt an arbitrary function that does well on the test distribution. In contrast, methods that enforce diversity, such as CoDE, explicitly recover meaningful predictive signals that can generalize to any test distribution where $p ( \mathbf { z } | y )$ changes.
164
+
165
+ Table 2: Additional results on ColoredMNIST and CelebA.
166
+
167
+ <table><tr><td rowspan="2"></td><td colspan="2">ColoredMNIST</td><td colspan="2">CelebA</td></tr><tr><td>Training</td><td>Adversarial</td><td>Ave</td><td>Worst</td></tr><tr><td>CoDE (sequential f1)</td><td>90.0</td><td>10.2</td><td>95.2</td><td>31.1</td></tr><tr><td>CoDE (sequential f2)</td><td>70.1</td><td>70.0</td><td>95.0</td><td>33.3</td></tr><tr><td>CoDE (sequential f3)</td><td>63.2</td><td>49.0</td><td></td><td></td></tr><tr><td>CoDE (sequential f5)</td><td>64.4</td><td>42.2</td><td></td><td></td></tr><tr><td>CoDE (joint M= 2)</td><td>73.4</td><td>60.2</td><td>89.2</td><td>83.3</td></tr><tr><td>CoDE (joint M = 3)</td><td>74.6</td><td>44.3</td><td></td><td></td></tr><tr><td>CoDE (joint M = 5)</td><td>71.9</td><td>43.1</td><td></td><td></td></tr></table>
168
+
169
+ # 3. Joint and sequential optimization are suited to different datasets.
170
+
171
+ From our experiments, we found that there is no clear preference between either choice in terms of generalization ability. Table 2 shows both joint and sequential results on the ColoredMNIST and CelebA datasets. For ColoredMNIST, we found that sequential training performed better than joint training. For CelebA, joint training yielded a stronger classifier.
172
+
173
+ This might be explained by the biases of the ERM model. In ColoredMNIST, as both latent factors (color and digit) are noisy predictors and as color presents a particularly simple shortcut, the ERM model solely learns from color. As such, a second classifier model that is trained sequentially can learn to predict solely from the digit feature. In contrast, the ERM model in CelebA has likely picked up some combination of the spurious (gender) and true (hair color) features, possibly because gender gives rise to complex features that are not ncessarily simpler to learn. This corroborates previous findings indicating that ERM models can learn an arbitrary combination of all predictive signals (Zhang et al., 2021; Kirichenko et al., 2022). As such, when trained sequentially, the second model fails to learn from hair color alone.
174
+
175
+ The advantages of sequential optimization are: (i) cheaper computational costs as $M$ increases, and (ii) providing a natural stopping point for training. The latter comes from the fact that we can select for $M$ by terminating the training process when the subsequent classifier is no longer predictive, which indicates that there are no further predictive factors to be learnt. In contrast, joint optimization is advantageous as it allows us to avoid the pathological sitation where earlier models learn combinations of predictive factors. As small values of $M$ work well for CoDEs, we note that the computational cost of CoDEs are not prohibitive.
176
+
177
+ # 5.2 BENCHMARK DATASETS
178
+
179
+ Setup We consider the following benchmark datasets:
180
+
181
+ • CelebA Liu et al. (2018); Sagawa et al. (2019): A dataset of celebrity faces with various labelled attributes. We consider the benchmark task in (Sagawa et al., 2019) of predicting the binary hair color attribute (blond or not), with gender (female or male) as the spurious attribute. There are therefore four groups. • Waterbirds (Wah et al., 2011; Sagawa et al., 2019): Setup described in Section 2. There are also four groups as both latent factors (background and foreground) are binary. • MF-Dominoes (MNIST-FashionMNIST) (LeCun et al., 1998; Xiao et al., 2017; Shah et al., 2020; Pagliardini et al., 2022): Each input image concatenates an MNIST digit (0 or 1) with a FashionMNIST object (coat or dress). The true label is the FashionMNIST object; the simpler MNIST feature is the shortcut. The minority groups represent $5 \%$ of the data.
182
+
183
+ Table 3 shows all results on the benchmark datasets.
184
+
185
+ # 4. CoDE scales well to large datasets and retains effectiveness at preventing shortcut learning.
186
+
187
+ <table><tr><td rowspan="2"></td><td colspan="2">CelebA</td><td colspan="2">Waterbirds</td><td colspan="2">MF-Dominoes</td></tr><tr><td>Method Ave</td><td>Worst</td><td>Ave</td><td>Worst</td><td>Ave</td><td>Worst</td></tr><tr><td>ERM</td><td>94.8</td><td>46.7</td><td>90.4</td><td>78.3</td><td>88.9</td><td>76.9</td></tr><tr><td>JTT</td><td>88.0*</td><td>81.1*</td><td>93.3*</td><td>86.7*</td><td>89.5</td><td>76.1</td></tr><tr><td>CoDE</td><td>89.2</td><td>83.3</td><td>91.5</td><td>79.4</td><td>92.1</td><td>91.4</td></tr></table>
188
+
189
+ Table 3: Main results on all datasets. CoDE achieves better adversarial or wrost-group accuracy than the other methods on all datasets except Waterbirds. ∗ Results from the JTT paper. We share the same model and training environment as their paper.
190
+
191
+ On CelebA and MF-Dominoes, CoDE achieves the best worst-group accuracy. Unlike the earlier ColoredMNIST dataset, we have no guarantees that the core assumption of latent conditional independence holds. However, the strong performance of CoDE on these datasets shows that such an assumption is generally valid and useful when scaled to more realistic datasets.
192
+
193
+ We note that CoDE performs poorly on Waterbirds. In our experiments, we selected $M = 2$ as the ensemble size. Even though there are no guarantees what will be the two conditionally independent classifiers that CoDE learns, in the other datasets, the results show that they do each correspond to the shortcut and true signal. This implies that in these datasets: (a) there are no features conditionally independent to both the shortcut and true signals and yet also strongly predictive of the label, and (b) the shortcut or true signal cannot be decomposed themselves into conditionally independent signals. Our hypothesis is that (b) is not true for Waterbirds. As the dataset is varied and contains a range of land and water backgrounds, there could be multiple spurious signals in the background that are somehow conditionally independent, resulting in these signals being learnt. Another possibility is that the ensemble could have learnt an imperfect or partial foreground signal.
194
+
195
+ # 5. Computational effectiveness is crucial to learn diverse ensembles at scale.
196
+
197
+ Beyond ColoredMNIST, we found that it was computationally prohibitive to run Ortho-Ensemble, as the size of ensembles required to work well (48 or 96) was too high. We also noted that we could not implement TC-Ensembles successfully on larger datasets, noting that the original authors do not test on datasets besides ColoredMNIST either. We believe that this further highlights the importance of computational efficiency in diverse ensembling.
198
+
199
+ # 6 DISCUSSION AND CONCLUSION
200
+
201
+ Appendix B discusses potential failure modes of our method.
202
+
203
+ We introduce CoDE, a method for learning an ensemble of diverse classifiers that rely on different predictive signals in the dataset. The key assumption made by CoDE conditional independence between predictive signals, which it enforces on classifiers’ output distributions. We find that CoDE works well in practice when applied to shortcut learning tasks. Future work includes: (a) evaluating CoDEs on other applications where multiple predictive signals exist, such as fairness-related tasks where we might want to learn classifiers that do not rely on sensitive attributes, and (b) considering other metrics for conditional independence that might provide more fine-grained signals than output distributions (e.g. minimizing mutual information between latent representations).
204
+
205
+ # ETHICS STATEMENT
206
+
207
+ Positive Impact Being robust to distribution shifts, CoDE will have a positive impact when deployed to high-stakes domains, where learning shortcut signals can have harmful social consequences. One such notable example is pneumonia prediction — models trained on pneumonia labels from chest $\mathrm { X }$ -ray scans have been shown to learn machine-specific artifacts in the background, which is a shortcut as hospitals have differing positivity rates and use different machines (Zech et al., 2018).
208
+
209
+ Negative Impact There are no notable negative impacts of using CoDE specifically, besides the general potential for all machine learning models to be abused in the wrong hands.
210
+
211
+ REPRODUCIBILITY STATEMENT
212
+
213
+ We intend to release public code with a camera-ready version of the paper.
214
+
215
+ # REFERENCES
216
+
217
+ Martin Arjovsky, Leon Bottou, Ishaan Gulrajani, and David Lopez-Paz. Invariant risk minimization. ´ arXiv preprint arXiv:1907.02893, 2019.
218
+
219
+ Nicholas Baker, Hongjing Lu, Gennady Erlikhman, and Philip J Kellman. Deep convolutional networks do not classify based on global object shape. PLoS computational biology, 14(12): e1006613, 2018.
220
+
221
+ Elias Bareinboim, Juan David Correa, Duligur Ibeling, and Thomas F. Icard. On pearl’s hierarchy and the foundations of causal inference. Probabilistic and Causal Inference, 2022.
222
+
223
+ Yoshua Bengio, Aaron Courville, and Pascal Vincent. Representation learning: A review and new perspectives. IEEE transactions on pattern analysis and machine intelligence, 35(8):1798–1828, 2013.
224
+
225
+ Johann Brehmer, Pim De Haan, Phillip Lippe, and Taco Cohen. Weakly supervised causal representation learning. arXiv preprint arXiv:2203.16437, 2022.
226
+
227
+ Leo Breiman. Bagging predictors. Machine learning, 24(2):123–140, 1996.
228
+
229
+ Joy Buolamwini and Timnit Gebru. Gender shades: Intersectional accuracy disparities in commercial gender classification. In Conference on fairness, accountability and transparency, pp. 77–91. PMLR, 2018.
230
+
231
+ Kalyanmoy Deb. Multi-objective optimization. In Search methodologies, pp. 403–449. Springer, 2014.
232
+
233
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
234
+
235
+ Ian Fischer. The conditional entropy bottleneck. Entropy, 22(9):999, 2020.
236
+
237
+ Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix A Wichmann, and Wieland Brendel. Imagenet-trained cnns are biased towards texture; increasing shape bias improves accuracy and robustness. arXiv preprint arXiv:1811.12231, 2018.
238
+
239
+ Robert Geirhos, Jorn-Henrik Jacobsen, Claudio Michaelis, Richard Zemel, Wieland Brendel, Matthias¨ Bethge, and Felix A Wichmann. Shortcut learning in deep neural networks. Nature Machine Intelligence, 2(11):665–673, 2020.
240
+
241
+ Tatsunori Hashimoto, Megha Srivastava, Hongseok Namkoong, and Percy Liang. Fairness without demographics in repeated loss minimization. In International Conference on Machine Learning, pp. 1929–1938. PMLR, 2018.
242
+
243
+ 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.
244
+
245
+ Irina Higgins, David Amos, David Pfau, Sebastien Racaniere, Loic Matthey, Danilo Rezende, and Alexander Lerchner. Towards a definition of disentangled representations. arXiv preprint arXiv:1812.02230, 2018.
246
+
247
+ Dirk Hovy and Anders Søgaard. Tagging performance correlates with author age. In Proceedings of the 53rd annual meeting of the Association for Computational Linguistics and the 7th international joint conference on natural language processing (volume 2: Short papers), pp. 483–488, 2015.
248
+
249
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
250
+
251
+ Polina Kirichenko, Pavel Izmailov, and Andrew Gordon Wilson. Last layer re-training is sufficient for robustness to spurious correlations. arXiv preprint arXiv:2204.02937, 2022.
252
+
253
+ Anders Krogh and John Hertz. A simple weight decay can improve generalization. Advances in neural information processing systems, 4, 1991.
254
+
255
+ Ludmila I Kuncheva and Christopher J Whitaker. Measures of diversity in classifier ensembles and their relationship with the ensemble accuracy. Machine learning, 51(2):181–207, 2003.
256
+
257
+ Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and scalable predictive uncertainty estimation using deep ensembles. Advances in neural information processing systems, 30, 2017.
258
+
259
+ Yann LeCun, Leon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to ´ document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
260
+
261
+ Yoonho Lee, Huaxiu Yao, and Chelsea Finn. Diversify and disambiguate: Learning from underspecified data. arXiv preprint arXiv:2202.03418, 2022.
262
+
263
+ Evan Z Liu, Behzad Haghgoo, Annie S Chen, Aditi Raghunathan, Pang Wei Koh, Shiori Sagawa, Percy Liang, and Chelsea Finn. Just train twice: Improving group robustness without training group information. In International Conference on Machine Learning, pp. 6781–6792. PMLR, 2021.
264
+
265
+ Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Large-scale celebfaces attributes (celeba) dataset. Retrieved August, 15(2018):11, 2018.
266
+
267
+ Francesco Locatello, Stefan Bauer, Mario Lucic, Gunnar Raetsch, Sylvain Gelly, Bernhard Scholkopf, ¨ and Olivier Bachem. Challenging common assumptions in the unsupervised learning of disentangled representations. In international conference on machine learning, pp. 4114–4124. PMLR, 2019.
268
+
269
+ Peyman Sheikholharam Mashhadi, Sławomir Nowaczyk, and Sepideh Pashami. Parallel orthogonal deep neural network. Neural Networks, 140:167–183, 2021.
270
+
271
+ Mazda Moayeri, Phillip Pope, Yogesh Balaji, and Soheil Feizi. A comprehensive study of image classification model sensitivity to foregrounds, backgrounds, and visual attributes. arXiv preprint arXiv:2201.10766, 2022.
272
+
273
+ Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
274
+
275
+ Daniel Pace, Alessandra Russo, and Murray Shanahan. Learning diverse representations for fast adaptation to distribution shift. arXiv preprint arXiv:2006.07119, 2020.
276
+
277
+ Matteo Pagliardini, Martin Jaggi, Franc¸ois Fleuret, and Sai Praneeth Karimireddy. Agree to disagree: Diversity through disagreement for better transferability. arXiv preprint arXiv:2202.04414, 2022.
278
+
279
+ Tianyu Pang, Kun Xu, Chao Du, Ning Chen, and Jun Zhu. Improving adversarial robustness via promoting ensemble diversity. In International Conference on Machine Learning, pp. 4970–4979. PMLR, 2019.
280
+
281
+ Aahlad Manas Puli, Lily H Zhang, Eric Karl Oermann, and Rajesh Ranganath. Out-of-distribution generalization in the presence of nuisance-induced spurious correlations. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id= 12RoR2o32T.
282
+
283
+ Alexandre Rame and Matthieu Cord. Dice: Diversity in deep ensembles via conditional redundancy adversarial estimation. arXiv preprint arXiv:2101.05544, 2021.
284
+
285
+ Andrew Slavin Ross, Michael C Hughes, and Finale Doshi-Velez. Right for the right reasons: Training differentiable models by constraining their explanations. arXiv preprint arXiv:1703.03717, 2017.
286
+
287
+ Andrew Slavin Ross, Weiwei Pan, and Finale Doshi-Velez. Learning qualitatively diverse and interpretable rules for classification. arXiv preprint arXiv:1806.08716, 2018.
288
+
289
+ Shiori Sagawa, Pang Wei Koh, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. arXiv preprint arXiv:1911.08731, 2019.
290
+
291
+ Robert E Schapire. The strength of weak learnability. Machine learning, 5(2):197–227, 1990.
292
+
293
+ Bernhard Scholkopf, Francesco Locatello, Stefan Bauer, Nan Rosemary Ke, Nal Kalchbrenner, ¨ Anirudh Goyal, and Yoshua Bengio. Towards causal representation learning. arXiv preprint arXiv:2102.11107, 2021.
294
+
295
+ Harshay Shah, Kaustav Tamuly, Aditi Raghunathan, Prateek Jain, and Praneeth Netrapalli. The pitfalls of simplicity bias in neural networks. Advances in Neural Information Processing Systems, 33:9573–9585, 2020.
296
+
297
+ Rui Shu, Yining Chen, Abhishek Kumar, Stefano Ermon, and Ben Poole. Weakly supervised disentanglement with guarantees. arXiv preprint arXiv:1910.09772, 2019.
298
+
299
+ Samarth Sinha, Homanga Bharadhwaj, Anirudh Goyal, Hugo Larochelle, Animesh Garg, and Florian Shkurti. Diversity inducing information bottleneck in model ensembles. arXiv preprint arXiv:2003.04514, 2020.
300
+
301
+ Damien Teney, Ehsan Abbasnedjad, and Anton van den Hengel. Learning what makes a difference from counterfactual examples and gradient supervision. In European Conference on Computer Vision, pp. 580–599. Springer, 2020.
302
+
303
+ Damien Teney, Ehsan Abbasnejad, Simon Lucey, and Anton van den Hengel. Evading the simplicity bias: Training a diverse set of models discovers solutions with superior ood generalization. arXiv preprint arXiv:2105.05612, 2021.
304
+
305
+ Antonio Torralba and Alexei A Efros. Unbiased look at dataset bias. In CVPR 2011, pp. 1521–1528. IEEE, 2011.
306
+
307
+ Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011.
308
+
309
+ Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms. arXiv preprint arXiv:1708.07747, 2017.
310
+
311
+ Kai Xiao, Logan Engstrom, Andrew Ilyas, and Aleksander Madry. Noise or signal: The role of image backgrounds in object recognition. arXiv preprint arXiv:2006.09994, 2020.
312
+
313
+ Yilun Xu, Hao He, Tianxiao Shen, and Tommi S Jaakkola. Controlling directions orthogonal to a classifier. In International Conference on Learning Representations, 2021.
314
+
315
+ John R Zech, Marcus A Badgeley, Manway Liu, Anthony B Costa, Joseph J Titano, and Eric Karl Oermann. Variable generalization performance of a deep learning model to detect pneumonia in chest radiographs: a cross-sectional study. PLoS medicine, 15(11):e1002683, 2018.
316
+
317
+ Dinghuai Zhang, Kartik Ahuja, Yilun Xu, Yisen Wang, and Aaron Courville. Can subnetwork structure be the key to out-of-distribution generalization? In International Conference on Machine Learning, pp. 12356–12367. PMLR, 2021.
318
+
319
+ Michael Zhang, Nimit S Sohoni, Hongyang R Zhang, Chelsea Finn, and Christopher Re. Correct-n- ´ contrast: A contrastive approach for improving robustness to spurious correlations. arXiv preprint arXiv:2203.01517, 2022.
320
+
321
+ # A EXPERIMENTAL DETAILS
322
+
323
+ Architecture and Training Details For ColoredMNIST, we use a CNN as the classifier, containing two convolutional layers and two fully-connected layers. Adam (Kingma & Ba, 2014) is used for optimization, with a learning rate of 0.001. For CelebA, Waterbirds, and MF-Dominoes, we use a ResNet-50 (He et al., 2016). SGD is used for optimization, with a learning rate of 0.001, momentum decay of 0.9, and weight decay of 0.001. Additionally, following previous work (e.g. Sagawa et al., 2019; Liu et al., 2021), the Waterbirds model is pre-trained on ImageNet (Deng et al., 2009) and includes data augmentation in the form of random horizontal flips and random resized cropping. For CelebA and Waterbirds, class reweighting is performed to ensure that there are roughly equal positive and negative labels. The random seed used for all experiments is 13.
324
+
325
+ Hyperparameters for CoDE and Baselines CoDE. For all four datasets, we used $M = 2$ as the ensemble size, besides ablations for $M$ as detailed in Appendix B. The results in Table 3 were achieved with sequential training for ColoredMNIST and with joint training for the other three datasets. For ColoredMNIST, $\lambda _ { 1 } = 1 2 0 0$ and $\lambda _ { 2 } = 1 0$ . For CelebA, $\lambda _ { 1 } = 5 0 0$ and $\lambda _ { 2 } = 0 . 1$ . For Waterbirds, $\lambda _ { 1 } = 5 0 0$ and $\lambda _ { 2 } = 0 . 1$ . For MF-Dominoes, $\lambda _ { 1 } = 3 0 0$ and $\lambda _ { 2 } = 0 . 1$ . JTT. We performed a hyperparameter sweep with $T \in \{ 1 , 5 , 1 0 \}$ (number of epochs for initial model training) and $\alpha \in \{ 2 , 1 0 , 1 0 0 \}$ (upweighting factor for mis-classified examples). Orthogonal Ensembles. All classifiers share the same feature extractor (i.e. convolutional output for ColoredMNIST and ResNet-50 feature representation for the other three datasets). We experimented with different values of $M$ , however, values of $M$ above 16 (for ColoredMNIST) and above 4 (for the other three datasets) were prohitibively expensive. As such, we did not try $M = 4 8$ or $M = 9 6$ as used by Teney et al. (2021). For these smaller values of $M$ that we tried, we did not notice an improvement from the ERM model. Besides ColoredMNIST, we did not report these results.
326
+
327
+ # B MODEL MIS-SPECIFICATION: POTENTIAL FAILURE MODES
328
+
329
+ The success of any method tackling distribution shifts depends on how well the assumptions made have been upheld. We discuss the potential implications when the model is mis-specified and these assumptions are no longer valid.
330
+
331
+ Conditional Dependence CoDE relies on the assumption that predictive signals are conditionally independent. We using the synthetic ColoredMNIST dataset to generate a DGP where such an assumption does not hold true. Instead of the standard setup where color labels are generated from the true labels, we generate color labels from the original (binarized) MNIST labels instead, at the same noise level $p _ { c } = 0 . 1$ . This means that the color and digit signals are now highly correlated. Both are still predictive since the true labels themselves were generated from MNIST labels.
332
+
333
+ Table 4 shows the results of this experiment. As we expect, conditionally dependent features cannot be recovered by minimizing conditional mutual information. The ensemble either recovers one of the two features (when trained sequentially) or neither. This confirms our intuition that conditional independence must be correctly specified for CoDE to work. While these results demonstrate a failure mode of CoDE, conditional independence between predictive factors of interest does hold well in many natural image datasets, as shown in Table 3.
334
+
335
+ Latent Mis-specification The size of the ensemble $M$ specifies how many predictive latent factors we believe generated the dataset. We can consider the mis-specification of $M$ in either direction: (i) if the true dimension of $\mathbf { z }$ is smaller than $M$ , and (ii) if the true dimension of $\mathbf { z }$ is larger than $M$ .
336
+
337
+ In case (i), since the number of conditional independent components has been over-specified, whether the ensemble has been jointly or sequentially trained makes a difference. Consider the results on the ColoredMNIST dataset in Table 2 again. In the sequential regime, the first two classifiers $f _ { 1 }$ and $f _ { 2 }$ correspond to the color and digit classifiers respectively, however, the subsequent few classifiers $f _ { 3 }$ and $f _ { 5 } ^ { } ,$ ) do not learn anything meaningful and perform poorly on both training and adversarial distributions. However, as noted in Section 5, this does not pose a serious problem since we can use validation data to naturally determine the stopping point. On the other hand, over-specification of $M$ is more worrying in the joint regime, as there is no guarantee that any of the true latent factors are learnt at all. As Table 2 shows, for $M = 3$ or 5, the best-performing classifier does not generalize.
338
+
339
+ Table 4: Results on ColoredMNIST with color-digit conditional dependence, on both joint and sequential training with $M = 2$ classifiers. When trained sequentially, the first classifier $f _ { 1 }$ learns the digit correlation since digit is most predictive in this setup. However, as color is no longer conditionally independent of digit, there is no predictive feature that can be learnt by the second classifier $f _ { 2 }$ , resulting in a close-to-random predictor. When trained jointly, neither of the classifiers correspond to the color or digit feature.
340
+
341
+ <table><tr><td>(pd,Pc)</td><td>Training (0.25, 0.1)</td><td>Adversarial (0.25, 0.9)</td><td>Random-Color (0.25, 0.5)</td><td>Perfect-Digit (0.0, 0.5)</td></tr><tr><td>CoDE (sequential f1)</td><td>77.1</td><td>63.2</td><td>70.6</td><td>90.5</td></tr><tr><td>CoDE (sequential f2)</td><td>53.6</td><td>50.1</td><td>51.5</td><td>54.5</td></tr><tr><td>CoDE (joint f1)</td><td>84.9</td><td>25.8</td><td>56.0</td><td>60.4</td></tr><tr><td>CoDE (joint f2)</td><td>54.3</td><td>73.0</td><td>64.4</td><td>77.5</td></tr></table>
342
+
343
+ In case (ii), where the number of conditional independent components is under-specified, the learnt ensemble may correspond to any subset of the true latent factors and individual classifiers could also learn arbitrary combinations of the latent factors. For example, the trivial case where $M = 1$ is underspecified simply returns the ERM model. In general, since $M$ is a hyperparameter, latent mis-specification does not pose a serious problem as we can tune its value using the validation data.
md/dev/1KaSx3GrBBm/1KaSx3GrBBm.md ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MOVING BEYOND HANDCRAFTED ARCHITECTURES IN SELF-SUPERVISED LEARNING
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ The current literature on self-supervised learning (SSL) focuses on developing learning objectives to train neural networks more effectively on unlabeled data. The typical development process involves taking well-established architectures, e.g., ResNet or ViT demonstrated on ImageNet, and using them to evaluate newly developed objectives on downstream scenarios. While convenient, this neglects the role of architectures which has been shown to be crucial in the supervised learning literature. In this work, we establish extensive empirical evidence showing that a network architecture plays a significant role in contrastive SSL. We conduct a large-scale study with over 100 variants of ResNet and MobileNet architectures and evaluate them across 11 downstream scenarios in the contrastive SSL setting. We show that there is no one network that performs consistently well across the scenarios. Based on this, we propose to learn not only network weights but also architecture topologies in the SSL regime. We show that “self-supervised architectures” outperform popular handcrafted architectures (ResNet18 and MobileNetV2) while performing competitively with the larger and computationally heavy ResNet50 on major image classification benchmarks (ImageNet-1K, iNat2021, and more). Our results suggest that it is time to consider moving beyond handcrafted architectures in contrastive SSL and start thinking about incorporating architecture search into self-supervised learning objectives.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Self-supervised learning (SSL) achieves impressive results on challenging tasks involving image, video, audio, and text. Models pretrained on large unlabeled data perform nearly as good and sometimes even better than their supervised counterparts (Caron et al., 2020; Chen & He, 2021). So far, the focus has been on designing effective learning objectives – e.g., pretext tasks (Gidaris et al., 2018; Caron et al., 2018), contrastive (Oord et al., 2018; Chen et al., 2020a) and noncontrastive (Grill et al., 2020) tasks – together with empirical (Cole et al., 2021; Feichtenhofer et al., 2021) and theoretical (Arora et al., 2019; Poole et al., 2019) studies providing key insights and underpinnings. Recent works propose new objectives with a different class of network architectures such as vision transformers (ViT) (Bao et al., 2021) and masked autoencoders (He et al., 2022).
12
+
13
+ However, there has been little focus on the role of architectures in SSL. Currently, the de facto protocol in SSL is to take architectures that perform well on established benchmarks in the supervised setting and to adapt them to the self-supervised setting by plugging in different learning objectives. For example, several existing work on contrastive learning use ResNet (He et al., 2016) as the backbone (Chen et al., 2020a; He et al., 2020). This is partly for convenience. Evaluating different architectures in SSL is computationally expensive; selecting an architecture in advance and fixing it throughout makes it easy to evaluate different learning objectives. This also stems from strong empirical success of those architectures in transfer learning, e.g., CNNs trained on large labeled data provide “unreasonable effectiveness” (Sun et al., 2017; Zhang et al., 2018; Sejnowski, 2020) in a variety of downstream cases. Nonetheless, one implicit assumption is that an architecture that works well in the supervised learning scenario will continue to be effective in the SSL regime.
14
+
15
+ We argue that this assumption is incorrect and dangerous. It is valid only to a limited extent and the performance starts deteriorating significantly when SSL is conducted on data whose distribution deviates much from the original distribution the architecture was trained on. This is counter to the promise of SSL, where one can learn optimal representation for a wide range of tasks. One main reason for performance degradation is that different data distributions benefit from different inductive biases: An architecture with specific layer types and the wiring between them naturally encodes inductive biases, which may be optimal only for a certain data distribution (e.g., objectcentric imagery such as ImageNet) and not for others (e.g., medical and satellite imagery). In fact, numerous studies have shown that standard “recipes” for architecture design do not translate well across different data distributions (Tuggener et al., 2021; Dey et al., 2021; Kolesnikov et al., 2019).
16
+
17
+ The main objective of this work is to show that the choice of network architecture crucially matters in SSL, and that it is not easy to handcraft architectures that are effective across different SSL scenarios. To see this, recall that the goal of SSL is to learn data representations capturing important features and attributes that generalize well across various downstream tasks. There has been extensive literature on the expressivity of neural networks (Raghu et al. (2017); Zhang et al. (2021a) and references therein); one of the important conclusions is that the network topology plays a significant role in determining the expressivity, i.e., the kinds of functions a network can approximate is bounded by the network capacity and available sample size in the finite sample regime. This implies that, in practice, SSL with a fixed architecture learns representations only within the scope of function space induced by the pre-selected architecture topology, and therefore, the ultimate success of SSL can be achieved when it finds optimal architecture from certain search space in conjunction with its weights for specific data distributions.
18
+
19
+ In this paper, we establish extensive empirical evidence showing that architecture matters in selfsupervised learning. We do this in two sets of large-scale studies. First, we sample 116 variants of ResNet (He et al., 2016) and MobileNet (Sandler et al., 2018) architectures with different topologies and evaluate them on 11 downstream tasks in the SSL setting. We pretrain all models under the same setting, optimizing the SimCLR objective (Chen et al., 2020a) on ImageNet (Deng et al., 2009), and investigate if there exist any correlation between these models in downstream performance on different datasets. We observe no strong correlation, except for tasks highly similar to ImageNet. We further show that ImageNet downstream performance, the gold standard benchmark in the SSL literature, is not indicative of performance on other downstream tasks. This implies that we need to be careful in choosing an architecture for evaluating any newly developed SSL objectives, as one might get different conclusions based on different network architectures.
20
+
21
+ This subsequently raises the question: Can we improve SSL by learning not only network weights but also architectures directly optimized for the given dataset? It removes the burden of manually searching for effective architectures in SSL, and if we succeed, it can substantially improve performance of SSL. To test this hypothesis, as the second set of our study, we apply a well-established NAS algorithm (Cai et al., 2018) to the SSL setting. Unlike the typical NAS setting that optimize on a labeled target dataset, we search for optimal architectures directly on an unlabeled pretraining dataset via contrastive learning (Chen et al., 2020a). We evaluate our $\mathrm { ^ { 6 6 } N A S } + \mathrm { S S L } ^ { \mathrm { 3 } }$ framework on datasets with different distributions, ImageNet-1K and iNat 2021 (Van Horn et al., 2021), and show that self-supervised architectures consistently outperform handcrafted ones in the same parameter range (MobileNetV2 and ResNet18) across 11 downstream tasks. This provides strong evidence suggesting the importance of learning architecture topologies in addition to their weights in SSL.
22
+
23
+ Our work focuses on studying the role of architectures in contrastive SSL with the SimCLR framework for CNN-based architectures such as ResNets and MobileNets. As a first step in this direction, we provide an in-depth analysis through large-scale experiments in this specific (yet limited) setting. Extending our study to different SSL approaches (He et al., 2020; Grill et al., 2020; He et al., 2022) and architectures such as ViTs would be an interesting direction but beyond the scope of this paper.
24
+
25
+ In summary, our main contributions are: 1) We establish extensive evidence showing that there isn’t one network architecture performing consistently well across different downstream scenarios in the SimCLR setting. We show this using 116 variants of ResNet and MobileNet architectures pretrained on ImageNet and evaluated on 11 downstream datasets. 2) We show that ImageNet performance (the gold standard in SSL benchmark) is not always indicative of downstream performance. This means that findings about SSL objectives shown only on ImageNet do not generalize across other data distributions. 3) We propose to self-supervise a CNN architecture topology and its network weights on unlabeled data. We show that self-supervised architectures outperform handcrafted ones in a similar parameter range for the SimCLR setting across different downstream datasets.
26
+
27
+ # 2 RELATED WORK
28
+
29
+ Role of architectures in SSL. There has been significant progress in learning representations via SSL (Gidaris et al., 2018; Chen et al., 2020a;c; Caron et al., 2020). Ericsson et al. (2021) provide an overview of different SSL setups and their performance on downstream tasks. Most works focus on improving self-supervised objectives to develop better representations while keeping architectures fixed. Our focus is orthogonal to this line of work. We study the role of architectures in SSL and investigate the benefits of self-supervising architecture topologies along with network weights.
30
+
31
+ Similar to ours, Kornblith et al. (2019) analyze transfer performance of different architectures pretrained on ImageNet across several downstream datasets. However, they focused on supervised learning, which need not translate to self-supervised setups (Kolesnikov et al., 2019). Caron et al. (2021) propose a self-distillation based SSL objective and compare the performance of ResNets with ViTs. In contrast, we focuse on contrastive SSL and the importance of architecture topologies for the class of CNNs. Kolesnikov et al. (2019) is the most related to ours but are limited to pretext-task based SSL and show results only for a few variants of VGG and ResNet. In comparison, we conduct a study on a much larger scale in a contrastive learning setup. Also, we provide insights into generalization performance of the networks across different datasets. Crucially, unlike all previous work in SSL, we propose to learn both architecture topologies and their network weights.
32
+
33
+ NAS and SSL. The literature on NAS has rapidly progressed in the past years; we refer the reader to the NAS survey by Elsken et al. (2019). Here we focus on the most directly relevant work to SSL. Mellor et al. (2021) search for networks without any training and verify their effectiveness of supervised benchmarks. Liu et al. (2020) show that highly performant architectures can be found without using any supervised labels during the search itself, and propose using DARTS (Liu et al., 2019) with self-supervised proxy tasks to search for architectures which will perform well on supervised datasets. In a similar vein, Zhang et al. (2021b) use random labels during the search phase of NAS, and Yan et al. (2020) learn representations of architectures via SSL and use them to improve NAS. Li et al. (2021) introduce a new self-supervised training scheme to search for architectures in a new hybrid search space. One common theme in this line of work is that they aim to harness SSL in aid of NAS. In contrast, we aim to utilize NAS to hunt for architectures which will perform well for self-supervised learning, thereby harnessing NAS in aid of SSL.
34
+
35
+ # 3 DOES ONE NETWORK RULE THEM ALL IN SSL?
36
+
37
+ We conduct a large scale study to investigate whether a particular architecture topology can be consistently effective across a wide range of SSL scenarios. To this end, we sample 116 models with different architecture topologies and analyze their performance on 11 downstream tasks.
38
+
39
+ To maximize generality while taming complexity of our study, we choose two most representative CNN architectures: ResNets and MobileNets. The former is the de facto backbone for numerous modern visual models (Kirillov et al., 2019; Wu et al., 2019) and SSL approaches (Caron et al., 2020; Chen & He, 2021), while the latter is used in low-resource setups (Cheng et al., 2017). We create 69 ResNet-like and 47 MobileNet-like architectures for our evaluation, varying the number of blocks at each of the 4 stages of a ResNet, the block structure (BasicBlock and Bottleneck), width, and number of groups. For MobileNet, we vary the width multiplier parameter and the number of blocks in each of the 6 stages. We choose the SimCLR objective (Chen et al., 2020a) for our experiments and pretrain each of the 116 architectures on ImageNet-1K. Owing to the large scale nature of the experiments and computational constraints, we limit the pretraining to 100 epochs and a batch size of 512. Each of these jobs takes roughly 1 day to finish on a system with $8 \times \mathrm { ~ V 1 0 0 ~ }$ (32GB) GPUs. We report linear evaluation results in all cases.
40
+
41
+ ImageNet performance is not indicative of downstream performance for SSL. To examine the correlation between ImageNet vs. downstream performance, we compute the Spearman’s rank correlation coefficient $\rho$ on top-1 validation accuracy between every dataset pair, shown in Fig. 1. We also show scatter plots in Fig. 2 revealing the relationship between ImageNet vs. downstream performance on the most representative cases; the complete set of scatter plots are in the appendix.
42
+
43
+ For ResNet-like architectures (Fig. 2 top row), we see strong correlation between ImageNet and CIFAR-100 ( $\rho = . 8 )$ ) as these datasets contain similar categories; about 90 classes in CIFAR-100 are the same class or a superclass in ImageNet. A similar observation is made (in Fig. 1) for Stanford Dogs $( \rho = . 7 7 )$ due to the 120 dog categories in ImageNet. However, we observe high variance in transfer performance for out-of-domain datasets, e.g., Flowers $( \rho = . 3 5 )$ , represented by only two ImageNet categories (daisy and yellow lady slipper). Correlation becomes negative on Stanford Cars $( \rho = - . 2 9 )$ and FGVC Aircraft $( \rho = - . 2 4 )$ , likely because ImageNet contains only a few categories of cars (10 classes) and aircraft (4 classes). Low correlation means network ranks are inconsistent and models performing well on ImageNet do not keep their precedence in other tasks.
44
+
45
+ ![](images/d365bf971a98922758f9bba2584f03a8e3a1f78f6ce0f45f6babac180c901c8e.jpg)
46
+ Figure 2: ImageNet performance is not indicative of downstream performance in SSL. We show linear evaluation top-1 accuracy of ImageNet (x-axis) vs. downstream datasets (y-axis) obtained from variations of ResNet (top) and MobileNet (bottom); all models are pretrained on ImageNet-1K using SimCLR under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
47
+
48
+ For MobileNet-like architectures (Fig. 2 bottom row), we see overall much lower correlation with ImageNet performance; the ResNet space showed correlation at least for in-distribution datasets. For e.g., we see correlation between ImageNet and CIFAR-100 drops from $\rho = . 8$ (ResNet) to $\rho \ = \ . 2 3$ (MobileNet). For other datasets like MIT67, correlation is higher $( \rho ~ = ~ . 5 2 )$ but still less meaningful due to high variability in performance (notice the cluster around $42 \%$ accuracy). These results indicate that MobileNets are even less tuned towards ImageNet than ResNets and any handcrafted architectures in this space is likely to be suboptimal on ImageNet and other downstream datasets.
49
+
50
+ ![](images/978f0c664da19142b0881594c45d900b24f08e3c1aad569ad28356448d151fe7.jpg)
51
+ Figure 1: ImageNet performance isn’t indicative of downstream performance in SSL. We show rank correlation between each pair of top-1 accuracy on 11 downstream tasks obtained from ImageNet-pretrained ResNets. We see no strong correlation except for ones similar to ImageNet, e.g., CIFAR-10/100 and Dogs120.
52
+
53
+ Our results highlight that the same architecture recipes in terms of ImageNet accuracy, which is frequently used as a predictor for various selfsupervised tasks, do not work well for different datasets in the SimCLR setting.
54
+
55
+ Larger networks do not always perform better in contrastive SSL. In general, large-parameter models yield better performance on ImageNet, both in supervised (Kornblith et al., 2019) and SSL setups (Chen et al., 2020a). We examine whether this trend holds for downstream datasets some of which are widely different from ImageNet. We follow the same setup as above and compute the
56
+
57
+ ![](images/cafca3409464ab3c90dd7c490f15db8e5376b27cf6d4909facd721ca5a0d87e0.jpg)
58
+ Figure 3: Larger models do not always perform better in SSL. We show the model size in terms of parameter counts ( $\mathbf { \widetilde { x } }$ -axis) vs. top-1 accuracy on different datasets obtained from variations of ResNet (top) and MobileNet (bottom) architectures; all models are pretrained on ImageNet-1K using SimCLR under the same protocol.
59
+
60
+ correlation between number of model parameters and top-1 validation accuracy on different datasets.
61
+ Fig. 3 shows scatter plots of the most representative results; full results are in the appendix.
62
+
63
+ For ResNet-like architectures (Fig. 3 top row), we do not see strong trends indicating larger models always perform better. In fact, on some downstream tasks we see negative correlation (Aircraft, $\rho =$ $- . 3 7 )$ with lighter networks being favored for better performance, or even non-linear relationship, e.g., notice the slight “U” pattern on Stanford Cars $\zeta = - . 1 4 )$ , indicating the behavior of ResNets on these datasets are wildly unexpected. Unsurprisingly, there is strong correlation with ImageNet $( \rho = . 8 5 )$ and CIFAR-100 $\langle \rho = . 8 7 \rangle$ , likely because ResNets are heavily hand-tuned on the kinds of images observed in these datasets. These results clearly suggest that the same architecture recipes which work well for ImageNet (increasing parameters through depth and width) do not hold for other downstream scenarios.
64
+
65
+ For MobileNet-like architectures (Fig. 3 bottom row), we see that there exists almost no interpretable trend. The fitted regression models (solid lines) and their confidence intervals (shaded area) show that the relationships are highly non-linear and non-monotonic; we shouldn’t read too much into the correlation coefficients (reported for completeness). These results indicate that MobileNets do not favor any one architecture and it is heavily reliant on the dataset it is trained on.
66
+
67
+ Our results suggest that larger models are not always better in SSL; lighter models can outperform heavier models on tasks like FGVC Aircraft. Previous work (Chen et al., 2020b) showed that increasing network depth/width improves downstream performance. However, they vary depth at a coarser level with 50/100/150 layers and width with $1 \times / 2 \times$ , leading to a large swing in network parameters (24-795M); here we show the same is not true at a finer level. Our results provide evidence that ResNet architectures are tuned to scale well on ImageNet but not the others; the trend is even weaker for MobileNet-like architectures, suggesting they are optimized for computational efficiency and not for achieving high accuracy on any particular dataset.
68
+
69
+ There is no winner in the battle of top vs. bottom heavy networks in SSL. Raghu et al. (2017) showed that CNNs are more sensitive to lower (initial) layer weights, suggesting that “not all weights are created equal” across layers. This raises the question: If CNNs are more sensitive to lower layers, will increasing the parameter count for lower layers yield better performance in SSL? To get insights into this, we split a network into two halves: “top” (layers closer to output) and “bottom” (closer to input). We use the ratio of top to bottom parameters as a measure of networks being “top-heavy” (high ratio) or “bottom-heavy” (low ratio).
70
+
71
+ Fig. 4 shows the downstream accuracy for ImageNet, Stanford Cars and Sports against this ratio. From the top-left subplot, we see that ResNet-ImageNet accuracy tend to increase with high top:bottom ratio, showing top-heavy networks generally perform better than the bottom-heavy counterparts. However, we no longer observe such trend in other datasets, and with MobileNets (Fig. 4 bottom row) we do not see such trend even for ImageNet.
72
+
73
+ An important point to realize: It is necessary to allocate the right portion of parameters to different layers of a given network topology, instead of allocating parameters in the top-heavy or bottom-heavy fashion assuming one will generally lead to better performance. ResNets and many other handcrafted CNNs (Simonyan & Zisserman, 2014; Szegedy et al., 2016; Huang et al., 2017) are usually top-heavy because of GPU memory limits; bottom-heavy networks occupy more memory in terms of activation maps. MobileNets alleviate this to some extent with lighter convolutions, allowing it to have more parameters in early layers. In object detection, Liang et al. (2019) also show that allocation of computational resources in the backbone is important for improved performance. While this architectural difference provides explanations about the wildly different trends we observe above, the key message here is that one recipe (top vs. bottom heavy) does not apply equally to different architectures, bolstering our claim that one network doesn’t rule them all in SSL.
74
+
75
+ Key takeaway: We need to move beyond handcrafted architectures in SSL. The three main observations above imply that finding an optimal architecture could be an important missing piece for selfsupervised learning. Our results show that the current practice in designing SSL objectives – i.e., optimizing for ImageNet performance based on ResNet backbones – could lead to misleading conclusions which do not generalize to other downstream scenarios. Also, the general belief that “the larger the better” in model size do not really hold in SSL, e.g., smaller
76
+
77
+ ![](images/05d93e00c55127665a07af3b122624e5289290a2942c4b8f7f95506fb063641e.jpg)
78
+ Figure 4: There is no winner in the top vs. bottom battle in SSL. Except for ResNet-ImageNet (top-left), we see no strong trend that suggests either top-heavy or bottom-heavy networks perform better.
79
+
80
+ ResNets can outperform larger ones even if they are pretrained following the same protocol. Let’s say, based on these observations, one is compelled to hunt for a new architecture geared specifically towards SSL. Our top vs. bottom analysis suggests that it can be extremely tricky to find the right architecture topology with optimal parameter allocation across different layers. All this suggests that it is time to consider moving beyond handcrafted architectures in SSL and start thinking about searching for optimal architectures as part of self-supervised learning objectives.
81
+
82
+ # 4 NEURAL ARCHITECTURE SEARCH FOR SSL
83
+
84
+ We turn to the idea of learning both the architecture topology and its network weights in an SSL framework, using NAS to improve SSL (rather than using SSL to improve NAS). It is important to draw a clear distinction between our idea and prior work that used SSL to improve NAS (Li et al., 2021; Liu et al., 2020; 2019; Yan et al., 2020; Zhang et al., 2021b) as well as work that used NAS to improve supervised learning (Elsken et al., 2019); our goal here is to show the benefit of harnessing NAS in aid of SSL and not for comparison with more recent SOTA NAS approaches.
85
+
86
+ While examining this idea appears to be straightforward, it requires careful design of experiments. The biggest hurdle is that both NAS and SSL require heavy compute resources; the former needs a search space large enough to cover a comprehensive range of architecture topologies, while the latter requires large datasets and batch sizes to be effective. This calls for an efficient framework to conduct our study. Furthermore, we need datasets large enough to pretrain the models on, and different enough to investigate the importance of data-dependent architectures in SSL. To meet our desiderata, we choose ProxylessNAS (Cai et al., 2018) as our NAS algorithm, MobileNet as our search space, and ImageNet-1K and iNat2021 (Van Horn et al., 2021) as our pretraining datasets.
87
+
88
+ ![](images/f884c9b3cec2a6d4dfcf115fe09d50c96657df2bb253448807cdf02bb24737c0.jpg)
89
+ Figure 5: Samples from datasets used in our study. We choose these datasets because of the apparent domain shift across them. ImageNet contains general yet coarsely categorized images compared to iNat2021, which contains an order of magnitude higher number of fine-grained categories; although some images look similar to each other, every image shown belongs to a different category highlighting the fine-grained nature of this dataset. The downstream datasets, except for CIFAR, are similarly fine-grained but on different domains.
90
+
91
+ # 4.1 EXPERIMENTAL SETUP
92
+
93
+ SSL objective. We use SimCLR (Chen et al., 2020a), one of the most well-established contrastive SSL framework. We follow the same augmentation methods and hyperparameter settings as in Chen et al. (2020a). While more recent SSL works exist (Caron et al., 2020; Chen & He, 2021), they are similar to SimCLR by utilizing a contrastive learning based objective. We adopt SimCLR for its simplicity and leave analysis of other SSL approaches for future work.
94
+
95
+ NAS algorithm. We choose ProxylessNAS for two reasons: efficiency and flexibility. One-shot NAS algorithms produce an architecture topology in a two-step process. They first find an optimal cell structure by solving a proxy task over a small dataset (e.g., CIFAR-10) and a smaller architecture (e.g., 8 cells), and then stack/repeat the best found cell topology for the target task (e.g., ImageNet with 20 cells). This reduces complexity at the cost of flexibility and introduces an optimization gap (Chen et al., 2021), requiring strong correlation between proxy and the actual target datasets. In contrast, ProxylessNAS produces an architecture by directly optimizing on a target task, as it can significantly ameliorate memory requirements of one-shot NAS methods. To ensure flexibility, it uses a “supernet” with a broad range of candidate operations orchestrating depth (via zero operations), width (via wider convolutions), and block structure (by allowing for operations to differ by level). At each training step, it optimizes one “subnet” on the target task as a surrogate, which greatly reduces compute and memory requirements.
96
+
97
+ Datasets. We use ImageNet-1K and iNat2021 to pretrain our models and evaluate them on their validation sets as well as on 10 downstream datasets used in Section 3. We deliberately choose the two pretraining datasets as they exhibit widely different characteristics, i.e., ImageNet-1K contains a variety of objects and scenes, while iNat2021 contains fine-grained species covering the tree of life. The former contains many inorganic object categories not present in the latter. This creates a domain gap, which allows us to investigate the importance of data-dependent architectures in SSL.
98
+
99
+ iNat2021 contains 2.7 million images (twice the size of ImageNet) representing 10K species (ten times more than ImageNet). To investigate the effect of dataset size during architecture search and pretraining, we use both the full and the mini versions of iNat2021 – the latter contains 500K images representing the same 10K classes. This gives us pretraining datasets at three different scales: 500K (iNat2021-mini), 1.2M (ImageNet), 2.7M (iNat2021).
100
+
101
+ Implementation details. For ProxylessNAS, we replace the original supervised classification loss with the contrastive loss of SimCLR and remove the latency loss as we currently do not consider hardware-constrained scenarios. We follow the original training schedule, i.e., a warmup phase for 40 epochs, which optimizes only the network weights and not the NAS parameters, followed by a search phase for 120 epochs. We use the SGD optimizer for network weights and the ADAM optimizer for NAS parameters, using initial learning rates of 0.25 and 0.1, respectively, and use the cosine decay schedule for both.
102
+
103
+ To make our experiments tractable, we use the MobileNetV2 search space which typically yields 3 to 18 million parameters; the ResNet search space is larger, yielding 20 to 60 million parameters. Working with smaller models means we can use large batch sizes, which is important for contrastive learning to work effectively; we use the batch size 640 given our computational budget. The candidate set of NAS operations consists of mobile inverted bottleneck convolution (MBConv) with kernel sizes $\{ 3 , 5 , 7 \}$ , expansion ratios $\{ 3 , 6 \}$ and zero operations. A higher expansion ratio enables a wider network with more channels for convolutions, while zero operations allow for choosing to remove operations, thereby learning the optimal depth. Once the search is done, we take the architecture and discard the learned weights; we train it again from scratch using the SimCLR objective on different datasets. This allows us to compare different architectures on fair ground. After pretraining, we conduct linear evaluation on all downstream datasets.
104
+
105
+ # 4.2 RESULTS AND DISCUSSION
106
+
107
+ Self-supervised architectures outperform handcrafted architectures in SSL. Table 1 compares our self-supervised architectures to MobileNetV2 and ResNet18/50, by searching, pretraining, and evaluating on ImageNet-1K, iNat2021 and iNat2021-mini. We report linear evaluation results on validation splits. The results show that our selfsupervised architectures outperform MobileNetV2 by a large margin, even with similar parameters (about 3M).
108
+
109
+ Table 1: Searched architectures vs. handcrafted architecture results. We search, pretrain, and evaluate ours on each of the three datasets in the last three columns. †SOTA results (in gray) from Chen et al. (2020a) for ImageNet and Cole et al. (2021) for iNat21 require larger batch sizes and longer training.
110
+
111
+ <table><tr><td>Model</td><td>Params</td><td>Batch</td><td>Epochs</td><td>ImageNet</td><td>iNat21</td><td>iNat21-mini</td></tr><tr><td>MobileV2</td><td>3.5M</td><td>640</td><td>100</td><td>41.9</td><td>30.2</td><td>13.6</td></tr><tr><td>Ours</td><td>3.3M</td><td>640</td><td>100</td><td>55.3</td><td>40.3</td><td>14.7</td></tr><tr><td>ResNet18</td><td>11M</td><td>640</td><td>100</td><td>49.8</td><td>30.3</td><td>20.1</td></tr><tr><td>ResNet50</td><td>23.5M</td><td>640</td><td>100</td><td>58.9</td><td>41.3</td><td>23.4</td></tr><tr><td>Ours</td><td>12-18M</td><td>640</td><td>100</td><td>59.1</td><td>43.8</td><td>25.1</td></tr><tr><td>ResNet50</td><td>23.5M</td><td>4096</td><td>1000</td><td>69.3t</td><td>50.6t</td><td>-</td></tr></table>
112
+
113
+ The self-supervised architectures also beat ResNet18 and ResNet50, with even smaller model size than ResNet50. The superior downstream performance of our approach should not be attributed solely to NAS, as the architecture search was performed without ever solving the downstream tasks. It is rather the incorporation of NAS into SSL that improved the quality of representations, leading to downstream performance boost. This shows the effectiveness of learning both the architecture topology and its weights in SSL.
114
+
115
+ Do self-supervised architectures generalize well to different data distributions? We take the three architectures searched on each dataset, discard their learned weights, and pretrain them on each dataset, yielding 9 pretrained models. We then evaluate the performance directly on validation splits of the respective datasets. Table 2 shows that transferring an architecture from $\mathrm { i N a t } 2 0 2 1$ to ImageNet leads to a marginal
116
+
117
+ Table 2: Self-supervised architecture transfer results. We evaluate architectures in the cross-dataset setting, pretraining and evaluating the searched architectures across three datasets (last three columns).
118
+
119
+ <table><tr><td>Searched on</td><td>Params</td><td>ImageNet</td><td>iNat21</td><td>iNat21-mini</td></tr><tr><td>ImageNet</td><td>12-18M</td><td>59.1</td><td>21.5</td><td>23.9</td></tr><tr><td>iNat21</td><td>12-18M</td><td>58.3</td><td>43.8</td><td>27.9</td></tr><tr><td>iNat21-mini</td><td>12-18M</td><td>58.0</td><td>22.4</td><td>25.1</td></tr></table>
120
+
121
+ performance drop compared to an architecture optimized directly on ImageNet $( 5 9 . 1 \%$ to $5 8 . 3 \%$ ); both these architectures still outperform handcrafted ResNet18 $( 4 9 . 8 \% )$ with a comparable model size. However, transferring an architecture from ImageNet to iNat2021 deteriorates performance significantly $( 4 3 . 8 \%$ to $2 1 . { \bar { 5 } } \%$ ). This implies an interesting finding, i.e., iNat21-searched architectures seem to be more resilient to domain shift than ImageNet-searched architectures. This could be due to the difference in dataset size (iNat21 has twice as many images as ImageNet), or due to the fine-grained nature of iNat21 resulting in an overall more difficult instance discrimination task (Chen et al., 2020a) that leads to more discriminative representations. The effect of dataset size on architecture search is also shown on iNat21-mini results. While transferring an architecture from ImageNet to iNat21-mini shows an expected drop in accuracy $( 2 5 . 1 \%$ to $2 3 . 9 \%$ ), transferring from the larger iNat21 improves performance $2 5 . 1 \%$ to $2 7 . 9 \%$ ). As both datasets are in the same domain and only differ in number of samples per class, higher search dataset size is the driving factor behind the gains in accuracy while pretraining on a smaller version of the dataset.
122
+
123
+ Downstream transfer experiments. The results above show that self-supervised architectures are superior to handcrafted architectures when tested in in-distribution settings, which might reflect a practical use case of self-supervised pretraining in the real-world setting (e.g., one has access to only small labeled but large unlabeled data from the same distribution). We now evaluate our approach on a downstream transfer scenario with possible domain shift and with much smaller datasets. To this end, we again use the 10 downstream tasks used in Section 3, which contain datasets coming from both in-distributions and out-of-distributions relative to the pretraining datasets.
124
+
125
+ Table 3: Downstream transfer results. We categorize downstream datasets as in-distribution (green) and outof-distribution (red) relative to the pretraining dataset based on class overlap; best viewed in color. We see that self-supervised architectures generally perform better on in-distribution downstream scenarios.
126
+
127
+ <table><tr><td>Pretrain Dataset</td><td>Arch.</td><td>Params</td><td>Pretrain Val. Set</td><td>CUB</td><td>NABirds</td><td>CIFAR10</td><td>Oxford Flowers</td><td>Stanford Dogs</td><td>Food101</td><td>Sport</td><td>Stanford Cars</td><td>MIT67</td><td>FGVC Aircraft</td></tr><tr><td rowspan="4">ImNet</td><td>MobileV2</td><td>3.5M</td><td>41.9</td><td>20.1</td><td>14.2</td><td>75.8</td><td>85.4</td><td>35.7</td><td>51.6</td><td>94.0</td><td>26.4</td><td>57.5</td><td>35.8</td></tr><tr><td>Ours</td><td>3.3M</td><td>55.3</td><td>31.8</td><td>24.4</td><td>78.8</td><td>91.7</td><td>49.2</td><td>61.7</td><td>94.3</td><td>30.4</td><td>62.5</td><td>38.1</td></tr><tr><td>ResNet18</td><td>11M</td><td>49.8</td><td>27.0</td><td>19.0</td><td>79.9</td><td>89.9</td><td>44.1</td><td>55.8</td><td>94.6</td><td>27.8</td><td>62.1</td><td>36.7</td></tr><tr><td>ResNet50</td><td>23.5M</td><td>58.9</td><td>31.4</td><td>24.6</td><td>85.9</td><td>92.8</td><td>52.3</td><td>65.7</td><td>94.3</td><td>35.1</td><td>69.6</td><td>42.0</td></tr><tr><td rowspan="3">iNat21</td><td>Ours</td><td>3-18M</td><td>59.1</td><td>34.3</td><td>26.1</td><td>81.8</td><td>92.2</td><td>51.0</td><td>64.7</td><td>94.7</td><td>33.2</td><td>66.1</td><td>39.4</td></tr><tr><td>ResNet18</td><td>11M</td><td>30.3</td><td>26.1</td><td>19.0</td><td>73.2</td><td>92.8</td><td>31.3</td><td>55.3</td><td>92.1</td><td>18.9</td><td>49.9</td><td>32.7</td></tr><tr><td>ResNet50</td><td>23.5M</td><td>41.3</td><td>31.2</td><td>23.2</td><td>75.1</td><td>95.1</td><td>39.7</td><td>65.1</td><td>94.3</td><td>22.3</td><td>55.0</td><td>37.6</td></tr><tr><td></td><td>Ours</td><td>3-18M</td><td>43.8</td><td>32.7</td><td>24.1</td><td>76.1</td><td>94.7</td><td>39.0</td><td>63.1</td><td>93.1</td><td>20.1</td><td>49.0</td><td>34.9</td></tr></table>
128
+
129
+ Table 3 summarizes the results (we color code in/out-of-distribution datasets based on our crude categorization; see appendix for our justification). We first compare our self-supervised architectures to MobileNetV2 in the same parameter range (3.5M vs $3 . 3 \mathbf { M }$ ; top two rows). We notice that self-supervised architectures significantly outperform MobileNetV2 in all datasets regardless of distributional shift. This is encouraging (i.e., self-supervised architectures can learn generalizable representations) but at the same time not totally surprising (i.e., MobileNet is optimized for efficiency and not for accuracy). Next, we compare ours to ResNet18 that has a similar parameter range although belonging to a class of architectures much different from our search space. Ours outperforms ResNet18 on all pretraining and evaluation datasets by a considerable margin. This shows that our approach is generalizable and can outperform architectures in the ResNet18 search space even though they are generally more computationally expensive than the MobileNet search space.
130
+
131
+ Finally, we compare ours to ResNet50 which is computationally heavier compared to ResNet18. We preface our analysis with a caveat that our self-supervised architectures are almost half the capacity of ResNet50, limiting their representational power. Keeping this in mind, we see that our approach starts to fail in some of the in-distribution and all of the out-of-distribution scenarios (red shaded cells). This is somewhat disappointing but perhaps expected: self-supervised architectures naturally encode inductive biases specific to the dataset they were optimized on. When a distributional shift happens, their performance can start deteriorating because out-of-domain data might require a different set of inductive biases. The strong performance by ResNet50 imply that the model might be striking the right balance across those datasets in terms of inductive biases, but our results in Table 1 and 2 show that ResNet50 can be less effective on newly developed datasets such as iNat2021.
132
+
133
+ # 5 CONCLUSION
134
+
135
+ This work lays the ground for moving beyond handcrafted architectures in SSL. By conducting large-scale experiments with 116 architectures and 11 downstream tasks, we established extensive empirical evidence showing that there isn’t one architecture that performs consistently well across different downstream scenarios in SSL. Motivated by this, we proposed to move beyond handcrafted architectures and learn both an architecture topology and its network weights in SSL. We provided convincing results demonstrating that the self-supervised architectures significantly outperform handcrafted MobileNetV2 and ResNet18 architectures on 11 downstream tasks, and competitively with ResNet50 even with almost half the model size. We re-emphasize that improvements are not solely due to NAS, as the architecture search was performed by solving SSL and not by optimizing directly on downstream tasks as in the typical NAS setting.
136
+
137
+ Our work barely scratches the surface and opens up many doors for future directions. Will our findings hold for different architectures such as Transformers and different modalities such as video and text? How can we make architecture search more effective for SSL? Can ideas from domain generalization improve the transferability of self-supervised architectures in the out-of-distribution setting? Or is it even the right idea to expect learned architectures to generalize to widely different domains? We hope the readers are as excited as us to investigate these challenging questions.
138
+
139
+ # REFERENCES
140
+
141
+ Sanjeev Arora, Hrishikesh Khandeparkar, Mikhail Khodak, Orestis Plevrakis, and Nikunj Saunshi. A theoretical analysis of contrastive unsupervised representation learning. arXiv preprint arXiv:1902.09229, 2019. 1
142
+
143
+ Hangbo Bao, Li Dong, and Furu Wei. Beit: Bert pre-training of image transformers. arXiv preprint arXiv:2106.08254, 2021. 1
144
+
145
+ Han Cai, Ligeng Zhu, and Song Han. Proxylessnas: Direct neural architecture search on target task and hardware. arXiv preprint arXiv:1812.00332, 2018. 2, 6, 15
146
+
147
+ 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, pp. 132–149, 2018. 1
148
+
149
+ Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. arXiv preprint arXiv:2006.09882, 2020. 1, 3, 7
150
+
151
+ Mathilde Caron, Hugo Touvron, Ishan Misra, Herve J ´ egou, 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. 3
152
+
153
+ Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pp. 1597–1607. PMLR, 2020a. 1, 2, 3, 4, 7, 8, 15, 17, 18
154
+
155
+ Ting Chen, Simon Kornblith, Kevin Swersky, Mohammad Norouzi, and Geoffrey E Hinton. Big self-supervised models are strong semi-supervised learners. Advances in neural information processing systems, 33:22243–22255, 2020b. 5
156
+
157
+ Xin Chen, Lingxi Xie, Jun Wu, and Qi Tian. Progressive darts: Bridging the optimization gap for nas in the wild. International Journal of Computer Vision, 129(3):638–655, 2021. 7
158
+
159
+ Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 15750–15758, 2021. 1, 3, 7
160
+
161
+ Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020c. 3
162
+
163
+ Yu Cheng, Duo Wang, Pan Zhou, and Tao Zhang. A survey of model compression and acceleration for deep neural networks. arXiv preprint arXiv:1710.09282, 2017. 3
164
+
165
+ Elijah Cole, Xuan Yang, Kimberly Wilber, Oisin Mac Aodha, and Serge Belongie. When does contrastive visual representation learning work? arXiv preprint arXiv:2105.05837, 2021. 1, 8
166
+
167
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009. 2, 16, 17, 18, 20
168
+
169
+ Debadeepta Dey, Shital Shah, and Sebastien Bubeck. Fear: A simple lightweight method to rank architectures. arXiv preprint arXiv:2106.04010, 2021. 2
170
+
171
+ Thomas Elsken, Jan Hendrik Metzen, Frank Hutter, et al. Neural architecture search: A survey. J. Mach. Learn. Res., 20(55):1–21, 2019. 3, 6
172
+
173
+ Linus Ericsson, Henry Gouk, and Timothy M Hospedales. How well do self-supervised models transfer? In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5414–5423, 2021. 3
174
+
175
+ Christoph Feichtenhofer, Haoqi Fan, Bo Xiong, Ross Girshick, and Kaiming He. A large-scale study on unsupervised spatiotemporal representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3299–3309, 2021. 1
176
+
177
+ Spyros Gidaris, Praveer Singh, and Nikos Komodakis. Unsupervised representation learning by predicting image rotations. arXiv preprint arXiv:1803.07728, 2018. 1, 3
178
+
179
+ Jean-Bastien Grill, Florian Strub, Florent Altche, Corentin Tallec, Pierre H Richemond, Elena ´ Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Daniel Guo, Mohammad Gheshlaghi Azar, et al. Bootstrap your own latent: A new approach to self-supervised learning. arXiv preprint arXiv:2006.07733, 2020. 1, 2
180
+
181
+ 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. 1, 2
182
+
183
+ Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9729–9738, 2020. 1, 2
184
+
185
+ Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollar, and Ross Girshick. Masked au- ´ toencoders are scalable vision learners. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16000–16009, 2022. 1, 2
186
+
187
+ 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. 6
188
+
189
+ Aditya Khosla, Nityananda Jayadevaprakash, Bangpeng Yao, and Fei-Fei Li. Novel dataset for finegrained image categorization: Stanford dogs. In Proc. CVPR Workshop on Fine-Grained Visual Categorization (FGVC), volume 2. Citeseer, 2011. 16, 20
190
+
191
+ Alexander Kirillov, Kaiming He, Ross Girshick, Carsten Rother, and Piotr Dollar. Panoptic segmen- ´ tation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9404–9413, 2019. 3
192
+
193
+ Alexander Kolesnikov, Xiaohua Zhai, and Lucas Beyer. Revisiting self-supervised visual representation learning. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 1920–1929, 2019. 2, 3
194
+
195
+ Simon Kornblith, Jonathon Shlens, and Quoc V Le. Do better imagenet models transfer better? In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2661–2671, 2019. 3, 4
196
+
197
+ Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In Proceedings of the IEEE international conference on computer vision workshops, pp. 554–561, 2013. 16, 20
198
+
199
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009. 16, 20
200
+
201
+ Changlin Li, Tao Tang, Guangrun Wang, Jiefeng Peng, Bing Wang, Xiaodan Liang, and Xiaojun Chang. Bossnas: Exploring hybrid cnn-transformers with block-wisely self-supervised neural architecture search. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 12281–12291, 2021. 3, 6
202
+
203
+ Li-Jia Li and Li Fei-Fei. What, where and who? classifying events by scene and object recognition. In 2007 IEEE 11th international conference on computer vision, pp. 1–8. IEEE, 2007. 16, 20
204
+
205
+ Feng Liang, Chen Lin, Ronghao Guo, Ming Sun, Wei Wu, Junjie Yan, and Wanli Ouyang. Computation reallocation for object detection. arXiv preprint arXiv:1912.11234, 2019. 6
206
+
207
+ Chenxi Liu, Piotr Dollar, Kaiming He, Ross Girshick, Alan Yuille, and Saining Xie. Are labels ´ necessary for neural architecture search? In European Conference on Computer Vision, pp. 798– 813. Springer, 2020. 3, 6
208
+
209
+ Hanxiao Liu, Karen Simonyan, and Yiming Yang. DARTS: Differentiable architecture search. In International Conference on Learning Representations, 2019. URL https://openreview. net/forum?id=S1eYHoC5FX. 3, 6
210
+
211
+ Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. arXiv preprint arXiv:1306.5151, 2013. 16
212
+
213
+ Joseph Mellor, Jack Turner, Amos Storkey, and Elliot J. Crowley. Neural architecture search without training, 2021. 3
214
+
215
+ Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y Ng. Reading digits in natural images with unsupervised feature learning. 2011. 16, 20
216
+
217
+ Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In 2008 Sixth Indian Conference on Computer Vision, Graphics & Image Processing, pp. 722–729. IEEE, 2008. 16, 20
218
+
219
+ Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018. 1
220
+
221
+ Ben Poole, Sherjil Ozair, Aaron Van Den Oord, Alex Alemi, and George Tucker. On variational bounds of mutual information. In International Conference on Machine Learning, pp. 5171– 5180. PMLR, 2019. 1
222
+
223
+ Ariadna Quattoni and Antonio Torralba. Recognizing indoor scenes. In 2009 IEEE Conference on Computer Vision and Pattern Recognition, pp. 413–420. IEEE, 2009. 16, 20
224
+
225
+ Maithra Raghu, Ben Poole, Jon Kleinberg, Surya Ganguli, and Jascha Sohl-Dickstein. On the expressive power of deep neural networks. In international conference on machine learning, pp. 2847–2854. PMLR, 2017. 2, 5
226
+
227
+ Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4510–4520, 2018. 2
228
+
229
+ Terrence J Sejnowski. The unreasonable effectiveness of deep learning in artificial intelligence. Proceedings of the National Academy of Sciences, 117(48):30033–30038, 2020. 1
230
+
231
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014. 6
232
+
233
+ Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In Proceedings of the IEEE international conference on computer vision, pp. 843–852, 2017. 1
234
+
235
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818–2826, 2016. 6
236
+
237
+ Lukas Tuggener, Jurgen Schmidhuber, and Thilo Stadelmann. Is it enough to optimize cnn architec-¨ tures on imagenet? arXiv preprint arXiv:2103.09108, 2021. 2
238
+
239
+ Grant Van Horn, Elijah Cole, Sara Beery, Kimberly Wilber, Serge Belongie, and Oisin Mac Aodha. Benchmarking representation learning for natural world image collections. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12884–12893, 2021. 2, 6
240
+
241
+ P. Welinder, S. Branson, T. Mita, C. Wah, F. Schroff, S. Belongie, and P. Perona. Caltech-UCSD Birds 200. Technical Report CNS-TR-2010-001, California Institute of Technology, 2010. 16, 20
242
+
243
+ Yuxin Wu, Alexander Kirillov, Francisco Massa, Wan-Yen Lo, and Ross Girshick. Detectron2. 2019. URL https://github. com/facebookresearch/detectron2, 2(3), 2019. 3
244
+
245
+ Shen Yan, Yu Zheng, Wei Ao, Xiao Zeng, and Mi Zhang. Does unsupervised architecture representation learning help neural architecture search? Advances in Neural Information Processing Systems, 33, 2020. 3, 6
246
+
247
+ Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning (still) requires rethinking generalization. Communications of the ACM, 64(3):107– 115, 2021a. 2
248
+
249
+ Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 586–595, 2018. 1
250
+
251
+ Xuanyang Zhang, Pengfei Hou, Xiangyu Zhang, and Jian Sun. Neural architecture search with random labels. arXiv preprint arXiv:2101.11834, 2021b. 3, 6
252
+
253
+ # APPENDIX
254
+
255
+ Fig. 6 provides an overview of our work. We show that no single handcrafted architecture performs consistently well across different tasks. It is therefore imperative to optimize for architecture topologies along with network weights for a specific task. Through extensive empirical results we show that such self-supervised architectures outperform their handcrafted counterparts in the same search space on the respective tasks.
256
+
257
+ ![](images/accf1356d2a88bdcd1df4d10e4829e92d0fd35757f21f6038b46032d63d2158b.jpg)
258
+ Figure 6: Conventional SSL frameworks learn network weights for a fixed handcrafted architecture (left). We show that learning architecture topologies along with their weights can improve performance in SSL (right).
259
+
260
+ # A SUPERVISED TRAINING PERFORMANCE OF SELF-SUPERVISED ARCHITECTURES
261
+
262
+ In addition to evaluating the performance of the searched architectures for SSL, we analyze their supervised training performance. We use the searched architectures and directly train them, from scratch without any pretraining, on downstream datasets using the supervised labels. Results are summarized in Table 4. We include architectures searched on ImageNet and iNat21, and MobileNetV2 for reference. It shows the searched architectures perform well even in the supervised setting, outperforming the handcrafted MobileNetV2 on most of the downstream datasets. However, a performance degradation is observed in out-of-distribution datasets like Stanford Cars and FGVC Aircraft. This is in line with the discussion in Section 4.2 of the main paper where the searched architecture performances deteriorate with distributional shift. Nevertheless, for the more in-distribution datasets, we obtain higher accuracies showing that the searched architectures are suitable for supervised training as well.
263
+
264
+ Table 4: Supervised performance of searched architectures.
265
+
266
+ <table><tr><td></td><td>CUB</td><td>CIFAR10</td><td>CIFAR100</td><td>Food</td><td>Flowers</td><td>Sport</td><td>Cars</td><td>Aircraft</td></tr><tr><td>MobileNetV2</td><td>58.2</td><td>93.7</td><td>71.9</td><td>80.8</td><td>90.0</td><td>94.2</td><td>88.6</td><td>81.4</td></tr><tr><td>Ours (ImNet)</td><td>57.9</td><td>93.1</td><td>74.7</td><td>78.1</td><td>96.7</td><td>95.0</td><td>71.0</td><td>75.5</td></tr><tr><td>Ours (iNat21)</td><td>64.5</td><td>93.9</td><td>75.8</td><td>81.6</td><td>98.1</td><td>96.3</td><td>72.3</td><td>72.9</td></tr></table>
267
+
268
+ # B CLASS MAPPING FROM IMAGENET TO DOWNSTREAM DATASETS
269
+
270
+ We provide a justification for characterizing downstream datasets as in-distribution/out-ofdistribution with respect to ImageNet as shown in Table 3 of the main paper. We provide a rough class mapping between ImageNet and the 10 downstream datasets. Note that obtaining an exact class mapping is difficult due to only an approximate mapping existing between any 2 datasets. In addition, there can be classes which contribute to improved features for another class while still being semantically different. For example, zebra (n02391049) can contribute to improved features for horses (sorrel-n02389026) due to similar shapes. We now list datasets with corresponding ImageNet classes/superclasses. While some superclasses can contain additional subclasses in the WordNet hierarchy, we restrict to only those classes in the ImageNet-1k dataset. Numbers in bracket denote the total number of classes roughly overlapping.
271
+
272
+ • CIFAR-10 (270): vehicle (n4524313), bird (n1503061), feline (n2120997), frog (n1639765), dog (n2084071), sorrel (n2389026)
273
+ • Stanford Dogs (120): dog (n2084071)
274
+ • CUB (60): bird (n1503061)
275
+ • NABirds (60): bird (n1503061)
276
+ • Food101 (20): nutriment (n7570720), beverage (n7881800), foodstuff (n7566340), sandwich (n7695965), bagel (n7693725), guacamole (n7583066), chocolate sauce (n7836838), carbonara (n7831146), french loaf (n7684084), pretzel (n7695742)
277
+ • Stanford Cars (10): car (n2958343)
278
+ • FGVC Aircraft (3): airliner (n2690373), warplane (n4552348), airship (n2692877)
279
+ • Oxford Flowers (2): yellow lady’s slipper (n12057211), daisy (n11939491)
280
+ • MIT67 (0): -
281
+ • Sports(0): -
282
+
283
+ Due to the inductive biases encoded during the search process specific to the dataset it is searched on, the self-supervised architecture performs well on more in-distribution datasets like CUB or NABirds. However, we see that for datasets like Stanford Cars and subsequent ones, there is little direct class overlap with ImageNet classes. This leads to lesser images being available for self-supervised pretraining which are in-distribution for these datasets. Consequently, due to the relatively out-of-distribution nature of these datasets we see in Table 3 of the main paper, our selfsupervised architectures are outperformed by the ResNet-50 baseline.
284
+
285
+ # C ADDITIONAL IMPLEMENTATION DETAILS
286
+
287
+ We sample ResNet architectures by varying the number of blocks at each of the 4 stages choosing from the set of $2 , 3 , 4$ blocks and choose the ones in the parameter range shown in Fig. 3 while also fitting in GPU memory. For MobileNets, we have 7 sequences (stages) and a higher variation of the number of blocks from [2-6] while also choosing the width parameter from the set $1 . 0 , 1 . 2 , 1 . 4 , 1 . 6 , 1 . 8 , 2 . 0$ and choose the ones in the 2M-7M parameter range and fitting in GPU memory. Note that a high number of blocks in the earlier stages take significantly more GPU memory due to larger feature map sizes.
288
+
289
+ For the architecture search phase, we use the optimizer hyperparameters as explained in Sec. 4.1 of the main paper. We use a weight decay of $4 e ^ { - 5 }$ for the weight parameters excluding batch normalization parameters. The initial convolution is a $3 { \tt X } 3$ convolution with stride 2. The network consists of 6 stages with 4 cells in the first 5 stages and 1 cell in the last stage. By default, the number of channels at each stage is 24, 40, 80, 96, 192, 320, which is multiplied by a constant width multiplier. We downsample it by a factor of 2 at the beginning of the first, second, third and fifth stage. Other architecture details are the default ones used in Cai et al. (2018). We use the same projection head as used normally for SimCLR Chen et al. (2020a) on top of the backbone network, which is a 2048 dimensional hidden layer and 128 dimensional output layer. For evaluation, we remove the projection head and use the output of the network backbone as the feature extractor. Augmentations are the same as in SimCLR with random resize scaling and cropping, flipping and color jitter. A temperature value of $\tau = 0 . 1$ is set for the contrastive loss.
290
+
291
+ ![](images/fd128bd086da0bc459cdfc02749b7abd25faae3e845591e86215b11e95baf798.jpg)
292
+ Figure 7: Self-supervised architectures for different pretraining datasets. MB3 and MB6 are the mobile inverted convolutions with expansion ratio of 3 and 6 respectively. We see that the majority of the preferred convolutions is MB6 $7 \times 7$ suggesting that the network prefers convolutions with more parameters for the self-supervised regime due to lots of data. For smaller datasets like iNat21Mini, MB6 convolutions are not as strongly preferred.
293
+
294
+ # D VISUALIZING SELF-SUPERVISED ARCHITECTURES FOR DIFFERENT PRETRAINING DATASETS
295
+
296
+ We visualize the types of convolutions searched at a $1 . 7 5 \mathrm { x }$ width multiplier for the 3 different pretraining datasets: ImageNet, iNat21 and iNat21Mini. Results are shown in Fig. 7. MB3 and MB6 are the mobile inverted convolutions with expansion ratio of 3 and 6 respectively. The grey lines denote the downsampling of image due to strided convolutions. All architectures are followed by a pooling layer to reduce the image size to $1 \times 1$ . In contrast to standard handcrafted architectures, larger $7 \times 7$ convolutions are preferred even in the later stages of the network. We also see that the majority of the preferred convolutions is MB6 $7 \times 7$ suggesting that the network prefers convolutions with more parameters for the self-supervised regime due to lots of data. This is less preferred in smaller datasets like iNat21Mini where MB3 convolutions are common especially in earlier stages of the network. It is difficult to draw conclusions on the type of network preferred between ImageNet and iNat21 showing that it is imperative to search for an optimal architecture rather than handcraft them.
297
+
298
+ # E DOWNSTREAM DATASET PERFORMANCE CORRELATION WITH IMAGENET
299
+
300
+ We show the downstream dataset correlation for all 10 downstream datasets in addition to ImageNet1K Deng et al. (2009): CIFAR10/100 Krizhevsky et al. (2009), Stanford Cars Krause et al. (2013) and Dogs Khosla et al. (2011), CUB-200 Welinder et al. (2010), MIT-67 Quattoni & Torralba (2009), SVHN Netzer et al. (2011), Flowers-102 Nilsback & Zisserman (2008), FGVC-Aircraft Maji et al. (2013), Sports8 Li & Fei-Fei (2007). These are shown for both ResNets (Fig. 8) and MobileNets (Fig. 9). We see similar results for the 5 datasets in addition to those shown in Fig. 3 of main paper. High correlation exists for datasets which are visually similar to ImageNet while it is less correlated for datasets which are out of domain. For MobileNets this correlation is even less pronounced with high variance in performance at higher ImageNet accuracies.
301
+
302
+ ![](images/0bba7b900089965a52388ce1f902c3c9b6cc53e5c1884cf0ca84918f10797416.jpg)
303
+ Figure 8: ImageNet performance correlation with 10 different downstream datasets for various ResNets. We show linear evaluation top-1 accuracy of ImageNet $\mathbf { \dot { x } }$ -axis) vs. different downstream datasets (y-axis) obtained from variations of ResNet; all models are pretrained on ImageNet-1K Deng et al. (2009) using SimCLR Chen et al. (2020a) under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
304
+
305
+ ![](images/70824b783eee5ebb816e486c629b8b2f0fb15cd94462f425e2695756953b96ee.jpg)
306
+ Figure 9: ImageNet performance correlation with 10 different downstream datasets for various MobileNets. We show linear evaluation top-1 accuracy of ImageNet $\mathbf { \widetilde { x } }$ -axis) vs. different downstream datasets (y-axis) obtained from variations of MobileNet; all models are pretrained on ImageNet-1K Deng et al. (2009) using SimCLR Chen et al. (2020a) under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
307
+
308
+ ![](images/f6a7746ca10efe2bcf8f6ff1e9ca1737ac46bc489713dce258d039d4835980b9.jpg)
309
+ Figure 10: Dataset performance correlation with 10 different datasets for various ResNets. We show the model size in terms of parameter counts $\mathbf { \widetilde { x } }$ -axis) vs. top-1 accuracy on different datasets obtained from variations of ResNet-like architectures; all models are pretrained on ImageNet-1K Deng et al. (2009) using SimCLR Chen et al. (2020a) under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
310
+
311
+ ![](images/43fda8482ba7f3742017ae263db37ba673a381a4bd5bda452e730fa8592579af.jpg)
312
+ Figure 11: Dataset performance correlation with 10 different datasets for various MobileNets. We show the model size in terms of parameter counts $\mathbf { \widetilde { x } }$ -axis) vs. top-1 accuracy on different datasets obtained from variations of MobileNet-like architectures; all models are pretrained on ImageNet-1K Deng et al. (2009) using SimCLR Chen et al. (2020a) under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
313
+
314
+ ![](images/7370ad50b35571a20834b016d378412186e599a7e683874e685da7feb210fd98.jpg)
315
+ Figure 12: Linear and rank correlation of ResNets between different pairs of 11 datasets We show correlation between every pair of top-1 accuracy on 11 downstream tasks obtained from ImageNet-pretrained ResNets. We see no strong correlation except for ones highly similar to the data the models were originally pretrained on, e.g., CIFAR-10/100 and Dogs120.
316
+
317
+ ![](images/efa643a0719af7cf0d7b6b0edc681bbc4514829f52ef93a07103374d1a8f41a3.jpg)
318
+
319
+ ![](images/7d32535940ca31ff4448230673c02a97883e7edfd1ef783b7da494664bd4913c.jpg)
320
+ Figure 13: Linear and rank correlation of MobileNets between different pairs of 11 datasets We show correlation between every pair of top-1 accuracy on 11 downstream tasks obtained from ImageNet-pretrained MobileNets. The correlation
321
+
322
+ ![](images/7b54e0d8565d1af9449e55fb75fc8fc58b76a0d58d19907da021698701e96d2a.jpg)
323
+
324
+ # F DATASET PERFORMANCE AS A FUNCTION OF NUMBER OF PARAMETERS
325
+
326
+ We show the dataset correlation with respect to number of parameters for 5 more datasets in addition to that shown in Fig. 4 of main paper. Fig. 10 summarizes the results for ResNets while Fig. 11 shows results for MobileNets. We see that similar results hold for the additional 5 datasets where more parameters, and consequently larger networks, does not always lead to better downstream performance.
327
+
328
+ # G LINEAR AND RANK CORRELATION FOR RESNETS/MOBILENETS
329
+
330
+ We show the summary of the correlation across different datasets for both ResNets (Fig. 12) and MobileNets (Fig. 13). In addition to Spearman’s rank correlation coefficient, we also show Pearson’s linear correlation coefficient. While Pearson’s linear coefficient is higher in the case of MobileNets, the linear fit still exhibits high variance for higher ImageNet accuracies, as seen in Fig. 9.
331
+
332
+ ![](images/e7eab649c5fd42ef4d4f2ac0653c9c6227eb0ae9a13f15160c00b95f22820cec.jpg)
333
+ Figure 14: ImageNet performance correlation with 10 different downstream datasets for various ResNets, MobileNets and searched architectures. The searched architectures outperform MobileNets while being comparable with ResNets at fewer parameters.
334
+
335
+ # H DATASET LICENSES
336
+
337
+ Table 5 lists some datasets we used and their licenses.
338
+
339
+ Table 5: Licenses of datasets.
340
+
341
+ <table><tr><td>Dataset</td><td>License</td></tr><tr><td>CIFAR-10 Krizhevsky et al. (2009)</td><td>MIT</td></tr><tr><td>CIFAR-100 Krizhevsky et al. (2009)</td><td>MIT</td></tr><tr><td>ImageNet Deng et al. (2009)</td><td>BSD 3-Clause</td></tr><tr><td>Sport8 Li &amp; Fei-Fei (2007)</td><td>CCO:Public Domain</td></tr><tr><td>Stanford Dogs Khosla et al. (2011)</td><td>BSD3-Clause</td></tr><tr><td>Stanford Cars Krause et al. (2013)</td><td>BSD 3-Clause</td></tr><tr><td>CUB-200 Welinder et al. (2010)</td><td>Data files @ Original Authors</td></tr><tr><td>MIT-67 Quattoni &amp; Torralba a (2009)</td><td>MIT</td></tr><tr><td>SVHN Netzer et al. (2011)</td><td>CCO:Public Domain</td></tr><tr><td>Flowers-102 Nilsback &amp; Zisserman (2008)</td><td>GNU General Public License,version 2</td></tr></table>
md/dev/1PL1NIMMrw/1PL1NIMMrw.md ADDED
@@ -0,0 +1,549 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SELF-CONSISTENCY IMPROVES CHAIN OF THOUGHT REASONING IN LANGUAGE MODELS
2
+
3
+ Xuezhi Wang†‡, Jason Wei†, Dale Schuurmans†, Quoc Le†, Ed H. Chi†, Sharan Narang†, Aakanksha Chowdhery†, Denny Zhou†§
4
+
5
+ †Google Research, Brain Team ‡xuezhiw@google.com, §dennyzhou@google.com
6
+
7
+ # ABSTRACT
8
+
9
+ Chain-of-thought prompting combined with pre-trained large language models has achieved encouraging results on complex reasoning tasks. In this paper, we propose a new decoding strategy, self-consistency, to replace the naive greedy decoding used in chain-of-thought prompting. It first samples a diverse set of reasoning paths instead of only taking the greedy one, and then selects the most consistent answer by marginalizing out the sampled reasoning paths. Self-consistency leverages the intuition that a complex reasoning problem typically admits multiple different ways of thinking leading to its unique correct answer. Our extensive empirical evaluation shows that self-consistency boosts the performance of chain-of-thought prompting with a striking margin on a range of popular arithmetic and commonsense reasoning benchmarks, including GSM8K $( + 1 7 . 9 \% )$ , SVAMP $( + 1 1 . 0 \% )$ , AQuA $( + 1 2 . 2 \% )$ , StrategyQA $( + 6 . 4 \% )$ and ARC-challenge $( + 3 . 9 \% )$ .
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Although language models have demonstrated remarkable success across a range of NLP tasks, their ability to demonstrate reasoning is often seen as a limitation, which cannot be overcome solely by increasing model scale (Rae et al., 2021; BIG-bench collaboration, 2021, inter alia). In an effort to address this shortcoming, Wei et al. (2022) have proposed chain-of-thought prompting, where a language model is prompted to generate a series of short sentences that mimic the reasoning process a person might employ in solving a task. For example, given the question “If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?”, instead of directly responding with “5”, a language model would be prompted to respond with the entire chain-of-thought: “There are 3 cars in the parking lot already. 2 more arrive. Now there are $3 +$ $2 = 5$ cars. The answer is 5.”. It has been observed that chain-of-thought prompting significantly improves model performance across a variety of multi-step reasoning tasks (Wei et al., 2022).
14
+
15
+ In this paper, we introduce a novel decoding strategy called self-consistency to replace the greedy decoding strategy used in chain-of-thought prompting (Wei et al., 2022), that further improves language models’ reasoning performance by a significant margin. Self-consistency leverages the intuition that complex reasoning tasks typically admit multiple reasoning paths that reach a correct answer (Stanovich & West, 2000). The more that deliberate thinking and analysis is required for a problem (Evans, 2010), the greater the diversity of reasoning paths that can recover the answer.
16
+
17
+ Figure 1 illustrates the self-consistency method with an example. We first prompt the language model with chain-of-thought prompting, then instead of greedily decoding the optimal reasoning path, we propose a “sample-and-marginalize” decoding procedure: we first sample from the language model’s decoder to generate a diverse set of reasoning paths; each reasoning path might lead to a different final answer, so we determine the optimal answer by marginalizing out the sampled reasoning paths to find the most consistent answer in the final answer set. Such an approach is analogous to the human experience that if multiple different ways of thinking lead to the same answer, one has greater confidence that the final answer is correct. Compared to other decoding methods, self-consistency avoids the repetitiveness and local-optimality that plague greedy decoding, while mitigating the stochasticity of a single sampled generation.
18
+
19
+ ![](images/e52f9a62e8d5a9a773304db1105dd4959b748fa605157f43d522da76b851f3c2.jpg)
20
+ Figure 1: The self-consistency method contains three steps: (1) prompt a language model using chain-of-thought (CoT) prompting; (2) replace the “greedy decode” in CoT prompting by sampling from the language model’s decoder to generate a diverse set of reasoning paths; and (3) marginalize out the reasoning paths and aggregate by choosing the most consistent answer in the final answer set.
21
+
22
+ Self-consistency is far simpler than prior approaches that either train an additional verifier (Cobbe et al., 2021) or train a re-ranker given additional human annotations to improve generation quality (Thoppilan et al., 2022). Instead, self-consistency is entirely unsupervised, works off-the-shelf with pre-trained language models, requires no additional human annotation, and avoids any additional training, auxiliary models or fine-tuning. Self-consistency also differs from a typical ensemble approach where multiple models are trained and the outputs from each model are aggregated, it acts more like a “self-ensemble” that works on top of a single language model.
23
+
24
+ We evaluate self-consistency on a wide range of arithmetic and commonsense reasoning tasks over four language models with varying scales: the public UL2-20B (Tay et al., 2022) and GPT-3-175B (Brown et al., 2020), and two densely-activated decoder-only language models: LaMDA-137B (Thoppilan et al., 2022) and PaLM-540B (Chowdhery et al., 2022). On all four language models, self-consistency improves over chain-of-thought prompting by a striking margin across all tasks. In particular, when used with PaLM-540B or GPT-3, self-consistency achieves new state-of-the-art levels of performance across arithmetic reasoning tasks, including GSM8K (Cobbe et al., 2021) $( + 1 7 . 9 \%$ absolute accuracy gains), SVAMP (Patel et al., 2021) $( + 1 1 . 0 \% )$ , AQuA (Ling et al., 2017) $( + 1 2 . 2 \% )$ , and across commonsense reasoning tasks such as StrategyQA (Geva et al., 2021) $( + 6 . 4 \% )$ and ARCchallenge (Clark et al., 2018) $( + 3 . 9 \% )$ . In additional experiments, we show self-consistency can robustly boost performance on NLP tasks where adding a chain-of-thought might hurt performance compared to standard prompting (Ye & Durrett, 2022). We also show self-consistency significantly outperforms sample-and-rank, beam search, ensemble-based approaches, and is robust to sampling strategies and imperfect prompts.
25
+
26
+ # 2 SELF-CONSISTENCY OVER DIVERSE REASONING PATHS
27
+
28
+ A salient aspect of humanity is that people think differently. It is natural to suppose that in tasks requiring deliberate thinking, there are likely several ways to attack the problem. We propose that such a process can be simulated in language models via sampling from the language model’s decoder. For instance, as shown in Figure 1, a model can generate several plausible responses to a math question that all arrive at the same correct answer (Outputs 1 and 3). Since language models are not perfect reasoners, the model might also produce an incorrect reasoning path or make a mistake in one of the reasoning steps (e.g., in Output 2), but such solutions are less likely to arrive at the same answer. That is, we hypothesize that correct reasoning processes, even if they are diverse, tend to have greater agreement in their final answer than incorrect processes.
29
+
30
+ We leverage this intuition by proposing the following self-consistency method. First, a language model is prompted with a set of manually written chain-of-thought exemplars (Wei et al., 2022). Next, we sample a set of candidate outputs from the language model’s decoder, generating a diverse set of candidate reasoning paths. Self-consistency is compatible with most existing sampling algorithms, including temperature sampling (Ackley et al., 1985; Ficler & Goldberg, 2017), top- $k$ sampling (Fan et al., 2018; Holtzman et al., 2018; Radford et al., 2019), and nucleus sampling (Holtzman et al., 2020). Finally, we aggregate the answers by marginalizing out the sampled reasoning paths and choosing the answer that is the most consistent among the generated answers.
31
+
32
+ <table><tr><td></td><td>GSM8K</td><td>MultiArith</td><td>AQuA</td><td>SVAMP</td><td>CSQA</td><td>ARC-c</td></tr><tr><td>Greedy decode</td><td>56.5</td><td>94.7</td><td>35.8</td><td>79.0</td><td>79.0</td><td>85.2</td></tr><tr><td>Weighted avg (unnormalized)</td><td>56.3±0.0</td><td>90.5±0.0</td><td>35.8±0.0</td><td>73.0±0.0</td><td>74.8±0.0</td><td>82.3 ±0.0</td></tr><tr><td>Weighted avg (normalized)</td><td>22.1 ± 0.0</td><td>59.7 ± 0.0</td><td>15.7 ± 0.0</td><td>40.5± 0.0</td><td>52.1±0.0</td><td>51.7 ± 0.0</td></tr><tr><td>Weighted sum (unnormalized)</td><td>59.9 ± 0.0</td><td>92.2 ± 0.0</td><td>38.2 ± 0.0</td><td>76.2 ± 0.0</td><td>76.2 ± 0.0</td><td>83.5± 0.0</td></tr><tr><td>Weighted sum (normalized)</td><td>74.1 ± 0.0</td><td>99.3 ± 0.0</td><td>48.0± 0.0</td><td>86.8± 0.0</td><td>80.7± 0.0</td><td>88.7 ±0.0</td></tr><tr><td>Unweighted sum (majority vote)</td><td>)74.4 ±0.1</td><td>99.3 ± 0.0</td><td>48.3 ± 0.5</td><td>86.6 ± 0.1</td><td>80.7 ± 0.1</td><td>88.7 ± 0.1</td></tr></table>
33
+
34
+ Table 1: Accuracy comparison of different answer aggregation strategies on PaLM-540B.
35
+
36
+ In more detail, assume the generated answers ${ \bf a } _ { i }$ are from a fixed answer set, $\mathbf { a } _ { i } \in \mathbb { A }$ , where $i = 1 , \ldots , m$ indexes the $m$ candidate outputs sampled from the decoder. Given a prompt and a question, self-consistency introduces an additional latent variable $\mathbf { r } _ { i }$ , which is a sequence of tokens representing the reasoning path in the $i$ -th output, then couples the generation of $( \mathbf { r } _ { i } , \mathbf { a } _ { i } )$ where $\mathbf { r } _ { i } \mathbf { a } _ { i }$ , i.e., generating a reasoning path $\mathbf { r } _ { i }$ is optional and only used to reach the final answer ${ \bf a } _ { i }$ . As an example, consider Output 3 from Figure 1: the first few sentences “She eats 3 for breakfast ... So she has $9 e g g s * \mathbb { S } 2 = \mathbb { S } I \mathbb { S } .$ ” constitutes $\mathbf { r } _ { i }$ , while the answer 18 from the last sentence, “The answer is $\$ 18$ , is parsed as ${ \bf a } _ { i }$ .1 After sampling multiple $\left( \mathbf { r } _ { i } , \mathbf { a } _ { i } \right)$ from the model’s decoder, self-consistency applies a marginalization over $\mathbf { r } _ { i }$ by taking a majority vote over ${ \bf a } _ { i }$ , i.e., arg maxa $\begin{array} { r } { \sum _ { i = 1 } ^ { m } \mathbb { 1 } ( \mathbf { a } _ { i } = a ) } \end{array}$ or as we defined as the most “consistent” answer among the final answer set.
37
+
38
+ In Table 1, we show the test accuracy over a set of reasoning tasks by using different answer aggregation strategies. In addition to majority vote, one can also weight each $( \mathbf { r } _ { i } , \mathbf { a } _ { i } )$ by $P ( \mathbf { r } _ { i } , \mathbf { a } _ { i } \mid$ prompt, question) when aggregating the answers. Note to compute $P ( \mathbf { r } _ { i } , \mathbf { a } _ { i } \mid$ prompt, question), we can either take the unnormalized probability of the model generating $( \mathbf { r } _ { i } , \mathbf { a } _ { i } )$ given (prompt, question), or we can normalize the conditional probability by the output length (Brown et al., 2020), i.e.,
39
+
40
+ $$
41
+ \begin{array} { r } { P ( \mathbf { r } _ { i } , \mathbf { a } _ { i } \mid \mathrm { p r o m p t } , \mathbf { q u e s t i o n } ) = \exp ^ { \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \log P ( t _ { k } | \mathrm { p r o m p t } , \mathbf { q u e s t i o n } , t _ { 1 } , \dots , t _ { k - 1 } ) } , } \end{array}
42
+ $$
43
+
44
+ where $\log { P ( t _ { k } \ | }$ prompt, question, $t _ { 1 } , \ldots , t _ { k - 1 } )$ ) is the log probability of generating the $k$ -th token $t _ { k }$ in $\left( \mathbf { r } _ { i } , \mathbf { a } _ { i } \right)$ conditioned on the previous tokens, and $K$ is the total number of tokens in $( \mathbf { r } _ { i } , \mathbf { a } _ { i } )$ . In Table 1, we show that taking the “unweighted sum”, i.e., taking a majority vote directly over ${ \bf a } _ { i }$ yields a very similar accuracy as aggregating using the “normalized weighted sum”. We took a closer look at the model’s output probabilities and found this is because for each $( \mathbf { r } _ { i } , \mathbf { a } _ { i } )$ , the normalized conditional probabilities $P ( \mathbf { r } _ { i } , \mathbf { a } _ { i } \mid$ prompt, question) are quite close to each other, i.e., the language model regards those generations as “similarly likely”.2 Additionally, when aggregating the answers, the results in Table 1 show that the “normalized” weighted sum (i.e., Equation 1) yields a much higher accuracy compared to its unnormalized counterpart. For completeness, in Table 1 we also report the results by taking a “weighted average”, i.e., each $a$ gets a score of its weighted sum divided by $\Sigma _ { i = 1 } ^ { m } \mathbb { 1 } ( \mathbf { a } _ { i } = \bar { a } )$ , which results in a much worse performance.
45
+
46
+ Self-consistency explores an interesting space between open-ended text generation and optimal text generation with a fixed answer. Reasoning tasks typically have fixed answers, which is why researchers have generally considered greedy decoding approaches (Radford et al., 2019; Wei et al., 2022; Chowdhery et al., 2022). However, we have found that even when the desired answer is fixed, introducing diversity in the reasoning processes can be highly beneficial; therefore we leverage sampling, as commonly used for open-ended text generation (Radford et al., 2019; Brown et al., 2020; Thoppilan et al., 2022), to achieve this goal. One should note that self-consistency can be applied only to problems where the final answer is from a fixed answer set, but in principle this approach can be extended to open-text generation problems if a good metric of consistency can be defined between multiple generations, e.g., whether two answers agree or contradict each other.
47
+
48
+ # 3 EXPERIMENTS
49
+
50
+ We conducted a series of experiments to compare the proposed self-consistency method with existing approaches on a range of reasoning benchmarks. We find that self-consistency robustly improves reasoning accuracy for every language model considered, spanning a wide range of model scales.
51
+
52
+ # 3.1 EXPERIMENT SETUP
53
+
54
+ Tasks and datasets. We evaluate self-consistency on the following reasoning benchmarks.3 • Arithmetic reasoning. For these tasks, we used the Math Word Problem Repository (KoncelKedziorski et al., 2016), including AddSub (Hosseini et al., 2014), MultiArith (Roy & Roth, 2015), and ASDiv (Miao et al., 2020). We also included AQUA-RAT (Ling et al., 2017), a recently published benchmark of grade-school-math problems (GSM8K; Cobbe et al., 2021), and a challenge dataset over math word problems (SVAMP; Patel et al., 2021). • Commonsense reasoning. For these tasks, we used CommonsenseQA (Talmor et al., 2019), StrategyQA (Geva et al., 2021), and the AI2 Reasoning Challenge (ARC) (Clark et al., 2018). • Symbolic Reasoning. We evaluate two symbolic reasoning tasks: last letter concatenation (e.g., the input is “Elon Musk” and the output should be “nk”), and Coinflip (e.g., a coin is heads-up, after a few flips is the coin still heads-up?) from Wei et al. (2022).
55
+
56
+ Language models and prompts. We evaluate self-consistency over four transformer-based language models with varying scales:
57
+
58
+ • UL2 (Tay et al., 2022) is an encoder-decoder model trained on a mixture of denoisers with 20- billion parameters. UL2 is completely open-sourced4 and has similar or better performance than GPT-3 on zero-shot SuperGLUE, with only 20B parameters and thus is more compute-friendly; • GPT-3 (Brown et al., 2020) with 175-billion parameters. We use two public engines code-davinci001 and code-davinci-002 from the Codex series (Chen et al., 2021) to aid reproducibility;5 • LaMDA-137B (Thoppilan et al., 2022) is a dense left-to-right, decoder-only language model with 137-billion parameters, pre-trained on a mixture of web documents, dialog data and Wikipedia; • PaLM-540B (Chowdhery et al., 2022) is a dense left-to-right, decoder-only language model with 540-billion parameters, pre-trained on a high quality corpus of 780 billion tokens with filtered webpages, books, Wikipedia, news articles, source code, and social media conversations.
59
+
60
+ We perform all experiments in the few-shot setting, without training or fine-tuning the language models. For a fair comparison we use the same prompts as in Wei et al. (2022): for all arithmetic reasoning tasks we use the same set of 8 manually written exemplars; for each commonsense reasoning task, 4-7 exemplars are randomly chosen from the training set with manually composed chain-of-thought prompts.6 Full details on the prompts used are given in Appendix A.3.
61
+
62
+ Sampling scheme. To sample diverse reasoning paths, we followed similar settings to those suggested in Radford et al. (2019); Holtzman et al. (2020) for open-text generation. In particular, for UL2-20B and LaMDA-137B we applied temperature sampling with $T = 0 . 5$ and truncated at the top- $k$ $k = 4 0$ ) tokens with the highest probability, for PaLM-540B we applied $T = 0 . 7 , k = 4 0$ , and for GPT-3 we use $T = 0 . 7$ without top- $k$ truncation. We provide an ablation study in Section 3.5 to show that self-consistency is generally robust to sampling strategies and parameters.
63
+
64
+ # 3.2 MAIN RESULTS
65
+
66
+ We report the results of self-consistency averaged over 10 runs, where we sampled 40 outputs independently from the decoder in each run. The baseline we compare to is chain-of-thought prompting with greedy decoding (Wei et al., 2022), referred to as CoT-prompting, which has been previously used for decoding in large language models (Chowdhery et al., 2022).
67
+
68
+ Arithmetic Reasoning The results are shown in Table 2.7 Self-consistency improves the arithmetic reasoning performance over all four language models significantly over chain-of-thought prompting. More surprisingly, the gains become more significant when the language model’s scale increases, e.g., we see $+ 3 \% { - } 6 \%$ absolute accuracy improvement over UL2-20B but $+ 9 \% - 2 3 \%$ for LaMDA137B and GPT-3. For larger models that already achieve high accuracy on most tasks (e.g., GPT-3 and PaLM-540B), self-consistency still contributes significant additional gains with $+ 1 2 \% - 1 8 \%$ absolute accuracy on tasks like AQuA and GSM8K, and $+ 7 \% - 1 1 \%$ on SVAMP and ASDiv. With self-consistency, we achieve new state-of-the-art results on almost all tasks: despite the fact that selfconsistency is unsupervised and task-agnostic, these results compare favorably to existing approaches that require task-specific training, or fine-tuning with thousands of examples (e.g., on GSM8K).
69
+
70
+ Table 2: Arithmetic reasoning accuracy by self-consistency compared to chain-of-thought prompting (Wei et al., 2022). The previous SoTA baselines are obtained from: a: Relevance and LCA operation classifier (Roy & Roth, 2015), b: Lan et al. (2021), c: Amini et al. (2019), d: Pi et al. (2022), e: GPT-3 175B finetuned with $7 . 5 \mathrm { k }$ examples (Cobbe et al., 2021), $g$ : GPT-3 175B finetuned plus an additional 175B verifier (Cobbe et al., 2021). The best performance for each task is shown in bold.
71
+
72
+ <table><tr><td></td><td>Method</td><td>AddSub</td><td>MultiArith</td><td>ASDiv</td><td>AQuA</td><td>SVAMP</td><td>GSM8K</td></tr><tr><td></td><td>Previous SoTA</td><td>94.9a</td><td>60.5a</td><td>75.36</td><td>37.9c</td><td>57.4d</td><td>35e / 55g</td></tr><tr><td>UL2-20B</td><td>CoT-prompting Self-consistency</td><td>18.2 24.8 (+6.6)</td><td>10.7 15.0 (+4.3)</td><td>16.9 21.5 (+4.6)</td><td>23.6 26.9 (+3.3)</td><td>12.6 19.4 (+6.8)</td><td>4.1 7.3 (+3.2)</td></tr><tr><td>LaMDA-137B</td><td>CoT-prompting Self-consistency</td><td>52.9 63.5 (+10.6)</td><td>51.8 75.7 (+23.9)</td><td>49.0 58.2 (+9.2)</td><td>17.7 26.8 (+9.1)</td><td>38.9 53.3 (+14.4)</td><td>17.1 27.7 (+10.6)</td></tr><tr><td>PaLM-540B</td><td>CoT-prompting Self-consistency</td><td>91.9 93.7 (+1.8)</td><td>94.7 99.3 (+4.6)</td><td>74.0 81.9 (+7.9)</td><td>35.8 48.3 (+12.5)</td><td>79.0 86.6 (+7.6)</td><td>56.5 74.4 (+17.9)</td></tr><tr><td>GPT-3 Code-davinci-001</td><td>CoT-prompting Self-consistency</td><td>57.2 67.8 (+10.6)</td><td>59.5 82.7 (+23.2)</td><td>52.7 61.9 (+9.2)</td><td>18.9 25.6 (+6.7)</td><td>39.8 54.5 (+14.7)</td><td>14.6 23.4 (+8.8)</td></tr><tr><td>GPT-3 Code-davinci-002</td><td>CoT-prompting Self-consistency</td><td>89.4 91.6 (+2.2)</td><td>96.2 100.0 (+3.8)</td><td>80.1 87.8 (+7.6)</td><td>39.8 52.0 (+12.2)</td><td>75.8 86.8 (+11.0)</td><td>60.1 78.0 (+17.9)</td></tr></table>
73
+
74
+ <table><tr><td></td><td>Method</td><td>CSQA</td><td>StrategyQA</td><td>ARC-e</td><td>ARC-c</td><td>Letter (4)</td><td>Coinflip (4)</td></tr><tr><td></td><td>Previous SoTA</td><td>91.2a</td><td>73.96</td><td>86.4℃</td><td>75.0℃</td><td>N/A</td><td>N/A</td></tr><tr><td>UL2-20B</td><td>CoT-prompting Self-consistency</td><td>51.4 55.7 (+4.3)</td><td>53.3 54.9 (+1.6)</td><td>61.6 69.8 (+8.2)</td><td>42.9 49.5 (+6.8)</td><td>0.0 0.0 (+0.0)</td><td>50.4 50.5 (+0.1)</td></tr><tr><td>LaMDA-137B</td><td>CoT-prompting Self-consistency</td><td>57.9 63.1 (+5.2)</td><td>65.4 67.8 (+2.4)</td><td>75.3 79.3 (+4.0)</td><td>55.1 59.8 (+4.7)</td><td>8.2 8.2 (+0.0)</td><td>72.4 73.5 (+1.1)</td></tr><tr><td>PaLM-540B</td><td>CoT-prompting Self-consistency</td><td>79.0 80.7 (+1.7)</td><td>75.3 81.6 (+6.3)</td><td>95.3 96.4 (+1.1)</td><td>85.2 88.7 (+3.5)</td><td>65.8 70.8 (+5.0)</td><td>88.2 91.2 (+3.0)</td></tr><tr><td>GPT-3 Code-davinci-001</td><td>CoT-prompting Self-consistency</td><td>46.6 54.9 (+8.3)</td><td>56.7 61.7 (+5.0)</td><td>63.1 72.1 (+9.0)</td><td>43.1</td><td>7.8 10.0 (+2.2)</td><td>71.4 75.9 (+4.5)</td></tr><tr><td>GPT-3</td><td>CoT-prompting</td><td>79.0</td><td>73.4</td><td>94.0</td><td>53.7 (+10.6) 83.6</td><td>70.4</td><td>99.0</td></tr></table>
75
+
76
+ Table 3: Commonsense and symbolic reasoning accuracy by self-consistency compared to chainof-thought prompting (Wei et al., 2022). The previous SoTA baselines are obtained from: $a$ : DeBERTaV3-large $^ +$ KEAR ( $\mathrm { { X u } }$ et al., 2021b), $b$ : Chowdhery et al. (2022), c: UnifiedQA-FT (Khashabi et al., 2020). The best performance for each task is shown in bold.
77
+
78
+ Commonsense and Symbolic Reasoning Table 3 shows the results on commonsense and symbolic reasoning tasks. Similarly, self-consistency yields large gains across all four language models, and obtained SoTA results on 5 out of 6 tasks. For symbolic reasoning, we test the out-of-distribution (OOD) setting where the input prompt contains examples of 2-letters or 2-flips but we test examples of 4-letters and 4-flips (this setting is more challenging as PaLM-540B or GPT-3 can already achieve perfect in-distribution accuracy). In this challenging OOD setting, the gain of self-consistency is still quite significant compared to CoT-prompting with sufficient model sizes.
79
+
80
+ To show the effect of the number of sampled reasoning paths, we plot the accuracy (mean and standard deviation over 10 runs) with respect to varying numbers of sampled paths (1, 5, 10, 20, 40) in Figure 2. The results show that sampling a higher number (e.g., 40) of reasoning paths leads to a consistently better performance, further emphasizing the importance of introducing diversity in the reasoning paths. In Table 4, we show self-consistency yields a richer set of reasoning paths compared to greedy decoding with a few example questions from two tasks.
81
+
82
+ ![](images/91c0b57fce63bbd74bd5c37ac54affcd3ffead95ee070efede9bc60786bb0af7.jpg)
83
+ Figure 2: Self-consistency (blue) significantly improves accuracy over CoT-prompting with greedy decoding (orange) across arithmetic and commonsense reasoning tasks, over LaMDA-137B. Sampling a higher number of diverse reasoning paths consistently improves reasoning accuracy.
84
+
85
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>GSM8K StrategyQA</td></tr><tr><td rowspan=1 colspan=1>Question</td><td rowspan=1 colspan=1>Henry made two stops during his 6O-mile bike trip.Hefirst stopped after 20miles.His second stop was15 milesbefore the end of the trip.How many milesdid he travel between his first and second stops?</td><td rowspan=1 colspan=1>Yes or no:IsAlbany,Georgia the most populousUSAlbany?</td></tr><tr><td rowspan=1 colspan=1>GreedyDecode</td><td rowspan=1 colspan=1>He traveled 6O miles in total.He stopped after 20 miles,so he traveled 60 -20= 40 miles between the first and second stops. The answer is 40.</td><td rowspan=1 colspan=1>Albany, Georgia is the most populous US Al-bany. Thus,the answer is yes.</td></tr><tr><td rowspan=1 colspan=1>SampledPath 1</td><td rowspan=1 colspan=1>Henry travelled a total of 6O miles.His first stop was 2O miles in,and hissecond stop was 15 miles before the end. So between his first and second stopshe travelled 60 -20-15=25 miles. The answer is 25.</td><td rowspan=1 colspan=1>The most populous US Albany is Albany, NewYork.Thus,Albany,Georgia is not the mostpopulous US Albany. So the answer is no.</td></tr><tr><td rowspan=1 colspan=1>SampledPath 2</td><td rowspan=1 colspan=1>He made two stops during a 6O-mile trip. The first was 2O miles into the trip.The second was 15 miles before the end of the trip. This means the second stopWas 60 -15=45 miles into the trip. Since he made the stops in order,the second stop must have been 45 -20 = 25 miles after the first stop.The answer is 25.</td><td rowspan=1 colspan=1>Albany,Georgia has a population of about 88,000. Albany, New York has a population ofabout 95,Ooo. Thus,Albany, Georgia is not themost populous US Albany. So the answer is no.</td></tr></table>
86
+
87
+ Table 4: Examples where self-consistency helps repair the errors over greedy decode, on PaLM-540B. Two sampled reasoning paths that are consistent with the ground truth are shown.
88
+
89
+ # 3.3 SELF-CONSISTENCY HELPS WHEN CHAIN-OF-THOUGHT HURTS PERFORMANCE
90
+
91
+ Ye & Durrett (2022) show that sometimes chain-of-thought prompting could hurt performance compared to standard prompting in few-shot in-context learning. Here we perform a study using self-consistency to see if it can help fill in the gap, over a set of common NLP tasks, including (1) Closed-Book Question Answering: BoolQ (Clark et al., 2019), HotpotQA (Yang et al., 2018), and (2) Natural Language Inference: e-SNLI (Camburu et al., 2018), ANLI (Nie et al., 2020) and RTE (Dagan et al., 2005; Bar-Haim et al., 2006; Giampiccolo et al., 2007; Bentivogli et al., 2009).
92
+
93
+ The results over PaLM-540B are shown in Table 5. For some tasks (e.g., ANLI-R1, e-SNLI, RTE), adding chain-of-thought does hurt performance compared to standard prompting (Brown et al., 2020), but self-consistency is able to robustly boost the performance and outperform standard prompting, making it a reliable way to add rationales in few-shot in-context learning for common NLP tasks.
94
+
95
+ <table><tr><td></td><td>ANLIR1/R2/R3</td><td>e-SNLI</td><td>RTE</td><td>BoolQ</td><td>HotpotQA (EM/F1)</td></tr><tr><td>Standard-prompting (no-rationale)</td><td>69.1 / 55.8 / 55.8</td><td>85.8</td><td>84.8</td><td>71.3</td><td>27.1/36.8</td></tr><tr><td>CoT-prompting (Wei et al.,2022)</td><td>68.8 / 58.9 / 60.6</td><td>81.0</td><td>79.1</td><td>74.2</td><td>28.9/39.8</td></tr><tr><td>Self-consistency</td><td>78.5 / 64.5 / 63.4</td><td>88.4</td><td>86.3</td><td>78.4</td><td>33.8 / 44.6</td></tr></table>
96
+
97
+ Table 5: Compare Standard/CoT prompting with self-consistency on common NLP tasks.
98
+
99
+ # 3.4 COMPARE TO OTHER EXISTING APPROACHES
100
+
101
+ We conduct a set of additional studies and show that self-consistency significantly outperforms existing methods including sample-and-rank, beam search, and ensemble-based approaches.
102
+
103
+ Comparison to Sample-and-Rank One commonly used approach to improve generation quality is sample-and-rank, where multiple sequences are sampled from the decoder and then ranked according to each sequence’s log probability (Adiwardana et al., 2020). We compare self-consistency with sample-and-rank on GPT-3 code-davinci-001, by sampling the same number of sequences from the decoder as self-consistency and taking the final answer from the top-ranked sequence. The results are shown in Figure 3. While sample-and-rank does improve the accuracy with additionally sampled sequences and ranking, the gain is much smaller compared to self-consistency.
104
+
105
+ ![](images/211c58f5fc739ddbb34ca25bc8a91e11996e73243a0ad766cce0146bc55d347b.jpg)
106
+ Figure 3: Self-consistency significantly outperforms sample-and-rank with the same # of samples.
107
+
108
+ Comparison to Beam Search In Table 6, we compare self-consistency with beam search decoding on the UL2-20B model. For a fair comparison we report the accuracy under the same number of beams and reasoning paths. On both tasks self-consistency outperforms beam search significantly. Note self-consistency can also adopt beam search to decode each reasoning path (results are shown as “Self-consistency using beam search”), but its performance is worse compared to self-consistency with sampling. The reason is that beam search yields a lower diversity in the outputs (Li & Jurafsky, 2016), while in self-consistency the diversity of the reasoning paths is the key to a better performance.
109
+
110
+ <table><tr><td></td><td>Beam size / Self-consistency paths</td><td>1</td><td>5</td><td>10</td><td>20</td><td>40</td></tr><tr><td rowspan="2">AQuA</td><td>Beam search decoding (top beam)</td><td>23.6 23.6</td><td>19.3 19.8 ± 0.3</td><td>16.1</td><td>15.0</td><td>10.2</td></tr><tr><td>Self-consistency using beam search Self-consistency using sampling</td><td>19.7 ± 2.5</td><td>24.9 ± 2.6</td><td>21.2 ±0.7 25.3 ± 1.8</td><td>24.6 ± 0.4 26.7 ± 1.0</td><td>24.2 ±0.5 26.9 ± 0.5</td></tr><tr><td rowspan="2">MultiArith</td><td></td><td>10.7</td><td>12.0</td><td>11.3</td><td></td><td></td></tr><tr><td>Beam search decoding (top beam)</td><td></td><td></td><td></td><td>11.0</td><td>10.5</td></tr><tr><td rowspan="2"></td><td>Self-consistency using beam search</td><td>10.7</td><td>11.8 ± 0.0</td><td>11.4 ± 0.1</td><td>12.3 ± 0.1</td><td>10.8 ±0.1</td></tr><tr><td>Self-consistency using sampling</td><td>9.5 ± 1.2</td><td>11.3 ± 1.2</td><td>12.3 ± 0.8</td><td>13.7 ± 0.9</td><td>14.7 ± 0.3</td></tr></table>
111
+
112
+ Table 6: Compare self-consistency with beam search decoding on the UL2-20B model.
113
+
114
+ Comparison to Ensemble-based Approaches We further compare self-consistency to ensemblebased methods for few-shot learning. In particular, we consider ensembling by: (1) prompt order permutation: we randomly permute the exemplars in the prompt 40 times to mitigate model’s sensitivity to prompt order (Zhao et al., 2021; Lu et al., 2021); and (2) multiple sets of prompts (Gao et al., 2021): we manually write 3 different sets of prompts. We took majority vote of the answers from greedy decoding in both approaches as an ensemble. Table 7 shows that compared to self-consistency, existing ensemble-based approaches achieve a much smaller gain.8 In addition, note that self-consistency is different from a typical model-ensemble approach, where multiple models are trained and their outputs are aggregated. Self-consistency acts more like a “self-ensemble” on top of a single language model. We additionally show the results of ensembling multiple models in Appendix A.1.3 where the model-ensembles perform much worse compared to self-consistency.
115
+
116
+ <table><tr><td></td><td>GSM8K</td><td>MultiArith</td><td>SVAMP</td><td>ARC-e</td><td>ARC-c</td></tr><tr><td>CoT (Wei et al., 2022)</td><td>17.1</td><td>51.8</td><td>38.9</td><td>75.3</td><td>55.1</td></tr><tr><td>Ensemble (3 sets of prompts)</td><td>18.6 ± 0.5</td><td>57.1 ± 0.7</td><td>42.1 ± 0.6</td><td>76.6 ± 0.1</td><td>57.0± 0.2</td></tr><tr><td>Ensemble (40 prompt permutations)</td><td>19.2 ± 0.1</td><td>60.9 ± 0.2</td><td>42.7 ± 0.1</td><td>76.9 ± 0.1</td><td>57.0 ±0.1</td></tr><tr><td>Self-Consistency (4O sampled paths)</td><td>27.7 ± 0.2</td><td>75.7 ± 0.3</td><td>53.3 ± 0.2</td><td>79.3 ± 0.3</td><td>59.8 ± 0.2</td></tr></table>
117
+
118
+ Table 7: Self-consistency outperforms prompt-order and multi-prompt ensembles on LaMDA-137B.
119
+
120
+ 8Self-consistency is compatible with both ensemble approaches and we show the results in Appendix A.1.4.
121
+
122
+ # 3.5 ADDITIONAL STUDIES
123
+
124
+ We conducted a number of additional experiments to analyze different aspects of the self-consistency method, including its robustness to sampling strategies and parameters, and how it works with imperfect prompts and non-natural-language reasoning paths.
125
+
126
+ Self-Consistency is Robust to Sampling Strategies and Scaling We show self-consistency is robust to sampling strategies and parameters, by varying $T$ in temperature sampling (Ackley et al., 1985; Ficler & Goldberg, 2017), $k$ in top- $k$ sampling (Fan et al., 2018; Holtzman et al., 2018; Radford et al., 2019), and $p$ in nucleus sampling (Holtzman et al., 2020), over PaLM-540B in Figure 4 (left). Figure 4 (right) shows that self-consistency robustly improves performance across all scales for the LaMDA-137B model series. The gain is relatively lower for smaller models due to certain abilities (e.g., arithmetic) only emerge when the model reaches a sufficient scale (Brown et al., 2020).
127
+
128
+ ![](images/87a328209d36c386b2c5751a4a40e895999983a1e5c87663caac19ecc466a090.jpg)
129
+ Figure 4: GSM8K accuracy. (Left) Self-consistency is robust to various sampling strategies and parameters. (Right) Self-consistency improves performance across language model scales.
130
+
131
+ Self-Consistency Improves Robustness to Imperfect Prompts For few-shot learning with manually constructed prompts, human annotators sometimes make minor mistakes when creating the prompts. We further study if self-consistency can help improve a language model’s robustness to imperfect prompts.9 We show the results in Table 8: while imperfect prompts decrease accuracy with greedy decoding $1 7 . 1 1 4 . 9$ ), self-consistency can fill in the gaps and robustly improve the results.
132
+
133
+ Additionally, we found that the consistency (in terms of $\%$ of decodes agreeing with the final aggregated answer) is highly correlated with accuracy (Figure 5, over GSM8K). This suggests that one can use self-consistency to provide an uncertainty estimate of the model in its generated solutions. In other words, one can use low consistency as an indicator that the model has low confidence; i.e., self-consistency confers some ability for the model to “know when it doesn’t know”.
134
+
135
+ <table><tr><td rowspan="3">LaMDA-137B</td><td>Prompt with correct chain-of-thought</td><td>17.1</td></tr><tr><td>Prompt with imperfect chain-of-thought + Self-consistency (40 paths)</td><td>14.9 23.4</td></tr><tr><td>Prompt with equations + Self-consistency (40 paths)</td><td>5.0 6.5</td></tr><tr><td rowspan="2">PaLM-540B</td><td>Zero-shot CoT (Kojima et al., 2022)</td><td>43.0</td></tr><tr><td>+ Self-consistency (40 paths)</td><td>69.2</td></tr></table>
136
+
137
+ Table 8: Self-consistency works under imperfect prompts, equation prompts and zero-shot chain-of-thought for GSM8K.
138
+
139
+ ![](images/904d0744036049f41de9ff1b79bfb3e5c595bb15c1aa6fad815946070f5097c4.jpg)
140
+ Figure 5: The consistency is correlated with model’s accuracy.
141
+
142
+ Self-Consistency Works for Non-Natural-Language Reasoning Paths and Zero-shot CoT We also tested the generality of the self-consistency concept to alternative forms of intermediate reasoning like equations (e.g., from “There are 3 cars in the parking lot already. 2 more arrive. Now there are $3 + 2 = 5$ cars.” to $" 3 + 2 = 5 "$ ). The results are shown in Table 8 (“Prompt with equations”): self-consistency still improves accuracy by generating intermediate equations; however, compared to generating natural language reasoning paths, the gain is smaller since the equations are much shorter and less opportunity remains for generating diversity in the decoding process. In addition, we tested self-consistency with zero-shot chain-of-thought (Kojima et al., 2022) and show that self-consistency works for zero-shot CoT as well and improves the results significantly $( + 2 6 . 2 \% )$ in Table 8.
143
+
144
+ # 4 RELATED WORK
145
+
146
+ Reasoning in language models. Language models are known to struggle in Type 2 tasks, such as arithmetic, logical and commonsense reasoning (Evans, 2010). Previous work has primarily focused on specialized approaches for improving reasoning (Andor et al., 2019; Ran et al., 2019; Geva et al., 2020; Pi˛ekos et al., 2021). Compared to prior work, self-consistency is applicable to a wide range of reasoning tasks without any additional supervision or fine-tuning, while still substantially improving the performance of the chain-of-thought prompting approach proposed in Wei et al. (2022).
147
+
148
+ Sampling and re-ranking in language models. Multiple decoding strategies for language models have been proposed in the literature, e.g., temperature sampling (Ackley et al., 1985; Ficler & Goldberg, 2017), top- $k$ sampling (Fan et al., 2018; Holtzman et al., 2018; Radford et al., 2019), nucleus sampling (Holtzman et al., 2020), minimum Bayes risk decoding (Eikema & Aziz, 2020; Shi et al., 2022), and typical decoding (Meister et al., 2022). Other work has sought to explicitly promote diversity in the decoding process (Batra et al., 2012; Li et al., 2016; Vijayakumar et al., 2018).
149
+
150
+ Re-ranking is another common approach to improve generation quality in language models (Adiwardana et al., 2020; Shen et al., 2021). Thoppilan et al. (2022) collect additional human annotations to train a re-ranker for response filtering. Cobbe et al. (2021) train a “verifier” to re-rank generated solutions, which substantially improves the solve rate on math tasks compared to just fine-tuning the language model. Elazar et al. (2021) improve the consistency of factual knowledge extraction by extending pre-training with an additional consistency loss. All these methods require either training an additional re-ranker or collecting additional human annotation, while self-consistency requires no additional training, fine-tuning, nor extra data collection.
151
+
152
+ Extract reasoning paths. Some previous work has considered task-specific approaches for identifying reasoning paths, such as constructing semantic graphs (Xu et al., 2021a), learning an RNN to retrieve reasoning paths over the Wikipedia graph (Asai et al., 2020), fine-tuning with human annotated reasoning paths on math problems (Cobbe et al., 2021), or training an extractor with heuristic-based pseudo reasoning paths (Chen et al., 2019). More recently, the importance of diversity in the reasoning processes has been noticed, but only leveraged via task-specific training, either through an additional QA model over extracted reasoning paths (Chen et al., 2019), or by the introduction of latent variables in a commonsense knowledge graph (Yu et al., 2022). Compared to these approaches, self-consistency is far simpler and requires no additional training. The approach we propose simply couples the generation of reasoning paths and a final answer by sampling from the decoder, using aggregation to recover the most consistent answer without additional modules.
153
+
154
+ Consistency in language models. Some prior work has shown that language models can suffer from inconsistency in conversation (Adiwardana et al., 2020), explanation generation (Camburu et al., 2020), and factual knowledge extraction (Elazar et al., 2021). Welleck et al. (2020) use “consistency” to refer to generating an infinite-length sequence in recurrent language models. Nye et al. (2021) improve the logical consistency of samples from a System 1 model by adding a System 2-inspired logical reasoning module. In this paper we focus on a slightly different notion of “consistency”, i.e., utilizing answer consistency among diverse reasoning paths to improve accuracy.
155
+
156
+ # 5 CONCLUSION AND DISCUSSION
157
+
158
+ We introduced a simple yet effective method called self-consistency, and observed that it significantly improves accuracy in a range of arithmetic and commonsense reasoning tasks, across four large language models with varying scales. Beyond accuracy gains, self-consistency is also useful for collecting rationales when performing reasoning tasks with language models, and for providing uncertainty estimates and improved calibration of language model outputs.
159
+
160
+ One limitation of self-consistency is that it incurs more computation cost. In practice people can try a small number of paths (e.g., 5 or 10) as a starting point to realize most of the gains while not incurring too much cost, as in most cases the performance saturates quickly (Figure 2). As part of future work, one could use self-consistency to generate better supervised data to fine-tune the model, such that the model can give more accurate predictions in a single inference run after fine-tuning. In addition, we observed that language models can sometimes generate incorrect or nonsensical reasoning paths (e.g., the StrategyQA example in Table 4, the two population numbers are not exactly correct), and further work is needed to better ground models’ rationale generations.
161
+
162
+ # REPRODUCIBILITY STATEMENT
163
+
164
+ In experiments, we included four different language models with varying scales. Two of them are public models: UL2 is a completely open-sourced model with model checkpoints available at https:// github.com/google-research/google-research/tree/master/ul2; GPT-3 is also a public model with public API available at https://openai.com/api/. For GPT-3, we have included two public engines (“code-davinci-001” and “code-davinci-002”) to further aid reproducibility, as Codex is currently free so anyone can reproduce the results. In addition, as our results make use of LaMDA-137B and PaLM-540B that are not publicly available, we provide the exact input prompts for all tasks in Appendix A.3 (and note that we do not perform any finetuning and only apply prompting to off-the-shelf language models).
165
+
166
+ # ETHICS STATEMENT
167
+
168
+ As we stated in the discussion, language models can sometimes generate nonsensical or non-factual reasoning paths, so one should use language models’ outputs with extra caution. We deal with reasoning tasks mostly and the generated rationales are only used for inspecting how a model reaches its answer. One could potentially use the generated rationales to further check why the model makes certain mistakes or whether the model contains any biases when performing a certain task. For language model in real-world use, further work is needed to better ground models’ predictions and improve model’s factuality and safety, to ensure the models do not cause harms to users.
169
+
170
+ # REFERENCES
171
+
172
+ David H. Ackley, Geoffrey E. Hinton, and Terrence J. Sejnowski. A learning algorithm for boltzmann machines. Cognitive Science, 9(1):147–169, 1985. ISSN 0364-0213. URL https://www. sciencedirect.com/science/article/pii/S0364021385800124.
173
+
174
+ Daniel Adiwardana, Minh-Thang Luong, David R. So, Jamie Hall, Noah Fiedel, Romal Thoppilan, Zi Yang, Apoorv Kulshreshtha, Gaurav Nemade, Yifeng Lu, and Quoc V. Le. Towards a human-like open-domain chatbot, 2020.
175
+
176
+ Aida Amini, Saadia Gabriel, Shanchuan Lin, Rik Koncel-Kedziorski, Yejin Choi, and Hannaneh Hajishirzi. MathQA: Towards interpretable math word problem solving with operation-based formalisms. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 2357–2367. Association for Computational Linguistics, June 2019. URL https://aclanthology.org/N19-1245.
177
+
178
+ Daniel Andor, Luheng He, Kenton Lee, and Emily Pitler. Giving BERT a calculator: Finding operations and arguments with reading comprehension. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), 2019. URL https://aclanthology. org/D19-1609.
179
+
180
+ Akari Asai, Kazuma Hashimoto, Hannaneh Hajishirzi, Richard Socher, and Caiming Xiong. Learning to retrieve reasoning paths over wikipedia graph for question answering. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum? id $=$ SJgVHkrYDH.
181
+
182
+ Roy Bar-Haim, Ido Dagan, Bill Dolan, Lisa Ferro, Danilo Giampiccolo, Bernardo Magnini, and Idan Szpektor. The second pascal recognising textual entailment challenge. In Proceedings of the second PASCAL challenges workshop on recognising textual entailment, 2006.
183
+
184
+ Dhruv Batra, Payman Yadollahpour, Abner Guzman-Rivera, and Gregory Shakhnarovich. Diverse m-best solutions in markov random fields. In Proceedings of the 12th European Conference on Computer Vision - Volume Part V, ECCV’12, pp. 1–16, Berlin, Heidelberg, 2012. Springer-Verlag. ISBN 9783642337147. URL https://doi.org/10.1007/978-3-642-33715-4_1.
185
+
186
+ Luisa Bentivogli, Peter Clark, Ido Dagan, and Danilo Giampiccolo. The fifth pascal recognizing textual entailment challenge. In TAC, 2009.
187
+
188
+ BIG-bench collaboration. Beyond the imitation game: Measuring and extrapolating the capabilities of language models. In preparation, 2021. URL https://github.com/google/ BIG-bench/.
189
+
190
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In Advances in Neural Information Processing Systems, 2020. URL https://proceedings.neurips.cc/paper/2020/ file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
191
+
192
+ Oana-Maria Camburu, Tim Rocktäschel, Thomas Lukasiewicz, and Phil Blunsom. esnli: Natural language inference with natural language explanations. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett (eds.), Advances in Neural Information Processing Systems 31, pp. 9539–9549. Curran Associates, Inc., 2018. URL http://papers.nips.cc/paper/ 8163-e-snli-natural-language-inference-with-natural-language-explanations. pdf.
193
+
194
+ Oana-Maria Camburu, Brendan Shillingford, Pasquale Minervini, Thomas Lukasiewicz, and Phil Blunsom. Make up your mind! adversarial generation of inconsistent natural language explanations. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 4157–4165, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020. acl-main.382. URL https://aclanthology.org/2020.acl-main.382.
195
+
196
+ Jifan Chen, Shih-Ting Lin, and Greg Durrett. Multi-hop question answering via reasoning chains. CoRR, abs/1910.02610, 2019. URL http://arxiv.org/abs/1910.02610.
197
+
198
+ Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
199
+
200
+ Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. Palm: Scaling language modeling with pathways, 2022. URL https://arxiv.org/abs/2204.02311.
201
+
202
+ Christopher Clark, Kenton Lee, Ming-Wei Chang, Tom Kwiatkowski, Michael Collins, and Kristina Toutanova. Boolq: Exploring the surprising difficulty of natural yes/no questions. In NAACL, 2019.
203
+
204
+ Peter Clark, Isaac Cowhey, Oren Etzioni, Tushar Khot, Ashish Sabharwal, Carissa Schoenick, and Oyvind Tafjord. Think you have solved question answering? try arc, the ai2 reasoning challenge. ArXiv, abs/1803.05457, 2018.
205
+
206
+ Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems, 2021.
207
+
208
+ Ido Dagan, Oren Glickman, and Bernardo Magnini. The pascal recognising textual entailment challenge. In Machine Learning Challenges Workshop, pp. 177–190. Springer, 2005.
209
+
210
+ Bryan Eikema and Wilker Aziz. Is MAP decoding all you need? the inadequacy of the mode in neural machine translation. In Proceedings of the 28th International Conference on Computational Linguistics, pp. 4506–4520, Barcelona, Spain (Online), December 2020. International Committee on Computational Linguistics. URL https://aclanthology.org/2020.coling-main. 398.
211
+
212
+ Yanai Elazar, Nora Kassner, Shauli Ravfogel, Abhilasha Ravichander, Eduard Hovy, Hinrich Schütze, and Yoav Goldberg. Measuring and improving consistency in pretrained language models. Transactions of the Association for Computational Linguistics, 9:1012–1031, 2021. doi: 10.1162/tacl_a_00410. URL https://aclanthology.org/2021.tacl-1.60.
213
+
214
+ Jonathan St BT Evans. Intuition and reasoning: A dual-process perspective. Psychological Inquiry, 21(4):313–326, 2010.
215
+
216
+ Angela Fan, Mike Lewis, and Yann Dauphin. Hierarchical neural story generation. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 889–898, Melbourne, Australia, July 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-1082. URL https://aclanthology.org/P18-1082.
217
+
218
+ Jessica Ficler and Yoav Goldberg. Controlling linguistic style aspects in neural language generation. In Proceedings of the Workshop on Stylistic Variation, pp. 94–104, Copenhagen, Denmark, September 2017. Association for Computational Linguistics. doi: 10.18653/v1/W17-4912. URL https: //aclanthology.org/W17-4912.
219
+
220
+ Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. 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. 3816–3830, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.295. URL https://aclanthology.org/2021.acl-long. 295.
221
+
222
+ Mor Geva, Ankit Gupta, and Jonathan Berant. Injecting numerical reasoning skills into language models. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, 2020. doi: 10.18653/v1/2020.acl-main.89. URL https://aclanthology.org/2020. acl-main.89.
223
+
224
+ Mor Geva, Daniel Khashabi, Elad Segal, Tushar Khot, Dan Roth, and Jonathan Berant. Did aristotle use a laptop? A question answering benchmark with implicit reasoning strategies. Transactions of the Association for Computational Linguistics, 2021. URL https://aclanthology.org/ 2021.tacl-1.21.
225
+
226
+ Danilo Giampiccolo, Bernardo Magnini, Ido Dagan, and Bill Dolan. The third pascal recognizing textual entailment challenge. In Proceedings of the ACL-PASCAL workshop on textual entailment and paraphrasing, pp. 1–9. Association for Computational Linguistics, 2007.
227
+
228
+ Ari Holtzman, Jan Buys, Maxwell Forbes, Antoine Bosselut, David Golub, and Yejin Choi. Learning to write with cooperative discriminators. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1638–1649, Melbourne, Australia, July 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-1152. URL https://aclanthology.org/P18-1152.
229
+
230
+ Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. In International Conference on Learning Representations, 2020. URL https: //openreview.net/forum?id=rygGQyrFvH.
231
+
232
+ Mohammad Javad Hosseini, Hannaneh Hajishirzi, Oren Etzioni, and Nate Kushman. Learning to solve arithmetic word problems with verb categorization. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2014. doi: 10.3115/v1/D14-1058. URL https://aclanthology.org/D14-1058.
233
+
234
+ Daniel Khashabi, Sewon Min, Tushar Khot, Ashish Sabharwal, Oyvind Tafjord, Peter Clark, and Hannaneh Hajishirzi. UNIFIEDQA: Crossing format boundaries with a single QA system. In Findings of the Association for Computational Linguistics: EMNLP 2020, pp. 1896–1907, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.findings-emnlp.171. URL https://aclanthology.org/2020.findings-emnlp.171.
235
+
236
+ Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho (eds.), Advances in Neural Information Processing Systems, 2022. URL https://openreview.net/forum?id $_ { \cdot } =$ e2TBb5y0yFf.
237
+
238
+ Rik Koncel-Kedziorski, Subhro Roy, Aida Amini, Nate Kushman, and Hannaneh Hajishirzi. MAWPS: A math word problem repository. In Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, 2016. doi: 10.18653/v1/N16-1136. URL https://aclanthology.org/N16-1136.
239
+
240
+ Yihuai Lan, Lei Wang, Qiyuan Zhang, Yunshi Lan, Bing Tian Dai, Yan Wang, Dongxiang Zhang, and Ee-Peng Lim. MWPToolkit: An open-source framework for deep learning-based math word problem solvers. arXiv preprint arXiv:2109.00799, 2021. URL https://arxiv.org/abs/ 2109.00799.
241
+
242
+ Jiwei Li and Dan Jurafsky. Mutual information and diverse decoding improve neural machine translation, 2016. URL https://arxiv.org/abs/1601.00372.
243
+
244
+ Jiwei Li, Will Monroe, and Dan Jurafsky. A simple, fast diverse decoding algorithm for neural generation. CoRR, abs/1611.08562, 2016. URL http://arxiv.org/abs/1611.08562.
245
+
246
+ Wang Ling, Dani Yogatama, Chris Dyer, and Phil Blunsom. Program induction by rationale generation: Learning to solve and explain algebraic word problems. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), 2017. doi: 10.18653/v1/P17-1015. URL https://aclanthology.org/P17-1015.
247
+
248
+ Yao Lu, Max Bartolo, Alastair Moore, Sebastian Riedel, and Pontus Stenetorp. Fantastically ordered prompts and where to find them: Overcoming few-shot prompt order sensitivity. ArXiv, abs/2104.08786, 2021.
249
+
250
+ Clara Meister, Tiago Pimentel, Gian Wiher, and Ryan Cotterell. Typical decoding for natural language generation. arXiv preprint arXiv:2202.00666, 2022.
251
+
252
+ Shen Yun Miao, Chao Chun Liang, and Keh Yih Su. A diverse corpus for evaluating and developing English math word problem solvers. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, 2020. URL https://aclanthology.org/2020. acl-main.92.
253
+
254
+ Yixin Nie, Adina Williams, Emily Dinan, Mohit Bansal, Jason Weston, and Douwe Kiela. Adversarial NLI: A new benchmark for natural language understanding. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics. Association for Computational Linguistics, 2020.
255
+
256
+ Maxwell Nye, Michael Henry Tessler, Joshua B. Tenenbaum, and Brenden M. Lake. Improving coherence and consistency in neural sequence models with dual-system, neuro-symbolic reasoning. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan (eds.), Advances in Neural Information Processing Systems, 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ uyKk_avJ-p4.
257
+
258
+ Arkil Patel, Satwik Bhattamishra, and Navin Goyal. Are NLP models really able to solve simple math word problems? In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 2080–2094, Online, June 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.naacl-main. 168. URL https://aclanthology.org/2021.naacl-main.168.
259
+
260
+ Xinyu Pi, Qian Liu, Bei Chen, Morteza Ziyadi, Zeqi Lin, Yan Gao, Qiang Fu, Jian-Guang Lou, and Weizhu Chen. Reasoning like program executors, 2022.
261
+
262
+ Piotr Pi˛ekos, Mateusz Malinowski, and Henryk Michalewski. Measuring and improving BERT’s mathematical abilities by predicting the order of reasoning. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 2: Short Papers), 2021. doi: 10.18653/v1/2021.acl-short.49. URL https://aclanthology.org/2021.acl-short.49.
263
+
264
+ Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019.
265
+
266
+ Jack W Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, et al. Scaling language models: Methods, analysis & insights from training gopher. arXiv preprint arXiv:2112.11446, 2021.
267
+
268
+ Qiu Ran, Yankai Lin, Peng Li, Jie Zhou, and Zhiyuan Liu. NumNet: Machine reading comprehension with numerical reasoning. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), 2019. doi: 10.18653/v1/D19-1251. URL https://aclanthology. org/D19-1251.
269
+
270
+ Subhro Roy and Dan Roth. Solving general arithmetic word problems. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, 2015. doi: 10.18653/v1/ D15-1202. URL https://aclanthology.org/D15-1202.
271
+
272
+ Jianhao Shen, Yichun Yin, Lin Li, Lifeng Shang, Xin Jiang, Ming Zhang, and Qun Liu. Generate & rank: A multi-task framework for math word problems. In Findings of the Association for Computational Linguistics: EMNLP 2021, pp. 2269–2279, Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. URL https://aclanthology. org/2021.findings-emnlp.195.
273
+
274
+ Freda Shi, Daniel Fried, Marjan Ghazvininejad, Luke Zettlemoyer, and Sida I. Wang. Natural language to code translation with execution. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 3533–3546, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics. URL https://aclanthology. org/2022.emnlp-main.231.
275
+
276
+ Keith E Stanovich and Richard F West. Individual differences in reasoning: Implications for the rationality debate? Behavioral and brain sciences, 23(5):645–665, 2000. URL https: //pubmed.ncbi.nlm.nih.gov/11301544/.
277
+
278
+ Alon Talmor, Jonathan Herzig, Nicholas Lourie, and Jonathan Berant. CommonsenseQA: A question answering challenge targeting commonsense knowledge. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), 2019. URL https://aclanthology. org/N19-1421.
279
+
280
+ Yi Tay, Mostafa Dehghani, Vinh Q. Tran, Xavier Garcia, Jason Wei, Xuezhi Wang, Hyung Won Chung, Dara Bahri, Tal Schuster, Steven Zheng, Denny Zhou, Neil Houlsby, and Donald Metzler. Unifying language learning paradigms, 2022. URL https://arxiv.org/abs/2205.05131.
281
+
282
+ Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, et al. Lamda: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022. URL https://arxiv.org/abs/ 2201.08239.
283
+
284
+ Ashwin Vijayakumar, Michael Cogswell, Ramprasaath Selvaraju, Qing Sun, Stefan Lee, David Crandall, and Dhruv Batra. Diverse beam search for improved description of complex scenes. Proceedings of the AAAI Conference on Artificial Intelligence, 32, Apr. 2018. URL https: //ojs.aaai.org/index.php/AAAI/article/view/12340.
285
+
286
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. Conference on Neural Information Processing Systems (NeurIPS), 2022. URL https://arxiv. org/pdf/2201.11903.
287
+
288
+ Sean Welleck, Ilia Kulikov, Jaedeok Kim, Richard Yuanzhe Pang, and Kyunghyun Cho. Consistency of a recurrent language model with respect to incomplete decoding. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 5553–5568, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020. emnlp-main.448. URL https://aclanthology.org/2020.emnlp-main.448.
289
+
290
+ Weiwen Xu, Yang Deng, Huihui Zhang, Deng Cai, and Wai Lam. Exploiting reasoning chains for multi-hop science question answering. In Findings of the Association for Computational Linguistics: EMNLP 2021, pp. 1143–1156, Punta Cana, Dominican Republic, November 2021a. Association for Computational Linguistics. URL https://aclanthology.org/2021. findings-emnlp.99.
291
+
292
+ Yichong Xu, Chenguang Zhu, Shuohang Wang, Siqi Sun, Hao Cheng, Xiaodong Liu, Jianfeng Gao, Pengcheng He, Michael Zeng, and Xuedong Huang. Human parity on commonsenseqa: Augmenting self-attention with external attention, 2021b. URL https://arxiv.org/abs/ 2112.03254.
293
+
294
+ Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William Cohen, Ruslan Salakhutdinov, and Christopher D. Manning. HotpotQA: A dataset for diverse, explainable multi-hop question answering. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 2369–2380, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1259. URL https://aclanthology.org/D18-1259.
295
+
296
+ Xi Ye and Greg Durrett. The unreliability of explanations in few-shot prompting for textual reasoning. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho (eds.), Advances in Neural Information Processing Systems, 2022. URL https://openreview.net/forum? id=Bct2f8fRd8S.
297
+
298
+ Wenhao Yu, Chenguang Zhu, Lianhui Qin, Zhihan Zhang, Tong Zhao, and Meng Jiang. Diversifying content generation for commonsense reasoning with mixture of knowledge graph experts. In Findings of Annual Meeting of the Association for Computational Linguistics (ACL), 2022.
299
+
300
+ Zihao Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research. PMLR, 2021. URL https://proceedings.mlr.press/ v139/zhao21c.html.
301
+
302
+ # A APPENDIX
303
+
304
+ A.1 ADDITIONAL EXPERIMENT RESULTS
305
+
306
+ # A.1.1 ROBUSTNESS TO SAMPLING STRATEGIES AND PARAMETERS
307
+
308
+ In Figure 6 we ablate the results with respect to different sampling strategies and parameters by varying $T$ in temperature sampling and $k$ in Top- $k$ sampling, on LaMDA-137B. We show that self-consistency is robust to various sampling strategies and parameters.
309
+
310
+ ![](images/5682763857dd59665317b37d4e2ff1237798960f4e4fb66b5db1538fb257bd34.jpg)
311
+ Figure 6: GSM8K accuracy over LaMDA-137B. Self-consistency works under various sampling strategies and sampling parameters.
312
+
313
+ In Figure 7 and Figure 8, we show the results of self-consistency compared with greedy decoding a single path over LaMDA-137B and PaLM-540B, respectively. Self-consistency improves over greedy decode by a quite significant margin on both models, on top of high accuracy already achieved by scaling up model sizes.
314
+
315
+ ![](images/dd06aeb61120fc868024f45c264d037f8b03f44182e787809b7cfde355dece76.jpg)
316
+ Figure 7: Self-consistency (blue) significantly improves accuracy across various arithmetic and commonsense reasoning tasks, over LaMDA-137B. Sampling a higher number of diverse reasoning paths consistently improves reasoning accuracy.
317
+
318
+ We further show additional sampled reasoning paths from the LaMDA-137B model in Table 12, and sampled reasoning paths from the PaLM-540B model in Table 13. We see that the diversity in the additionally sampled reasoning paths indeed helps the model arrive at a more correct final answer after aggregation.
319
+
320
+ # A.1.2 ROBUSTNESS TO DIFFERENT SETS OF PROMPTS
321
+
322
+ In Table 9, we further show that self-consistency is quite robust to different sets of input prompts. We manually wrote 3 different sets of chain-of-thought as prompts to the model. Across all sets of prompts, self-consistency yields consistent gains over the original CoT approach.
323
+
324
+ # A.1.3 COMPARED TO MODEL ENSEMBLES
325
+
326
+ Additionally, we provide results of directly ensembling the outputs from multiple language models. The results are shown in Table 10, by greedily decoding sequences from 3 language models and taking the majority vote (averaged over 10 runs). Note this is a typical ensemble approach (averaging over the predictions over multiple models) and it achieves a performance significantly worse than self-consistency (self-consistency over PaLM-540B gets an accuracy of $7 4 . 4 \%$ ), as lower-capacity models drag down the performance of higher-capacity models. In addition, this approach is limited in two ways: 1) It requires multiple models for an ensemble which might not always be available, while self-consistency only requires one single model to “self-ensemble”; 2) If one of the models is much weaker, it can actually hurt the final performance.
327
+
328
+ ![](images/528b99ea5220667091bc895ecec5856d21dd707b103c238b2499d6362bf59214.jpg)
329
+ Figure 8: Self-consistency (blue) significantly improves accuracy across various arithmetic and commonsense reasoning tasks, over PaLM-540B. Sampling a higher number of diverse reasoning paths consistently helps reasoning accuracy.
330
+
331
+ <table><tr><td></td><td>Prompt set 1 (used in the main text)丨Prompt set 2丨Prompt set 3</td><td></td><td></td></tr><tr><td>CoT (Wei et al., 2022)</td><td>56.5</td><td>54.6</td><td>54.0</td></tr><tr><td>Self-consistency</td><td>74.4 (+17.9)</td><td>72.1 (+17.5)</td><td>70.4 (+16.4)</td></tr></table>
332
+
333
+ Table 9: GSM8K accuracy over PaLM-540B. The results show robustness of self-consistency with respect to different prompts in the input.
334
+
335
+ <table><tr><td></td><td>Method</td><td>GSM8K accuracy</td></tr><tr><td>Single model</td><td>PaLM-540B,greedy/self-consistency</td><td>56.5 / 74.4</td></tr><tr><td rowspan="4">Ensemble of models</td><td>LaMDA-137B+PaLM-540B</td><td>36.9 ± 0.5</td></tr><tr><td>PaLM-540B + GPT-3 (code-davinci-001,175B)</td><td>36.6 ± 0.4</td></tr><tr><td>LaMDA-137B + GPT-3 (code-davinci-001,175B)</td><td>16.0 ± 0.8</td></tr><tr><td>LaMDA-137B +PaLM-540B + GPT-3 (code-davinci-001,175B)</td><td>33.3 ± 0.7</td></tr></table>
336
+
337
+ Table 10: Comparison of GSM8K accuracy over multiple-model ensembles.
338
+
339
+ # .1.4 COMBINING SELF-CONSISTENCY WITH OTHER ENSEMBLING STRATEGIE
340
+
341
+ Self-consistency is completely compatible with other ensemble strategies, although the gains achieved by self-consistency are significantly higher than other ensemble strategies (and can “override” the performance gains achieved by other ensemble strategies). We further performed experiments and include the results in Table 11 (for a fair comparison, we use 40 sets of prompts, or 40 prompt permutations to compare with self-consistency with 40 paths, all experiments are based on PaLM540B).
342
+
343
+ <table><tr><td></td><td>GSM8K accuracy</td></tr><tr><td>Different sets of prompts (x40)</td><td>58.9</td></tr><tr><td>Prompt-permutation (x40)</td><td>59.6</td></tr><tr><td>Self-consistency (x40)</td><td>74.4</td></tr><tr><td>Self-consistency +different sets of prompts (x40)</td><td>75.4</td></tr><tr><td>Self-consistency + prompt-permutation (x40)</td><td>73.8</td></tr></table>
344
+
345
+ Table 11: Combining self-consistency with other ensembling strategies.
346
+
347
+ # A.2 DETAILS ON RESOURCES AND INFERENCE
348
+
349
+ For all four language models we perform prompting-based inference only. For UL2 we use TPU v3 $2 \mathrm { x } 2$ configuration, 4 chips, 8 cores). For GPT-3 models the experiments are done though the public API.10 For LaMDA-137B we use TPU v3 (8x8 configuration, 64 chips, 128 cores). For PaLM-540B we use TPU v4 (4x4x12 configuration, 192 chips, 384 cores). Most inference jobs take 1 to 4 hours (over about 1,000 examples) for each task on UL2 and LaMDA-137B, and about 2 to 12 hours on PaLM-540B. Some tasks (e.g., commonsense reasoning) take longer but do not exceed 2 days for each task.
350
+
351
+ For GPT-3 models, we use $1 2 8 \mathrm { m a x }$ tokens for all methods, without frequency penalty or presence penalty. For all models, we take the generated outputs until the start of the next $\ " \mathrm { Q } : \ " $ to parse the final answers, consistent with our prompting format.
352
+
353
+ Table 12: Additional examples where self-consistency helps repair the errors over greedy decode on LaMDA-137B. Two sampled reasoning paths that are consistent with the ground truth are shown.
354
+
355
+ <table><tr><td rowspan=1 colspan=1>Question</td><td rowspan=1 colspan=1>Greedy Decode</td><td rowspan=1 colspan=1>Sampled Path 1</td><td rowspan=1 colspan=1>Sampled Path 2</td></tr><tr><td rowspan=1 colspan=1>[MultiArith] Sam had 10 socks.If he threw away3 old onesthatdidn&#x27;t fitandbought 36newones,how many socks would hehave?</td><td rowspan=1 colspan=1>Sam had 1O socks.He threwaway 3 old ones that didn&#x27;t fit.He bought 36 new ones.Thatmeans he has 10+36-3=41socks. The answer is 41.</td><td rowspan=1 colspan=1>Sam had 10 socks.Hethrew away 3old ones.Sonow he has 7 left. Then hebought 36 new ones.Sonow he has 7 + 36 = 43socks. The answer is 43.</td><td rowspan=1 colspan=1>He had 1O socks.He threw away3 old ones that didn&#x27;t ft.Hebought 36 new ones.So in totalhe has 10-3+36=43 socks.Theanswer is 43.</td></tr><tr><td rowspan=1 colspan=1>[SVAMP] In a school there are697 girls and the rest are boys.If thereare 228 moregirls thanboys.How many boys are therein that school?</td><td rowspan=1 colspan=1>There are 697 girls and the restare boys.That means there are697+ 228 = 925 girls. Therest are boys.So the number ofboys is 925-697 = 228. Theanswer is 228.</td><td rowspan=1 colspan=1>The number of boys is thedifference between 697and 228.This is 697 - 228= 469.The answer is 469.</td><td rowspan=1 colspan=1>In the beginning there are 697girls and the rest are boys.So,thenumber of boys must be 697 - 228= 469 boys. The answer is 469.</td></tr><tr><td rowspan=1 colspan=1>[AQuA] There arelO oranges ina basket.Find the no.of ways inwhich2 oranges are chosen fromthe basket?(a)45 (b) 90 (c)120(d) 150 (e) 180</td><td rowspan=1 colspan=1>There are 1O oranges in a bas-ket.So there are 10 waysin which 2 oranges are chosenfrom the basket.</td><td rowspan=1 colspan=1>There are 1O oranges in abasket.We need to choose2 oranges from the basket.So the number of ways are10C2.So the answer is (a).</td><td rowspan=1 colspan=1>There are 1O oranges in the bas-ket.If you choose 2 oranges,youhave 10C2=45 ways of choosing2 oranges. So the answer is (a).</td></tr><tr><td rowspan=1 colspan=1>[CommonsenseQA] The manlaidon thesoft mossand lookedup at the trees,where was theman?(a) niagra falls (b) forest(c) waterfall (d) ground (e) tree</td><td rowspan=1 colspan=1>The answer must be somethingthat is soft and mossy. Of theabove choices,only ground issoft and mossy. So the answeris (d).</td><td rowspan=1 colspan=1>Theanswermustbesomewhere where mossis found.Of the abovechoices,only forests areknown for having moss.So the answer is (b).</td><td rowspan=1 colspan=1>The answer must be a place wherethe man is laying down and look-ing up at trees.Of the abovechoices,only forest isaplacewhere people lay down and lookat trees. So the answer is (b).</td></tr><tr><td rowspan=1 colspan=1>[ARC] Which of thesewill mostlikely harm a habitat?(a) plant-ing trees. (b) water pollution. (c)rainfall. (d) sunlight.</td><td rowspan=1 colspan=1>Planting trees will not harm ahabitat. So the answer is (a).</td><td rowspan=1 colspan=1>The answer is (b),waterpollution,because it willmost likely harm the habi-tat. The other answers arenot likely to harm the habi-tat.</td><td rowspan=1 colspan=1>The answeris (b), water pollution.Treesare good fora habitat, rain-fall is necessary for a habitat,andsunlight is necessary fora habitat.So the answer is (b).</td></tr><tr><td rowspan=1 colspan=1>[ARC-challenge] Which pro-cessin thecarbon cycle takes thelongest to complete? (a) emis-sion of waste.(b) respiration inanimals.(c) photosynthesis inplants.(d) formation of fossil fu-els.</td><td rowspan=1 colspan=1>The process of photosynthesisin plants takes the longest tocomplete. So the answer is (c).</td><td rowspan=1 colspan=1>The formation of fossil fu- els takes the longest timeto complete.So the an-swer is (d).</td><td rowspan=1 colspan=1>The process that takes the longesttime to complete is the forma-tion of fossil fuels,which hap-pens over millions of years. Sothe answer is (d).</td></tr></table>
356
+
357
+ Table 13: Additional examples where self-consistency helps repair the errors over greedy decode on PaLM-540B. Two sampled reasoning paths that are consistent with the ground truth are shown.
358
+
359
+ <table><tr><td rowspan=1 colspan=1>Question</td><td rowspan=1 colspan=1>Greedy Decode</td><td rowspan=1 colspan=1>Sampled Path 1</td><td rowspan=1 colspan=1>Sampled Path 2</td></tr><tr><td rowspan=1 colspan=1>[GSM8K] Kyle bought lastyear&#x27;s best-selling book for$19.50. This is with a 25% dis-count from the original price.What was the original price ofthebook?</td><td rowspan=1 colspan=1>The book was sold for $19.50.This is 25% less than the origi-nal price.This means the originalprice was 100%. 25% of100%is 25%.So the original pricewas 100%- 25%= 75%.Theoriginal price was 75% of $19.50.75% of $19.50 is 75% * $19.50 =$14.625. The answer is $14.625.</td><td rowspan=1 colspan=1>The original price of the bookis $19.50.Since it was dis-counted by 25%,the originalprice was 19.50 / 0.75 = 26.The answer is 26.</td><td rowspan=1 colspan=1>Kyle bought a book that is soldfor $19.50.With a 25% discount,the original price must be higher.If we call the original price X,then the discounted price is 0.75x.Since this is $19.50,we can write0.75x = 19.50. Solving this,wefind that the original price is X =19.50 /0.75 = $26. The answer is$26.</td></tr><tr><td rowspan=1 colspan=1>[AQuA] The capacity of atank of dimensions (8 m x 6m x 2.5 m) is (a) 120 litres (b)1200 litres (c) 12000 litres (d)120000 litres (e) None of these</td><td rowspan=1 colspan=1>The volume of the tank is 8 m *6 m *2.5 m=120 m.So thecapacity of the tank is 120 m.Sothe answer is (c).</td><td rowspan=1 colspan=1>The volume of the tank is 8m* 6m* 2.5m=120m.This isequal to 120000 litres. So theanswer is (d)</td><td rowspan=1 colspan=1>The volume of the tank is 8 m *6m * 2.5 m=120 m3.One cu-bic meter contains 1Ooo litres,sothe tank contains 120 m3 *1000liters/m3 = 120,000 liters.So theanswer is (d).</td></tr><tr><td rowspan=1 colspan=1>[StrategyQA] Yesorno:Can the Great Depression betreated with Prozac?</td><td rowspan=1 colspan=1>The Great Depression was aneconomic depression.Prozac isa drug used to treat depression.Thus, the Great Depression couldbe treated with Prozac. So the an-swer is yes.</td><td rowspan=1 colspan=1>Prozac is an anti-depressantmedication. The Great Depres-sion is not a disease.Thus,Prozac cannot treat the GreatDepression. So the answer isno.</td><td rowspan=1 colspan=1>The Great Depression is a time pe-riod.Prozac is used to treat de-pression (the mental illness). Thus,the Great Depression can not betreated with Prozac.So the answeris no.</td></tr><tr><td rowspan=1 colspan=1>[ARC-easy] Which source ofenergy is nonrenewable? (a)coal.(b) sunlight.(c) water.(d) wood.</td><td rowspan=1 colspan=1>Coal,sunlight,and water areall renewable sources of energy.Wood is a nonrenewable source ofenergy.So the answer is (d).</td><td rowspan=1 colspan=1>A nonrenewable source of en-ergy is one in which the sourceis not replenished in a shortamount of time.Thus, the onlyoption that is nonrenewable iscoal. So the answer is (a).</td><td rowspan=1 colspan=1>Coal is a fossil fuel and is formedfrom dead organisms from the past.Coal cannot be produced in a shortperiod of time,so it is considereda nonrenewable source of energy.So the answer is (a).</td></tr><tr><td rowspan=1 colspan=1>[ARC-challenge] Studentsstudiedthe revolutionofEartharound the Sun.Duringwhichmonth willFlorida have themost sunlight energy avail-able?(a)March.(b)June.(c)September.(d) December.</td><td rowspan=1 colspan=1>The Earth is closest to the Sunin December, hence Florida willhave the most sunlight energyavailable in December. So the an-swer is (d).</td><td rowspan=1 colspan=1>Earth is closest to the Sun onJune 21,the summer solstice.So the answer is (b).</td><td rowspan=1 colspan=1>Florida is closer to the sun duringJune,so it will have the most sun-light energy during that month. Sothe answer is (b).</td></tr></table>
360
+
361
+ # A.3 FULL SETS OF PROMPTS
362
+
363
+ We list the full details of the prompts used for two newly-introduced datasets, AQUA-RAT (Ling et al., 2017) and AI2 Reasoning Challenge (ARC) (Clark et al., 2018), where we manually composed the example chain-of-thought in this paper, in Table 14 and Table 15, respectively.
364
+
365
+ Table 14: Few-shot exemplars for AQUA-RAT.
366
+
367
+ <table><tr><td>Q: John found that the average of 15 numbers is 40.If 10 is added to each number then the mean of the numbers is? Answer Choices: (a) 50 (b) 45 (c) 65 (d) 78 (e) 64</td></tr><tr><td>A: If 10 is added to each number, then the mean of the numbers also increases by 10.So the new mean would be 5O. The answer is (a).</td></tr><tr><td>Q: If a/b=3/4 and 8a + 5b=22,then find the value of a. Answer Choices: (a) 1/2 (b)3/2 (c)5/2 (d) 4/2 (e) 7/2</td></tr><tr><td>A: If a/b=3/4,then b=4a/3.So 8a + 5(4a/3)=22.This simplifies to 8a +20a/3 =22,which means 44a/3=22. So a is equal to 3/2. The answer is (b).</td></tr><tr><td>Q: A person is traveling at 2O km/hr and reached his destinyin 2.5 hr then find the distance?Answer Choices:</td></tr><tr><td>(a) 53 km (b) 55 km (c) 52 km (d) 60 km (e) 50 km A: The distance that the person traveled would have been 20 km/hr *2.5 hrs = 50 km. The answer is (e).</td></tr><tr><td>Q: How many keystrokes are neded to type the numbers from 1 to 50o? Answer Choices: (a)1156 (b)1392 (c) 1480 (d) 1562 (e) 1788</td></tr><tr><td>A: There are 9one-digit numbers from1 to 9.There are 90 two-digit numbers from 10 to 99.There are 401 three-digit numbers from 100 to 500.9 + 90(2) + 401(3)=1392.The answer is (b).</td></tr></table>
368
+
369
+ Q: George wants to warm his hands quickly by rubbing them. Which skin surface will produce the most heat? (a) dry palms. (b) wet palms. (c) palms covered with oil. (d) palms covered with lotion.
370
+ A: Dry surfaces will more likely cause more friction via rubbing than other smoother surfaces, hence dry palms will produce the most heat. The answer is (a).
371
+ Q: Which factor will most likely cause a person to develop a fever? (a) a leg muscle relaxing after exercise. (b) a bacterial population in the bloodstream. (c) several viral particles on the skin. (d) carbohydrates being digested in the stomach.
372
+ A: Option (b), bacterial population is the most likely cause for a person developing fever. The answer is (b). Q: Which change in the state of water particles causes the particles to become arranged in a fixed position? (a) boiling. (b) melting. (c) freezing. (d) evaporating.
373
+ A: When water is freezed, the particles are arranged in a fixed position; the particles are still moving for all other options. The answer is (c).
374
+ Q: When a switch is used in an electrical circuit, the switch can (a) cause the charge to build. (b) increase and decrease the voltage. (c) cause the current to change direction. (d) stop and start the flow of current. A: The function of a switch is to start and stop the flow of a current. The answer is (d).
375
+
376
+ Table 15: Few-shot exemplars for ARC easy/challenge.
377
+ Table 16: Few-shot exemplars for HotpotQA (closed-book setting).
378
+
379
+ <table><tr><td>Q: Which magazine was started first Arthur&#x27;s Magazine or First for Women?</td></tr><tr><td>A: Arthur&#x27;s Magazine started in 1844. First for Women started in 1989.So Arthur&#x27;s Magazine was started first. The answer is Arthur&#x27;s Magazine.</td></tr><tr><td>Q: The Oberoi family is part of a hotel company that has a head office in what city?</td></tr><tr><td>A: The Oberoi family is part of the hotel company called The Oberoi Group.The Oberoi Group has its head office in Delhi.The answeris Delhi.</td></tr><tr><td>Q: What nationality was James Henry Miller&#x27;s wife?</td></tr><tr><td>A: James Henry Miller&#x27;s wife is June Miller. June Miller is an American.The answer is American.</td></tr><tr><td>Q: The Dutch-Belgian television series that &quot;House of Anubis&quot; was based on first aired in what year?</td></tr><tr><td>A: &quot;House of Anubis&quot;is basedon the Dutch-Belgian television series Het Huis Anubis.Het Huis Anubis is first</td></tr></table>
380
+
381
+ As additional information, we also list the exact set of prompts used for all arithmetic reasoning tasks in Table 17, since there are multiple sets of prompts introduced in Wei et al. (2022). The prompts for CommonsenseQA and StrategyQA are the same as used in Wei et al. (2022).
382
+
383
+ We provide the exact prompts used for common NLP tasks in the following tables as well, including NLI (Table 18, Table 19, Table 20) and Closed-Book Question-Answering tasks (Table 16, Table 21).
384
+
385
+ Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?
386
+ A: We start with 15 trees. Later we have 21 trees. The difference must be the number of trees they planted. So, they must have planted $2 1 - 1 5 = 6$ trees. The answer is 6.
387
+ Q: If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot? A: There are 3 cars in the parking lot already. 2 more arrive. Now there are $3 + 2 = 5$ cars. The answer is 5. Q: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total? A: Leah had 32 chocolates and Leah’s sister had 42. That means there were originally $3 2 + 4 2 = 7 4$ chocolates. 35 have been eaten. So in total they still have $7 4 - 3 5 = 3 9$ chocolates. The answer is 39. Q: Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?
388
+ A: Jason had 20 lollipops. Since he only has 12 now, he must have given the rest to Denny. The number of lollipops he has given to Denny must have been $2 0 - 1 2 = 8 $ lollipops. The answer is 8.
389
+ Q: Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?
390
+ A: He has 5 toys. He got 2 from mom, so after that he has $5 + 2 = 7$ toys. Then he got 2 more from dad, so in total he has $7 + 2 = 9$ toys. The answer is 9.
391
+ Q: There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?
392
+ A: There are 4 days from monday to thursday. 5 computers were added each day. That means in total $4 ^ { * } 5 =$ 20 computers were added. There were 9 computers in the beginning, so now there are $9 + 2 0 = 2 9$ computers. The answer is 29.
393
+ Q: Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?
394
+ A: Michael initially had 58 balls. He lost 23 on Tuesday, so after that he has $5 8 - 2 3 = 3 5$ balls. On Wednesday he lost 2 more so now he has $3 5 - 2 = 3 3$ balls. The answer is 33.
395
+ Q: Olivia has $\$ 23$ . She bought five bagels for $\$ 3$ each. How much money does she have left?
396
+ A: She bought 5 bagels for $\$ 3$ each. This means she spent $5 * \ S 3 = \ S 1 5$ on the bagels. She had $\$ 23$ in beginning, so now she has $\$ 23-\$ 15=58$ . The answer is 8.
397
+
398
+ Premise:
399
+
400
+ "Conceptually cream skimming has two basic dimensions - product and geography."
401
+
402
+ Based on this premise, can we conclude the hypothesis "Product and geography are what make cream skimming work." is true?
403
+
404
+ OPTIONS:
405
+ - yes
406
+ - no
407
+ - it is not possible to tell
408
+
409
+ A: Based on "cream skimming has two basic dimensions" we can’t infer that these two dimensions are what make cream skimming work. The answer is it is not possible to tell.
410
+
411
+ Premise:
412
+ "One of our member will carry out your instructions minutely."
413
+ Based on this premise, can we conclude the hypothesis "A member of my team will execute your orders with
414
+ immense precision." is true?
415
+ OPTIONS:
416
+ - yes
417
+ - no
418
+ - it is not possible to tell
419
+
420
+ A: "one of" means the same as "a member of", "carry out" means the same as "execute", and "minutely" means the same as "immense precision". The answer is yes.
421
+
422
+ Premise:
423
+ "Fun for adults and children."
424
+ Based on this premise, can we conclude the hypothesis "Fun for only children." is true?
425
+ OPTIONS:
426
+ - yes
427
+ - no
428
+ - it is not possible to tell
429
+
430
+ A: "adults and children" contradicts "only children". The answer is no.
431
+
432
+ Premise:
433
+ "He turned and smiled at Vrenna."
434
+ Based on this premise, can we conclude the hypothesis "He smiled at Vrenna who was walking slowly behind
435
+ him with her mother." is true?
436
+ OPTIONS:
437
+ - yes
438
+ - no
439
+ - it is not possible to tell
440
+
441
+ A: the premise does not say anything about "Vrenna was walking". The answer is it is not possible to tell.
442
+
443
+ Premise:
444
+ "well you see that on television also"
445
+ Based on this premise, can we conclude the hypothesis "You can see that on television, as well." is true?
446
+ OPTIONS:
447
+ - yes
448
+ - no
449
+ - it is not possible to tell
450
+
451
+ A: "also" and "as well" mean the same thing. The answer is yes.
452
+
453
+ OPTIONS:
454
+ - yes
455
+ - no
456
+ - it is not possible to tell
457
+
458
+ A: "Vrenna and I both" contradicts "neither Vrenna nor myself". The answer is no.
459
+
460
+ Premise:
461
+ "A person on a horse jumps over a broken down airplane."
462
+ Based on this premise, can we conclude the hypothesis "A person is training his horse for a competition." is true? OPTIONS:
463
+ - yes
464
+ - no
465
+ - it is not possible to tell
466
+ A: The person is not necessarily training his horse. The answer is it is not possible to tell. Premise:
467
+ "A person on a horse jumps over a broken down airplane."
468
+ Based on this premise, can we conclude the hypothesis "A person is at a diner, ordering an omelette." is true? OPTIONS:
469
+ - yes
470
+ - no
471
+ - it is not possible to tell
472
+ A: One jumping horse cannot be in a diner ordering food. The answer is no. Premise:
473
+ "A person on a horse jumps over a broken down airplane."
474
+ Based on this premise, can we conclude the hypothesis "A person is outdoors, on a horse." is true? OPTIONS:
475
+ - yes
476
+ - no
477
+ - it is not possible to tell
478
+ A: A broken down airplane is outdoors. The answer is yes. Premise:
479
+ "Children smiling and waving at camera."
480
+ Based on this premise, can we conclude the hypothesis "They are smiling at their parents." is true?
481
+ OPTIONS:
482
+ - yes
483
+ - no
484
+ - it is not possible to tell
485
+ A: Just because they are smiling and waving at a camera does not imply their parents or anyone is anyone behind it. The answer is it is not possible to tell.
486
+ Premise:
487
+ "Children smiling and waving at camera."
488
+ Based on this premise, can we conclude the hypothesis "The kids are frowning." is true? OPTIONS:
489
+ - yes
490
+ - no
491
+ - it is not possible to tell
492
+
493
+ A: One cannot be smiling and frowning at the same time. The answer is no.
494
+
495
+ Premise:
496
+ "Children smiling and waving at camera."
497
+ Based on this premise, can we conclude the hypothesis "There are children present." is true? OPTIONS:
498
+ - yes
499
+ - no
500
+ - it is not possible to tell
501
+ A:The children must be present to see them smiling and waving. The answer is yes.
502
+
503
+ Premise:
504
+
505
+ "No Weapons of Mass Destruction Found in Iraq Yet."
506
+
507
+ Based on this premise, can we conclude the hypothesis "Weapons of Mass Destruction Found in Iraq." is true?
508
+
509
+ A: "No Weapons of Mass Destruction Found" contradicts "Weapons of Mass Destruction Found". The answer is no.
510
+
511
+ Premise:
512
+
513
+ "A place of sorrow, after Pope John Paul II died, became a place of celebration, as Roman Catholic faithful gathered in downtown Chicago to mark the installation of new Pope Benedict XVI."
514
+
515
+ Based on this premise, can we conclude the hypothesis "Pope Benedict XVI is the new leader of the Roman Catholic Church." is true?’
516
+
517
+ A: "installation of new Pope Benedict XVI." means "Pope Benedict XVI is the new leader". The answer is yes.
518
+
519
+ Premise:
520
+
521
+ "A man is due in court later charged with the murder 26 years ago of a teenager whose case was the first to be featured on BBC One’s Crimewatch. Colette Aram, 16, was walking to her boyfriend’s house in Keyworth, Nottinghamshire, on 30 October 1983 when she disappeared. Her body was later found in a field close to her home. Paul Stewart Hutchinson, 50, has been charged with murder and is due before Nottingham magistrates later."
522
+
523
+ Based on this premise, can we conclude the hypothesis "Paul Stewart Hutchinson is accused of having stabbed a girl." is true?
524
+
525
+ A: The premise does not say Paul Stewart Hutchinson "stabbed" this girl. The answer is no.
526
+
527
+ Premise:
528
+
529
+ "Herceptin was already approved to treat the sickest breast cancer patients, and the company said, Monday, it will discuss with federal regulators the possibility of prescribing the drug for more breast cancer patients." Based on this premise, can we conclude the hypothesis "Herceptin can be used to treat breast cancer." is true?
530
+
531
+ A: "Herceptin was approved to treat breast cancer" implies that "Herceptin can be used to treat breast cancer".
532
+ The answer is yes.
533
+
534
+ Q: does system of a down have 2 singers?
535
+
536
+ A: System of a Down currently consists of Serj Tankian, Daron Malakian, Shavo Odadjian and John Dolmayan.
537
+ Serj and Daron do vocals, so the band does have two singers. The answer is yes.
538
+
539
+ Q: do iran and afghanistan speak the same language?
540
+
541
+ A: Iran and Afghanistan both speak the Indo-European language Persian. The answer is yes.
542
+
543
+ Q: is a cello and a bass the same thing?
544
+
545
+ A: The cello is played sitting down with the instrument between the knees, whereas the double bass is played standing or sitting on a stool. The answer is no.
546
+
547
+ Q: can you use oyster card at epsom station?
548
+
549
+ A: Epsom railway station serves the town of Epsom in Surrey and is not in the London Oyster card zone. The answer is no.
md/dev/1QQnYd02etI/1QQnYd02etI.md ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UNIFIED VISION AND LANGUAGE PROMPT LEARNING
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Prompt tuning, a parameter- and data-efficient transfer learning paradigm that tunes only a small number of parameters in a pre-trained model’s input space, has become a trend in the vision community since the emergence of large visionlanguage models like CLIP. We present a systematic study on two representative prompt tuning methods, namely text prompt tuning and visual prompt tuning. A major finding is that none of the unimodal prompt tuning methods performs consistently well: text prompt tuning fails on data with high intra-class visual variances while visual prompt tuning cannot handle low inter-class variances. To combine the best from both worlds, we propose a conceptually simple approach called Unified Prompt Tuning (UPT), which learns a tiny neural network to jointly optimize prompts across different modalities. Extensive experiments on over 11 vision datasets show that UPT achieves a better trade-off than the unimodal counterparts on few-shot learning benchmarks, as well as on domain generalization benchmarks. Code and models will be released to facilitate future research.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Vision-language (VL) models pre-trained on millions of image-text pairs (e.g., CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021)) have shown excellent transferability on a variety of downstream tasks, such as few-shot learning (Zhou et al., 2022a;b; Ju et al., 2021) and open-vocabulary perception (Gu et al., 2022; Zhou et al., 2022c; Zang et al., 2022; Ghiasi et al., 2021). When adapting large VL models to downstream tasks, it is often impractical to fine-tune the entire model directly due to their huge parameter size. To make adaptation more efficiently, many studies (Gao et al., 2021; Li & Liang, 2021; Lester et al., 2021; Zhou et al., 2022a; Lu et al., 2022; Ju et al., 2021; Yao et al., 2021; Jia et al., 2022; Bahng et al., 2022) have explored prompt tuning where the idea is to fine-tune a small number of parameters in a pre-trained model’s input space, called prompt, while keeping the majority of pre-trained parameters frozen.
12
+
13
+ A typical VL model consists of two sub-networks—an image encoder and a text encoder—to extract features from visual and textual modalities respectively. Correspondingly, existing prompt tuning approaches can be grouped into two types: text prompt tuning and visual prompt tuning. For text prompt tuning methods, e.g., CoOp (Zhou et al., 2022a), extra text prompt tokens treated as learnable parameters are applied on the text encoder (Fig. 1(a)) to mitigate the issue that hand-crafted text prompt templates (e.g., “a photo of a [CLASS].”) are often sub-optimal. On the contrary, visual prompt tuning approaches focus on modulating the image encoder (Fig. 1(b)). A representative method is VPT (Jia et al., 2022), which injects learnable parameters into multiple layers of a Vision Transformer. Notably, these prompt-based methods treat the two modalities in isolation.
14
+
15
+ Despite significant improvements achieved recently, we observe that current prompt tuning approaches (Zhou et al., 2022a; Jia et al., 2022) fail to perform consistently due to inherent variances in visual and text features in downstream tasks. That is to say, using the unimodal prompt may obtain good results on one dataset but not on others.
16
+
17
+ To analyze the phenomenon, we measure the discrepancy in data distribution focusing on the intraclass variance of visual features and inter-class variance of text embedding, and study the correlation between data statistics and performance improvement. As shown in Fig. 1(d), when the intra-class variance of image features is large (bottom right), CoOp struggles to learn suitable text prompts for improving the text classifier. As for visual prompt tuning, VPT faces difficulties when the interclass variance of text features is small, as shown in bottom left of Fig. 1(e). That is, if the text classifiers are based on text features of low separability, tuning visual prompts would lend little help to improve the final performance. Moreover, intra-class visual variance and inter-class text variance are typically orthogonal. As a consequence, the performance of unimodal prompt tuning methods varies widely across different datasets: CoOp beats VPT by $8 . 1 \%$ on Flowers102 (Nilsback & Zisserman, 2008) while VPT outperforms CoOp by $8 . 4 \%$ on EuroSAT (Helber et al., 2019).
18
+
19
+ ![](images/61a5b482223f042b9e5ad0d88db275988b5b17c8486555e68f490deded9d8046.jpg)
20
+ Figure 1: Top: Architectures of (a) text prompt tuning (Zhou et al., 2022a), (b) visual prompt tuning (Jia et al., 2022) and (c) our multimodal unified prompt tuning ( $\textcircled { 3 }$ : learnable; $\frac { 2 0 0 } { 9 0 0 }$ : frozen parameters). Bottom: the performance improvements $( \% )$ of text prompt tuning (d) and visual prompt tuning (e) compared with the zero-shot CLIP baseline. We show that the variance of visual and text features ( $\scriptstyle { \dot { x } }$ -axis) will affect the improvements $y$ -axis). We project the text/visual features of the dataset (pointed by the dashed arrow) into a unit sphere to show the variance of different distributions. Please refer to the appendix for the implementation details about how we compute the feature variance.
21
+
22
+ We argue that the key would be to simultaneously adapt both text and visual prompts to overcome the vast differences across different data distributions. A straightforward solution is to introduce both text and visual prompts to the model and jointly optimize the two modality-specific prompts. However, we find that such a na¨ıve joint training leads to poor performance due to the intrinsic discrepancy between text and image modalities. In particular, the performance is occasionally worse than tuning modality-specific prompts as shown in our experiments.
23
+
24
+ Solving the aforementioned issues requires modality-agnostic optimization to bridge the isolated prompts. To this end, we present a unified prompt tuning method for both text and visual modalities, dubbed Unified Prompt Tuning (UPT). See Fig. 1(c). Specifically, we start with a shared prompt and propose a lightweight self-attention network to generate the prompts for CLIP’s text and visual encoders respectively. We empirically show that such a conceptually simple design can preserve the benefit of individual modalities.
25
+
26
+ Our contributions are summarized as follows. 1) We provide a comprehensive study on existing text and visual prompt tuning methods, and identify the shortcoming of unimodal learning. 2) We present a unified prompt learning method for VL models, which is simple and easy to implement. 3) We conduct extensive experiments to show that unified prompt tuning outperforms previous unimodal prompt tuning methods under the few-shot learning and domain generalization settings.
27
+
28
+ # 2 METHODOLOGY
29
+
30
+ We first introduce vision-language models focusing on CLIP (Radford et al., 2021), in company with text/visual prompt tuning approaches for visual recognition in Sec. 2.1. We then analyze the
31
+
32
+ limitations of previous single-modal prompt tuning approaches in Sec. 2.2. Finally, we present technical details of our proposed unified prompt learning in Sec. 2.3.
33
+
34
+ # 2.1 PRELIMINARIES
35
+
36
+ CLIP. CLIP (Radford et al., 2021) consists of two sub-networks: an image encoder $\phi$ and a text encoder $\psi$ . These two encoders, respectively, map the text and image inputs into a joint hidden space $\mathbb { R } ^ { d }$ , where the semantics of vision and language modalities are well-aligned. Here, $d$ refers to the final hidden dimension of the text or image encoder (e.g., $d = 2 5 6$ in the ResNet (He et al., 2016) backbone and $d = 5 1 2$ in the ViT backbone). Given an input image $_ { \textbf { \em x } }$ and a set of categories $\mathbf { Y } = \{ y _ { 1 } , y _ { 2 } , . . . , y _ { k } \}$ (e.g., $k = 1 0 0 0$ for ImageNet (Deng et al., 2009)), the image encoder extracts the corresponding image feature $z = f _ { \phi } ( \pmb { x } ) \in \mathbb { R } ^ { d }$ . While the class names in $\mathbf { Y }$ are first filled into a hand-crafted text prompt template a photo of a [CLASS] to obtain the text descriptions A, further processed by the text encoder for the text representations: $\mathbf { W } = f _ { \psi } ( \mathbf { A } ) \in \mathbb { R } ^ { d \times k }$ . The final prediction is computed as follows:
37
+
38
+ $$
39
+ p ( y = i \mid \pmb { x } ) = \frac { \exp \left( \cos \left( \pmb { w } _ { i } , \pmb { z } \right) / \tau \right) } { \sum _ { j = 1 } ^ { k } \exp \left( \cos \left( \pmb { w } _ { j } , \pmb { z } \right) / \tau \right) } ,
40
+ $$
41
+
42
+ where $\cos ( \cdot , \cdot )$ denotes the cosine similarity and $\tau$ is a fixed temperature value (e.g., $\tau = 1 0 0$ ). Conceptually, such a decision process for the input image $_ { \textbf { \em x } }$ in Eq. (1) is formulated in a way that the text encoder $\psi$ takes a role of generating dynamic classifiers W from open-set categories $\mathbf { Y }$ , with the image encoder $\phi$ producing encoded visual features $_ { z }$ . In practice, it is generally infeasible to fine-tune the millions of parameters (i.e., $\phi$ and $\psi$ ) in a VL model for transfer learning in every downstream task.
43
+
44
+ Text Prompt Tuning. For efficient and effective model adaptation, text prompt tuning approaches consider generating more adaptive classifiers without fine-tuning the text encoder $\psi$ . For example, Context Optimization $\left( \mathbf { C o O p } \right)$ (Zhou et al., 2022a) introduce a set of learnable parameters $\textbf { T } \in$ $\mathbb { R } ^ { d \times m }$ to replace the hand-crafted text prompt template (a photo of a [CLASS]). The wordembedding of class names in $\mathbf { Y }$ will concatenate with these text prompts in the following form:
45
+
46
+ $$
47
+ \mathrm { \hat { T } } = [ t _ { 1 } , t _ { 2 } , \dots , t _ { m } , \mathrm { C L A S S } ] .
48
+ $$
49
+
50
+ Here, the symbol $m$ denotes the prompt length. The resulting dynamic text representations are extracted by the text encoder: $\mathbf { W } = f _ { \psi } ( \hat { \mathbf { T } } ) \in \mathbb { R } ^ { d \times k }$ . In each downstream task, the learnable prompts $\mathbf { T }$ will be optimized with each task-specific objective function, e.g., a cross-entropy classification loss $\mathcal { L } _ { \mathrm { C E } } ( p , y )$ in few-shot learning. Note that both the image and text encoders $\cdot \phi$ and $\psi$ ) are frozen during downstream training. As a result, updating the text prompt $\mathbf { T }$ will correspondingly adjust the decision boundaries with generated classifiers $\mathbf { W }$ for downstream tasks.
51
+
52
+ Visual Prompt Tuning. Conversely, visual prompt tuning methods focus on extracting more transferable visual features while keeping the visual encoder $\phi$ unchanged. Following the success of text prompt tuning approaches, recent Visual Prompt Tuning (VPT) (Jia et al., 2022) introduces a similar prompt tuning recipe for the visual encoder $\phi$ . Suppose the image encoder $\phi$ contains $L$ Vision Transformer layers, the output of $i$ -th layer, $l _ { i }$ , where $i = 1 , 2 , \dots , L$ , is given by:
53
+
54
+ $$
55
+ [ { \pmb { c } } ^ { i + 1 } , z _ { 1 } ^ { i + 1 } , \dots , z _ { s } ^ { i + 1 } ] = l _ { i } \left( \left[ { \pmb { c } } ^ { i } , z _ { 1 } ^ { i } , \dots , z _ { s } ^ { i } \right] \right) ,
56
+ $$
57
+
58
+ where $c \in \mathbb { R } ^ { d }$ denotes the classification token ([CLS]), and $Z = [ z _ { 1 } , z _ { 2 } , \ldots , z _ { s } ] \in \mathbb { R } ^ { d \times s }$ denotes the input image patch tokens with length $s$ . For the $i$ -th encoder layer, a set of learnable visual prompts $\mathbf { V } ^ { i } \in \mathbb { R } ^ { \tilde { d } \times n }$ are inserted and computed as follows:
59
+
60
+ $$
61
+ [ { \pmb { c } } ^ { i + 1 } , \ldots , { \pmb { Z } } ^ { i + 1 } ] = l _ { i } \left( \left[ { \pmb { c } } ^ { i } , { \pmb { V } } ^ { i } , { \pmb { Z } } ^ { i } \right] \right) ,
62
+ $$
63
+
64
+ where $n$ stands for the length of visual prompts. Two VPT variants are proposed: VPT-shallow and VPT-deep. For VPT-shallow, the visual prompts are only inserted into the first Transformer layer $( i = 1 )$ ). Whereas for VPT-deep, visual prompts are introduced at every layer. The learnable visual prompts are data-independent, which once learned, can modulate the visual features $_ z$ of input images for better downstream transfer learning.
65
+
66
+ ![](images/a2f6fb7b57ea291e0e8a3927f47bbab05b6b928830b7026ef4495cee2202d69a.jpg)
67
+ Figure 2: Visualization of input features $_ { z }$ (projected points) and text classifier W (projected lines) on EuroSAT and Flowers102.
68
+
69
+ # 2.2 ANALYSIS
70
+
71
+ We conduct a series of probing studies to analyze the characteristics of text/visual prompt tuning. First, when adapting the CLIP model with two representative text and visual prompt tuning approaches $\mathrm { C o O p }$ (Zhou et al., 2022a) and VPT (Jia et al., 2022)), we measure the variance of both visual features $_ z$ and text embeddings W (i.e., classifiers) for all 11 downstream vision datasets (see Appendix for detailed implementations). For text prompt tuning, as shown in Fig. 1(d), we observe that CoOp performs well on datasets with low intra-class variance between visual features, such as Flowers102, but fails on Food101 dataset with high intra-class feature variance. As for visual prompt tuning, VPT succeeds in improving performance on SUN397 dataset with large inter-class text embeddings, while being less effective on Food101 and Flowers102 with relatively smaller inter-class text embedding variance. The performance improvements of text/visual prompt tuning are highly correlated with the variance of visual features $_ z$ or text embeddings W in downstream datasets.
72
+
73
+ In order to understand this phenomenon, we select two downstream vision datasets (Flowers102 (Nilsback & Zisserman, 2008), EuroSAT (Helber et al., 2019)) for further analysis. During downstream training, we project both visual features $_ z$ and text embeddings W (i.e., classifiers) into joint sphere space ${ \bar { \mathbb { R } } } ^ { 3 }$ for better visualization. As we illustrated in Fig. 2, we can observe that: 1) For the EuroSAT dataset with high intra-class visual feature variance, text prompts in $\mathrm { C o O p }$ fails to adapt the text classifiers W. Clearly, the text classifiers in Fig. $2 ( \mathbf { b } )$ are almost unchanged compared with zero-shot CLIP baseline (Fig. 2(a)). 2) For the Flowers102 dataset with low inter-class text embedding variance, visual prompts in VPT are not effective in modulating the visual features $_ { z }$ (Fig. ${ \bf \Pi } ( \mathbf { g } )$ ), thus cannot obtain considerable performance gain.
74
+
75
+ In conclusion, the single-modal prompt tuning approaches $\mathrm { C o O p }$ and VPT), face the dilemma that consistent improvements over Zero-shot CLIP are hard to achieve due to inherent variances of visual features and text embedding in downstream tasks. Our observation motivates us to present a unified prompt tuning method that tunes the $_ z$ and W at the same time.
76
+
77
+ # 2.3 UNIFIED PROMPT TUNING
78
+
79
+ Driven by our analysis, we devise a simple yet effective multi-modal Unified Prompt Tuning (UPT) approach for adapting VL models. Specifically, instead of introducing two sets of isolated modalityspecific prompts (i.e., T in Eq. (2) and $\mathbf { V }$ in Eq. (4)) for the text and visual encoders, we consider learning a set of unified modality-agnostic prompts for tuning VL models. As shown in Fig. 3, we define a set of learnable prompts $\breve { U } \in \mathbb { R } ^ { \tilde { d } \times n }$ with length $n$ . Rather than na¨ıvely appending the unified prompts into the text and visual encoders, we employ a lightweight Transformer layer $\theta$ to
80
+
81
+ ![](images/67e45a492de5f0902b22916fc823c82b9d462ebd1e101e53e7f18fabc740ad53.jpg)
82
+ Figure 3: The architecture of (a) our unified prompt $U$ that is applied to $\mathbf { ( b ) }$ CLIP text encoder and (c) CLIP image encoder.
83
+
84
+ transform unified prompts $U$ as follows:
85
+
86
+ $$
87
+ \begin{array} { r l } & { U ^ { \prime } = \mathrm { S A } \left( U \right) + \mathrm { L N } \left( U \right) , } \\ & { \hat { U } = \mathrm { F F N } \left( \mathrm { L N } \left( U ^ { \prime } \right) \right) + \mathrm { L N } \left( U ^ { \prime } \right) , } \end{array}
88
+ $$
89
+
90
+ where the self-attention operator SA, feed-forward network FFN and layer normalization LN are applied to obtain the transformed prompts $\hat { U }$ . The self-attention module in the lightweight Transformer layer allows beneficial interaction between two modalities, so as to maximize the complementary effects. Our unified prompts can be introduced into multiple layers of VL models. In particular, for each $i$ -th layer of text and image encoders, we consider learning a set of layer-wise prompts $U ^ { i }$ , and split transformed $\hat { \pmb { U } } ^ { i }$ into two parts $\hat { U } ^ { i } = \{ \hat { U } _ { t } ^ { i } , \hat { U } _ { v } ^ { i } \}$ , sending into the text and visual encoders respectively. During downstream training, we froze both the text and visual encoder $\dot { \psi }$ and $\phi$ ) and only optimize the unified prompts $U$ and the lightweight Transformer layer $\theta$ . In this way, both the dynamic classifiers W and visual features $_ z$ in Eq. (1) are effectively tuned for reliable prediction in the downstream task. As shown in Fig. 2 (d) and (h), our unified prompts can simultaneously obtain well-aligned text classifiers and separable visual features compared with single-modal counterparts.
91
+
92
+ # 3 EXPERIMENTS
93
+
94
+ In this section, we conduct experiments under two problem settings, i.e., (i) few-shot image classification (Sec. 3.1) and (ii) domain generalization (Sec. 3.2). We also present ablation studies in Sec. 3.3 on several design choices and extra experimental results about generalizability in Appendix.
95
+
96
+ Baselines. We compare our approach against the following methods: (1) Zero-shot CLIP. This baseline uses hand-crafted text prompt templates and does not involve any prompt-learning strategies. (2) Single-modal Prompt Tuning methods, including CoOp (Zhou et al., 2022a) and ProDA (Lu et al., 2022) for the text modality, and VPT (Jia et al., 2022) for the visual modality. In the domain generalization setting, we further compare with CoCoOp (Zhou et al., 2022b), which improves CoOp’s generalization performance with an input-conditional design. For VPT, we report the results of both the shallow and deep variants, as described in Sec. 2.1.
97
+
98
+ # 3.1 FEW-SHOT LEARNING
99
+
100
+ In this section, we measure a model’s generalization ability by conducting prompt tuning using different strategies, with just a limited amount of labeled examples per-class in the specific downstream task. Detailed implementation is presented in Appendix.
101
+
102
+ Datasets. We follow (Zhou et al., 2022b) to use 11 datasets (ImageNet (Deng et al., 2009), Caltech101 (Fei-Fei et al., 2004), OxfordPets (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), EuroSAT (Helber et al., 2019)) as our benchmarks. Following (Zhou et al., 2022a), we use the fewshot evaluation protocol selecting 1/2/4/8/16 shots for training and the whole test set for evaluation. We report averaged results over three runs with different random seeds to reduce the variance. The detailed results are shown in Fig. 4.
103
+
104
+ Limitation of Single-modal Baselines. Figure 4 shows that the performance improvements of existing text prompt tuning method CoOp and visual prompt tuning method VPT are not consistent across different datasets. In particular, CoOp obtains better performance than VPT on some datasets, such as StanfordCars and SUN397. However, for other datasets with high intra-class visual variances, VPT is much more effective than CoOp. For instance, on the EuroSAT dataset, VPT-deep beats $\mathrm { C o O p }$ by over $12 \%$ . The discrepancy of previous single-modal baselines is also consistent with our motivation in Fig. 1(d) and Fig. 1(e). According to VPT (Jia et al., 2022), VPT-deep is more effective than VPT-shallow, and our experimental results also verify this point. We later show that VPT-shallow obtains much stronger performance than the VPT-deep in the domain generalization setting (Sec. 3.2).
105
+
106
+ ![](images/7f2fe993c3668a606909d93a194552a52f5961592c7252717552ed40130576c0.jpg)
107
+ Figure 4: Main results over 11 datasets under the few-shot learning setting. We report the average accuracy $( \% )$ of 1/2/4/8/16 shots over three runs. Overall, the proposed UPT (blue line) achieves apparent improvements compared with the Zero-shot CLIP and single-modal prompt tuning baselines $\mathrm { C o O p }$ , ProDA and VPT).
108
+
109
+ UPT vs. Single-modal Baselines. Our UPT achieves clear advantages over the single-modal prompt-tuning counterparts CoOp, ProDA and VPT, as suggested by the averaged performance (topleft of Fig. 4). In general, the average performance gap between UPT and baselines increases with the shot number available for prompt tuning. Specifically, UPT obtains $0 . 4 8 / 1 . 3 6 / 1 . 2 9 / 2 . 4 6 / 3 . 1 9 ( \% )$ accuracy improvements compared with the text prompt tuning method CoOp on 1/2/4/8/16 shots settings. Even compared with the strong text prompt tuning baseline ProDA, UPT still boosts the accuracy of $0 . 1 1 / 1 . { \overset { \cdot } { 0 } } 1 / 0 . 6 7 / 1 . 5 / 1 . 6 1 ( \% )$ . Similarly, UPT achieves $0 . 8 9 / 2 . 7 0 / 2 . 0 3 / 2 . 4 0 / 2 . 0 1 ( \% )$ accuracy gains over the visual prompt tuning approach VPT-deep. Notably, UPT significantly boosts the performance over CoOp and VPT-deep on challenging large datasets, such as ImageNet with 1,000 classes and SUN397 with 397 categories. UPT also surpasses CoOp and VPT-deep on finegrained datasets such as StanfordCars and FGVC Aircraft. We also observe that UPT shows less improvement on the two datasets (OxfordPets and Food101), possibly caused by the noisy training data (Zhou et al., 2022a; Bossard et al., 2014). Overall, the experimental results in Fig. 4 demonstrate the effectiveness of our proposed UPT.
110
+
111
+ Table 1: Main results under the domain generalization setting. We report the average accuracy $( \% )$ of 16 shots over three runs. The best and second best methods are highlighted in red and orange , respectively.
112
+
113
+ <table><tr><td rowspan="2">#</td><td rowspan="2">Method</td><td>Source</td><td colspan="4">Target</td><td rowspan="2">Overall Average</td><td rowspan="2">00D Average</td></tr><tr><td>ImageNet</td><td>-V2</td><td>-S</td><td>-A</td><td>-R</td></tr><tr><td></td><td>CoOp</td><td>71.51</td><td>64.20</td><td>47.99</td><td>49.71</td><td>75.21</td><td>61.72</td><td>59.28</td></tr><tr><td></td><td>CoCoOp</td><td>71.02</td><td>64.07</td><td>48.75</td><td>50.63</td><td>76.18</td><td>62.13</td><td> 59.91</td></tr><tr><td></td><td>VPT-shallow</td><td>68.98</td><td>62.10</td><td>47.68</td><td>47.19</td><td>76.10</td><td>60.38</td><td>58.27</td></tr><tr><td>1234</td><td>VPT-deep</td><td>70.57</td><td>63.67</td><td>47.66</td><td>43.85</td><td>74.42</td><td>60.04</td><td>57.40</td></tr><tr><td>5</td><td>Joint Training</td><td>71.42</td><td>64.36</td><td>48.20</td><td>49.71</td><td>76.23</td><td>61.97</td><td>59.61</td></tr><tr><td>6</td><td>Shared</td><td>71.46</td><td>64.43</td><td>48.13</td><td>50.03</td><td>75.76</td><td>61.96</td><td>59.55</td></tr><tr><td>7</td><td>MLP</td><td>71.00</td><td>64.11</td><td>48.65</td><td>48.76</td><td>76.14</td><td>61.78</td><td>59.48</td></tr><tr><td>8</td><td>UPT</td><td>72.63</td><td>64.35</td><td>48.66</td><td>50.66</td><td>76.24</td><td>62.51</td><td> 59.98</td></tr></table>
114
+
115
+ ![](images/5b3cbe1f1b4fb1f455f9e5634a72ef4d7ac81c1eaba4befe1124729e53440768.jpg)
116
+ Figure 5: Ablation studies on different design choices. (a): jointly train the existing text and visual prompt tuning approaches; (b): shared prompts for all modalities; (c): using two MLP layers to generate the prompts.
117
+
118
+ # 3.2 DOMAIN GENERALIZATION
119
+
120
+ Pre-trained VL models like CLIP have shown strong generalization ability. However, the prompt tuned on a specific downstream dataset may hinder the generalization ability on categories outside the training set. In this section, we evaluate the generalization ability of different prompt tuning methods on out-of-distribution (OOD) data.
121
+
122
+ Datasets. We follow (Zhou et al., 2022a) to use five datasets (ImageNet (Deng et al., 2009), ImageNet V2 (Recht et al., 2019), ImageNet-Sketch (Wang et al., 2019), ImageNet-A (Hendrycks et al., 2021b) and ImageNet-R (Hendrycks et al., 2021a)) for evaluation. Following the protocol, we train a model on ImageNet and evaluate it on four other variants of ImageNet with their domains shifted.
123
+
124
+ Results. Table 1 summarizes the results. We report the average accuracy on both the source and target datasets (penultimate column), and the OOD average accuracy on target datasets (last column). The results show that VPT-shallow (row #2) achieves higher OOD accuracy than VPT-deep (row #3), and text prompt tuning methods outperform visual prompt tuning approaches. Furthermore, the proposed UPT (row #8) is generally a better option than single-modal baselines (rows #1-#4) and obtains comparable performance with CoCoOp. Our UPT achieves the best results three times on five datasets, showing that UPT is a reliable prompt tuning method among its competitors in the domain generalization setting.
125
+
126
+ # 3.3 ABLATION STUDIES
127
+
128
+ Comparison with the Joint Training Baseline. As shown in Fig. 5(a), a straightforward approach for multi-modal prompts is tune the text prompt (using CoOp) and visual prompt (using VPT) jointly.
129
+
130
+ Table 2: Ablation studies on different multi-modal prompt design choices in Fig. 5 over 11 datasets. We report the accuracy results under the 16 shots setting. The best and second best methods are highlighted in red and orange , respectively.
131
+
132
+ <table><tr><td>#</td><td>Prrega</td><td>eee</td><td>Grreeaer</td><td>s1edpitrit</td><td>ssrrprteets</td><td>Tiroeni0</td><td></td><td>FTaaeieelr [orpoon</td><td></td><td>163308</td><td></td><td>JtoSSS</td><td>UUIIII</td><td>2neace</td></tr><tr><td>1</td><td>CoOp</td><td>71.36</td><td>95.93</td><td>92.74</td><td>77.45</td><td>95.90</td><td>86.36</td><td>38.04</td><td>73.59</td><td>68.38</td><td>78.77</td><td></td><td>82.04</td><td>78.24</td></tr><tr><td>2</td><td>VPT-shallow</td><td>68.98</td><td>94.66</td><td>92.61</td><td>69.09</td><td></td><td>81.40</td><td>86.91</td><td>30.93</td><td>68.08</td><td>52.28</td><td>84.87</td><td>75.19</td><td>73.18</td></tr><tr><td>3</td><td>VPT-deep</td><td>70.57</td><td>95.83</td><td>92.91</td><td>76.13</td><td></td><td>94.96</td><td>86.18</td><td>40.96</td><td>71.63</td><td>69.79</td><td>91.53</td><td>82.76</td><td>79.39</td></tr><tr><td>4</td><td>Joint Training</td><td>71.42</td><td>95.84</td><td></td><td>93.34 79.02</td><td></td><td>95.25</td><td>86.55</td><td>40.56</td><td>74.17</td><td>67.83</td><td>78.94</td><td>82.81</td><td>78.70</td></tr><tr><td>5</td><td>Shared</td><td>71.46</td><td>95.50</td><td>92.99</td><td>78.66</td><td></td><td>95.55</td><td>86.67</td><td>39.18</td><td>73.64</td><td>67.69</td><td>73.36</td><td>82.06</td><td>77.88</td></tr><tr><td>6</td><td>MLP</td><td>71.00</td><td>95.59</td><td>93.74</td><td>75.88</td><td>93.38</td><td></td><td>87.20</td><td>37.17</td><td>72.74</td><td>67.31</td><td>90.66</td><td>81.43</td><td>78.73</td></tr><tr><td>7</td><td>UPT (Ours)</td><td>72.63 95.94</td><td></td><td>92.95</td><td></td><td>84.33 97.11</td><td></td><td>85.00</td><td>46.80</td><td>75.92 70.65</td><td></td><td>90.51</td><td>84.03 81.44</td><td></td></tr></table>
133
+
134
+ ![](images/f8905de698bb1983af8c7ec1a80c6337a8c33c12f232aa908c9d3e4c84cbcdf8.jpg)
135
+ Figure 6: Visualization of attention response map between visual prompts and image patch tokens. The images are test images from ImageNet. We visualize the self-attention module from the last block of ViT of the CLIP image encoder.
136
+
137
+ We investigate the effectiveness of such joint training scheme, and report its results in Table 2 row #4 and Table 1 row #5. On the few-shot learning setting, we see that such a joint training solution performs better than $\mathrm { C o O p }$ and VPT-shallow, which shows that multi-modal optimization is helpful to a certain extent. But the joint training approach obtains slightly worse accuracy than the VPT-deep $7 8 . 7 0 \%$ vs. $7 9 . 3 9 \%$ ) since VPT-deep involves a large number of parameters. On the domain generalization setting, we find the joint training method performs much better than VPT-deep. Also, the joint training method shows inferior performance to our UPT, demonstrating that our self-attention base mechanism is more effective.
138
+
139
+ Shared Prompts for Text and Visual Modalities. We also investigate the results of directly sharing prompts for different modalities. As shown in Fig. 5(b), the shared prompts will be optimized for both text and visual modalities. This scheme differs from the proposed UPT, where the shared prompts are transformed with self attention. Experimental results are presented in Table 2 row #5 and Table 1 row #6, and we observe that such a prompt sharing strategy achieves worst performance among all the ablation design choices.
140
+
141
+ MLP Baseline. For our proposed UPT, we use a Transformer layer with the self-attention operator to partially share the hyper-parameters for different modalities. Here, we study a simpler design that generates the unified prompts with two MLP layers. Results are presented on Table 2 row #6 and Table 1 row #7. The MLP baseline is still competitive, yielding best performance on two datasets. Nonetheless, the average results is still poorer than the proposed self-attention based approach.
142
+
143
+ # 3.4 QUALITATIVE RESULTS
144
+
145
+ While it is hard to visualize what have been learned during text prompt tuning, it is possible to visualize the visual prompts learned by VPT and UPT following the self-supervised learning method, DINO (Caron et al., 2021). In particular, for each layer of the Vision Transformer (ViT), we can compute the self-attention response map of visual prompts and image patch tokens. Figure 6 compares such response maps by VPT and the proposed UPT. We find that UPT shows stronger selfattention responses compared with VPT. This could be the possible reason why UPT achieves better performance on the few-shot learning and the OOD generalization settings.
146
+
147
+ # 4 RELATED WORK
148
+
149
+ Vision-Language Models. Recent vision-language pre-trained models (Radford et al., 2021; Jia et al., 2021) use the contrastive loss to align an image encoder (e.g., ViT (Dosovitskiy et al., 2021)) and a text encoder (e.g., BERT (Kenton & Toutanova, 2019)) in a common feature space. These vision-language models are trained on web-scale image-text pairs and are transferable across various downstream tasks such as point cloud classification (Zhang et al., 2022a), video classification (Qian et al., 2022), object detection (Gu et al., 2022; Du et al., 2022; Zhou et al., 2022c; Zang et al., 2022) and semantic segmentation (Ghiasi et al., 2021). In this work, we aim to explore how to adapt the CLIP model to the downstream few-shot recognition task.
150
+
151
+ Text Prompt Tuning. The concept of prompt tuning was first proposed in the NLP area (Liu et al., 2021; Gao et al., 2021; Li & Liang, 2021; Lester et al., 2021). In particular, a text prompt refers to a task-specific template for language models. For example, in sentiment analysis, the template might be “I [MASK] the movie.” where the mask placeholder will be filled with either “love” or “hate.” Common practices in text prompt tuning include (i) searching for a specific word in the dictionary, known as hard prompt learning (Gao et al., 2021), or (ii) turning masked tokens into learnable vectors, known as soft prompt learning (Li & Liang, 2021; Lester et al., 2021). Text prompt tuning has also been applied in computer vision after the emergence of large vision-language models (e.g., CLIP (Radford et al., 2021)), which are too big to fine-tune. A representative work is CoOp (Zhou et al., 2022a), which turned the input context tokens in CLIP’s text branch into learnable vectors for adapting CLIP to downstream image recognition. Other follow-ups of $\mathrm { C o O p }$ include CoCoOp (Zhou et al., 2022b), DualCoOp (Sun et al., 2022), ProGrad (Xing et al., 2022), and ProDA (Lu et al., 2022).
152
+
153
+ Visual Prompt Tuning. The idea of visual prompt tuning is to adapt large pre-trained Vision Transformers (Dosovitskiy et al., 2021) by adding learnable parameters in the visual input space, which is analogous to text prompt tuning in NLP. VPT (Jia et al., 2022) and Visual Prompting (Bahng et al., 2022) both add trainable tokens to the input of Transformer models. A recent work, NOAH (Zhang et al., 2022b), uses neural architecture search algorithms to identify the optimal configuration of prompt modules. In comparison to the unimodal prompt learning methods discussed above, our paper provides a timely study on how to achieve a better trade-off using multimodal prompt learning.
154
+
155
+ # 5 CONCLUSION
156
+
157
+ With the rapid scaling of vision models along the size dimension, efficient downstream adaptation methods have become essential for facilitating large-scale deployment of vision models in the wild. Our paper provides a timely and comprehensive study on how to adapt large vision-language models like CLIP from the prompt learning perspective. In particular, our study unveils that the previous unimodal prompt tuning methods do not work consistently well across different computer vision datasets. In contrast, the proposed UPT method, despite having a simple design, achieves a better trade-off compared with the unimodal counterparts. The results suggest that one should exploit correspondences between different modalities for prompt learning.
158
+
159
+ On the other hand, the results achieved by UPT are by no means perfect: in the ablation studies we observe that some alternative designs, such as using MLP instead of Transformer, might sometimes give better performance. In summary, we believe multimodal prompt learning is a promising framework, and we expect more improvements to be achieved with more advanced (and efficient) designs.
160
+
161
+ # REFERENCES
162
+
163
+ Hyojin Bahng, Ali Jahanian, Swami Sankaranarayanan, and Phillip Isola. Visual prompting: Modifying pixel space to adapt pre-trained models. arXiv preprint arXiv:2203.17274, 2022.
164
+
165
+ Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101–mining discriminative components with random forests. In ECCV, pp. 446–461. Springer, 2014.
166
+
167
+ Mathilde Caron, Hugo Touvron, Ishan Misra, Herve J ´ egou, Julien Mairal, Piotr Bojanowski, and ´ Armand Joulin. Emerging properties in self-supervised vision transformers. In ICCV, pp. 9650– 9660, 2021.
168
+
169
+ Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In CVPR, pp. 3606–3613, 2014.
170
+
171
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR, pp. 248–255. IEEE, 2009.
172
+
173
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. ICLR, 2021.
174
+
175
+ Yu Du, Fangyun Wei, Zihe Zhang, Miaojing Shi, Yue Gao, and Guoqi Li. Learning to prompt for open-vocabulary object detection with vision-language model. In CVPR, pp. 14084–14093, 2022.
176
+
177
+ 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, pp. 178–178. IEEE, 2004.
178
+
179
+ Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. In ACL, 2021.
180
+
181
+ Golnaz Ghiasi, Xiuye Gu, Yin Cui, and Tsung-Yi Lin. Open-vocabulary image segmentation. arXiv preprint arXiv:2112.12143, 2021.
182
+
183
+ Xiuye Gu, Tsung-Yi Lin, Weicheng Kuo, and Yin Cui. Open-vocabulary object detection via vision and language knowledge distillation. In ICLR, 2022.
184
+
185
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, pp. 770–778, 2016.
186
+
187
+ 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., 12(7):2217–2226, 2019.
188
+
189
+ Dan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Zhu, Samyak Parajuli, Mike Guo, et al. The many faces of robustness: A critical analysis of out-of-distribution generalization. In ICCV, pp. 8340–8349, 2021a.
190
+
191
+ Dan Hendrycks, Kevin Zhao, Steven Basart, Jacob Steinhardt, and Dawn Song. Natural adversarial examples. In CVPR, pp. 15262–15271, 2021b.
192
+
193
+ 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, pp. 4904–4916. PMLR, 2021.
194
+
195
+ Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and Ser-Nam Lim. Visual prompt tuning. arXiv preprint arXiv:2203.12119, 2022.
196
+
197
+ Chen Ju, Tengda Han, Kunhao Zheng, Ya Zhang, and Weidi Xie. Prompting visual-language models for efficient video understanding. arXiv reprint arXiv:2112.04478, 2021.
198
+
199
+ Jacob Devlin Ming-Wei Chang Kenton and Lee Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL, pp. 4171–4186, 2019.
200
+
201
+ Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In ICCV workshops, pp. 554–561, 2013.
202
+ Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In EMNLP, 2021.
203
+ Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. ACL, 2021.
204
+ Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. Pretrain, prompt, and predict: A systematic survey of prompting methods in natural language processing. arXiv preprint arXiv:2107.13586, 2021.
205
+ Yuning Lu, Jianzhuang Liu, Yonggang Zhang, Yajing Liu, and Xinmei Tian. Prompt distribution learning. In CVPR, 2022.
206
+ Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. arXiv preprint arXiv:1306.5151, 2013.
207
+ Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In ICVGIP, pp. 722–729. IEEE, 2008.
208
+ Omkar M Parkhi, Andrea Vedaldi, Andrew Zisserman, and CV Jawahar. Cats and dogs. In CVPR, pp. 3498–3505. IEEE, 2012.
209
+ 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.
210
+ 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, pp. 8748–8763. PMLR, 2021.
211
+ Benjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize to imagenet? In ICML, pp. 5389–5400. PMLR, 2019.
212
+ 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.
213
+ Ximeng Sun, Ping Hu, and Kate Saenko. Dualcoop: Fast adaptation to multi-label recognition with limited annotations. arXiv preprint arXiv:2206.09541, 2022.
214
+ Haohan Wang, Songwei Ge, Zachary Lipton, and Eric P Xing. Learning robust global representations by penalizing local predictive power. In NeurIPS, pp. 10506–10518, 2019.
215
+ Yongqin Xian, Bernt Schiele, and Zeynep Akata. Zero-shot learning-the good, the bad and the ugly. In CVPR, pp. 4582–4591, 2017.
216
+ Jianxiong Xiao, James Hays, Krista A Ehinger, Aude Oliva, and Antonio Torralba. Sun database: Large-scale scene recognition from abbey to zoo. In CVPR, pp. 3485–3492. IEEE, 2010.
217
+ Yinghui Xing, Qirui Wu, De Cheng, Shizhou Zhang, Guoqiang Liang, and Yanning Zhang. Class-aware visual prompt tuning for vision-language pre-trained model. arXiv preprint arXiv:2208.08340, 2022.
218
+ Yuan Yao, Ao Zhang, Zhengyan Zhang, Zhiyuan Liu, Tat-Seng Chua, and Maosong Sun. Cpt: Colorful prompt tuning for pre-trained vision-language models. arXiv preprint arXiv:2109.11797, 2021.
219
+ Yuhang Zang, Wei Li, Kaiyang Zhou, Chen Huang, and Chen Change Loy. Open-vocabulary detr with conditional matching. In ECCV, 2022.
220
+ Renrui Zhang, Ziyu Guo, Wei Zhang, Kunchang Li, Xupeng Miao, Bin Cui, Yu Qiao, Peng Gao, and Hongsheng Li. Pointclip: Point cloud understanding by clip. In CVPR, pp. 8552–8562, 2022a.
221
+ Yuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. Neural prompt search. arXiv preprint arXiv:2206.04673, 2022b.
222
+ Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for visionlanguage models. International Journal of Computer Vision (IJCV), 2022a.
223
+ Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Conditional prompt learning for vision-language models. In CVPR, 2022b.
224
+ Xingyi Zhou, Rohit Girdhar, Armand Joulin, Philipp Krahenb ¨ uhl, and Ishan Misra. Detecting ¨ twenty-thousand classes using image-level supervision. In ECCV, 2022c.
225
+
226
+ # Appendix
227
+
228
+ In the supplementary materials, we discuss the implementation details and more experimental results. Section A explains how we compute the intra-/inter- class variance for Fig.(1) of the main paper. Section B reports the implementation details of our paper. Section C presents more experimental results under the base-to-new generalization and cross-dataset transfer settings.
229
+
230
+ # A INTRA-/INTER- CLASS VARIANCE
231
+
232
+ In this section, we provide the implementation details about how we compute the intra-class visual variance and inter-class text variance for different datasets (Fig.1 (d)(e) in the main paper.
233
+
234
+ Intra-class Visual Variance. Given one dataset with $k$ classes in total, for each image $_ { \textbf { \em x } }$ that belongs to class $c$ , we first use the CLIP image encoder $\phi$ to extract the corresponding image feature $f _ { \phi } ( \bar { \pmb x ) }$ . Then we get the intra-class variance of class $c$ as:
235
+
236
+ $$
237
+ \mathsf { v a r } _ { c } = \frac { 1 } { \vert \vert X _ { c } \vert \vert } \sum _ { x \in X _ { c } } \left( f _ { \phi } ( \pmb { x } ) - \bar { f } _ { \phi } ( \pmb { x } ) \right) ^ { 2 } ,
238
+ $$
239
+
240
+ where $X _ { c }$ denotes to the set of images that have the ground-truth class label $c$ , and $\bar { f } _ { \phi } ( \pmb { x } )$ refers to the mean values of class $c$ . Then we can compute the intra-class variance $\operatorname { V a r } _ { \mathrm { v } }$ for all the $k$ classes as
241
+
242
+ $$
243
+ \mathrm { V a r } _ { \mathrm { v } } = { \frac { 1 } { k } } \sum _ { c = 1 } ^ { k } \mathrm { v a r } _ { c } .
244
+ $$
245
+
246
+ Inter-class Text Variance. For each dataset, we first compute the CLIP text features $\pmb { w }$ of classs $c$ , and the mean value $\bar { \pmb w }$ of all the $k$ classes. Then we get the inter-class text variance $\mathrm { V a r } _ { \mathrm { t } }$ as:
247
+
248
+ $$
249
+ \mathrm { V a r _ { t } } = { \frac { 1 } { k } } \sum _ { c = 1 } ^ { k } ( w _ { c } - { \bar { w } } ) ^ { 2 } .
250
+ $$
251
+
252
+ # B IMPLEMENTATION DETAILS
253
+
254
+ Our implementation is based on the source code of $\mathrm { C o O p }$ (Zhou et al., 2022a). We use ViT-B/16 as the CLIP backbone (Radford et al., 2021). Following (Zhou et al., 2022b), we set the context length of $\mathrm { C o O p }$ as $m = 4$ (same for VPT). For Zero-shot CLIP and VPT, we use the default prompt template, “a photo of a [CLS].” We use SGD as the optimizer, with an initial learning rate of 0.002, which is decayed by the cosine annealing rule. The batch size is set to 32 for all datasets.
255
+
256
+ # C MORE EXPERIMENTAL RESULTS
257
+
258
+ Recent work CoCoOp (Zhou et al., 2022b) points out that the text prompts learned by $\mathrm { C o O p }$ (Zhou et al., 2022a) are not generalizable to novel classes and out-of-distribution data. CoCoOp defines two new settings - base-to-new generalization and cross-dataset transfer - to measure the generalizability ability of prompt learning approaches. In this section, we provide the experimental results of our UPT in these two settings.
259
+
260
+ Datasets. We use the same 11 datasets we used in the few-shot learning setting (section 3.1 in the main paper). Following CoCoOp (Zhou et al., 2022b), we use the 16-shot protocol and report the averaged results over three runs, and set the training schedule as ten epochs. We report the accuracy on base and new classes, and the harmonic mean for base-to-novel trade-off.
261
+
262
+ # C.1 BASE-TO-NEW GENERALIZATION
263
+
264
+ In the base-to-new generalization setting, we split the classes into two disjoint groups - base classes and new classes. All the prompt learning approaches are required to train on the base classes, while evaluation is conducted on the base and new classes separately. The experimental results are shown in Table 3.
265
+
266
+ Table 3: Comparison results in the base-to-new generalization setting. H: Harmonic mean (Xian et al., 2017). The best and second best methods are highlighted in red and orange , respectively. The method ‘VPT-s’ refers to VPT-shallow.
267
+
268
+ <table><tr><td colspan="4">(a) Average over 11 datasets.</td><td colspan="4">(b) ImageNet.</td><td colspan="4">(c) Caltech101.</td></tr><tr><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>CLIP</td><td>69.34</td><td>74.22</td><td>71.70</td><td>CLIP</td><td></td><td>72.43 68.14</td><td>70.22</td><td>CLIP</td><td></td><td>96.8494.00</td><td>95.40</td></tr><tr><td>CoOp</td><td>82.69</td><td>63.22</td><td>71.66</td><td>CoOp</td><td>76.47</td><td>67.88</td><td>71.92</td><td>CoOp</td><td>98.00</td><td>89.81</td><td>93.73</td></tr><tr><td>CoCoOp</td><td>80.47</td><td>71.69</td><td>75.83</td><td>CoCoOp</td><td>75.98</td><td>70.43</td><td>73.10</td><td>CoCoOp</td><td>97.96</td><td>93.81</td><td>95.84</td></tr><tr><td>VPT-s</td><td>73.32</td><td>73.21</td><td>73.16</td><td>VPT-s</td><td>74.47</td><td>69.13</td><td>71.70</td><td>VPT-s</td><td>97.47</td><td>93.80</td><td>95.60</td></tr><tr><td> VPT-deep</td><td>75.81</td><td>72.40</td><td>73.97</td><td>VPT-deep</td><td>75.80</td><td>68.76</td><td>72.11</td><td> VPT-deep</td><td>97.50</td><td>94.10</td><td>95.77</td></tr><tr><td>UPT</td><td>76.88</td><td></td><td>75.5776.15</td><td>UPT</td><td>75.83</td><td>70.8073.23</td><td></td><td>UPT</td><td>97.70</td><td></td><td>95.6396.14</td></tr><tr><td colspan="4">(d) OxfordPets.</td><td colspan="4">(e) StanfordCars.</td><td colspan="4">(f) Flowers102.</td></tr><tr><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>CLIP</td><td>91.17</td><td>97.26</td><td>94.12</td><td>CLIP</td><td>63.37</td><td>74.89</td><td>68.65</td><td>CLIP</td><td>72.08</td><td>77.80</td><td>74.83</td></tr><tr><td>CoOp CoCoOp</td><td>93.67</td><td>95.29</td><td>94.47</td><td>CoOp</td><td>78.12</td><td>60.40</td><td>68.13</td><td>CoOp</td><td>97.60</td><td>59.67</td><td>74.06</td></tr><tr><td>VPT-s</td><td>95.20</td><td>97.69</td><td>96.43</td><td>CoCoOp</td><td>70.49</td><td>73.59</td><td>72.01</td><td>CoCoOp</td><td>94.87</td><td>71.75</td><td>81.71</td></tr><tr><td></td><td>93.90</td><td>96.87</td><td>95.36</td><td>VPT-s</td><td>66.00</td><td>74.23</td><td>69.88</td><td>VPT-s</td><td>75.83</td><td>75.73</td><td>75.78</td></tr><tr><td>VPT-deep</td><td>94.33 95.50</td><td></td><td>94.91</td><td>VPT-deep</td><td>69.23</td><td>74.03</td><td>71.55</td><td>VPT-deep</td><td>83.63</td><td>70.50</td><td>76.50</td></tr><tr><td>UPT</td><td colspan="3">96.07 97.6096.32</td><td>UPT</td><td>68.5075.37</td><td></td><td>71.77</td><td>UPT</td><td>85.00</td><td></td><td>77.3380.99</td></tr><tr><td></td><td colspan="3">(g) Food101.</td><td></td><td>(h) FGVCAircraft.</td><td></td><td></td><td></td><td>(i) SUN397.</td><td></td><td></td></tr><tr><td></td><td colspan="3">Base New</td><td>H</td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>CLIP CoOp</td><td>90.10</td><td>91.22</td><td>90.66</td><td>CLIP</td><td>27.19</td><td>36.29</td><td>31.09</td><td>CLIP</td><td>69.36</td><td>75.35</td><td>72.23</td></tr><tr><td>CoCoOp</td><td>88.33</td><td>82.26</td><td>85.19</td><td>CoOp</td><td>40.44</td><td>22.30</td><td>28.75</td><td>CoOp</td><td>80.60</td><td>65.89</td><td>72.51</td></tr><tr><td>VPT-s</td><td>90.70</td><td>91.29</td><td>90.99</td><td>CoCoOp</td><td>33.41</td><td>23.71</td><td>27.74</td><td>CoCoOp</td><td>79.74</td><td>76.86</td><td>78.27</td></tr><tr><td></td><td>90.17</td><td>90.97</td><td>90.56</td><td>VPT-s</td><td>30.83</td><td>35.17</td><td>32.86</td><td>VPT-s</td><td>75.40</td><td>77.27</td><td>76.32</td></tr><tr><td>VPT-deep</td><td>90.20 91.17</td><td></td><td>90.68</td><td>VPT-deep</td><td>33.40</td><td>35.17</td><td>34.26</td><td>VPT-deep</td><td>78.23 76.63</td><td></td><td>77.43</td></tr><tr><td>UPT</td><td colspan="3">90.72 92.0091.35</td><td>UPT</td><td>32.76</td><td>36.10</td><td>34.53</td><td>UPT</td><td>78.90</td><td></td><td>78.5678.73</td></tr><tr><td></td><td colspan="3">() DTD.</td><td></td><td>(k) EuroSAT.</td><td></td><td></td><td></td><td>(l) UCF101.</td><td></td><td></td></tr><tr><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>CLIP CoOp</td><td>53.24</td><td>59.90</td><td>56.37</td><td>CLIP</td><td>56.48</td><td>64.05</td><td>60.03</td><td>CLIP</td><td>70.53</td><td>77.50</td><td>73.85</td></tr><tr><td>CoCoOp</td><td>79.44</td><td>41.18</td><td>54.24</td><td>CoOp</td><td>92.19</td><td>54.74</td><td>68.69</td><td>CoOp</td><td>84.69</td><td>56.05</td><td>67.46</td></tr><tr><td>VPT-s</td><td>77.01</td><td>56.00</td><td>64.85</td><td>CoCoOp</td><td>87.49</td><td>60.04</td><td>71.21</td><td>CoCoOp</td><td>82.33</td><td>73.45</td><td>77.64</td></tr><tr><td>VPT-deep</td><td>55.27</td><td>57.16</td><td>56.20</td><td>VPT-s</td><td>71.67</td><td>58.87</td><td>64.64</td><td>VPT-s</td><td>75.60</td><td>76.10</td><td>75.85</td></tr><tr><td></td><td>64.87</td><td>55.40</td><td>59.76</td><td>VPT-deep</td><td>66.70</td><td>60.67</td><td>63.54</td><td> VPT-deep</td><td>80.07</td><td>74.50</td><td>77.18</td></tr><tr><td>UPT</td><td colspan="3">69.53 62.1365.63</td><td>UPT</td><td>73.57</td><td></td><td>70.4371.96</td><td>UPT</td><td>78.10</td><td></td><td>76.3377.21</td></tr></table>
269
+
270
+ Single-modal Baselines. We observe that previous single-modal baselines perform dramatically different on the base and new splits. In particular, the text prompt tuning method CoOp achieves the highest performance on base classes and poor performance on new classes. On the contrary, visual prompt tuning approaches VPT-shallow and VPT-deep obtain high accuracy on base classes, but low accuracy on new classes. Such results show the intrinsic discrepancy between single-modal text and visual prompt tuning methods. CoOp optimizes specifically for base classes but at the expense of generalization ability on new classes. The advanced text prompt tuning approach CoCoOp with the input-conditional design achieves the best base and new trade-off among the single-modal baselines.
271
+
272
+ Strong Generalizability of UPT. As shown in Table 3, UPT is more generalizable than baseline methods when taking into account both the base and new classes. As for base classes, UPT is better than VPT but worse than $\mathrm { C o O p }$ . This is reasonable because UPT are jointly optimized on the text and visual modalities, and the visual modality branch is not specifically for base classes. For new classes, UPT has significantly improved performance. For instance, UPT obtains $+ 1 2 . 3 5 / + 2 . 3 6 / + 3 . 1 7$ gains for CoOp/VPT-shallow/VPT-deep. UPT even achieves $+ 1 . 3 5$ gains on new classes compared with the CLIP baseline without prompt learning. In summary, the experimental results under the base-to-new generalization setting show strong generalizability of UPT.
273
+
274
+ Table 4: Comparison results in the cross-dataset transfer setting. Prompts applied to the 10 target datasets are learned from source ImageNet dataset. The best and second best methods are highlighted in red and orange , respectively.
275
+
276
+ <table><tr><td></td><td>Source</td><td colspan="10">Target</td></tr><tr><td></td><td>1enege</td><td>CErleeaer</td><td>DPPpprtet</td><td>srsrrretttes</td><td>TiroinG</td><td>JorPoon</td><td>FrTeiettt</td><td>160308</td><td>CII</td><td>JItoII</td><td>UUUIII</td><td>aneace</td></tr><tr><td>CoOp CoCoOp</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></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>VPT-shallow</td><td>68.98</td><td>93.07</td><td>89.63</td><td>63.63</td><td>70.50</td><td>85.03</td><td>24.01</td><td>66.30</td><td>45.13</td><td>45.56</td><td>66.80</td><td>65.33</td></tr><tr><td>VPT-deep</td><td>70.57</td><td>90.33</td><td>88.50</td><td>57.87</td><td>63.83</td><td>76.90</td><td>21.93</td><td>63.10</td><td>42.13</td><td>40.63</td><td>64.53</td><td>61.85</td></tr><tr><td>UPT</td><td>70.86</td><td>93.31</td><td></td><td></td><td></td><td>90.57 65.3372.33 86.17</td><td>24.57</td><td>67.66</td><td>45.67</td><td>44.94</td><td></td><td>68.23 65.85</td></tr></table>
277
+
278
+ # C.2 CROSS-DATASET TRANSFER
279
+
280
+ In the cross-dataset transfer setting, prompts learned from ImageNet are applied to ten other target datasets to evaluate the generalizability. The detailed results are presented in Table 4. We find VPT-shallow achieves higher accuracy than VPT-deep, and the text prompt tuning method CoCoOp outperforms visual prompt tuning approaches. On the source dataset, UPT obtains better performance than VPT but worse than CoOp. On target datasets, UPT obtains the best performance on six out of ten. The results on the cross-dataset transfer setting also verify that our proposed UPT is more generalizable than single-modal baselines.
md/dev/1W0z96MFEoH/1W0z96MFEoH.md ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BENCHMARKING THE SPECTRUM OF AGENT CAPABILITIES
2
+
3
+ # Danijar Hafner
4
+
5
+ Google Research, Brain Team University of Toronto mail@danijar.com
6
+
7
+ # ABSTRACT
8
+
9
+ Evaluating the general abilities of intelligent agents requires complex simulation environments. Existing benchmarks typically evaluate only one narrow task per environment, requiring researchers to perform expensive training runs on many different environments. We introduce Crafter, an open world survival game with visual inputs that evaluates a wide range of general abilities within a single environment. Agents either learn from the provided reward signal or through intrinsic objectives and are evaluated by semantically meaningful achievements that can be unlocked during each episode, such as discovering resources and crafting tools. Consistently unlocking all achievements requires strong generalization, deep exploration, and long-term reasoning. We experimentally verify that Crafter is of appropriate difficulty to drive future research and provide baselines scores of reward agents and unsupervised agents. Furthermore, we observe sophisticated behaviors emerging from maximizing the reward signal, such as building tunnel systems, bridges, houses, and plantations. We hope that Crafter will accelerate research progress by quickly evaluating a wide spectrum of abilities.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Crafter is an open world survival game for reinforcement learning research. Shown in Figure 1, Crafter features randomly generated 2D worlds with forests, lakes, mountains, and caves. The player needs to forage for food and water, find shelter to sleep, defend against monsters, collect materials, and build tools. The game mechanics are inspired by the popular game Minecraft and were simplified and optimized for research productivity. Crafter aims to be a fruitful benchmark for reinforcement learning by focusing on the following design goals:
14
+
15
+ Research challenges Crafter poses substantial challenges to current methods. Procedural generation requires strong generalization, the technology tree evaluates wide and deep exploration, image observations calls for representation learning, repeated subtasks and sparse rewards evaluate long-term reasoning and credit assignment.
16
+
17
+ Meaningful evaluation Agents are evaluated by a range of achievements that can be unlocked in each episode. The achievements correspond to meaningful milestones in behavior, offering insights into ability spectrum of both reward agents and unsupervised agents.
18
+
19
+ Iteration speed Crafter evaluates many agent abilities within a single environment, vastly reducing the computational requirements over benchmarks suites that require training on many separate environments from scratch, while making it more likely that the measured performance is representative of new domains.
20
+
21
+ ![](images/927083a984075d7f618fcdcdfd9c0e2627a41223e2bbb0f4e892d8cd75b47a70.jpg)
22
+ Figure 1: Agent view of a procedurally generated world in Crafter, showing terrain types, resources, and creatures. Agents learn from image inputs and aim to unlock a range of semantically meaningful achievements during each episode. The achievements evaluate strong generalization, wide and deep exploration, and long-term reasoning.
23
+
24
+ ![](images/4ff4aac35ce68fcec48907c7d4ec4e105662b82d357033b534ebdbc6dea74b40.jpg)
25
+ Figure 2: Play Crafter yourself through the human interface.
26
+
27
+ # 2 RELATED WORK
28
+
29
+ Benchmarks have been a driving force behind the progress and successes of reinforcement learning as a field (Bellemare et al., 2013; Brockman et al., 2016; Kempka et al., 2016; Beattie et al., 2016; Tassa et al., 2018; Juliani et al., 2018). Benchmarks often require a large amount of computational resources and yet only test a small fraction of the abilities that a general agent should master (Cobbe et al., 2020). This section directly compares Crafter to four particularly related benchmarks.
30
+
31
+ Minecraft Crafter is inspired by the successful 3D video game Minecraft, which is available to researchers via Malmo (Johnson et al., 2016) and MineRL (Guss et al., 2019). Minecraft features diverse open worlds with randomly generated and modifiable terrain, as well as many different resources, tools, and monsters. However, Minecraft is too complex to be solved by current methods (Milani et al., 2020), it is unclear by what metric agents should be evaluated by, the environment is slow, and can be difficult to use because it requires Java and a window server. In comparison, Crafter captures many principles of Minecraft in a simple and fast environment, where results can be obtained in a matter of hours, and where a large number of semantically meaningful evaluation metrics are available for reinforcement learning with or without extrinsic reward. The goal of Crafter is not to replace Minecraft but progress faster towards it.
32
+
33
+ Atari The Atari Learning Environment (Bellemare et al., 2013) has been the gold standard benchmark in reinforcement learning. It comprises around 54 individual games, depending on the evaluation protocol (Mnih et al., 2015; Schulman et al., 2017; Badia et al., 2020; Hafner et al., 2020). While the large number of games tests different abilities of agents, they require a large amount of computation. The recommended protocol of training the agent with 5 random seeds on each game for 200M steps requires over 2000 GPU days (Castro et al., 2018; Hessel et al., 2018). This substantially slows down experimentation and makes the complete benchmark infeasible for most academic labs. Moreover, Atari games are nearly deterministic, so agents can approximately memorize their action sequences and are not required to generalize to new situations (Machado et al., 2018).
34
+
35
+ ProcGen ProcGen (Cobbe et al., 2020) provides a benchmark that is similar to Atari but explicitly addresses the determinism present in Atari through the use of procedural generation and randomized textures. It consists of 16 games, where each episode features a randomly generated level layout. Similarly, Crafter relies on procedural generation to provide a different world map with different distribution of resources and monsters for every episode. However, ProcGen still requires training methods on 16 individual games for 200M environment steps, which each focus on a narrow aspect of an agent’s general abilities. In comparison, Crafter evaluates many different abilities of an agent by training only on a single environment for 5M steps, substantially accelerating experimentation.
36
+
37
+ NetHack NetHack (Küttler et al., 2020) is a text-based game, where the player traverses a randomly generated system of dungeons with many different items and creatures. Unlike the other discussed environments, NetHack uses symbolic inputs and thus does not evaluate an agent’s ability to learn representations of high-dimensional inputs. The game is challenging due to the large amount of knowledge required about the many different items and their effects, even for human players. As a result, NetHack requires many environment steps for agents to acquire this domain-specific knowledge; 1B steps were used in the original paper. In contrast, Crafter generates diverse complex worlds from simple underlying rules, focusing more on generalization than memorization of facts.
38
+
39
+ # 3 CRAFTER BENCHMARK
40
+
41
+ We introduce Crafter, a benchmark that evaluates a variety of agent abilities in a single environment. This section describes the game mechanics of the environment, the interface of agent inputs and actions, the evaluation protocol that is based on a range of semantically meaningful achievements, and the open challenges that Crafter poses for future research.
42
+
43
+ ![](images/427b06e7de5d61130b9b23d25f5e328a4c7a56adcafda3ff8cce2bce7ef89914.jpg)
44
+ Figure 3: Crafter procedurally generates a unique world for every episode that features several terrain types: grasslands, forests, lakes, mountains, caves. Memorizing action sequences is thus not a viable strategy and agents are forced to learn behaviors that generalize to new situations.
45
+
46
+ # 3.1 GAME MECHANICS
47
+
48
+ This section describes the game mechanics of Crafter, namely its randomly generated world maps, the levels of health and other internal quantities that the player has to maintain, the resources it can collect and objects and tools it can make from them, as well as the creatures and how they are influenced by the time of day. The images of all materials and objects are shown in Figure E.1. All randomness in the environment is uniquely determined by an integer seed that is derived from the initial seed passed to the environment and the episode number.
49
+
50
+ Terrain generation A unique world is generated for every episode, shown in Figure 3. The world leverages an underlying grid of $6 4 \times 6 4$ cells but the agent only observes the world through pixel images. The terrain features grasslands, lakes, and mountains. Lakes can have shores, grasslands can have forests, and mountains can have caves, ores, and lava. These are determined by OpenSimplex noise (Spencer, 2014), a form of locally smooth noise. Within the areas determined by noise, objects appear with equal probability at any location, such as trees in forests and skeletons in caves.
51
+
52
+ Health and survival The player has levels of health, food, water, and rest that it must prevent from reaching zero. The levels for food, water, and rest decrease over time and are restored by drinking from a lake, chasing cows or growing fruits to eat, and sleeping in places where monsters cannot attack. Once one of the three levels reaches zero, the player starts losing health points. It can also lose health points when attacked by monsters. When the health points reach zero, the player dies. Health points regenerate over time when the player is not hungry, thirsty, or sleepy.
53
+
54
+ Resources and crafting There are many resources, such as saplings, wood, stone, coal, iron, and diamonds, the player can collect in its inventory and use to build tools and place objects in the world. Many of the resources require tools that the place must first build from more basic resources, leading to a technology tree with several levels. Standing nearby a table enables the player to craft wood pickaxes and swords, as well as stone pickaxes and stone swords. Crafting a furnace from stone enables crafting iron pickaxes and iron swords from both iron, coal, and wood.
55
+
56
+ Creatures and night Creatures are initialized in random locations and move randomly. Zombies and cows live in grasslands and are automatically spawned and despawned to ensure a given amount of creatures. At night, the agent’s view is restricted and noisy and a larger number of zombies is spawned. This makes it difficult to survive without securing a shelter, such as a cave. Skeletons live in caves and try to keep the player at a distance to shoot arrows at the player. The player can interact with creatures to decrease their health points. Cows move randomly and offer a food source.
57
+
58
+ # 3.2 ENVIRONMENT INTERFACE
59
+
60
+ This section defines the specification of the environment, explains the available actions, agent inputs, episode termination, and additional information provided by the environment. The design goal of these is to make the environment easy to use and inspect. The environment uses the Gym interface (Brockman et al., 2016) with visual agent inputs and flat categorical actions.
61
+
62
+ ![](images/963f582bd37aa5dd9aa4ebdcb613e4e02e884f41702752f577e51296fcb57fba.jpg)
63
+ Figure 4: The 22 achievements that can be unlocked within each episode. The arrows indicate which achievements will be completed along the way of working toward more challenging achievements. Several of the earlier tasks have to be repeated multiple times, such as collecting resources, to progress further. A reward is only given when an achievement is unlocked for the first time during the episode.
64
+
65
+ Observations Agent receive color images of size $6 4 \times 6 4 \times 3$ as their only inputs. The image shows a local top-down view of the map, reaching 4 cells west and east and 3 cells north and south of the player position. Below this view of the world, the image shows the current inventory state of the player, including its health points, food, water, and rest levels, collected materials, and crafted tools. The agent needs to learn to read its inventory state out of the image.
66
+
67
+ Actions The action space is a flat categorical space with 17 actions, represented by integer indices. The actions allow the player to move in all 4 directions along the grid, interact with the object in front of it, go to sleep, place objects, and make tools. Each object and tool has a separate action associated with it. Tools are kept in the inventory whereas objects are automatically placed in front of the player. If the agent does not hold the required materials for making an object or tool, the action has no effect.
68
+
69
+ Termination Each episode terminates when the player’s health points reach 0. This can happen when the player dies out of hunger, thirst, or tiredness, when attacked by a zombie or skeleton, or when falling into lava. Health points automatically regenerate, as long as the agent is not too hungry, thirsty, or sleepy. There is no negative reward for dying, as the reward signal already includes a penalty for losing health points. Episodes also end when reaching the time limit of 10,000 steps.
70
+
71
+ Additional information The environment allows access to privileged information about the world state that the agent is forbidden to observe. This includes numeric inventory counts, achievement counts, the current coordinate of the player on the grid, and a semantic grid representation of the map. These can be used for debugging purposes or for other research scenarios, such as predicting the underlying environment state to evaluate representation learning or video prediction models.
72
+
73
+ # 3.3 EVALUATION PROTOCOL
74
+
75
+ To evaluate the diverse abilities of artificial agents on Crafter, we define two benchmarks. The first benchmark allows agents to access a provided reward signal, while the second benchmark does not and requires agents to purely learn from intrinsic objectives. Besides access to the provided reward signal, the evaluation protocols are identical. An agent is granted a budget of 1M environment steps to interact with the environment. The agent performance is evaluated through success rates of the individual achievements throughout its training, as well as an aggregated score.
76
+
77
+ Achievements To evaluate a wide spectrum of agent abilities, Crafter defines 22 achievements. The achievements are shown in Figure 4 and correspond to semantically meaningful behaviors, such as collecting various resources, building objects and tools, finding food and water, defeating monsters, and waking up safely after sleeping. The achievements cover a wide range of difficulties, making them suitable to evaluate both weak and strong players and providing continuous feedback throughout the development process of new methods. Some achievements are independent of each other to test for breadth of exploration, while others depend on each other to test for deep exploration.
78
+
79
+ Reward Crafter provides a sparse reward signal that is the sum of two components. The main component is a reward of $+ 1$ every time the agent unlocks each achievement for the first time during the current episode. The second component is a reward of $- 0 . 1$ for every health point lost and a reward of $+ 0 . 1$ for every health point that is regenerated. Because the maximum number of health points is 9, the second reward component only affects the first decimal of the episode return, and ceiling the episode return yields the number of achievements unlocked during the episode.
80
+
81
+ Success rates The success rates offer insights into the breadth of abilities learned by an agent. The success rates are computed separately for each of the achievements, as the fraction of training episodes during which the agent has unlocked the achievement at least once. It is computed across all episodes that lead up to the budget of 1M environment steps, requiring agents to be data-efficient.1 Note that the number of environment steps is fixed but the number of episodes can differ between agents. Unlocking an achievement more than once per episode does not affect the success rate.
82
+
83
+ Score The score summarizes the agent abilities into a single number. It is computed by aggregating the success rates for the individual achievements. Unlocking difficult achievements, even if it happens rarely, should contribute more than increasing the success rate of achievements that are already unlocked frequently even further. To account for the range of difficulties of the achievements, we average the success rates in log-space, known as the geometric mean.2 Unlike the reward, the score thus takes the achievement’s difficulties into account, without having to know them beforehand.
84
+
85
+ Discussion Aggregating across tasks via a geometric mean weighs tasks based on their difficulty to the agent, resulting in higher scores for agents that explore more broadly. For example, collecting a diamond $1 \%$ of the time instead of $0 \%$ is a meaningful improvement, whereas collecting wood $9 5 \%$ of the time instead of $90 \%$ is not. This allows distinguishing how broadly agents have explored their environment even if they achieve similar rewards. The geometric mean also establishes a meaningful metric for unsupervised agents, which may get bored of tasks after performing them a few times and then move on to new tasks. A caveat of the geometric mean is that agents with rewards are evaluated by something they only indirectly optimize for, which can change their ranking order. Increasing reward and score is generally correlated, but capacity-limited agents may choose to optimize reward by mastering easy tasks and ignoring hard tasks, which only slowly increases the geometric mean.
86
+
87
+ # 3.4 RESEARCH CHALLENGES
88
+
89
+ Crafter aims to evaluate a diverse range of agent abilities within a single environment. Thus, if a method performs well on Crafter there should be a high chance that it also handles the challenges of other environments. The challenges also make Crafter suitable for evaluating progress on open research questions, such as strong generalization, wide and deep exploration, discovering reusable skills, and long-term memory and reasoning. Crafter is designed to pose the following challenges:
90
+
91
+ Exploration Independent achievements evaluate wide exploration, without offering a linear path for the agent to follow. Dependent achievements evaluate deep exploration of the technology tree. Collecting a diamond requires an iron pickaxe, which in turn requires a furnace, table, coal, iron, and wood. The furnace requires collecting stone, which requires building a wood pickaxe at a table.
92
+
93
+ Generalization Every episode is situated in a unique world that is procedurally generated. Moreover, many aspects of the game reoccur in different contexts, such as creatures and resources that can be found in different landscapes and times of day. This forces successful agents to recognize similar situations in different circumstances and be robust to changes in irrelevant details.
94
+
95
+ ![](images/07995ac8b8af22f31c0b8ac4cad048aa54297cdbb8fd679443eed524925b0785.jpg)
96
+ Figure 5: Crafter Benchmark Scores for various agents with and without rewards. Current top methods achieve scores of up to $10 \%$ that are far from the $50 \%$ of human experts, posing a substantial challenge for future research. Crafter scores are computed as the geometric mean across achievements of their success rates within the budget of 1M environment steps. Numbers in Table 1.
97
+
98
+ Reusable skills Advancing in the game requires the agent to repeat several behaviors over long horizons, such as finding food, defending against monsters, and collecting common materials that are needed many times. The behavior of a successful agent naturally decomposes into sub-tasks, making Crafter suitable for studying hierarchical reinforcement learning.
99
+
100
+ Credit assignment Only sparse rewards are given for unlocking an achievement for the first time during each episode. Moreover, several achievements require long-term reasoning, such as collecting the necessary resources for crafting a particular tool or planting saplings that can be harvested many hundred time steps later. This makes Crafter a challenge for temporal credit assignment.
101
+
102
+ Memory The agent inputs only show the player’s immediate surroundings, making Crafter partially observed. To survive for a long time, agents need to remember where to find lakes to drink and open grasslands to hunt. Moreover, to effectively find rare resources, such as iron and diamonds, the agent needs to remember what parts of the map it has already searched.
103
+
104
+ Representation The agent observes its environment via high-dimensional images, from which it has to extract entities that are meaningful for decision making. Similar to applications in the real world, the reward signal is sparse and the amount of environment interaction limited. As a result, successful agents will likely rely on explicit representation learning techniques.
105
+
106
+ Survival In previous environments, the player can often survive by doing nothing. This allows for degenerate solutions to intrinsic objectives, unlike the real world where animals are forced to adapt to survive and maintain homeostasis and allostasis. In Crafter, the player struggles to survive through the constant pressure of maintaining enough water, food, rest, and defending against zombies.
107
+
108
+ <table><tr><td>Method</td><td>Score (%)</td><td>Return</td></tr><tr><td>Human Experts</td><td>50.5±6.8</td><td>14.3±2.3</td></tr><tr><td>DreamerV2</td><td>10.0±1.2</td><td>9.0±1.7</td></tr><tr><td>PPO</td><td>4.6±0.3</td><td>4.2±1.2</td></tr><tr><td>Rainbow</td><td>4.3±0.2</td><td>5.0±1.3</td></tr><tr><td>Plan2Explore (Unsup)</td><td>2.1±0.1</td><td>2.1±1.5</td></tr><tr><td>RND (Unsup)</td><td>2.0±0.1</td><td>0.7±1.3</td></tr><tr><td>Random</td><td>1.6±0.0</td><td>2.1±1.3</td></tr></table>
109
+
110
+ Table 1: Crafter benchmark scores. The Crafter score is computed as the geometric mean of success rates for all 22 achievements available in the environment. The score prefers general agents that unlock a wide range of achievements over those that unlock a small number of achievements very frequently. For example, an agent that explores many different achievements over the course of training achieves a higher score than one that only performs same simple tasks over an over. The score thus establishes a meaningful metric both for agents with and without reward.
111
+
112
+ ![](images/afbd1f04deffd2ccdfcebecd668b62d441d5ed684c326b9a42c003932a5d2fd6.jpg)
113
+ Figure 6: Agent ability spectrum showing the success rates of agents with rewards. These are unlocking percentages for all 22 achievements, computed over all training episodes. Rainbow manages to drink water and forage for food. PPO additionally rarely collects coal and builds stone tools. DreamerV2 achieves these more frequently and additionally sometimes grows and eats fruits. Numbers in Appendix A.
114
+
115
+ # 4 EXPERIMENTS
116
+
117
+ To established baselines for future work, we train various reinforcement learning methods on Crafter either with and without rewards. The two benchmarks follow the evaluation protocol in Section 3.3, which grants each agent a budget of 1M environment frames and computes the success rates of the individual achievements across all training episodes, as well as an aggregate score for the agent. Furthermore, we analyze the emergent agent behaviors qualitatively and record a dataset of human expert players to estimate the difficulty of the environment. The environment, code for the baseline agents and figures in this paper, and the human dataset are available on the project website. 3
118
+
119
+ # 4.1 BENCHMARK WITH REWARDS
120
+
121
+ We provide baselines scores for three reinforcement learning algorithms on Crafter with rewards. DreamerV2 (Hafner et al., 2020) learns a world model and optimizes a policy through planning in latent space. We used its default hyper parameters for Atari and increased the model size. PPO (Schulman et al., 2017) is a popular method that learns to map input images to actions through policy gradients. We use a convolutional neural network policy with hyper parameters that were tuned for Atari (Hill et al., 2018). Rainbow (Hessel et al., 2018) is based on Q-Learning and combines several advances, including for exploration. The defaults for Atari did not work well, so we tuned the hyper parameters for Crafter and found a compromise between Atari defaults and the data-efficient version of the method (van Hasselt et al., 2019) to be ideal. All agents trained for 1M environment steps in under 24 hours on a single GPU and we repeated the training for 10 random seeds per method. The training reward curves are included in Appendix D.
122
+
123
+ The scores are listed in Table 1 and visualized in Figure 5. DreamerV2 achieves a score of $1 0 . 0 \%$ , followed by PPO with $4 . 6 \%$ and Rainbow of $4 . 3 \%$ . Despite these being top reinforcement learning methods, they lack behind the score of expert human players of $5 0 . 5 \%$ , which we describe in further detail in Section 4.3. We conclude that Crafter is a challenging benchmark, where current methods make learning progress but future research is needed to achieve high performance. For comparison, we report the episode returns in Table 1, computed over the episodes within the last $1 0 ^ { 5 }$ environment steps of training. We find a trend similar to the scores but notice that the methods are harder to tell apart, because differences on hard tasks that are rarely achieved affect the return less. Moreover, the scores are more meaningful for unsupervised agents, which should explore many achievements over time, but not necessarily remain interested in them until the end of training. The success rates for individual achievements are visualized in Figure 7, which offer insights into the breadth and depth of agent abilities. Rainbow displays high success rates on easier achievements. PPO learned to additionally make stone tools and furnaces. DreamerV2 achieved these more frequently and discovered growing and harvesting plants. None of the agents learned to collect and use iron for tools or to collect diamonds, or to achieve high success rates on many of the achievements.
124
+
125
+ ![](images/8317bb62cc63fd883c757ada4f4b08f83669a451ab64b8b482bcd7ae2d0299cf.jpg)
126
+ Figure 7: Agent ability spectrum showing the success rates for Crafter without rewards. Random actions unlock the 6 easiest achievements sometimes, such as drinking water and collecting wood. Plan2Explore forages for food and defeats monsters more frequently, to ensure longer survival. RND additionally collects stones and rarely even collects coal and builds furnaces. Numbers in Appendix B.
127
+
128
+ # 4.2 UNSUPERVISED BENCHMARK
129
+
130
+ We provide baselines scores for two unsupervised reinforcement learning agents on Crafter without rewards. We also include a baseline that simply chooses random actions. RND (Burda et al., 2018b) is a popular exploration method that seeks out novel inputs, estimated as the prediction error of a network that aims to predict fixed random embeddings of the input images. We use its default parameters for Atari. Plan2Explore (Sekar et al., 2020) learns a world model to plan for the expected information gain of imagined trajectories, allowing it to directly seek out imagined states that have not been experienced before. We implement Plan2Explore on top of DreamerV2 and keep the same hyper parameters. We use a non-episodic value function as RND does, which helps exploration in episodic environments (Burda et al., 2018b). All agents trained for 1M environment steps in under 24 hours on a single GPU and we repeated the training for 10 random seeds per method.
131
+
132
+ The scores are listed in Table 1 and in Figure 5. Plan2Explore achieves a score of $2 . 1 \%$ , followed by RND at $2 . 0 \%$ , both ahead of the random agent at $1 . 6 \%$ . Despite these being top unsupervised reinforcement learning methods, they lack far behind optimal performance or even the performance of agents that learn with rewards, posing a substantial challenge for future research. The results are encouraging, showing that unsupervised objectives by themselves can lead to meaningful behaviors (Burda et al., 2018a) in Crafter. Inspecting the success rates for individual achievements in Figure 6 confirms that Plan2Explore and RND make progress in exploring the different behaviors compared to the random agent, including occasionally collecting coal, placing furnaces, and making stone swords, which are several steps deep into the technology tree.
133
+
134
+ # 4.3 EMERGENT BEHAVIORS
135
+
136
+ To better understand the potential of the environment, we train DreamerV2 for 50M steps and investigate the behaviors qualitatively. In this amount of time, the agent learns to build stone tools and even iron tools on individual occurrences. Interestingly, we observe a range of sophisticated emergent behaviors, such as building tunnel systems, building bridges to cross lakes, and outsmarting skeletons by dodging arrows, blocking arrows with stones, and digging through walls to surprise skeletons from the side. Furthermore, DreamerV2 learns to seek shelter to protect itself from the zombies at night by hiding in caves and even digging its own caves and closing the entrances with stones. Finally, we find that the agent sometimes manages to build plantations of many saplings, defends them against monsters, and eats the growing fruits in order to ensure a reliable and steady food supply. A video of the emergent behaviors is available on the project website.
137
+
138
+ # 4.4 HUMAN EXPERTS DATASET
139
+
140
+ Crafter includes a graphical user interface that allows humans to play the game via the keyboard and record the trajectories of the game. The human interface can be installed via the command shown in Figure 2. Through the human interface, we recorded the games of 5 human experts for a combined total of 100 episodes. The experts were given the instructions of the game and allowed several hours of practice. Out of the 100 episodes, 5 episodes unlock all 22 achievements. The human experts achieved a score of $5 0 . 5 \%$ , unlocking all achievements as shown in Table C.1. The achievements most difficult to humans were to collect diamonds and grow and harvest plans, with success rates of $12 \%$ and $8 \%$ , respectively. While the human dataset is separate from the Crafter benchmark, it provides an estimate of human performance and can be used for research on learning from demonstrations and imitation learning. The human dataset is available on the project website.
141
+
142
+ # 5 DISCUSSION
143
+
144
+ Future work We selected the difficulty of Crafter to be challenging yet not hopeless for current methods. As research progresses towards solving the challenges that are currently present, it may become necessary to extend Crafter by new enemies, resources, items, and achievements. Being written purely in Python, Crafter can easily be extended in this way. Moreover, grouping the 22 achievements into categories, such as memory, generalization, and exploration, would allow us to summarize agent abilities more abstractly (Osband et al., 2019). We did not attempt such a categorization because it is subjective and will become clearer as more researchers use the environment.
145
+
146
+ Summary We introduced Crafter, a benchmark with visual inputs that evaluates a variety of general agent abilities in a single environment. We described the game mechanics, evaluation protocol, and open challenges posed by the benchmark, and performed experiments with several agents with and without rewards to provide baseline scores. Agents are evaluated based on how frequently they manage to unlock achievements that correspond to semantically meaningful milestones of behavior. We conclude that Crafter is well suited and of appropriate difficulty to guide future research on intelligent agents, both for learning from extrinsic rewards and purely from intrinsic objectives.
147
+
148
+ Acknowledgements We would like to thank Oleh Rybkin, Ben Eysenbach, Sherjil Ozair, Julius Kunze, Feryal Behbahani, Timothy Lillicrap, Jimmy Ba, Nicolas Heess, Kory Mathewson, Mohammad Norouzi, Hamza Merzic, and Sergey Levine for discussions and feedback.
149
+
150
+ # REFERENCES
151
+
152
+ Adrià Puigdomènech Badia, Bilal Piot, Steven Kapturowski, Pablo Sprechmann, Alex Vitvitskyi, Zhaohan Daniel Guo, and Charles Blundell. Agent57: Outperforming the atari human benchmark. In International Conference on Machine Learning, pp. 507–517. PMLR, 2020.
153
+
154
+ Charles Beattie, Joel Z Leibo, Denis Teplyashin, Tom Ward, Marcus Wainwright, Heinrich Küttler, Andrew Lefrancq, Simon Green, Víctor Valdés, Amir Sadik, et al. Deepmind lab. arXiv preprint arXiv:1612.03801, 2016.
155
+
156
+ Marc G Bellemare, Yavar Naddaf, Joel Veness, and Michael Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research, 47:253–279, 2013.
157
+
158
+ Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym, 2016.
159
+
160
+ Yuri Burda, Harri Edwards, Deepak Pathak, Amos Storkey, Trevor Darrell, and Alexei A Efros. Large-scale study of curiosity-driven learning. arXiv preprint arXiv:1808.04355, 2018a.
161
+
162
+ Yuri Burda, Harrison Edwards, Amos Storkey, and Oleg Klimov. Exploration by random network distillation. arXiv preprint arXiv:1810.12894, 2018b.
163
+
164
+ Pablo Samuel Castro, Subhodeep Moitra, Carles Gelada, Saurabh Kumar, and Marc G Bellemare. Dopamine: A research framework for deep reinforcement learning. arXiv preprint arXiv:1812.06110, 2018.
165
+
166
+ Karl Cobbe, Chris Hesse, Jacob Hilton, and John Schulman. Leveraging procedural generation to benchmark reinforcement learning. In International conference on machine learning, pp. 2048–2056. PMLR, 2020.
167
+
168
+ William H Guss, Cayden Codel, Katja Hofmann, Brandon Houghton, Noboru Kuno, Stephanie Milani, Sharada Mohanty, Diego Perez Liebana, Ruslan Salakhutdinov, Nicholay Topin, et al. The minerl competition on sample efficient reinforcement learning using human priors. arXiv e-prints, pp. arXiv–1904, 2019.
169
+
170
+ Danijar Hafner, Timothy Lillicrap, Mohammad Norouzi, and Jimmy Ba. Mastering atari with discrete world models. arXiv preprint arXiv:2010.02193, 2020.
171
+
172
+ Matteo Hessel, Joseph Modayil, Hado Van Hasselt, Tom Schaul, Georg Ostrovski, Will Dabney, Dan Horgan, Bilal Piot, Mohammad Azar, and David Silver. Rainbow: Combining improvements in deep reinforcement learning. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
173
+
174
+ Ashley Hill, Antonin Raffin, Maximilian Ernestus, Adam Gleave, Anssi Kanervisto, Rene Traore, Prafulla Dhariwal, Christopher Hesse, Oleg Klimov, Alex Nichol, Matthias Plappert, Alec Radford, John Schulman, Szymon Sidor, and Yuhuai Wu. Stable baselines. https://github.com/ hill-a/stable-baselines, 2018.
175
+
176
+ Matthew Johnson, Katja Hofmann, Tim Hutton, and David Bignell. The malmo platform for artificial intelligence experimentation. In IJCAI, pp. 4246–4247. Citeseer, 2016.
177
+
178
+ Arthur Juliani, Vincent-Pierre Berges, Ervin Teng, Andrew Cohen, Jonathan Harper, Chris Elion, Chris Goy, Yuan Gao, Hunter Henry, Marwan Mattar, et al. Unity: A general platform for intelligent agents. arXiv preprint arXiv:1809.02627, 2018.
179
+
180
+ Michał Kempka, Marek Wydmuch, Grzegorz Runc, Jakub Toczek, and Wojciech Jaskowski. Vizdoom: ´ A doom-based ai research platform for visual reinforcement learning. In 2016 IEEE Conference on Computational Intelligence and Games (CIG), pp. 1–8. IEEE, 2016.
181
+
182
+ Heinrich Küttler, Nantas Nardelli, Alexander H Miller, Roberta Raileanu, Marco Selvatici, Edward Grefenstette, and Tim Rocktäschel. The nethack learning environment. arXiv preprint arXiv:2006.13760, 2020.
183
+
184
+ Marlos C Machado, Marc G Bellemare, Erik Talvitie, Joel Veness, Matthew Hausknecht, and Michael Bowling. Revisiting the arcade learning environment: Evaluation protocols and open problems for general agents. Journal of Artificial Intelligence Research, 61:523–562, 2018.
185
+ Stephanie Milani, Nicholay Topin, Brandon Houghton, William H Guss, Sharada P Mohanty, Keisuke Nakata, Oriol Vinyals, and Noboru Sean Kuno. Retrospective analysis of the 2019 minerl competition on sample efficient reinforcement learning. In NeurIPS 2019 Competition and Demonstration Track, pp. 203–214. PMLR, 2020.
186
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. Nature, 518(7540):529, 2015.
187
+ Ian Osband, Yotam Doron, Matteo Hessel, John Aslanides, Eren Sezener, Andre Saraiva, Katrina McKinney, Tor Lattimore, Csaba Szepesvari, Satinder Singh, et al. Behaviour suite for reinforcement learning. arXiv preprint arXiv:1908.03568, 2019.
188
+ John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
189
+ Ramanan Sekar, Oleh Rybkin, Kostas Daniilidis, Pieter Abbeel, Danijar Hafner, and Deepak Pathak. Planning to explore via self-supervised world models. arXiv preprint arXiv:2005.05960, 2020.
190
+ Kurt Spencer. Noise!, 2014. URL https://uniblock.tumblr.com/post/ 97868843242/noise.
191
+ Yuval Tassa, Yotam Doron, Alistair Muldal, Tom Erez, Yazhe Li, Diego de Las Casas, David Budden, Abbas Abdolmaleki, Josh Merel, Andrew Lefrancq, et al. Deepmind control suite. arXiv preprint arXiv:1801.00690, 2018.
192
+ Hado $\mathrm { \bf P }$ van Hasselt, Matteo Hessel, and John Aslanides. When to use parametric models in reinforcement learning? Advances in Neural Information Processing Systems, 32:14322–14333, 2019.
193
+
194
+ # A SUCCESS RATES WITH REWARDS
195
+
196
+ Table A.1: Success rates on Crafter with rewards. Success rates are computed as the fraction of episodes during which the achievement has been unlocked at least once. It is computed across all training episodes within the budget of 1M environment steps. The score is the geometric mean of success rates over all achievements, as described in Section 3.3. Note that the score is computed for each seed separately before averaging over seeds and not the other way around. Numbers within $9 5 \%$ of the best number in each row are highlighted in bold.
197
+
198
+ <table><tr><td>Achievement</td><td>Rainbow</td><td>PPO</td><td>DreamerV2</td></tr><tr><td>Collect Coal</td><td>0.0%</td><td>0.4%</td><td>14.7%</td></tr><tr><td>Collect Diamond</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Collect Drink</td><td>24.0%</td><td>30.3%</td><td>80.0%</td></tr><tr><td>Collect Iron</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Collect Sapling</td><td>97.4%</td><td>66.7%</td><td>86.6%</td></tr><tr><td>Collect Stone</td><td>0.2%</td><td>3.0%</td><td>42.7%</td></tr><tr><td>Collect Wood</td><td>74.9%</td><td>83.0%</td><td>92.7%</td></tr><tr><td>Defeat Skeleton</td><td>0.7%</td><td>0.2%</td><td>2.6%</td></tr><tr><td>Defeat Zombie</td><td>39.6%</td><td>2.0%</td><td>53.1%</td></tr><tr><td>Eat Cow Eat Plant</td><td>26.1%</td><td>12.0%</td><td>17.1%</td></tr><tr><td>Make Iron Pickaxe</td><td>0.0%</td><td>0.0%</td><td>0.1%</td></tr><tr><td>Make Iron Sword</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Make Stone Pickaxe</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td></td><td>0.0%</td><td>0.0%</td><td>0.2%</td></tr><tr><td>Make Stone Sword</td><td>0.0%</td><td>0.0%</td><td>0.3%</td></tr><tr><td>MakeWood Pickaxe</td><td>4.8%</td><td>21.1%</td><td>59.6%</td></tr><tr><td>MakeWood Sword</td><td>9.8%</td><td>20.1%</td><td>40.2%</td></tr><tr><td>Place Furnace</td><td>0.0%</td><td>0.1%</td><td>1.8%</td></tr><tr><td>Place Plant</td><td>94.2%</td><td>65.0%</td><td>84.4%</td></tr><tr><td>Place Stone</td><td>0.0%</td><td>1.7%</td><td>29.0%</td></tr><tr><td>Place Table Wake Up</td><td>52.3%</td><td>66.1%</td><td>85.7%</td></tr><tr><td></td><td>93.3%</td><td>92.5%</td><td>92.8%</td></tr><tr><td>Score</td><td>4.3%</td><td>4.6%</td><td>10.0%</td></tr></table>
199
+
200
+ # B SUCCESS RATES WITHOUT REWARDS
201
+
202
+ Table B.1: Success rates on Crafter without rewards. Success rates are computed as the fraction of episodes during which the achievement has been unlocked at least once. It is computed across all training episodes within the budget of 1M environment steps. The score is the geometric mean of success rates over all achievements, as described in Section 3.3. Note that the score is computed for each seed separately before averaging over seeds and not the other way around. Numbers within $9 5 \%$ of the best number in each row are highlighted in bold.
203
+
204
+ <table><tr><td>Achievement</td><td>Random</td><td>RND</td><td>Plan2Explore</td></tr><tr><td>Collect Coal</td><td>0.0%</td><td>0.1%</td><td>0.1%</td></tr><tr><td>Collect Diamond</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Collect Drink</td><td>9.3%</td><td>52.1%</td><td>48.7%</td></tr><tr><td>Collect Iron</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Collect Sapling</td><td>50.2%</td><td>34.1%</td><td>25.5%</td></tr><tr><td>Collect Stone</td><td>0.0%</td><td>0.6%</td><td>0.5%</td></tr><tr><td>Collect Wood</td><td>24.4%</td><td>49.6%</td><td>46.8%</td></tr><tr><td>Defeat Skeleton</td><td>0.0%</td><td>0.3%</td><td>0.2%</td></tr><tr><td>Defeat Zombie</td><td>0.1%</td><td>0.3%</td><td>0.2%</td></tr><tr><td>Eat Cow</td><td>0.4%</td><td>0.9%</td><td>0.7%</td></tr><tr><td>Eat Plant</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Make Iron Pickaxe</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Make Iron Sword</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Make Stone Pickaxe</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Make Stone Sword</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr><tr><td>Make Wood Pickaxe</td><td>0.3%</td><td>2.5%</td><td>3.3%</td></tr><tr><td>Make Wood Sword</td><td>0.3%</td><td>2.6%</td><td>3.3%</td></tr><tr><td>Place Furnace</td><td>0.0%</td><td>0.1%</td><td>0.0%</td></tr><tr><td>Place Plant</td><td>44.6%</td><td>21.4%</td><td>14.0%</td></tr><tr><td>Place Stone</td><td>0.0%</td><td>0.4%</td><td>0.3%</td></tr><tr><td>Place Table</td><td>4.4%</td><td>16.7%</td><td>16.3%</td></tr><tr><td>Wake Up</td><td>93.6%</td><td>7.8%</td><td>47.8%</td></tr><tr><td>Score</td><td>1.6%</td><td>2.0%</td><td>2.1%</td></tr></table>
205
+
206
+ C SUCCESS RATES OF HUMAN EXPERTS
207
+
208
+ <table><tr><td rowspan=1 colspan=1>Achievement</td><td rowspan=1 colspan=1>Human Experts</td></tr><tr><td rowspan=2 colspan=1>Collect CoalCollect DiamondCollect DrinkCollect IronCollect SaplingCollect StoneCollect WoodDefeat SkeletonDefeat ZombieEat CowEat PlantMake Iron PickaxeMake Iron SwordMake Stone PickaxeMake Stone SwordMake Wood PickaxeMake Wood SwordPlace FurnacePlace PlantPlace StonePlace TableWake Up</td><td rowspan=1 colspan=1>86.0%</td></tr><tr><td rowspan=1 colspan=1>12.0%92.0%53.0%67.0%100.0%100.0%31.0%84.0%89.0%8.0%26.0%22.0%78.0%78.0%100.0%45.0%32.0%24.0%90.0%100.0%73.0%</td></tr><tr><td rowspan=1 colspan=1>Score</td><td rowspan=1 colspan=1>50.5%</td></tr></table>
209
+
210
+ Table C.1: Success rates of human experts on Crafter. The success rates of human experts are computed as the fraction of all 100 recorded games during which the achievement has been unlocked at least once. To compute the score analogously to the artificial agents, we randomly split the 100 games into 5 groups that are treated as the different seeds. We then follow the same procedure as for the artificial agents.
211
+
212
+ # D EPISODE REWARD
213
+
214
+ ![](images/338f346d7a084460e94455d5a4881b2faa5b4f45790ff6f10db2e632f8cad139.jpg)
215
+ Figure D.1: Total episode reward with shaded standard deviation. The optimal achievable episode reward is 22. While visualizing rewards can be informative for debugging, final performance on Crafter should be reported by computing the score instead. The score takes the different difficulties of the achievements into account and is defined as the geometric mean of the success rates for all achievements, as described in Section 3.3.
216
+
217
+ # E TEXTURES
218
+
219
+ ![](images/0d8c08cdc16878b50eb4f96d1c275fa25daf0c68d2532ac314e0d75397258e5d.jpg)
220
+ Figure E.1: Crafter features worlds with several materials, resources, objects, and creatures. The player can interact with these to collect resources, maintain its food and water supplies, craft pickaxes and swords, and defend itself. The textures were specifically created for Crafter.
221
+
222
+ Table F.1: The action space is a flat categorical space, making Crafter easy to use. The 17 actions enable the agent to move, collect materials, place objects, craft objects, and interact with what is in front of the player. Actions whose requirements are not satisfied have no effect.
223
+
224
+ <table><tr><td>Integer</td><td>Name</td><td>Requirement</td></tr><tr><td>0</td><td>Noop</td><td>Always applicable.</td></tr><tr><td>1</td><td>Move Left</td><td>Flat ground left to the agent.</td></tr><tr><td>2</td><td>Move Right</td><td>Flat ground right to the agent.</td></tr><tr><td></td><td>Move Up</td><td>Flat ground above the agent.</td></tr><tr><td>34</td><td>Move Down</td><td>Flat ground below the agent.</td></tr><tr><td>5</td><td>Do</td><td>Facing creature or material; have necessary tool.</td></tr><tr><td>6</td><td>Sleep</td><td>Energy level is below maximum.</td></tr><tr><td>7</td><td>Place Stone</td><td>Stone in inventory.</td></tr><tr><td>8</td><td>Place Table</td><td>Wood in inventory.</td></tr><tr><td>9</td><td>Place Furnace</td><td>Stone in inventory.</td></tr><tr><td>10</td><td>Place Plant</td><td>Sapling in inventory.</td></tr><tr><td>11</td><td>MakeWood Pickaxe</td><td>Nearby table;wood in inventory.</td></tr><tr><td>12</td><td>Make Stone Pickaxe</td><td>Nearby table; wood, stone in inventory.</td></tr><tr><td>13</td><td>Make Iron Pickaxe</td><td>Nearby table, furnace; wood, coal, iron an inventory.</td></tr><tr><td>14</td><td>MakeWoodSword</td><td>Nearby table; wood in inventory.</td></tr><tr><td>15</td><td>Make Stone Sword</td><td>Nearby table; wood, stone in inventory.</td></tr><tr><td>16</td><td>Make Iron Sword</td><td>Nearby table,furnace; wood,coal, iron in inventory.</td></tr></table>
225
+
226
+ # G ACHIEVEMENT CURVES OF RAINBOW
227
+
228
+ ![](images/d8ff547c8eaea779ee2f87193c3e3ceccae323aa5987a92db81fff15bb63877d.jpg)
229
+ Figure G.1: Achievement counts of Rainbow with shaded min and max.
230
+
231
+ # H ACHIEVEMENT CURVES OF PPO
232
+
233
+ ![](images/ec05f24e779a8afca9372d913efee15f22166c1b172a81e9e31d74563be9e746.jpg)
234
+ Figure H.1: Achievement counts of PPO with shaded min and max.
235
+
236
+ # I ACHIEVEMENT CURVES OF DREAMERV2
237
+
238
+ ![](images/a5b5b00cceec2d12353949146116927a8f8b38180ea23555fd0c1de881e9d931.jpg)
239
+ Figure I.1: Achievement counts of DreamerV2 with shaded min and max.
240
+
241
+ ![](images/19a5cebc1da9f12fe2227dbd43278ace8b14cb339620d39d4e8648b7b195328a.jpg)
242
+ Figure J.1: Achievement counts of random actions with shaded min and max.
243
+
244
+ # K ACHIEVEMENT CURVES OF UNSUPERVISED RND
245
+
246
+ ![](images/ca65c424ae4225c58fc334aaf6505814883ad5294f8898fbc72b6b73a7467191.jpg)
247
+ Figure K.1: Achievement counts of unsupervised RND with shaded min and max.
248
+
249
+ ![](images/d172937b53f24365d2be9d54009ea862518c6b9a7a2e08359c69416a505600e9.jpg)
250
+ Figure L.1: Achievement counts of unsupervised Plan2Explore with shaded min and max.
md/dev/1W8UwXAQubL/1W8UwXAQubL.md ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Multi-Agent Reinforcement Learning is A Sequence Modeling Problem
2
+
3
+ Muning Wen1,2, Jakub Grudzien Kuba3, Runji Lin4, Weinan Zhang1, Ying Wen1, Jun Wang2,5, Yaodong Yang6,7,† 1Shanghai Jiao Tong University, 2Digital Brain Lab, 3University of Oxford, 4Institute of Automation, Chinese Academy of Science, 5University College London, 6Beijing Institute for General AI, 7Institute for AI, Peking University
4
+
5
+ # Abstract
6
+
7
+ Large sequence models (SM) such as GPT series and BERT have displayed outstanding performance and generalization capabilities in natural language process, vision and recently reinforcement learning. A natural follow-up question is how to abstract multi-agent decision making also as an sequence modeling problem and benefit from the prosperous development of the SMs. In this paper, we introduce a novel architecture named Multi-Agent Transformer (MAT) that effectively casts cooperative multi-agent reinforcement learning (MARL) into SM problems wherein the objective is to map agents’ observation sequences to agents’ optimal action sequences. Our goal is to build the bridge between MARL and SMs so that the modeling power of modern sequence models can be unleashed for MARL. Central to our MAT is an encoder-decoder architecture which leverages the multi-agent advantage decomposition theorem to transform the joint policy search problem into a sequential decision making process; this renders only linear time complexity for multiagent problems and, most importantly, endows MAT with monotonic performance improvement guarantee. Unlike prior arts such as Decision Transformer fit only precollected offline data, MAT is trained by online trial and error from the environment in an on-policy fashion. To validate MAT, we conduct extensive experiments on StarCraftII, Multi-Agent MuJoCo, Dexterous Hands Manipulation, and Google Research Football benchmarks. Results demonstrate that MAT achieves superior performance and data efficiency compared to strong baselines including MAPPO and HAPPO. Furthermore, we demonstrate that MAT is an excellent few-short learner on unseen tasks regardless of changes in the number of agents. See our project page at https://sites.google.com/view/multi-agent-transformer(1)
8
+
9
+ # 1 Introduction
10
+
11
+ Multi-agent reinforcement learning (MARL) [44, 8] is a challenging problem for its difficulty which arises not only from identifying each individual agent’s policy improvement direction, but also from combining agents’ policy updates jointly which should be beneficial for the whole team. Recently, such difficulty in multi-agent learning has been eased owing to the introduction of centralized training for decentralized execution (CTDE) [11, 45], which allows agents to access the global information and opponents’ actions during the training phase. This framework enables successful developments of methods that directly inherit single-agent algorithms. For examples, COMA replaces the policy-gradient (PG) estimate with a multi-agent PG (MAPG) counterpart [11], MADDPG extends deterministic policy gradient into multi-agent settings with a centralized critic [20, 34], QMIX leverages deep Qnetworks for decentralized agents and introduces a centralized mixing network for Q-value decomposition [29, 36, 26]. MAPPO endowing all agents with the same set of parameters and then training by trust-region methods [46]. PR2 [42] and GR2 [43] methods conduct recursive reasoning under the CTDE framework. These methods, however, cannot cover the whole complexity of multi-agent interactions; in fact, some of them are shown to fail in the simplest cooperative task [15]. To resolve this issue, the multi-agent advantage decomposition theorem was proposed [15, Theorem 1] which captures how different agents contribute to the return and provides an intuition behind the emergence of cooperation through a sequential decision making process scheme. Based on it, HATRPO and HAPPO algorithms [15, 17, 16] were derived which, thanks to the decomposition theorem and sequential update scheme, established new state-of-the-art methods for MARL. However, their limitation is that the agents’ policies are unaware of the purpose to develop cooperation and still rely on a carefully handcrafted maximization objective. Ideally, a team of agents should be aware of the jointness of their training by design, thereby following a holistic and effective paradigm—an ideal solution that is yet to be proposed.
12
+
13
+ In recent years, sequence models (SM) have made a substantial progress in natural language processing (NLP) [27]. For example, GPT series [3] and BERT models [9], built on autoregressive SMs, have demonstrated remarkable performance on a wide range of downstream tasks and achieved strong performance on few-shot generalization tasks. Although SM are mostly used in language tasks due to its natural fitting with the sequential property of languages, the sequential approaches are not confined to NLP only, but is instead a widely applicable general foundation model [2]. For example, in computer vision (CV), one can split an image into sub-images and align them in a sequence as if they were tokens in NLP tasks [9, 10, 12]. Although the idea of solving CV tasks by SM is straightforward, it serves as the foundation to some of the best-performing CV algorithms [38, 41, 39]. Furthermore, sequential methods are starting to spawn powerful multi-modal visual language models such as Flamingo [1], DALL-E [28], and GATO [30] in the recent past.
14
+
15
+ Coming with effective and expressive network architectures such as Transformer [40], sequence modeling techniques have also attracted tremendous attention from the RL community, which results in a series of successful offline RL developments based on the Transformer architecture [5, 14, 30, 23]. These methods show great potentials in tackling some of the most fundamental RL training problems, such as long-horizon credit assignment and reward sparsity [37, 24, 25]. For example, by training autoregressive models on pre-collected offline data in a purely supervised way, Decision Transformer [5] bypasses the need for computing cumulative rewards through dynamic programming, but rather generates future actions conditioning on the desired returns, past states and actions. Despite their remarkable successes, none of these methods have been designed to model the most difficult (also unique to MARL) aspect of multi-agent systems—the agents’ interactions. In fact, if we were to simply endow all agents with a Transformer policy and train them independently, their joint performance still could not be guaranteed to improve [15, Proposition 1]. Therefore, while a myriad of powerful SMs are available, MARL—an area that would greatly benefit from SM—has not truly taken advantage of their performance benefit. The key research question to ask is then
16
+
17
+ # How can we model MARL problems by sequence models ?
18
+
19
+ In this paper, we take several steps to provide an affirmative answer to the above research question. Our goal is to enhance MARL studies with powerful sequential modeling techniques. To fulfill that, we start by proposing a novel MARL training paradigm which establishes the connection between cooperative MARL problems and sequence modeling problems. Central to the new paradigm are the multi-agent advantage decomposition theorem and sequential update scheme, which effectively transform multi-agent joint policy optimization into a sequential policy search process. As a natural outcome of our findings, we introduce Multi-Agent Transformer (MAT), an encoder-decoder architecture that implements generic MARL solutions through SM. Unlike Decision Transformer [5], MAT is trained online based on trials and errors in an on-policy fashion; therefore, it does not require collecting demonstrations upfront. Importantly, the implementation of the multi-agent advantage decomposition theorem ensures MAT to enjoy monotonic performance improvement guarantee during training. MAT establishes a new state-of-the-art baseline model for cooperative MARL tasks. We justify such a claim by evaluating MAT on the benchmarks of StarCraftII, Multi-Agent MuJoCo, Dexterous Hands Manipulation, and Google Research Football; results show that MAT achieves superior performance over strong baselines, such as MAPPO [46], HAPPO [15], QMIX [29] and UPDeT [13]. Finally, we show that MAT possesses great potentials in task generalizations, which holds regardless of the agent number in new tasks.
20
+
21
+ # 2 Preliminaries
22
+
23
+ In this section, we first introduce the cooperative MARL problem formulation and the multi-agent advantage decomposition theorem, which serves as the cornerstone of our work. We then review existing MARL methods that relate to MAT, and finally familiarize the reader with the Transformer.
24
+
25
+ # 2.1 Problem Formulation
26
+
27
+ Cooperative MARL problems are often modeled by Markov games $\langle \mathcal { N } , \mathcal { O } , \pmb { \mathcal { A } } , R , P , \gamma \rangle$ [19]. ${ \mathcal { N } } =$ $\{ 1 , \ldots , n \}$ is the set of agents, $\begin{array} { r } { \mathcal { O } = \prod _ { i = 1 } ^ { n } \mathcal { O } ^ { i } } \end{array}$ is the product of local observation spaces of the i=1 agents, namely the joint observation space, $\begin{array} { r } { \pmb { \mathcal { A } } = \prod _ { i = 1 } ^ { n } \pmb { \mathcal { A } } ^ { i } } \end{array}$ is the product of the agents’ action spaces, namely the joint action space, $R : \mathcal { O } \times \pmb { A } [ - \bar { R } _ { \operatorname* { m a x } } , R _ { \operatorname* { m a x } } ]$ is the joint reward function, $P : \mathcal { O } \times \pmb { \mathcal { A } } \times \mathcal { O } \mathbb { R }$ is the transition probability function, and $\gamma \in [ 0 , 1 )$ is the discount factor. At time step $t \in \mathbb { N }$ , an agent $i \in \mathcal N$ observes an observation $\mathbf { o } _ { t } ^ { i } \in \mathcal { O } ^ { i }$ (2) $\mathbf { \tilde { \omega } } ( o = \left( o ^ { 1 } , \ldots , o ^ { n } \right)$ is a “joint” observation) and takes an action $\mathbf { a } _ { t } ^ { i }$ according to its policy $\pi ^ { i }$ , which is the $i ^ { \mathrm { { t h } } }$ component of the agents’ joint policy $\pi$ . At each time step, all agents take actions simultaneously based on their observation with no sequential dependencies. The transition kernel $P$ and the joint policy induce the (improper) marginal observation distribution $\begin{array} { r } { \rho _ { \pi } ( \cdot ) \triangleq \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } \mathrm { P r } ( \mathbf { o } _ { t } = o | \pi ) } \end{array}$ . At the end of each time step, the whole team receives a joint reward $R ( \mathbf { o } _ { t } , \mathbf { a } _ { t } )$ and observe $\mathbf { o } _ { t + 1 }$ , whose probability distribution is $P ( \cdot | \mathbf { o } _ { t } , \mathbf { a } _ { t } )$ . Following this process infinitely long, the agents earn a discounted cumulative return of $\begin{array} { r } { R ^ { \gamma } \triangleq \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } R ( \mathbf { o } _ { t } , \mathbf { a } _ { t } ) } \end{array}$ .
28
+
29
+ # 2.2 Multi-Agent Advantage Decomposition Theorem
30
+
31
+ The agents evaluate the value of actions and observations with $Q _ { \pi } ( o , a )$ and $V _ { \pi } ( o )$ , defined as
32
+
33
+ $$
34
+ \begin{array} { r } { \begin{array} { c } { Q _ { \pi } ( o , a ) \triangleq \mathbb { E } _ { \mathbf { o } _ { 1 : \infty } \sim P , \mathbf { a } _ { 1 : \infty } \sim \pi } \left[ R ^ { \gamma } | \mathbf { o } _ { 0 } = o , \mathbf { a } _ { 0 } = a \right] , } \\ { V _ { \pi } ( o ) \triangleq \mathbb { E } _ { \mathbf { a } _ { 0 } \sim \pi , \mathbf { o } _ { 1 : \infty } \sim P , \mathbf { a } _ { 1 : \infty } \sim \pi } \left[ R ^ { \gamma } | \mathbf { o } _ { 0 } = o \right] . } \end{array} } \end{array}
35
+ $$
36
+
37
+ The jointness of the objective causes difficulties associated with the credit assignment problem— having received a shared reward, individual agents are unable to deduce their own contribution to the team’s success or failure [4]. Indeed, applying traditional RL methods which simply employ the above value functions leads to obstacles in training, such as the growing variance of multi-agent policy gradient (MAPG) estimates [17]. Hence, to tackle these, notions of local value functions [21] and counterfactual baselines [11] have been developed. In this paper, we work with the most general notions of this kind—the multi-agent observation-value functions [15]. That is, for arbitrary disjoint, ordered subsets of agents $i _ { 1 : m } = \overline { { { \{ i _ { 1 } , \ldots , i _ { m } \} } } }$ and $j _ { 1 : h } = \{ j _ { 1 } , \dots , j _ { h } \}$ , for $m , h \le n$ , we define the multi-agent observation-value function by
38
+
39
+ $$
40
+ Q _ { \pi } ( o , \pmb { a } ^ { i _ { 1 : m } } ) \triangleq \mathbb { E } \big [ R ^ { \gamma } | \mathbf { o } _ { 0 } ^ { i _ { 1 : n } } = o , \mathbf { a } _ { 0 } ^ { i _ { 1 : m } } = \pmb { a } ^ { i _ { 1 : m } } \big ] ,
41
+ $$
42
+
43
+ which recovers the original state-action value function in Equation (1) when $m = n$ , and the original observation-value function when $m = 0$ (i.e., when the set $i _ { 1 : m }$ is empty). Based on Equation (2), we can further measure the contribution of a chosen subset of agents to the joint return and define the multi-agent advantage function by
44
+
45
+ $$
46
+ A _ { \pi } ^ { i _ { 1 } ; m } \big ( \pmb { o } , \pmb { a } ^ { j _ { 1 } ; h } , \pmb { a } ^ { i _ { 1 : m } } \big ) \triangleq Q _ { \pi } ^ { j _ { 1 } ; h , ~ i _ { 1 : m } } \big ( \pmb { o } , \pmb { a } ^ { j _ { 1 : h } } , \pmb { a } ^ { i _ { 1 : m } } \big ) - Q _ { \pi } ^ { j _ { 1 : h } } \big ( \pmb { o } , \pmb { a } ^ { j _ { 1 : h } } \big ) .
47
+ $$
48
+
49
+ The above quantity describes how much better/worse than average the joint action $\textbf { \em a }$ will be if agents $i _ { 1 : m }$ take the joint action $\pmb { a } ^ { i _ { 1 : m } }$ , once $j _ { 1 : h }$ have taken $\pmb { a } ^ { j _ { 1 : h } }$ . Again, when $h = 0$ , the advantage compares the value of $\pmb { a } ^ { i _ { 1 : m } }$ to the baseline value function of the whole team. This value-functional representation of agents’ actions enables studying interactions between them, as well to decompose the joint value function signal, thus helping alleviate the severity of the credit assignment problem [29, 35, 22]. The insights of Equation (3) is accomplished by means of the following theorem.
50
+
51
+ Theorem 1 (Multi-Agent Advantage Decomposition [17]). Let $i _ { 1 : n }$ be a permutation of agents. Then, for any joint observation $\pmb { o } = \pmb { o } \in \mathcal { O }$ and joint action $\pmb { a } = \pmb { a } ^ { i _ { 1 : n } } \in \mathcal { A }$ , the following equation always holds with no further assumption needed,
52
+
53
+ $$
54
+ A _ { \pi } ^ { i _ { 1 : n } } \left( o , a ^ { i _ { 1 : n } } \right) = \sum _ { m = 1 } ^ { n } A _ { \pi } ^ { i _ { m } } \left( o , a ^ { i _ { 1 : m - 1 } } , a ^ { i _ { m } } \right) .
55
+ $$
56
+
57
+ Importantly, this theorem provides an intuition guiding the choice of incrementally improving actions. Suppose that agent $i _ { 1 }$ picks an action $a ^ { i _ { 1 } }$ with positive advantage, $A _ { \pi } ^ { i _ { 1 } } ( o , a ^ { i _ { 1 } } ) \dot { > } 0$ . Then, imagine that for all $j = 2 , \dots , n$ , agent $i _ { j }$ knows the joint action $\mathbf { \Delta } a ^ { i _ { 1 : j - 1 } }$ of its predecessors. In this case, it can choose an action $a ^ { i _ { j } }$ for which the advantage $A _ { \pi } ^ { i _ { j } } ( o , \pmb { a } ^ { i _ { 1 : j - 1 } } , a ^ { i _ { j } } )$ is positive. Altogether, the theorem assures that the joint action $\pmb { a } ^ { i _ { 1 : n } }$ has positive advantage. Furthermore, notice that the joint the complexity of this search is additive, Pni=1 |Ai |, in the sizes of the action spaces. If we were to action has been chosen in perform the search directly in the joint action space, we would browse a set of multiplicative size, steps, each of which searched an individual agent’s action space. Hence, $\begin{array} { r } { \left| \mathcal { A } \right| = \prod _ { i = 1 } ^ { n } \left| \mathcal { A } ^ { i } \right| } \end{array}$ . Later, we will build upon this insight to design a SM that optimizes joint policies efficiently, agent by agent, without the necessity of considering the joint action space at once.
58
+
59
+ # 2.3 Existing Methods in MARL
60
+
61
+ We now briefly summarize two state-of-the-art MARL algorithms. Both of them build upon Proximal Policy Optimization (PPO) [33]—a RL method famous for its simplicity and its performance stability.
62
+
63
+ MAPPO [46] is the first, and the most direct, approach for applying PPO in MARL. It equips all agents with one shared set of parameters and use agents’ aggregated trajectories for the shared policy’s update; at iteration $k + 1$ , it optimizes the policy parameter $\theta _ { k + 1 }$ by maximizing the clip objective of
64
+
65
+ $$
66
+ \sum _ { i = 1 } ^ { n } \mathbb { E } _ { \mathbf { o } \sim \rho _ { \pi _ { \theta _ { k } } } , \mathbf { a } \sim \pi _ { \theta _ { k } } } \left[ \operatorname* { m i n } \left( \frac { \pi _ { \theta } ( \mathbf { a } ^ { i } | \mathbf { o } ) } { \pi _ { \theta _ { k } } ( \mathbf { a } ^ { i } | \mathbf { o } ) } A _ { \pi _ { \theta _ { k } } } ( \mathbf { o } , \mathbf { a } ) , \mathrm { c l i p } \left( \frac { \pi _ { \theta } ( \mathbf { a } ^ { i } | \mathbf { o } ) } { \pi _ { \theta _ { k } } ( \mathbf { a } ^ { i } | \mathbf { o } ) } , 1 \pm \epsilon \right) A _ { \pi _ { \theta _ { k } } } ( \mathbf { o } , \mathbf { a } ) \right) \right] ,
67
+ $$
68
+
69
+ where the clip operator clips the input value (if necessary) so that it stays within the interval $[ 1 - \epsilon , 1 + \epsilon ]$ . However, enforcing parameter sharing is equivalent to putting a constraint $\theta ^ { i } = \theta ^ { j } , \forall i , j \in \mathcal { N }$ on the joint policy space, which can lead to an exponentially-worse sub-optimal outcome [15]. This motivates a more principled development of heterogeneous-agent trust-region methods, e.g., HAPPO.
70
+
71
+ HAPPO [15] is currently one of the SOTA algorithm that fully leverages Theorem (1) to implement multi-agent trust-region learning with monotonic improvement guarantee. During an update, the agents choose a permutation $i _ { 1 : n }$ at random, and then following the order in the permutation, every agent $i _ { m }$ picks $\bar { \pi _ { \mathrm { n e w } } ^ { i _ { m } } } = \pi ^ { i _ { m } }$ that maximizes the objective of
72
+
73
+ $$
74
+ \mathbb { E } _ { \mathbf { o } \sim \rho _ { \pi _ { \mathrm { o d d } } } , \mathbf { a } ^ { i _ { 1 : m } } - 1 \sim \pi _ { \mathrm { n e r } } ^ { i _ { 1 : m } - 1 } , \mathbf { a } ^ { i _ { m } } \sim \pi _ { \mathrm { o d d } } ^ { i _ { m } } } \left[ \operatorname* { m i n } \left( \mathbf { r } ( \pi ^ { i _ { m } } ) A _ { \pi _ { \mathrm { o d d } } } ^ { i _ { 1 : m } } ( \boldsymbol { o } , \mathbf { a } ^ { i _ { 1 : m } } ) , \mathrm { c l i p } ( \mathbf { r } ( \pi ^ { i _ { m } } ) , 1 \pm \epsilon ) A _ { \pi _ { \mathrm { o d d } } } ^ { i _ { 1 : m } } ( \mathbf { o } , \mathbf { a } ^ { i _ { 1 : m } } ) \right) \right] ,
75
+ $$
76
+
77
+ where $\mathbf { r } ( \pi ^ { i _ { m } } ) = \pi ^ { i _ { m } } ( \mathbf { a } ^ { i _ { m } } | \mathbf { o } ) / \pi _ { \mathrm { o l d } } ^ { i _ { m } } \left( \mathbf { a } ^ { i _ { m } } | \mathbf { o } \right)$ . Note that the expectation is taken over the newly-updated previous agents’ policies, i.e, $\pi _ { \mathrm { n e w } } ^ { i _ { 1 : m - 1 } }$ ; this reflects an intuition that, under Theorem (1), the agent $i _ { m }$ reacts to its preceding agents $i _ { 1 : m - 1 }$ . However, one drawback of HAPPO is that agent’s policies has to follow the sequential update scheme in the permutation, thus it cannot be run in parallel.
78
+
79
+ # 2.4 The Transformer Model
80
+
81
+ Transformer [40] was originally designed for machine translation tasks (e.g., input English, output French). It maintains an encoder-decoder structure, where the encoder maps an input sequence of tokens to latent representations and then the decoder generates a sequence of desired outputs in an auto-regressive manner wherein at each step of inference, the Transformer takes all previously generated tokens as the input. One of the most essential component in Transformer is the scaled dot-product attention, which captures the interrelationship of input sequences. The attention function is written as Attention $\begin{array} { r } { \mathrm { \mathrm { \Omega } } _ { ^ { 1 } } ( \mathbf { Q } , \mathbf { K } , \mathbf { V } ) = \operatorname { s o f t m a x } \big ( \frac { \mathbf { Q } \mathbf { K } ^ { T } } { \sqrt { d _ { k } } } \big ) \mathbf { V } } \end{array}$ V, where the Q, K, V corresponds to the vector of queries, keys and values, which can be learned during training, and the $d _ { k }$ represent the dimension of $\mathbf { Q }$ and $\mathbf { K }$ . Self-attentions refer to cases when $\mathbf { Q } , \mathbf { K } , \mathbf { V }$ share the same set of parameters.
82
+
83
+ ![](images/44c48541656c918c52b627f3e9d5d3661d597e84653999bdf5d132f8ba8df7a9.jpg)
84
+ Figure 1: Conventional multi-agent learning paradigm (left) wherein all agents take actions simultaneously vs. the multi-agent sequential decision paradigm (right) where agents take actions by following a sequential order, each agent accounts for decisions from preceding agents as red arrows suggest.
85
+
86
+ Inspired by the attention mechanism, UPDeT [13] handles various observation sizes by decoupling each agent’s observations into a sequence of observation-entities, matching them with different actiongroups, and modeling the relationship between the matched observation-entities with a Transformerbased function for better representation learning in MARL problems. Apart from this, based on the sequential property described in the Theorem (1) and the principle behind HAPPO [15], it is intuitive to think about another Transformer-based implementation for multi-agent trust-region learning. By treating a team of agents as a sequence, the Transformer architecture allows us to model teams of agents with variable numbers and types, while avoiding drawbacks of MAPPO/HAPPO. We will describe in more details how a cooperative MARL problem can be solved by a sequence model.
87
+
88
+ # 3 The Surprising Connection Between MARL and Sequence Models
89
+
90
+ To establish the connection between MARL and sequence models, Theorem (1) provides a new angle of understanding the MARL problem from a SM perspective. If each agent knows its predecessors’ actions with an arbitrary decision order, the sum of agents’ local advantages $A _ { \pi } ^ { i _ { j } } \left( o , \pmb { a } ^ { i _ { 1 : m - 1 } } , a ^ { i _ { m } } \right)$ will be exactly equal to the joint advantages $A _ { \pi } ^ { i _ { 1 : n } } ( o , \pmb { a } ^ { i _ { 1 : n } } )$ . This orderly decision setting across agents simplifies the update of their joint policy, where maximizing each agent’s own local advantage is equivalent to maximizing the joint advantage. As such, agents do not need to worry about interference from other agents anymore during the policy update; the local advantage functions have already captured the relationship between agents. This property revealed by Theorem (1) inspires us to propose a multi-agent sequential decision paradigm for MARL problems as show in Figure (1), where we assign agents with an arbitrary decision order (one permutation for each iteration); each agent can access its predecessors’ behaviors, based on which it then takes the optimal decision. This sequential paradigm motivates us to leverage a sequential model, e.g., Transformer, to explicitly capture the sequential relationship between agents described in Theorem (1).
91
+
92
+ Underpinned by Theorem (1), sequence modeling reduces the complexity growth of MARL problems with the number of agents from multiplicative to additive, thus rendering linear complexity. With the help of the Transformer architecture, we can model policies of heterogeneous agents with an unified network but treat each agent discriminatively with different position, and thus ensuring high sample efficiency while avoiding the exponentially-worse outcome that MAPPO is facing. Besides, in order to guarantee the monotonic improvement of joint policies, HAPPO has to update each policy one-by-one during training, by leveraging previous update results of $\pi ^ { i _ { 1 } } , . . . , \pi ^ { i _ { m - 1 } }$ to improve $\pi ^ { i _ { m } }$ , which becomes critical in computational efficiency at large size of agents. By contramechanism of Transformer architectures allows for batching the ground truth actions $a _ { t } ^ { i _ { 0 } } , . . . , a _ { t } ^ { i _ { n - 1 } }$ ain1 onin the buffer to predict $a _ { t } ^ { i _ { 1 } } , . . . , a _ { t } ^ { i _ { n } }$ and update policies simultaneously, which significantly improves the training speed and makes it feasible for large size of agents. Furthermore, in cases that the number and the type of agents are different, SM can incorporates them into an unified solution through its capability on modeling sequences with flexible sequence length, rather than treat different agent numbers as different tasks. To realize the above idea, we introduce a practical architecture named Multi-Agent Transformer in the next section.
93
+
94
+ ![](images/7d48b9cbf47618a759b37dc1e10c48b8ef89fed8192a3d059497153e41e166e1.jpg)
95
+ Figure 2: The encoder-decoder architecture of MAT. At each time step, the encoder takes in a sequence of agents’ observations and encodes them into a sequence of latent representations, which is then passed into the decoder. The decoder generate each agent’s optimal action in a sequential and auto-regressive manner. The masked attention blocks ensures agents can only access its preceding agents’ actions during training. We list the full pseudocode of MAT in Appendix A and a video that shows the dynamic data flow of MAT in https://sites.google.com/view/multi-agent-transformer.
96
+
97
+ # 4 The Multi-Agent Transformer
98
+
99
+ To implement the sequence modeling paradigm for MARL, our solution is Multi-Agent Transformer (MAT). The idea of applying the Transformer architecture comes from the fact that the mapping between the input of agents’ observation sequence $\left( o ^ { i _ { 1 } } , \ldots , o ^ { i _ { n } } \right)$ and the output of agents’ action sequence $( a ^ { i _ { 1 } } , \ldots , a ^ { i _ { n } } )$ are sequence modeling tasks similar to machine translations. As eluded by Theorem (1), the action $a ^ { i _ { m } }$ depends on all previous agents’ decisions $\mathbf { a } ^ { i _ { 1 : m - 1 } }$ . Hence, our MAT in Figure (2) consists of an encoder, which learns representations of the joint observations, and a decoder which outputs actions for each individual agent in an auto-regressive manner.
100
+
101
+ The encoder, whose parameters we denote by $\phi$ , takes a sequence of observations $\left( o ^ { i _ { 1 } } , \ldots , o ^ { i _ { n } } \right)$ in arbitrary order and passes them through several computational blocks. Each such block consists of a self-attention mechanism and a multi-layer perceptron (MLP), as well as residual connections to prevent gradient vanishing and network degradation with the increase of depth. We denote the output encoding of the observations as $( \hat { o } ^ { i _ { 1 } } , \dots , \hat { o } ^ { i _ { n } } )$ , which encodes not only the information of agents $( i _ { 1 } , \ldots , i _ { n } )$ but also the high-level interrelationships that represent agents’ interactions. In order to learn expressive representations, in the training phase, we make the encoder to approximate the value functions, whose objective is to minimize the empirical Bellman error by
102
+
103
+ $$
104
+ L _ { \mathrm { E n c o d e r } } ( \phi ) = \frac { 1 } { T n } \sum _ { m = 1 } ^ { n } \sum _ { t = 0 } ^ { T - 1 } \Big [ R ( \mathbf { o } _ { t } , \mathbf { a } _ { t } ) + \gamma V _ { \vec { \phi } } ( \hat { \mathbf { o } } _ { t + 1 } ^ { i _ { m } } ) - V _ { \phi } ( \hat { \mathbf { o } } _ { t } ^ { i _ { m } } ) \Big ] ^ { 2 } ,
105
+ $$
106
+
107
+ where $\bar { \phi }$ is the target network’s parameter, which is non-differentiable and updated every few epochs.
108
+
109
+ The decoder, whose parameters we denote by $\theta$ , passes the embedded joint action $\pmb { a } ^ { i _ { 0 : m - 1 } } , m =$ $\{ 1 , \ldots n \}$ (where $a ^ { i _ { 0 } }$ is an arbitrary symbol indicating the start of decoding) to a sequence of decoding blocks. Crucially, every decoding block comes with a masked self-attention mechanism, where the masking makes sure that, for every $i _ { j }$ , attention is computed only between the $i _ { r } ^ { \mathrm { t h } }$ and the $i _ { j } ^ { \mathrm { t h } }$ action heads wherein $r < j$ so that the sequential update scheme can be maintained. This is then followed by a second masked attention function, which computes the attention between the action heads and observation representations. Finally, the block finishes with an MLP and skipping connections. The output to the last decoder block is a sequence of representations of the joint actions, $\{ \hat { \pmb { a } } ^ { i _ { 0 } : i - 1 } \} _ { i = 1 } ^ { m }$ . This is fed to an MLP that outputs the probability distribution of $i _ { m }$ ’s action, namely, the policy $\pi _ { \theta } ^ { i _ { m } } ( \mathbf { a } ^ { i _ { m } } | \hat { \mathbf { o } } ^ { i _ { 1 : n } } , \mathbf { a } ^ { i _ { 1 : m - 1 } } ) $ . To train the decoder, we minimize the following clipping PPO objective of
110
+
111
+ ![](images/05b4d70e3ed71091e35c8894f1dc7246c770b17c0f70d3241565b25f49c9e247.jpg)
112
+ Figure 3: Demonstrations of the Bi-DexHands and the HalfCheetah environments.
113
+
114
+ ![](images/2226ea430ed36b5f48270f30a6b9760f1439abfb81507b6a7fab4bd1eaad67f7.jpg)
115
+ Figure 4: Performance comparisons on the Multi-Agent MuJoCo and the Bi-DexHands benchmarks.
116
+
117
+ $$
118
+ \begin{array} { l } { { \displaystyle { \cal L } _ { \mathrm { D e c o d e r } } ( \theta ) = - \frac { 1 } { T n } \sum _ { m = 1 } ^ { n } \sum _ { t = 0 } ^ { T - 1 } \operatorname* { m i n } \Big ( \mathrm { \bf r } _ { t } ^ { i _ { m } } ( \theta ) \hat { A } _ { t } , \mathrm { c l i p } ( \mathrm { \bf r } _ { t } ^ { i _ { m } } ( \theta ) , 1 \pm \epsilon ) \hat { A } _ { t } \Big ) } , } \\ { { \displaystyle \mathrm { \bf ~ r } _ { t } ^ { i _ { m } } ( \theta ) = \frac { \pi _ { \theta } ^ { i _ { m } } \big ( { \bf a } _ { t } ^ { i _ { m } } \big | \hat { \bf { \bf { \boldsymbol \Phi } } } _ { t } ^ { i _ { 1 : n } } , \hat { \bf { \bf { a } } } _ { t } ^ { i _ { 1 : m - 1 } } \big ) } { \pi _ { \theta _ { \mathrm { o l d } } } ^ { i _ { m } } \big ( { \bf a } _ { t } ^ { i _ { m } } \big | \hat { \bf { \bf { \boldsymbol \Phi } } } _ { t } ^ { i _ { 1 : n } } , \hat { \bf { a } } _ { t } ^ { i _ { 1 : m - 1 } } \big ) } , } } \end{array}
119
+ $$
120
+
121
+ where $\hat { A } _ { t }$ is an estimate of the joint advantage function. One can apply generalized advantage estimation (GAE) [32] with $\begin{array} { r } { \hat { V } _ { t } = \frac { 1 } { n } \sum _ { m = 1 } ^ { n } V \big ( \hat { \mathbf { o } } _ { t } ^ { i _ { m } } \big ) } \end{array}$ as a robust estimator for the joint value function. Notably, the action generation process is different between the inference and the training stage. In the inference stage, each action is generated auto-regressively, in the sense that $\mathbf { a } ^ { i _ { m } }$ will be inserted back into the decoder again to generate $\mathrm { a } ^ { i _ { m + 1 } }$ (starting with $\mathrm { \mathbf { a } } ^ { i _ { 0 } }$ and ending with $\mathrm { a } ^ { i _ { n - 1 } }$ ). While during the training stage, the output of all actions, $\mathbf { a } ^ { i _ { 1 : n } }$ can be computed in parallel simply because $\mathbf { a } ^ { i _ { 1 : n - 1 } }$ have already been collected and stored in the replay buffer.
122
+
123
+ The attention mechanism, which lies in the heart of MAT, encodes observations and actions with a weight matrix calculated by multiplying the embedded queries, $( q ^ { i _ { 1 } } , \ldots , q ^ { i _ { n } } )$ , and keys, $( k ^ { i _ { 1 } } , \ldots , k ^ { i _ { n } } )$ , where each of the weight $w \tilde { ( } q ^ { i _ { r } } , k ^ { i _ { j } } ) = \langle q ^ { i _ { r } ^ { \perp } } , k ^ { i _ { j } } \rangle$ . The embedded values $( v ^ { i _ { 1 } } , \ldots , v ^ { i _ { n } } )$ are multiplied with the weight matrix to output representations. While the unmasked attention in the encoder uses a full weight matrix to extract the interrelationship between agents, i.e., $\hat { \mathbf { O } } ^ { i _ { 1 : n } }$ , the masked attentions in the decoder capture $\mathbf { a } ^ { i _ { 1 : m } }$ with triangular matrices where $\bar { w ( q ^ { i _ { r } } , k ^ { i _ { j } } ) } = 0$ for $r \textless j$ (see an visual illustration in Appendix A). With the properly masked attention mechanism, the decoder can safely output the policy $\pi _ { \theta } ^ { i _ { m + 1 } } ( \mathbf { a } ^ { i _ { m + 1 } } | \hat { \mathbf { o } } ^ { i _ { 1 : n } } , \mathbf { a } ^ { i _ { 1 : m } } )$ , which finishes the implementation of Theorem (1).
124
+
125
+ The monotonic improvement guarantee. An MAT agent $i _ { m }$ optimizes a trust-region objective that is conditioned on new decisions of agents $i _ { 1 : m - 1 }$ by means of conditioning its policy ratio on them (see Equation (5)). As such, it increases the joint return monotonically like if it followed the sequential update scheme of HAPPO [15, Theorem 2]. However, as oppose to that method, the MAT model does not require $i _ { m }$ to wait until its predecessors make their updates, nor it uses their updated action distribution for importance sampling calculations. In fact, as actions of all agents are outputs of MAT, their clipping objectives can be computed in parallel (during training), thus dominating
126
+
127
+ Table 1: Performance evaluations of win rate and standard deviation on the SMAC benchmark, where UPDeT’s official codebase supports several Marine-based tasks only.
128
+
129
+ <table><tr><td>Task</td><td>Difficulty</td><td>MAT</td><td>MAT-Dec</td><td>MAPPO</td><td>HAPPO</td><td>QMIX</td><td>UPDeT</td><td>Steps</td></tr><tr><td>3m</td><td>Easy</td><td>100.0(1.8)</td><td>100.0(1.1)</td><td>100.0(0.4)</td><td>100.0(1.2)</td><td>96.91.3</td><td>100.0(5.2)</td><td>5e5</td></tr><tr><td>8m</td><td>Easy</td><td>100.0(1.1)</td><td>97.5(2.5)</td><td>96.8(2.9)</td><td>97.5(1.1)</td><td>97.71.9</td><td>96.3(9.7)</td><td>1e6</td></tr><tr><td>1c3s5z</td><td>Easy</td><td>100.0(2.4)</td><td>100.0(0.4)</td><td>100.0(2.2)</td><td>97.5(1.8)</td><td>96.9(1.5)</td><td>/</td><td>2e6</td></tr><tr><td>MMM</td><td>Easy</td><td>100.0(2.2)</td><td>98.1(2.1)</td><td>95.6(4.5)</td><td>81.2(22.9)</td><td>91.2(3.2)</td><td>/</td><td>2e6</td></tr><tr><td>2c vs 64zg</td><td>Hard</td><td>100.0(1.3)</td><td>95.9(2.3)</td><td>100.0(2.7)</td><td>90.0(4.8)</td><td>90.3(4.0)</td><td>/</td><td>5e6</td></tr><tr><td>3s vs 5z</td><td>Hard</td><td>100.0(1.7)</td><td>100.0(1.3)</td><td>100.0(2.5)</td><td>91.9(5.3)</td><td>92.3(4.4)</td><td>/</td><td>5e6</td></tr><tr><td>3s5z</td><td>Hard</td><td>100.0(1.9)</td><td>100.0(3.3)</td><td>72.5(26.5)</td><td>90.0(3.5)</td><td>84.3(5.4)</td><td>/</td><td>3e6</td></tr><tr><td>5m vs 6m</td><td>Hard</td><td>90.6(4.4)</td><td>83.1(4.6)</td><td>88.2(6.2)</td><td>73.8(4.4)</td><td>75.8(3.7)</td><td>90.6(6.1)</td><td>1e7</td></tr><tr><td>8m vs 9m</td><td>Hard</td><td>100.0(3.1)</td><td>95.0(4.6)</td><td>93.8(3.5)</td><td>86.2(4.4)</td><td>92.6(4.0)</td><td>/</td><td>5e6</td></tr><tr><td>10m vs 11m</td><td>Hard</td><td>100.0(1.4)</td><td>100.0(2.0)</td><td>96.3(5.8)</td><td>77.5(9.7)</td><td>95.8(6.1)</td><td>/</td><td>5e6</td></tr><tr><td>25m</td><td>Hard</td><td>100.0(1.3)</td><td>86.9(5.6)</td><td>100.0(2.7)</td><td>70.1(8.1)</td><td>90.2(9.8)</td><td>2.8(3.1)</td><td>2e6</td></tr><tr><td>27m vs 30m</td><td>Hard+</td><td>100.0(0.7)</td><td>95.3(2.2)</td><td>93.1(3.2)</td><td>5.6(2.8)</td><td>39.2(8.8)</td><td>/</td><td>1e7</td></tr><tr><td>MMM2</td><td>Hard+</td><td>93.8(2.6)</td><td>91.2(5.3)</td><td>81.8(10.1)</td><td>68.8(13.7)</td><td>88.3(2.4)</td><td>/</td><td>1e7</td></tr><tr><td>6h vs 8z</td><td>Hard+</td><td>98.8(1.3)</td><td>93.8(4.7)</td><td>88.4(5.7)</td><td>0.3(0.4)</td><td>9.7(3.1)</td><td>/</td><td>1e7</td></tr><tr><td>3s5z vs 3s6z</td><td>Hard+</td><td>96.5(1.3)</td><td>85.3(7.5)</td><td>84.3(19.4)</td><td>82.8(21.2)</td><td>68.8(21.2)</td><td>/</td><td>2e7</td></tr></table>
130
+
131
+ ![](images/3d7ba93c472c245a76d1e9b46ca6a00f09693e351a67723eef51e51c2a4db1c4.jpg)
132
+ Figure 5: Performance comparison on the Google Research Football tasks with 2-4 agents from left to right respectively.
133
+
134
+ HAPPO on the time complexity. Lastly, to assure that the limiting joint policy is such that none of the agents is incentivized to change its policy (Nash equilibrium), MAT requires permutating the sequential order of updates at every iteration, which is inline with the discovery in HAPPO [15, Theorem 3].
135
+
136
+ # 5 Experiments and Results
137
+
138
+ MAT provides a new solution paradigm for cooperative MARL problems. The key insights of MAT are the sequential update scheme, which is inspired by Theorem (1), as well as the encoder-decoder architecture, which provides a highly-efficient implementation for a sequence modeling perspective. Importantly, MAT inherits the monotonic improvement guarantee, and agents’ policies can be learned in parallel during training. We firmly believe MAT will become a game changer for MARL studies.
139
+
140
+ To evaluate if MAT meets our expectations, we test MAT on the StarCraftII Multi-Agent Challenge (SMAC) benchmark [31] where MAPPO with parameter sharing [46] has shown superior performance, and the Multi-Agent MuJoCo benchmark [7] where HAPPO [15] shows the current state-of-the-art performance. SMAC and MuJoCo environments are common benchmarks in the MARL field. On top of them, we also test MAT on the Bimanual Dexterous Hands Manipulation (Bi-DexHands) [6] which provides a list of challenging bimanual manipulation tasks (see Figure (3)), and the Google Research Football [18] benchmark with a series of cooperation scenarios in football game.
141
+
142
+ We apply the same hyper-parameters of baseline algorithms from their original paper to ensure their best performance, and adopt the same hyper-parameter tuning process for our methods with details in Appendix B. To ensure fair comparisons to CTDE methods, we also introduce a CTDE-variant of MAT called MAT-Dec, which essentially adopts a fully decentralized actor for each individual agent (rather than using the decoder proposed in MAT) while keeping the encoder fixed. The critic’s loss for MAT-Dec is $\begin{array} { r } { L ( \phi ) = \frac { 1 } { T } \sum _ { t = 0 } ^ { T - 1 } \left[ R ( \mathbf { o } _ { t } , \mathbf { a } _ { t } ) + \gamma \frac { 1 } { n } \sum _ { m = 1 } ^ { n } V _ { \vec { \phi } } ( \hat { \mathbf { o } } _ { t + 1 } ^ { i _ { m } } ) - \frac { 1 } { n } \sum _ { m = 1 } ^ { n } V _ { \phi } ( \hat { \mathbf { o } } _ { t } ^ { i _ { m } } ) \right] ^ { 2 } , } \end{array}$ and we apply the local advantage estimation $A _ { t } \big ( \hat { \mathbf { o } } _ { t } ^ { i _ { m } } , a ^ { i _ { m } } \big )$ to guide the subsequent policy update.
143
+
144
+ ![](images/475361329427df4de80617968b1a2a1d3b504e83678e33306c556403d6d3eefd.jpg)
145
+ Figure 6: Performance on the HalfCheetah task with different disabled joints shown in Figure (3a).
146
+
147
+ # 5.1 Performance on Cooperative MARL Benchmarks
148
+
149
+ According to Table (1) and Figure (4), MAPPO significantly outperforms HAPPO in SMAC with higher sample efficiency. This verified the homogeneity of SMAC agents and the heterogeneity of multi-agent MuJoCo agents, that are also discovered by Kuba et al. [15]. Take the SMAC task $2 5 m$ as an example, all the marines are equivalent and interchangeable so that agents can learn from their teammate’s experience. Sharing parameters in this settings means leveraging 25 times more examples to train each agents comparing with separated network of HAPPO, and thus enjoying higher learning efficiency. On the other hand, with the heterogeneous settings of multi-agent MuJoCo, training a "foot" agent with experience from a "thigh" agent can surely harm its performance since they represent different functions on the Cheetah. However, MAT outperforms MAPPO and HAPPO in almost all tasks in Table (1) and Figure (4), indicating its modeling capability on both homogeneous and heterogeneous-agent tasks. MAT also enjoys the superior performance over MAT-Dec, which emphasize the importance of the decoder architecture in the MAT design. On the Bi-DexHands tasks, MAT outperforms MAPPO and HAPPO methods by a large margin. We save the Google Football results to Figure (5), where the conclusion stays the same.
150
+
151
+ # 5.2 MAT as Excellent Few-short Learners
152
+
153
+ Since Transformer-based models often demonstrate strong generalization performance on few-short tasks [3, 9], we believe MAT can possess strong generalization ability on unseen MARL tasks as well. To validate such an assumption, we design zero-shot and few-shot experiments on SMAC and multi-agent MuJoCo tasks. For SMAC tasks, we pre-train agents on eight tasks involving five types of units (3m, 8m vs 9m, 10m vs 11m, 25m, 3s vs 3z, 2s3z, 3s5z, MMM ) with 10M examples in total and then apply them on six separate and much harder tasks (5m vs 6m, 8m, $2 7 m$ vs 30m, 2s vs 1sc, 1c3s5z, MMM2 ) including seven types of units. This setting is designed to evaluate the generalization ability of MAT when training on simple tasks but transferring to more diverse and complex downstream tasks. In terms of multi-agent MuJoCo, we reuse the models trained on the complete HalfCheetah robot as the pre-trained agent and then directly apply it to six new tasks, each with a different leg being disfunctioned (see Figure (3a)). We investigate the generalization capability of pre-trained models on each downstream task with $0 \%$ (zero-shot), $1 \%$ , $5 \%$ , $10 \%$ few-short new examples, respectively. Note that common MARL baselines such as HAPPO assume fixed number of agents during training, thus it cannot directly handle the cases with changing number of agents.
154
+
155
+ Table 2: Median evaluation win rate and the standard deviation on the SMAC benchmark for pre-trained models with different number of online examples.
156
+
157
+ <table><tr><td rowspan="2">Methods #examples</td><td colspan="4">MAT</td><td colspan="4">MAPPO</td><td colspan="4">MAT-from scratch</td></tr><tr><td>0%</td><td>1%</td><td>5%</td><td>10%</td><td>0%</td><td>1%</td><td>5%</td><td>10%</td><td>0%</td><td>1%</td><td>5%</td><td>10%</td></tr><tr><td>5m vs 6m</td><td>0.0(0.0)</td><td>0.0(0.0)</td><td>5.8(3.1)</td><td>18.8(7.1)</td><td>0.0(0.0)</td><td>0.0(0.0)</td><td>4.3(3.8)</td><td>21.9(12.2)</td><td>0.0(0.0)</td><td>0.0(0.0)</td><td>1.9(1.3)</td><td>3.8(2.1)</td></tr><tr><td>8m</td><td>100(0.0)</td><td>100(1.2)</td><td>100(0.3)</td><td>100(2.1)</td><td>100(0.0)</td><td>100(1.4)</td><td>100(0.3)</td><td>100(1.4)</td><td>0.0(0.0)</td><td>10.6(23.8)</td><td>92.5(3.7)</td><td>100(1.4)</td></tr><tr><td>27m vs 30m</td><td>0.0(0.0)</td><td>6.3(2.4)</td><td>53.8(16.4)</td><td>71.2(8.2)</td><td>9.4(3.6)</td><td>15(5.9)</td><td>26.2(7.8)</td><td>26.8(9.7)</td><td>0.0(0.0)</td><td>0.0(0.0)</td><td>0.0(0.3)</td><td>0.3(15.6)</td></tr><tr><td>2s vs 1sc</td><td>0.0(0.0)</td><td>15.6(13.8)</td><td>100(9.7)</td><td>100(0.0)</td><td>0.0(0.0)</td><td>43.1(17.6)</td><td>100(1.1)</td><td>100(1.8)</td><td>0.0(0.0)</td><td>19.3(33.3)</td><td>96.3(6.2)</td><td>100(0.3)</td></tr><tr><td>1c3s5z</td><td>3.1(1.8)</td><td>5.6(5.0)</td><td>82.5(5.5)</td><td>100(2.7)</td><td>3.1(1.8)</td><td>4.3(4.9)</td><td>73.8(13.0)</td><td>97.5(2.1)</td><td>0.0(0.0)</td><td>7.5(4.8)</td><td>87.5(3.9)</td><td>100(1.4)</td></tr><tr><td>MMM2</td><td>0.0(3.6)</td><td>0.0(1.8)</td><td>33.8(13.7)</td><td>62.5(12.1)</td><td>0.0(0.0)</td><td>0.0(1.4)</td><td>13.8(7.0)</td><td>36.2(9.6)</td><td>0.0(0.0)</td><td>0.0(0.0)</td><td>0.0(0.0)</td><td>0.0(0.7)</td></tr></table>
158
+
159
+ Table 3: Average evaluation score and standard deviation on Multi-Agent MuJoCo for pre-trained models with different number of online examples.
160
+
161
+ <table><tr><td rowspan="2">Methods #examples</td><td colspan="4">MAT</td><td colspan="4">MAPPO</td><td colspan="4">MAT-from scratch</td></tr><tr><td>0%</td><td>1%</td><td>5%</td><td>10%</td><td>0%</td><td>1%</td><td>5%</td><td>10%</td><td>0%</td><td>1%</td><td>5%</td><td>10%</td></tr><tr><td>back foot</td><td>2100(89)</td><td>2837(95)</td><td>4691(235)</td><td>5646(79)</td><td>2936(301)</td><td>3017(135)</td><td>3221(119)</td><td>3304(129)</td><td>-0.44(0.4)</td><td>-5.18(11)</td><td>670(1098)</td><td>1635(1184)</td></tr><tr><td>back shin</td><td>4005(316)</td><td>4143(230)</td><td>6077(209)</td><td>7176(74)</td><td>2406(32)</td><td>2542(108)</td><td>2796(137)</td><td>2955(127)</td><td>-0.31(0.1)</td><td>-3.95(17)</td><td>743(537)</td><td>1252(1123)</td></tr><tr><td>back thigh</td><td>5361(45)</td><td>5641(150)</td><td>7101(119)</td><td>7460(61)</td><td>3043(79)</td><td>3060(143)</td><td>3217(3)</td><td>3353(71)</td><td>-0.54(0.3)</td><td>-4.87(7.7)</td><td>930(589)</td><td>2067(861)</td></tr><tr><td>fore foot</td><td>1313(512)</td><td>1955(232)</td><td>4856(146)</td><td>6054(172)</td><td>623(44)</td><td>970(185)</td><td>2025(371)</td><td>2480(239)</td><td>-0.37(0.2)</td><td>-2.25(7.9)</td><td>1821(157)</td><td>2877(106)</td></tr><tr><td>fore shin</td><td>2435(13)</td><td>2617(71)</td><td>3851(57)</td><td>4373(83)</td><td>1715(55)</td><td>2457(125)</td><td>3096(59)</td><td>3310(54)</td><td>-0.15(0.06)</td><td>-0.96(6.0)</td><td>1461(101)</td><td>3003(316)</td></tr><tr><td>fore thigh</td><td>5631(321)</td><td>6448(417)</td><td>7952(109)</td><td>8347(81)</td><td>3087(110)</td><td>3171(83)</td><td>3340(52)</td><td>3519(59)</td><td>-0.29(0.3)</td><td>0.82(14)</td><td>1021(177)</td><td>2600(215)</td></tr></table>
162
+
163
+ We summarize the zero-shot and few-shot results of each algorithm in Table (2) and (3), where the bold number indicates the best performance. We also provide the performance of MAT if it was given the same amount of data but is trained from scratch, the "MAT-from scratch", as the control group to demonstrate the effectiveness of pre-training process. As both tables suggest, bold numbers are mainly located in the area of MAT, which justify MAT’s strong generalisation performance as a few-short learner. Surprisingly, we find that the few-shot MAT with only $10 \%$ data show even higher rewards than its counterpart that is purely trained on HalfCheetah with the same disabled joints (back foot, back shin and back thigh ) and $100 \%$ full amount data, we believe it is because the pre-train process offers initial weights that are not only closer to optimum but also less likely to stuck in bad local optima than random initialization.
164
+
165
+ # 6 Conclusion
166
+
167
+ In the past five years, large sequence models have achieved remarkable successes on solving visual language tasks. In this paper, we take the initial effort to build the connection between multi-agent reinforcement learning (MARL) problems and generic sequence models (SM), with the ambition that MARL researchers can hereafter benefit from the prosperous development on the sequence modeling side. Specifically, we contribute by unifying a general solution to cooperative MARL problems into a Transformer like encoder-decoder model. The proposed Multi-Agent Transformer (MAT) leverages the multi-agent advantage decomposition theorem, which essentially transforms the joint policy optimization process into a sequential decision making process that can be simply implemented by an auto-regressive model. We have demonstrated MAT’s strong empirical performance on three challenging benchmarks against current state-of-the-art MARL solutions including MAPPO and HAPPO. Based on the established connection between MARL and SM, in the future, we plan to bring multi-agent learning tasks into large multi-modal SM, chasing for more generally intelligent models as the most recent success of GATO has already demonstrated [30].
168
+
169
+ # Acknowledgment
170
+
171
+ The SJTU team is partially supported by “New Generation of AI 2030” Major Project (2018AAA0100900), Shanghai Municipal Science and Technology Major Project (2021SHZDZX0102), Shanghai Sailing Program (21YF1421900), and National Natural Science Foundation of China (62076161, 62106141).
172
+
173
+ References
174
+ [1] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. arXiv preprint arXiv:2204.14198, 2022.
175
+ [2] Rishi Bommasani, Drew A Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, et al. On the opportunities and risks of foundation models. arXiv preprint arXiv:2108.07258, 2021.
176
+ [3] Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. NeurIPS, 2020.
177
+ [4] Yu-Han Chang, Tracey Ho, and Leslie Kaelbling. All learning is local: Multi-agent learning in global reward games. Advances in neural information processing systems, 16, 2003.
178
+ [5] Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Michael Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision transformer: Reinforcement learning via sequence modeling. arXiv preprint arXiv:2106.01345, 2021.
179
+ [6] Yuanpei Chen, Yaodong Yang, Tianhao Wu, Shengjie Wang, Xidong Feng, Jiechuang Jiang, Stephen Marcus McAleer, Hao Dong, Zongqing Lu, and Song-Chun Zhu. Towards human-level bimanual dexterous manipulation with reinforcement learning. arXiv preprint arXiv:2206.08686, 2022.
180
+ [7] Christian Schröder de Witt, Bei Peng, Pierre-Alexandre Kamienny, Philip H. S. Torr, Wendelin Böhmer, and Shimon Whiteson. Deep multi-agent reinforcement learning for decentralized continuous cooperative control. CoRR, abs/2003.06709, 2020.
181
+ [8] Xiaotie Deng, Yuhao Li, David Henry Mguni, Jun Wang, and Yaodong Yang. On the complexity of computing markov perfect equilibrium in general-sum stochastic games. arXiv preprint arXiv:2109.01795, 2021.
182
+ [9] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT (1), 2019.
183
+ [10] 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.
184
+ [11] Jakob Foerster, Gregory Farquhar, Triantafyllos Afouras, Nantas Nardelli, and Shimon Whiteson. Counterfactual multi-agent policy gradients. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
185
+ [12] Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. Masked autoencoders are scalable vision learners. arXiv preprint arXiv:2111.06377, 2021.
186
+ [13] Siyi Hu, Fengda Zhu, Xiaojun Chang, and Xiaodan Liang. Updet: Universal multi-agent reinforcement learning via policy decoupling with transformers. arXiv preprint arXiv:2101.08001, 2021.
187
+ [14] Michael Janner, Qiyang Li, and Sergey Levine. Offline reinforcement learning as one big sequence modeling problem. Advances in Neural Information Processing Systems, 34, 2021.
188
+ [15] Jakub Grudzien Kuba, Ruiqing Chen, Munning Wen, Ying Wen, Fanglei Sun, Jun Wang, and Yaodong Yang. Trust region policy optimisation in multi-agent reinforcement learning. ICLR, 2022.
189
+ [16] Jakub Grudzien Kuba, Xidong Feng, Shiyao Ding, Hao Dong, Jun Wang, and Yaodong Yang. Heterogeneous-agent mirror learning: A continuum of solutions to cooperative marl. arXiv preprint arXiv:2208.01682, 2022.
190
+
191
+ [17] Jakub Grudzien Kuba, Muning Wen, Linghui Meng, Haifeng Zhang, David Mguni, Jun Wang, Yaodong Yang, et al. Settling the variance of multi-agent policy gradients. Advances in Neural Information Processing Systems, 34:13458–13470, 2021.
192
+
193
+ [18] Karol Kurach, Anton Raichuk, Piotr Stanczyk, Micha ´ ł Zaj ˛ac, Olivier Bachem, Lasse Espeholt, Carlos Riquelme, Damien Vincent, Marcin Michalski, Olivier Bousquet, et al. Google research football: A novel reinforcement learning environment. arXiv preprint arXiv:1907.11180, 2019.
194
+
195
+ [19] Michael L Littman. Markov games as a framework for multi-agent reinforcement learning. In Machine learning proceedings 1994, pages 157–163. Elsevier, 1994.
196
+
197
+ [20] Ryan Lowe, Yi Wu, Aviv Tamar, Jean Harb, Pieter Abbeel, and Igor Mordatch. Multi-agent actorcritic for mixed cooperative-competitive environments. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pages 6382–6393, 2017.
198
+
199
+ [21] Xueguang Lyu, Yuchen Xiao, Brett Daley, and Christopher Amato. Contrasting centralized and decentralized critics in multi-agent reinforcement learning. arXiv preprint arXiv:2102.04402, 2021.
200
+
201
+ [22] Anuj Mahajan, Tabish Rashid, Mikayel Samvelyan, and Shimon Whiteson. Maven: Multi-agent variational exploration. Advances in Neural Information Processing Systems, 32, 2019.
202
+
203
+ [23] Linghui Meng, Muning Wen, Yaodong Yang, Chenyang Le, Xiyun Li, Weinan Zhang, Ying Wen, Haifeng Zhang, Jun Wang, and Bo Xu. Offline pre-trained multi-agent decision transformer: One big sequence model conquers all starcraftii tasks. arXiv preprint arXiv:2112.02845, 2021.
204
+
205
+ [24] David Mguni, Jianhong Wang, Taher Jafferjee, Nicolas Perez-Nieves, Wenbin Song, Yaodong Yang, Feifei Tong, Hui Chen, Jiangcheng Zhu, Yali Du, et al. Learning to shape rewards using a game of switching controls. arXiv preprint arXiv:2103.09159, 2021.
206
+
207
+ [25] David Henry Mguni, Taher Jafferjee, Jianhong Wang, Nicolas Perez-Nieves, Oliver Slumbers, Feifei Tong, Yang Li, Jiangcheng Zhu, Yaodong Yang, and Jun Wang. Ligs: Learnable intrinsicreward generation selection for multi-agent learning. In International Conference on Learning Representations, 2021.
208
+
209
+ [26] Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. nature, 518(7540):529–533, 2015.
210
+
211
+ [27] Prakash M Nadkarni, Lucila Ohno-Machado, and Wendy W Chapman. Natural language processing: an introduction. Journal of the American Medical Informatics Association, 18(5):544– 551, 2011.
212
+
213
+ [28] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pages 8821–8831. PMLR, 2021.
214
+
215
+ [29] Tabish Rashid, Mikayel Samvelyan, Christian Schroeder, Gregory Farquhar, Jakob Foerster, and Shimon Whiteson. Qmix: Monotonic value function factorisation for deep multi-agent reinforcement learning. In International Conference on Machine Learning, pages 4295–4304. PMLR, 2018.
216
+
217
+ [30] Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, and Nando de Freitas. A generalist agent. arXiv preprint arXiv:2205.06175, 2022.
218
+
219
+ [31] Mikayel Samvelyan, Tabish Rashid, Christian Schroeder de Witt, Gregory Farquhar, Nantas Nardelli, Tim GJ Rudner, Chia-Man Hung, Philip HS Torr, Jakob Foerster, and Shimon Whiteson. The starcraft multi-agent challenge. 2019.
220
+
221
+ [32] John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel. Highdimensional continuous control using generalized advantage estimation. arXiv preprint arXiv:1506.02438, 2015.
222
+ [33] John Schulman, F. Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. ArXiv, abs/1707.06347, 2017.
223
+ [34] David Silver, Guy Lever, Nicolas Heess, Thomas Degris, Daan Wierstra, and Martin Riedmiller. Deterministic policy gradient algorithms. In International conference on machine learning, pages 387–395. PMLR, 2014.
224
+ [35] Kyunghwan Son, Daewoo Kim, Wan Ju Kang, David Earl Hostallero, and Yung Yi. Qtran: Learning to factorize with transformation for cooperative multi-agent reinforcement learning. In International Conference on Machine Learning, pages 5887–5896. PMLR, 2019.
225
+ [36] Peter Sunehag, Guy Lever, Audrunas Gruslys, Wojciech Marian Czarnecki, Vinicius Zambaldi, Max Jaderberg, Marc Lanctot, Nicolas Sonnerat, Joel Z Leibo, Karl Tuyls, et al. Valuedecomposition networks for cooperative multi-agent learning. arXiv preprint arXiv:1706.05296, 2017.
226
+ [37] Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018.
227
+ [38] Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Hervé Jégou. Going deeper with image transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 32–42, 2021.
228
+ [39] Zhengzhong Tu, Hossein Talebi, Han Zhang, Feng Yang, Peyman Milanfar, Alan Bovik, and Yinxiao Li. Maxvit: Multi-axis vision transformer. arXiv preprint arXiv:2204.01697, 2022.
229
+ [40] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pages 5998–6008, 2017.
230
+ [41] Wenxiao Wang, Lu Yao, Long Chen, Binbin Lin, Deng Cai, Xiaofei He, and Wei Liu. Crossformer: A versatile vision transformer hinging on cross-scale attention. arXiv preprint arXiv:2108.00154, 2021.
231
+ [42] Ying Wen, Yaodong Yang, Rui Luo, Jun Wang, and Wei Pan. Probabilistic recursive reasoning for multi-agent reinforcement learning. In International Conference on Learning Representations, 2018.
232
+ [43] Ying Wen, Yaodong Yang, and Jun Wang. Modelling bounded rationality in multi-agent interactions by generalized recursive reasoning. In Christian Bessiere, editor, Proceedings of the Twenty-Ninth International Joint Conference on Artificial Intelligence, IJCAI-20, pages 414–421. International Joint Conferences on Artificial Intelligence Organization, 7 2020. Main track.
233
+ [44] Yaodong Yang and Jun Wang. An overview of multi-agent reinforcement learning from game theoretical perspective. arXiv preprint arXiv:2011.00583, 2020.
234
+ [45] Yaodong Yang, Ying Wen, Jun Wang, Liheng Chen, Kun Shao, David Mguni, and Weinan Zhang. Multi-agent determinantal q-learning. In International Conference on Machine Learning, pages 10757–10766. PMLR, 2020.
235
+ [46] Chao Yu, A. Velu, Eugene Vinitsky, Yu Wang, A. Bayen, and Yi Wu. The surprising effectiveness of mappo in cooperative, multi-agent games. ArXiv, abs/2103.01955, 2021.
md/dev/1YEF6TA8Di/1YEF6TA8Di.md ADDED
@@ -0,0 +1,475 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Langevin Quasi-Monte Carlo
2
+
3
+ Sifan Liu Department of Statistics Stanford University Stanford, CA 94305 sfliu@stanford.edu
4
+
5
+ # Abstract
6
+
7
+ Langevin Monte Carlo (LMC) and its stochastic gradient versions are powerful algorithms for sampling from complex high-dimensional distributions. To sample from a distribution with density $\pi \overset { \cdot } { ( } \theta ) \propto \overset { \cdot } { \exp ( - U ( \theta ) ) }$ , LMC iteratively generates the next sample by taking a step in the gradient direction $\nabla U$ with added Gaussian perturbations. Expectations w.r.t. the target distribution $\pi$ are estimated by averaging over LMC samples. In ordinary Monte Carlo, it is well known that the estimation error can be substantially reduced by replacing independent random samples by quasi-random samples like low-discrepancy sequences. In this work, we show that the estimation error of LMC can also be reduced by using quasirandom samples. Specifically, we propose to use completely uniformly distributed (CUD) sequences with certain low-discrepancy property to generate the Gaussian perturbations. Under smoothness and convexity conditions, we prove that LMC with a low-discrepancy CUD sequence achieves smaller error than standard LMC. The theoretical analysis is supported by compelling numerical experiments, which demonstrate the effectiveness of our approach.
8
+
9
+ # 1 Introduction
10
+
11
+ Sampling from probability distributions is a crucial task in both statistics and machine learning. However, when the target distribution does not permit exact sampling, researchers often rely on Markov chain Monte Carlo (MCMC) methods. These techniques simulate a Markov chain that converges to the target distribution as its stationary distribution. Recently, MCMC samplers based on discretizing the continuous-time Langevin diffusion have become popular, due to its ease of implementation and ability to handle stochastic gradients (Welling and Teh, 2011).
12
+
13
+ The primary focus of this work is on the quality of samples generated by Langevin Monte Carlo (LMC) algorithms in terms of estimating the expectation $\mathbb { E } _ { \theta \sim \pi } \left[ f ( \theta ) \right]$ for some integrand $f$ by sample averages. In the context of Bayesian inference, the target distribution $\pi$ is typically the posterior distribution, and computing the posterior expectation, posterior variance, or confidence intervals are of great interest. In the context of post-selection inference, the target distribution $\pi$ is the probability distribution conditioned on the selection event, and computing the selection-adjusted p-value is the main task. LMC has been widely used in this problem as well (Markovic and Taylor, 2016; Shi et al., 2022). In all these situations, the accuracy of the sample average estimator is critical and affects the downstream data analysis.
14
+
15
+ In traditional Monte Carlo sampling, it is well known that using quasi-Monte Carlo (QMC) samples, instead of independent and identically distributed (i.i.d.) random samples, can lead to significant error reduction. So it is natural to ask whether we can apply QMC techniques to improve Langevin Monte Carlo sampling as well. In this work, we introduce the Langevin quasi-Monte Carlo (LQMC) algorithm, which replaces the i.i.d. random inputs in the LMC algorithm with quasi-random numbers.
16
+
17
+ ![](images/bea1dbc0489080cb7836fa89b3f143e12237f65da9d81a18d220019f9c986b24.jpg)
18
+ Figure 1: Scatter plots of 251 points generated from Mersenne Twister 19937 (left) and 251 points generated from a linear congruential generator (LCG) of period 251. Points from an entire period of a pseudo-random number generator (right) fill the unit square more evenly than the same number of points from a PRNG with a larger period (left).
19
+
20
+ These quasi-random numbers are carefully designed to sample from the target distribution more evenly and more balanced, leading to improved estimation accuracy.
21
+
22
+ Not all quasi-Monte Carlo point sets are suitable for simulating Markov chains. Suppose the Markov chain is driven by a sequence of uniform random vectors in the unit cube. A sufficient condition for the sequence is known as completely uniformly distributed (CUD). In our implementation of the driving sequence, we use an entire period of a pseudo-random number generator (PRNG). While modern computer simulations often use PRNGs with a large period, such as Mersenne Twister with a period of $2 ^ { 1 9 9 3 7 } - 1$ , our approach runs through the entire period of a PRNG with a relatively small period in the LMC algorithm. The advantage of using an entire period of a PRNG is that the points are more evenly distributed, which is more desirable for numerical integration. We illustrate the balancing property of an entire PRNG in Figure 1.
23
+
24
+ The main contributions of this paper are threefold. First, we propose a novel technique of using quasi-random numbers in Langevin-type algorithms, which can be applied to a wide range of such algorithms by substituting i.i.d. random numbers with a sequence of quasi-random numbers. The quasi-random numbers are constructed similarly as usual PRNGs, therefore no extra computational complexity is required. Second, we evaluate the performance of the proposed LQMC algorithm in a variety of numerical experiments, demonstrating that it can significantly reduce the mean squared error (MSE) of traditional LMC by a factor ranging from 2 to 500, depending on the problem. Finally, we provide theoretical analysis showing that LQMC can reduce the Monte Carlo part of the error from $O ( n ^ { - 1 / 2 } )$ to $O ( n ^ { - 1 + \delta } )$ for any $\delta > 0$ in situations where the Markov chain is strongly contracting and the integrand function $f$ is sufficiently regular. This error reduction is consistent with the usual improvement achieved by using quasi-Monte Carlo in place of plain Monte Carlo.
25
+
26
+ The rest of the paper is organized as follows. In Section 2, we provide some background on LMC and QMC, followed by a review of related work. Section 3 describes the LQMC algorithm and its implementation details. In Section 4, we present theoretical guarantees for the proposed method. Finally, in Section 5, we provide empirical results to evaluate the performance of LQMC and compare it with the standard LMC algorithm.
27
+
28
+ # 2 Backgrounds
29
+
30
+ This section provides some background on Langevin Monte Carlo and quasi-Monte Carlo.
31
+
32
+ # 2.1 Langevin Monte Carlo
33
+
34
+ Suppose we want to sample from the target distribution $\pi ( \theta ) \propto \exp ( - U ( \theta ) )$ where $\theta \in \mathbb { R } ^ { d }$ and $U$ is known as the potential function. LMC algorithms are based on Euler-Maruyama discretization of the Langevin diffusion $\theta ( t )$ , which satisfies the stochastic differential equation
35
+
36
+ $$
37
+ \mathrm { d } \theta ( t ) = - \nabla U ( \theta ( t ) ) \mathrm { d } t + \sqrt { 2 } \mathrm { d } W _ { t } ,
38
+ $$
39
+
40
+ where $\{ W _ { t } \} _ { t \ge 0 }$ is a $d$ -dimensional standard Brownian motion. Under mild technical conditions, the Langevin diffusion $\theta ( t )$ has $\pi$ as its unique invariant distribution (Roberts and Tweedie, 1996). With a discretization step size $h$ , LMC updates the sample $\theta _ { k }$ by
41
+
42
+ $$
43
+ \theta _ { k + 1 } \theta _ { k } - h \nabla U ( \theta _ { k } ) + \sqrt { 2 h } \xi _ { k + 1 }
44
+ $$
45
+
46
+ where $\xi _ { k } \overset { i i d } { \sim } \mathcal { N } ( 0 , I _ { d } )$
47
+
48
+ In many applications, we are interested in computing the expectation $\mu : = \mathbb { E } _ { \theta \sim \pi } \left[ f ( \theta ) \right]$ over $\pi$ for some $\pi$ -integrable function $f$ . The LMC estimator of $\mu$ is the sample average
49
+
50
+ $$
51
+ { \hat { \mu } } _ { n } = { \frac { 1 } { n } } \sum _ { k = 1 } ^ { n } f ( \theta _ { k } ) ,
52
+ $$
53
+
54
+ where $n$ is the number of iterations.
55
+
56
+ Teh et al. (2016) provide an asymptotic bias-variance decomposition of the MSE of the weighted average $\frac { \sum _ { k = 1 } ^ { n } h _ { k } f ( \theta _ { k } ) } { \sum _ { k = 1 } ^ { n } h _ { k } }$ and show that the optimal step size scales as $h _ { k } \asymp k ^ { - 1 / 3 }$ , leading to an MSE of order $O ( n ^ { - 2 / 3 } )$ . Here $h _ { k }$ is the step size used at the $k$ -th iteration. Vollmer et al. (2016) generalize this result to the non-asymptotic setting with a constant step size $h$ . They show that the MSE is of order $\begin{array} { r } { O ( h ^ { 2 } + \frac { 1 } { n h } ) } \end{array}$ , where $\bar { h } ^ { 2 }$ corresponds to the squared bias and $\scriptstyle { \frac { 1 } { n h } }$ corresponds to the variance.
57
+
58
+ # 2.2 Quasi-Monte Carlo
59
+
60
+ QMC is an alternative to Monte Carlo for numerical integration and is well-known for having much higher accuracy than Monte Carlo. QMC is primarily designed to numerically evaluate the integral $\begin{array} { r } { \mu = \int _ { [ 0 , 1 ] ^ { d } } f ( \dot { \mathbf u } ) \mathrm d \mathbf u } \end{array}$ . It estimates $\mu$ by taking points $\bar { \mathbf { u } } _ { i } \in [ \bar { 0 } , 1 ] ^ { d }$ and let the estimator be
61
+
62
+ $$
63
+ { \hat { \mu } } = { \frac { 1 } { n } } \sum _ { i = 1 } ^ { n } f ( \mathbf { u } _ { i } ) .
64
+ $$
65
+
66
+ Unlike Monte Carlo which takes $\mathbf { u } _ { i }$ to be identically independently distributed (i.i.d.), QMC constructs the point set $\{ { \mathbf { u } } _ { i } \} _ { i = 1 } ^ { n }$ that aims to minimize the star discrepancy
67
+
68
+ $$
69
+ D _ { n } ^ { * } = D _ { n } ^ { * } ( \mathbf { u } _ { 1 } , \ldots , \mathbf { u } _ { n } ) = \operatorname* { s u p } _ { \mathbf { a } \in [ 0 , 1 ] ^ { d } } \bigg \lvert \frac { 1 } { n } \sum _ { i = 1 } ^ { n } 1 \{ \mathbf { u } _ { i } \in [ \mathbf { 0 } , \mathbf { a } ) \} - \prod _ { j = 1 } ^ { d } a _ { j } \bigg \rvert .
70
+ $$
71
+
72
+ The star discrepancy measures the uniformity of the point sets by comparing the fraction of points inside $[ \mathbf { 0 } , \mathbf { a } )$ and the volume $\textstyle \prod _ { j = 1 } ^ { d } a _ { j }$ , taking supreme over all the rectangles inside $[ 0 , 1 ] ^ { d }$ anchored at 0. QMC can generate points with $D _ { n } ^ { * } = O ( n ^ { - 1 } ( \log n ) ^ { d - 1 } )$ , thus QMC is also known as low-discrepancy sequence. Commonly used QMC points include Sobol’ sequence (Sobol’, 1967), Niederreiter’s sequence (Niederreiter, 1987), Halton’s sequence, and lattice rules. For a comprehensive survey, we refer to the monograph Dick and Pillichshammer (2010). If the integrand $f$ has bounded variation in the sense of Hardy and Krause $\| f \| _ { \mathrm { H K } }$ , then the Koksma-Hlawka inequality (see e.g. Dick and Pillichshammer (2010)) bounds the integration error by
73
+
74
+ $$
75
+ | \hat { \mu } - \mu | \leq D _ { n } ^ { * } \cdot \| f \| _ { \mathrm { H K } } \leq O ( n ^ { - 1 } ( \log n ) ^ { d - 1 } ) .
76
+ $$
77
+
78
+ While the Koksma-Hlawka inequality shows that QMC is asymptotically better than usual Monte Carlo, it doesn’t provide a practical way to estimate the error. Moreover, integrands might have infinite Hardy-Krause variation.
79
+
80
+ One can apply randomization techniques to QMC to address both problems. Common randomization techniques include random shifts (Cranley and Patterson, 1976) and scrambling (Owen, 1995). For RQMC samples $\mathbf { u } _ { 1 } , \ldots , \mathbf { u } _ { n }$ , each $\mathbf { u } _ { i } \sim \dot { \mathrm { U n i f } } ( [ 0 , 1 ] ^ { d } )$ individually but they have the low-discrepancy property collectively with probability 1. One can estimate the error by multiple independent random replicates. For sufficiently smooth $f$ , the scrambled Sobol’ sequence has variance $O ( \tilde { ( } n ^ { - 3 } ( \log n ) ^ { d - 1 } )$ (Owen, 1997a,b).
81
+
82
+ # 2.3 Related work
83
+
84
+ The first attempt to apply quasi-random numbers to simulate stochastic differential equations was made by Hofmann and Mathé (1997). They showed that if a numerical scheme is weakly convergent with i.i.d. samples, then using completely uniformly distributed (CUD) sequences also leads to consistent estimation. They also demonstrated that certain low-discrepancy sequences are not suitable for simulating SDEs. There have also been some efforts to apply QMC to MCMC. Owen and Tribble (2005) proposed to apply CUD sequences to a Metropolis algorithm and showed that the method is consistent in problems with finite state spaces. Chen et al. (2011) generalized the consistency result to continuous state spaces under the assumption that the Markov chain is a contraction. More recently, Dick et al. (2016); Dick and Rudolf (2014) proved that there exists constructions of the driving sequence $\{ { \bf u } _ { k } \} _ { k \ge 1 }$ such that the discrepancy between the empirical distribution of MCMC samples and the target distribution is bounded by $O ( n ^ { - 1 / 2 } ( \log n ) ^ { 1 / 2 } )$ , the same rate achieved by random inputs. Another line of applying QMC to Markov chains is known as array-RQMC proposed by L’Ecuyer et al. (2008). Array-RQMC runs in parallel multiple Markov chains, and each iteration involves a complicated reordering of the states so that the low-discrepancy among the chains is maintained. Empirically, it achieves significantly smaller estimation error than usual MCMC, but theoretical guarantees remain a challenging open problem.
85
+
86
+ There has been a growing interest in using QMC techniques in various machine learning tasks, such as variational inference (Buchholz et al., 2018; Liu and Owen, 2021), policy learning and evaluation (Arnold et al., 2022), reinforcement learning with evolution strategies (Choromanski et al., 2019; Rowland et al., 2018), compression of large datasets (Dick and Feischl, 2021), example selection in stochastic gradient descent (SGD) (Lu et al., 2021), and deep learning for solving partial differential equations (Longo et al., 2021).
87
+
88
+ Numerous efforts have been devoted to improving LMC and stochastic gradient Langevin dynamics (SGLD). To overcome the instability of Euler-Maruyama discretization, various numerical schemes have been proposed, including higher-order integrators (Chen et al., 2015), underdamped LMC (Cheng et al., 2018), and stochastic Runge-Kutta diffusion (Li et al., 2019). For SGLD, variance reduction techniques such as SAGA and SVGR (Dubey et al., 2016) and control variates (Baker et al., 2019) have been proposed. LMC also provides a useful perspective for optimization, as demonstrated by the analyses in Chen et al. (2016); Dalalyan (2017); Raginsky et al. (2017); Xu et al. (2018); Erdogdu et al. (2018). Our contribution is orthogonal to all the aforementioned work, as our algorithm only modifies the random numbers used in the algorithm. Therefore, our method can be combined with other algorithms without interference.
89
+
90
+ # 3 QMC for LMC
91
+
92
+ In the LMC algorithm, we can think of the Markov chain as being driven by a sequence of uniform variables $\mathbf { u } _ { k }$ in the unit cube $[ 0 , 1 ] ^ { d }$ . For instance, the Gaussian perturbation can be represented as $\xi _ { k } = \Phi ^ { - 1 } ( { \mathbf { u } } _ { k } )$ , where $\Phi ^ { - 1 }$ denotes the inverse Gaussian CDF applied element-wise to $\mathbf { u } _ { k }$ . If a stochastic gradient is employed, the randomness associated with the stochastic gradient can also be expressed as uniform variables. Therefore, we can write the transition of the Markov chain as $\theta _ { k + 1 } \bar { = } \psi ( \theta _ { k } , { \bf u } _ { k + 1 } )$ . In typical computer experiments, $\mathbf { u } _ { k }$ are not really i.i.d. but are deterministic pseudo-random numbers. In this section, we will describe an alternative method of generating the pseudo-random numbers $\mathbf { u } _ { k }$ , which are carefully constructed and can lead to more accurate sample averages.
93
+
94
+ The idea here is to use point sets that are more evenly distributed such as QMC points, which can lead to significant improvement in the usual Monte Carlo estimation. However, caution is required when using QMC points to simulate an SDE like (1). This is because the correlation between successive QMC samples may introduce undesired behavior in the Markov chain, as demonstrated in (Tribble, 2007, Section 3.2). To avoid the dependence among successive values, we require that the blocks of points $( v _ { i } , v _ { i + 1 } , \ldots , v _ { i + d - 1 } )$ for any lag $d$ are uniformly distributed. This notion of uniformity is formally known as completely uniformly distributed (CUD, Korobov (1948)), which we define next.
95
+
96
+ We say an infinite sequence $\{ \mathbf { u } _ { i } \} _ { i = 1 } ^ { \infty } \subseteq [ 0 , 1 ] ^ { d }$ is uniformly distributed on $[ 0 , 1 ] ^ { d }$ if the star discrepancy $D ^ { * } \big ( \{ { \bf \dot { u } } _ { i } \} _ { i = 1 } ^ { n } \big )$ goes to 0 as $n \to \infty$ , where the star discrepancy is defined in Equation 3.
97
+
98
+ Definition 3.1 (Completely uniformly distributed sequence (CUD)). An infinite sequence $\{ v _ { i } \} _ { i = 0 } ^ { \infty } \subset [ 0 , 1 ]$ is called completely uniformly distributed, if for all positive integer $d _ { \mathrm { { z } } }$ the sequence $\{ ( v _ { k } , \ldots , v _ { k + d - 1 } ) \} _ { k = 0 } ^ { \infty } \subseteq \mathbb { R } ^ { d }$ is uniformly distributed on $[ 0 , 1 ] ^ { d }$ . $A$ triangular array $\begin{array} { r c l } { \mathbf { v } _ { n } } & { = } & { \left( v _ { n , 1 } , \ldots , v _ { n , N _ { n } } \right) } \end{array}$ is called array-CUD, if for all positive integer $d _ { \mathrm { { z } } }$ , $D ^ { * } ( ( v _ { n , 1 } , \dots , v _ { n , d } ) , ( v _ { n , 2 } , \dots , v _ { n , d + 1 } ) , \dots , ( v _ { n , N _ { n } - d + 1 } , \dots , v _ { n , N _ { n } } ) ) \to 0$ as $n \to \infty$ , $N _ { n } \infty$ .
99
+
100
+ In other words, the subsequent $d$ -tuples in a CUD sequence are uniformly distributed in the $d .$ - dimensional unit cube for any positive dimension $d$ . Now we are ready to present the main algorithm.
101
+
102
+ # 3.1 LQMC algorithm
103
+
104
+ Let $\{ v _ { i } \} _ { i = 0 } ^ { \infty }$ be a CUD sequence. Let $\mathbf { u } _ { k } = ( v _ { k d } , \ldots , v _ { ( k + 1 ) d - 1 } ) \in \mathbb { R } ^ { d }$ be the $k$ -th non-overlapping $d$ -tuple from the sequence $k \geq 0 ,$ . A CUD sequence is often constructed deterministically. They can further be randomized using the Cranley-Patterson (i.e. random shift) rotation (Cranley and Patterson, 1976)
105
+
106
+ $$
107
+ \mathbf { u } _ { k } \mathbf { u } _ { k } + \Delta \mod 1 ,
108
+ $$
109
+
110
+ where $\Delta \sim \mathrm { U n i f } ( [ 0 , 1 ] ^ { d } )$ . The Cranley-Patterson rotation randomly shifts each dimension of $\mathbf { u } _ { k }$ by a uniform random number separately. Then each $\mathbf { u } _ { k }$ is uniformly distributed on $[ 0 , 1 ] ^ { d }$ . If we apply the inverse Gaussian CDF to each coordinate of $\mathbf { u } _ { k }$ , then $\Phi ^ { - 1 } ( \bar { \mathbf { u } } _ { k } ) \sim \mathcal { N } ( 0 , I _ { d } )$ . In the Langevin-type algorithms, we will let ${ \xi _ { k } = \Phi ^ { - 1 } ( { \mathbf { u } } _ { k } ) }$ and use $\xi _ { k }$ as the Gaussian perturbation in the $k$ -th iteration. Specifically, each iteration takes the form
111
+
112
+ $$
113
+ \theta _ { k + 1 } = \theta _ { k } - h \nabla U ( \theta _ { k } ) + \sqrt { 2 h } \cdot \Phi ^ { - 1 } ( \mathbf { u } _ { k + 1 } ) , \quad k \geq 0 .
114
+ $$
115
+
116
+ Thus the transition map is $\psi ( \theta , { \mathbf { u } } ) = \theta - h \nabla U ( \theta ) + \sqrt { 2 h } \Phi ^ { - 1 } ( { \mathbf { u } } )$ . In practice, we can only run finite many iterations. In the following, we will describe how to construct a finite CUD sequence and feed it into the LMC algorithm.
117
+
118
+ # 3.2 Construction of CUD sequences
119
+
120
+ A finite CUD (array-CUD) sequence is often implemented by using an entire period of a pseudo random number generator with a small period (Tribble, 2007). There exist other constructions of CUD sequences. For further details, interested readers can refer to Levin (1999). We propose to use the linear-feedback shift register (LFSR) provided in Chen (2011), because it has demonstrated good performance and the computational effort required is comparable to other commonly used PRNGs.
121
+
122
+ The binary Galois LFSR (Tausworthe generator, Tausworthe (1965)) of order $m$ updates the states $b _ { i } \in \{ 0 , 1 \}$ recursively by
123
+
124
+ $$
125
+ b _ { i } = \sum _ { j = 0 } ^ { m - 1 } a _ { j } b _ { i - m + j } \mod 2 , \quad i \geq m
126
+ $$
127
+
128
+ with initial states $b _ { 0 } , b _ { 1 } , \dotsc , b _ { m - 1 }$ pre-specified. The $m$ -tuple $( b _ { i } , b _ { i + 1 } , \ldots , b _ { i + m - 1 } ) \in { \bf G F } ( 2 ) ^ { m }$ can only take $2 ^ { m }$ different values. If there is an $m$ -tuple that is all zero, then all $b _ { i }$ ’s in this sequence must be zero. So the period of the sequence $\{ b _ { i } \} _ { i \ge 0 }$ is at most $n = 2 ^ { m } - 1$ . Moreover, the period is exactly equal to $2 ^ { m } - 1$ if and only if the characteristic polynomial
129
+
130
+ $$
131
+ x ^ { m } + a _ { m - 1 } x ^ { m - 1 } + \ldots + a _ { 1 } x + a _ { 0 }
132
+ $$
133
+
134
+ is a primitive polynomial over $\mathrm { G P } ( 2 )$ (Niederreiter, 1992, Lemma 9.1). Given the states $\{ b _ { i } \} _ { i \ge 0 }$ and an offset $s > 0$ such that $\operatorname* { g c d } ( s , 2 ^ { \acute { m } } - 1 ) = 1$ , $v _ { i }$ is computed with
135
+
136
+ $$
137
+ v _ { i } = \sum _ { j = 0 } ^ { m - 1 } b _ { s i + j } 2 ^ { - j - 1 } , \quad i = 0 , 1 , \ldots , 2 ^ { m } - 2 .
138
+ $$
139
+
140
+ That is, for each $i$ , we take the $m$ -tuple $( b _ { s i + j } ) _ { 0 \leq j < m }$ and interpret it as the binary expansion of $v _ { i }$ For the next step, we jump $s$ bits ahead in the sequence $\{ b _ { i } \} _ { i \ge 0 }$ and use the $m$ -tuple starting from $b _ { s ( i + 1 ) }$ . Chen (2011) provided a table of the LFSR generators for $1 0 \leq m \leq 3 2$ . They searched the offsets so that the LFSR has good equi-distributed properties. Our experiments use the LFSR generators listed there.
141
+
142
+ Given the sequence $\{ v _ { i } \} _ { i = 0 } ^ { n - 1 }$ of length $n$ , we repeat it $d$ times and arrange $v _ { i }$ ’s in the following $n \times d$ matrix
143
+
144
+ $$
145
+ \left( \begin{array} { c c c c } { { v _ { 0 } } } & { { v _ { 1 } } } & { { \cdot \cdot \cdot } } & { { v _ { d - 1 } } } \\ { { v _ { d } } } & { { v _ { d + 1 } } } & { { \cdot \cdot \cdot } } & { { v _ { 2 d - 1 } } } \\ { { \vdots } } & { { \vdots } } & { { \ddots } } & { { \vdots } } \\ { { v _ { ( n - 1 ) d } } } & { { v _ { ( n - 1 ) d + 1 } } } & { { \cdot \cdot \cdot } } & { { v _ { n d - 1 } } } \end{array} \right) .
146
+ $$
147
+
148
+ We run the LMC algorithm $n = 2 ^ { m } - 1$ iterations. The $k$ -th uniform vector $\mathbf { u } _ { k }$ is the $k$ -th row of the above matrix. The procedure is summarized in Algorithm 1.
149
+
150
+ # Algorithm 1 Langevin quasi-Monte Carlo (LQMC)
151
+
152
+ Input: Number of iterations $n = 2 ^ { m } - 1$ such that $\operatorname* { g c d } ( 2 ^ { m } - 1 , d ) = 1$ , step size $h$ , initial value $\theta _ { 0 }$ Generate an LFSR sequence $\{ v _ { i } \} _ { i \ge 0 }$ of period $2 ^ { m } - 1$ . Let $\mathbf u _ { k } = ( v _ { ( k - 1 ) d } , \dots , v _ { k d - 1 } ) \in [ 0 , 1 ] ^ { d }$ , for $1 \leq k \leq n$ . Apply Cranley-Patterson rotation (random shift) to $\mathbf { u } _ { k }$ ’s. for $k 1 , \ldots , n$ do $\theta _ { k } \gets \theta _ { k - 1 } - h \nabla U ( \theta _ { k - 1 } ) + \sqrt { 2 h } \Phi ^ { - 1 } ( \mathbf { u } _ { k } )$ end for
153
+ Output: $\theta _ { 1 } , \ldots , \theta _ { n }$
154
+
155
+ If $\operatorname* { g c d } ( n , d ) = 1$ , then each column of the matrix (5) contains no repeated values. This means that among the $n = 2 ^ { m } - 1$ iterations of the LQMC algorithm, each dimension uses one value in each sub-interval ( k2m , k+12m ] at most once (0 ≤ k ≤ 2m − 1). This perfect one-dimensional stratification is one of the reasons why CUD may achieve smaller estimation error than pseudo-random numbers. If $\operatorname* { g c d } ( n , d ) > 1$ , then we take $d ^ { \prime }$ to be the smallest integer greater than $d$ and co-prime with $n$ . We then create the matrix in (5) similarly but with $d ^ { \prime }$ columns. In the LQMC algorithm, we take $\mathbf { u } _ { k }$ to be the $k$ -th row of the matrix but only use the first $d$ coordinates.
156
+
157
+ Algorithm 1 may seem to be restricted by having a fixed number of iterations, $n = 2 ^ { m } - 1$ . However, in practice, the LQMC algorithm can be started with an initial value of $m$ . If the chain does not converge after $2 ^ { m } - 1$ iterations, one can continue the chain with another freshly generated LFSR, possibly with a larger period. This allows for flexibility in adjusting the number of iterations based on the convergence of the chain. Additionally, if a burn-in period is required, one can first run the algorithm with an LFSR of a small period to serve as the burn-in stage and then continue with a larger LFSR. Furthermore, running multiple chains with independent random shifts is embarrassingly parallel. We present the algorithm in the form of the basic LMC algorithm with accurate gradient and constant learning rate. However, as we noted previously, other Langevin-type algorithms can also utilize the CUD sequence directly by substituting the pseudo-random numbers with the LFSR sequence.
158
+
159
+ # 4 Theoretical guarantee
160
+
161
+ Here we study the estimation error $\textstyle | n ^ { - 1 } \sum _ { k = 1 } ^ { n } f ( \theta _ { k } ) - \pi ( f ) |$ of LQMC for some test function $f$ that is 1-Lipschitz and bounded. As the first attempt to prove the convergence rate of using QMC in LMC, we impose the relatively strong conditions of smoothness and convexity.
162
+
163
+ Assumption 1. The potential function $U$ is $L$ -smooth
164
+
165
+ $$
166
+ \| \nabla U ( \theta ) - \nabla U ( \theta ^ { \prime } ) \| _ { 2 } \le L \| \theta - \theta ^ { \prime } \| _ { 2 } , \quad \forall \theta , \theta ^ { \prime } ,
167
+ $$
168
+
169
+ and $M$ -strongly convex
170
+
171
+ $$
172
+ U ( \theta ^ { \prime } ) \geq U ( \theta ) + \nabla U ( \theta ) ^ { \top } ( \theta ^ { \prime } - \theta ) + \frac { M } { 2 } \| \theta ^ { \prime } - \theta \| _ { 2 } ^ { 2 } , \quad \forall \theta , \theta ^ { \prime } .
173
+ $$
174
+
175
+ We will also assume a constant step size $h$ . While LMC with vanishing step sizes converges weakly to the target distribution, in practice a constant step size is often used (Vollmer et al., 2016; Brosse et al., 2018). With a constant step size, we can derive a non-asymptotic error bound for LQMC.
176
+
177
+ Assumption 1 implies that if the step size $\begin{array} { r } { h \le \frac { 2 } { L + M } } \end{array}$ , then the transition map $\psi$ is a strong contraction with parameter $\rho = 1 - h M$ , i.e.
178
+
179
+ $$
180
+ \| \psi ( \boldsymbol { \theta } , { \mathbf u } ) - \psi ( \boldsymbol { \theta } ^ { \prime } , { \mathbf u } ) \| _ { 2 } = \| \boldsymbol { \theta } - \boldsymbol { \theta } ^ { \prime } - h ( \nabla U ( \boldsymbol { \theta } ) - \nabla U ( \boldsymbol { \theta } ^ { \prime } ) ) \| _ { 2 } \le \rho \| \boldsymbol { \theta } - \boldsymbol { \theta } ^ { \prime } \| _ { 2 } .
181
+ $$
182
+
183
+ See e.g. Lemma 2 of Dalalyan and Karagulyan (2019). The strong contraction implies that if we start two chains from $\theta$ and $\theta ^ { \prime }$ , and use the same random numbers at every step, then the two chains will merge exponentially fast. In other words, the state $\theta _ { k }$ largely depends on the most recent iterations and quickly forgets about the past history. Formally, let $\mathbf w _ { k } ^ { ( \ell ) } = ( \bar { \mathbf u } _ { k } , \dots , \mathbf u _ { k - \ell + 1 } )$ denote the random numbers used in the most recent $\ell$ steps. Define the $\ell \cdot$ -step transition as
184
+
185
+ $$
186
+ \theta _ { k } = \psi _ { \ell } ( \theta _ { k - \ell } , \mathbf { w } _ { k } ^ { ( \ell ) } )
187
+ $$
188
+
189
+ and let $\bar { f } _ { \ell } ( \mathbf w _ { k } ^ { ( \ell ) } )$ denote the value of $f ( \theta _ { k } )$ marginalized over $\theta _ { k - \ell } \sim \pi$ , i.e.
190
+
191
+ $$
192
+ \bar { f } _ { \ell } ( \mathbf { w } _ { k } ^ { ( \ell ) } ) = \int f \circ \psi _ { \ell } ( x , \mathbf { w } _ { k } ^ { ( \ell ) } ) \pi ( \mathrm { d } x ) .
193
+ $$
194
+
195
+ Thus $\bar { f } _ { \ell } ( \mathbf { w } _ { k } ^ { ( \ell ) } )$ only depends on the most recent $\ell$ iterations. Due to the strong contraction, $\big | \bar { f } _ { \ell } \big ( \mathbf { w } _ { k } ^ { ( \ell ) } \big ) -$ $f ( \theta _ { k } ) |$ decays exponentially fast with $\ell$ . So for large $\ell$ , the estimation error of $\scriptstyle n ^ { - 1 } \sum _ { k = 1 } ^ { n } f ( \theta _ { k } )$ is close to the error of $\begin{array} { r } { \frac { 1 } { n - \ell } \sum _ { k = \ell + 1 } ^ { n } \bar { f } _ { \ell } ( \mathbf { w } _ { k } ^ { ( \ell ) } ) } \end{array}$ . The latter can be viewed as a $d { \boldsymbol { \ell } }$ -dimensional numerical integration scheme based on the point set $\{ \mathbf { w } _ { k } ^ { ( \ell ) } \} _ { k = \ell + 1 } ^ { n }$ . By leveraging the discrepancy bound of the LFSR sequence and assuming that $\bar { f } _ { \ell }$ has bounded variation in the sense of Hardy and Krause, we can derive an error bound using the Koksma-Hlawka inequality (4). Now we state the main error bound and leave the detailed proof in the Appendix A.
196
+
197
+ Theorem 4.1 (Error bound of LQMC). Let Assumption 1 hold. Define the step size h ≤ 2L+M , $\rho = 1 - h M$ , $\ell = \lceil ( 1 / 2 ) \log _ { \rho } h \rceil$ . Let $\theta _ { 1 } , \ldots , \theta _ { n }$ be the output of Algorithm 1 which runs $n$ iterations with step size $\begin{array} { r } { h \le \frac { 2 } { L + M } } \end{array}$ . Assume the LFSR sequence $\{ v _ { i } \} _ { i \ge 0 }$ in use has period $n = 2 ^ { m } - 1$ , offset $s$ , and $g c d ( m , n ) = \operatorname* { g c d } ( d \ell , n ) = 1$ . If $\bar { f } _ { \ell }$ has bounded variation in the sense of Hardy and Krause, then as $n \to \infty$ we have
198
+
199
+ $$
200
+ \left| \frac { 1 } { n } \sum _ { k = 1 } ^ { n } f ( \theta _ { k } ) - \pi ( f ) \right| \le C _ { 1 } n ^ { - 1 + \delta } + C _ { 2 } h ^ { 1 / 2 } , \quad \forall \delta > 0 .
201
+ $$
202
+
203
+ Here $\delta$ hides poly-logarithmic factors $( \log n ) ^ { d }$ , $C _ { 1 }$ depends on $d , \ell$ and $\| \bar { f } _ { \ell } \| _ { H K }$ , and $\begin{array} { r } { C _ { 2 } = \frac { 3 \sqrt { 2 } } { 2 } \frac { L } { M } d + } \end{array}$ $\operatorname* { m a x } _ { 0 \leq k \leq n } \| \theta _ { k } \| + \mathbb { E } _ { \pi } \left[ \| \theta \| \right]$
204
+
205
+ The upper bound consists of two terms. The first term represents the numerical integration error, which arises from the discrepancy of the point set used in the integration scheme. By utilizing low-discrepancy CUD sequences, we can reduce this numerical integration error (the first term) from the standard rate of $O ( n ^ { - 1 / 2 } )$ to a faster rate of $O ( n ^ { - 1 + \delta } )$ for any $\delta > 0$ . However, it is important to note that when using a constant step size $h$ in LMC, the bias term (second term) does not vanish. This bias term includes not only the discretization error of the Langevin diffusion, but also the difference between $f ( \theta _ { k } )$ and its truncated version $\bar { f } _ { \ell } ( \mathbf w _ { k } ^ { ( \ell ) } )$ . Consequently, the bias term in our analysis is larger than the bias term in Vollmer et al. (2016), which employs different techniques and assumptions based on the Poisson equation.
206
+
207
+ The theorem’s assumption of finite Hardy-Krause variation is a common requirement in error bounds for QMC methods, and it can be challenging to verify in practice. Basu and Owen (2016) provide sufficient conditions in order for $f \circ \psi _ { \ell }$ to have finite HK variation, requiring the $\ell \cdot$ -step transition $\psi _ { \ell }$ to be sufficiently smooth. In the next section, we aim to assess the practical performance of the proposed LQMC algorithm through numerical experiments.
208
+
209
+ # 5 Numerical experiments
210
+
211
+ To comprehensively evaluate the performance of the algorithm, we will consider both convex and non-convex potentials, both low-dimensional and high-dimensional state spaces, both accurate and stochastic gradients, both smooth and discontinuous integrands, as well as different learning rate schedules. Additional numerical results can be found in the Appendix B.
212
+
213
+ ![](images/711d95f81584702ce987bb3b555e889589fcac7e1ae0f7fa9aa7d395db72c8fa.jpg)
214
+ Figure 2: Bayesian logistic regression with accurate gradients (top) and stochastic gradients (bottom).
215
+
216
+ # 5.1 Bayesian logistic regression
217
+
218
+ We first consider the Bayesian logistic model
219
+
220
+ $$
221
+ \begin{array} { r } { y _ { i } \mid x _ { i } \sim \mathrm { B e r n o u l l i } ( ( 1 + \exp ( - x _ { i } ^ { \mathsf { T } } \beta ) ) ^ { - 1 } ) , \quad 1 \le i \le N , } \\ { \beta \sim \mathcal { N } ( 0 , I _ { d } ) . \qquad } \end{array}
222
+ $$
223
+
224
+ We take $N = 2 0$ , $d = 1 0$ . The features $x _ { i }$ are generated from $\mathcal { N } ( 0 , \Sigma )$ with $\Sigma _ { i j } = 2 ^ { - | i - j | }$ . The coefficients $\beta$ and the data $y _ { i }$ ’s are generated from the same model. We consider the test functions $f ( x ) = x _ { j } , x _ { j } ^ { 2 } , \mathbf { 1 } _ { \{ x _ { j } > 0 \} }$ for $j = 1 , \ldots , d$ . The step size $h$ is fixed to 0.001.
225
+
226
+ We compute the MSE of the estimator based on usual LMC and the proposed LQMC with CUD sequences and report the MSE averaged over all coordinates and 20 random replicates. We do not have a closed form for the expectations $\mathbb { E } \left[ f \right]$ , so the ground truth is estimated using a high-accuracy estimator proposed in He et al. (2023) using scrambled Sobol’ sequence with a very large sample size.
227
+
228
+ In Figure 2 (top panel), we present a log-log plot of the MSE against the number of iterations. Across all three test functions, we observe that LQMC reduces the MSE by a factor ranging from 4 to 8. As the number of iterations increases, the curve corresponding to LQMC reaches a plateau. This behavior can be attributed to the discretization error inherent in the unadjusted LMC, which cannot be further reduced by increasing the number of iterations.
229
+
230
+ In the bottom panel of Figure 2, we increase the number of observations to $N = 1 0 0$ and incorporate stochastic gradient estimation in the Langevin algorithm. Specifically, at each iteration, we estimate the gradient using a random subset of 10 observations. The results demonstrate that LQMC still provides a big improvement when $n$ is smaller than $2 ^ { 1 4 }$ . However, as $n$ surpasses $2 ^ { 1 4 }$ , we observe that the LQMC curve flattens again. It is worth noting that the improvement achieved by LQMC in this scenario is less pronounced compared to the previous example, primarily due to the presence of noise in the gradient estimates.
231
+
232
+ # 5.2 Bayesian linear regression
233
+
234
+ Now we try a higher-dimensional example with Bayesian linear regression. The model is defined as
235
+
236
+ $$
237
+ \begin{array} { r l } & { \boldsymbol { y } _ { i } \sim \mathcal { N } ( x _ { i } ^ { \intercal } \beta , \sigma ^ { 2 } = 4 ^ { - 1 } ) , \quad 1 \leq i \leq N , } \\ & { \beta \sim \mathcal { N } ( 0 , I ) . } \end{array}
238
+ $$
239
+
240
+ We take $d = 1 0 0$ and $N = 2 0$ . We generate $x _ { i } \in \mathbb { R } ^ { d }$ similarly as in the logistic regression example. The test functions and step size are also unchanged. The posterior distribution of $\beta$ has the closed form $\begin{array} { r } { \mathcal { N } \left( ( \frac { X ^ { \top } X } { \sigma ^ { 2 } } + I ) ^ { - 1 } \frac { X ^ { \widehat { \mathsf { T } } } Y } { \sigma ^ { 2 } } , ( \frac { X ^ { \top } X } { \sigma ^ { 2 } } + I ) ^ { - 1 } \right) } \end{array}$ . The results are shown in Figure 3. We see that even at 100 dimension, LQMC still brings a substantial improvement over LMC in terms of MSE. In particular, for the integrand $f ( x ) = x _ { j }$ , LQMC achieves a reduction in MSE of approximately 500-fold compared to LMC.
241
+
242
+ ![](images/bbfcb350aef010496d700422f157e1fb65400bdfea5ca9ef459b33cbb7646348.jpg)
243
+ Figure 3: Bayesian linear regression in 100 dimensions.
244
+
245
+ ![](images/8d6b00ad90b084168d4d46cfd574ad385bcee892df89ec67464f8e036835017e.jpg)
246
+ Figure 4: Crossed random effect.
247
+
248
+ # 5.3 A hierarchical Bayesian model
249
+
250
+ We consider a hierarchical Bayesian model known as the crossed random effect model
251
+
252
+ $$
253
+ \begin{array} { r l } & { Y _ { i j } \sim { \mathcal N } ( \mu + a _ { i } + b _ { j } , 1 ) , \quad 1 \leq i \leq I , \ 1 \leq j \leq J , } \\ & { \mu \sim { \mathcal N } ( 0 , 1 ) , \ a _ { i } \stackrel { i i d } { \sim } { \mathcal N } ( 0 , \sigma _ { a } ^ { 2 } ) , \ b _ { j } \stackrel { i i d } { \sim } { \mathcal N } ( 0 , \sigma _ { b } ^ { 2 } ) , } \\ & { \log ( \sigma _ { a } ^ { 2 } ) , \ \log ( \sigma _ { b } ^ { 2 } ) \stackrel { i i d } { \sim } { \mathcal N } ( 0 , 1 ) . } \end{array}
254
+ $$
255
+
256
+ The goal is to sample from the posterior distribution of $( \mu , \mathbf { a } , \mathbf { b } , \log ( \sigma _ { a } ^ { 2 } ) , \log ( \sigma _ { b } ^ { 2 } ) )$ , which has dimension $d = I + J + 3$ . We take $I = 3$ , $J = 5$ . We will consider the test functions $f ( x ) = x _ { j }$ $( 1 \leq j \leq d )$ . The ground truth of $\mathbb { E } \left[ f ( x ) \right]$ is estimated by Langevin dynamics with Metropolis adjustments (MALA) using a large sample size.
257
+
258
+ We will compare the performance of the LQMC algorithm using three different step sizes: a constant step size of $1 0 ^ { - 4 }$ , a constant step size of $1 0 ^ { - 2 }$ , and decreasing step sizes with $h _ { k } \bar { = } c _ { 0 } ( c _ { 1 } + k ) ^ { - 1 / 3 }$ . The choice of $c _ { 0 }$ and $c _ { 1 }$ ensures that the step size decreases from $\mathrm { 1 0 ^ { - 2 } }$ to $1 0 ^ { - 4 }$ throughout the entire algorithm. The use of the exponent $- 1 / 3$ in the decreasing step sizes is recommended in Teh et al. (2016). The results of these comparisons are presented in Figure 4.
259
+
260
+ In the small step size case (left panel), we observe that the errors of LMC and LQMC are initially comparable for small values of $n$ . This is because the algorithm converges slowly, and thus the error is dominated by the bias. However, as $n$ increases, the improvement of LQMC becomes evident. In the large step size case (middle panel), the MSE of LQMC is consistently smaller than that of LMC even for small values of $n$ . This is because the algorithm converges faster to the target distribution with a larger step size $h$ . Therefore, the improvement of LQMC is more pronounced. Interestingly, in this particular example, using decreasing step sizes yields similar accuracy to using a constant step size of $1 0 ^ { - 4 }$ . It is worth noting that the MSE of LMC does not decrease at a rate of $n ^ { - 2 / 3 }$ as in Teh et al. (2016). This is because the line in the plot does not represent the accuracy against the iteration $k$ within a single training process. Instead, it reflects the accuracy achieved after completing all $n$ iterations of the algorithm, considering different values of $n$ .
261
+
262
+ ![](images/044ec0893d8ac106377d731757837a9257b8c1e1fc339530b893fe2cdfbbd550.jpg)
263
+ Figure 5: Double well potential.
264
+
265
+ # 5.4 Nonconvex potential
266
+
267
+ Finally we investigate a double-well potential function $\begin{array} { r } { U ( x ) = \frac { 1 } { 4 } x ^ { 2 } - \frac { 1 } { 2 } \log ( 1 + x ^ { 2 } ) } \end{array}$ from Pagès and Panloup (2018). We know $\mathbb { E } \left[ x \right] = 0$ and $\mathbb { i } \left[ \mathbf { 1 } _ { \{ \underline { { x } } \geq 0 \} } \right] = 0 . 5$ . The second moment $\mathbb { E } \left[ x ^ { 2 } \right]$ is computed by Gaussian quadrature. See the results in Figure 5. Since the potential has two separate local minimums, it takes longer for the Langevin algorithm to explore the space sufficiently and converge to the target distribution. Once converged, the improvement of LQMC over LMC is still significant.
268
+
269
+ # Acknowledgments and Disclosure of Funding
270
+
271
+ The author thanks Prof. Art Owen for helpful conversations. This work was partially funded by the NSF grant DMS-2152780 and the Stanford Data Science Scholars program.
272
+
273
+ # References
274
+
275
+ Arnold, S. M., L’Ecuyer, P., Chen, L., Chen, Y.-F., and Sha, F. (2022). Policy learning and evaluation with randomized quasi-Monte Carlo. In International Conference on Artificial Intelligence and Statistics, pages 1041–1061. PMLR.
276
+ Baker, J., Fearnhead, P., Fox, E. B., and Nemeth, C. (2019). Control variates for stochastic gradient MCMC. Statistics and Computing, 29:599–615.
277
+ Basu, K. and Owen, A. B. (2016). Transformations and Hardy–Krause variation. SIAM Journal on Numerical Analysis, 54(3):1946–1966.
278
+ Brosse, N., Durmus, A., and Moulines, E. (2018). The promises and pitfalls of stochastic gradient Langevin dynamics. Advances in Neural Information Processing Systems, 31.
279
+ Buchholz, A., Wenzel, F., and Mandt, S. (2018). Quasi-Monte Carlo variational inference. In International Conference on Machine Learning, pages 668–677. PMLR.
280
+ Chen, C., Carlson, D., Gan, Z., Li, C., and Carin, L. (2016). Bridging the gap between stochastic gradient MCMC and stochastic optimization. In Artificial Intelligence and Statistics, pages 1051–1060. PMLR.
281
+ Chen, C., Ding, N., and Carin, L. (2015). On the convergence of stochastic gradient MCMC algorithms with high-order integrators. Advances in neural information processing systems, 28.
282
+ Chen, S. (2011). Consistency and convergence rate of Markov chain quasi Monte Carlo with examples. PhD thesis, Stanford University.
283
+ Chen, S., Dick, J., and Owen, A. (2011). Consistency of Markov chain quasi-Monte Carlo on continuous state spaces. The Annals of Statistics, 39(2):673–701.
284
+ Cheng, X., Chatterji, N. S., Bartlett, P. L., and Jordan, M. I. (2018). Underdamped Langevin MCMC: A non-asymptotic analysis. In Conference on learning theory, pages 300–323. PMLR.
285
+ Choromanski, K., Pacchiano, A., Parker-Holder, J., and Tang, Y. (2019). Structured Monte Carlo sampling for nonisotropic distributions via determinantal point processes. arXiv preprint arXiv:1905.12667.
286
+ Cranley, R. and Patterson, T. N. (1976). Randomization of number theoretic methods for multiple integration. SIAM Journal on Numerical Analysis, 13(6):904–914.
287
+ Dalalyan, A. (2017). Further and stronger analogy between sampling and optimization: Langevin Monte Carlo and gradient descent. In Conference on Learning Theory, pages 678–689. PMLR.
288
+ Dalalyan, A. S. and Karagulyan, A. (2019). User-friendly guarantees for the Langevin Monte Carlo with inaccurate gradient. Stochastic Processes and their Applications, 129(12):5278–5311.
289
+ Dick, J. and Feischl, M. (2021). A quasi-monte carlo data compression algorithm for machine learning. Journal of Complexity, 67:101587.
290
+ Dick, J. and Pillichshammer, F. (2010). Digital Sequences, Discrepancy and Quasi-Monte Carlo Integration. Cambridge University Press, Cambridge.
291
+ Dick, J. and Rudolf, D. (2014). Discrepancy estimates for variance bounding Markov chain quasiMonte Carlo. Electron. J. Probab, 19(105):1–24.
292
+ Dick, J., Rudolf, D., and Zhu, H. (2016). Discrepancy bounds for uniformly ergodic Markov chain quasi-Monte Carlo. Annals of Applied Probability, 26(5):3178–3205.
293
+ Dubey, K. A., J Reddi, S., Williamson, S. A., Poczos, B., Smola, A. J., and Xing, E. P. (2016). Variance reduction in stochastic gradient Langevin dynamics. Advances in neural information processing systems, 29.
294
+ Erdogdu, M. A., Mackey, L., and Shamir, O. (2018). Global non-convex optimization with discretized diffusions. Advances in Neural Information Processing Systems, 31.
295
+ He, Z., Zheng, Z., and Wang, X. (2023). On the error rate of importance sampling with randomized quasi-Monte Carlo. SIAM Journal on Numerical Analysis, 61(2):515–538.
296
+ Hofmann, N. and Mathé, P. (1997). On quasi-Monte Carlo simulation of stochastic differential equations. Mathematics of computation, 66(218):573–589.
297
+ Korobov, N. (1948). On functions with uniformly distributed fractional parts. In Dokl. Akad. Nauk SSSR, volume 62, pages 21–22.
298
+ L’Ecuyer, P., Lécot, C., and Tuffin, B. (2008). A randomized quasi-Monte Carlo simulation method for Markov chains. Operations Research, 56(4):958–975.
299
+ Levin, M. B. (1999). Discrepancy estimates of completely uniformly distributed and pseudorandom number sequences. International Mathematics Research Notices, 1999(22):1231–1251.
300
+ Li, X., Wu, Y., Mackey, L., and Erdogdu, M. A. (2019). Stochastic Runge-Kutta accelerates Langevin Monte Carlo and beyond. Advances in neural information processing systems, 32.
301
+ Liu, S. and Owen, A. B. (2021). Quasi-Monte Carlo quasi-Mewton in variational Bayes. The Journal of Machine Learning Research, 22(1):11043–11065.
302
+ Longo, M., Mishra, S., Rusch, T. K., and Schwab, C. (2021). Higher-order quasi-monte carlo training of deep neural networks. SIAM Journal on Scientific Computing, 43(6):A3938–A3966.
303
+ Lu, Y., Meng, S. Y., and De Sa, C. (2021). A general analysis of example-selection for stochastic gradient descent. In International Conference on Learning Representations.
304
+ Markovic, J. and Taylor, J. (2016). Bootstrap inference after using multiple queries for model selection. arXiv preprint arXiv:1612.07811.
305
+ Niederreiter, H. (1987). Point sets and sequences with small discrepancy. Monatshefte für Mathematik, 104:273–337.
306
+ Niederreiter, H. (1992). Random Number Generation and Quasi-Monte Carlo Methods. SIAM.
307
+ Owen, A. B. (1995). Randomly permuted $( t , m , s )$ -nets and $( t , s )$ -sequences. In Monte Carlo and Quasi-Monte Carlo Methods in Scientific Computing, pages 299–317, New York. Springer-Verlag.
308
+ Owen, A. B. (1997a). Monte Carlo variance of scrambled net quadrature. SIAM Journal of Numerical Analysis, 34(5):1884–1910.
309
+ Owen, A. B. (1997b). Scrambled net variance for integrals of smooth functions. Annals of Statistics, 25(4):1541–1562.
310
+ Owen, A. B. and Tribble, S. D. (2005). A quasi-Monte Carlo Metropolis algorithm. Proceedings of the National Academy of Sciences, 102(25):8844–8849.
311
+ Pagès, G. and Panloup, F. (2018). Weighted multilevel langevin simulation of invariant measures. Annals of Applied Probability, 28(6):3358–3417.
312
+ Raginsky, M., Rakhlin, A., and Telgarsky, M. (2017). Non-convex learning via stochastic gradient Langevin dynamics: a nonasymptotic analysis. In Conference on Learning Theory, pages 1674– 1703. PMLR.
313
+ Roberts, G. O. and Tweedie, R. L. (1996). Exponential convergence of Langevin distributions and their discrete approximations. Bernoulli, pages 341–363.
314
+ Rowland, M., Choromanski, K. M., Chalus, F., Pacchiano, A., Sarlos, T., Turner, R. E., and Weller, A. (2018). Geometrically coupled monte carlo sampling. Advances in Neural Information Processing Systems, 31.
315
+ Shi, J., Liu, C., and Mackey, L. (2022). Sampling with mirrored stein operators. In International Conference on Learning Representations.
316
+ Sobol’, I. M. (1967). On the distribution of points in a cube and the approximate evaluation of integrals. Zhurnal Vychislitel’noi Matematiki i Matematicheskoi Fiziki, 7(4):784–802.
317
+ Tausworthe, R. C. (1965). Random numbers generated by linear recurrence modulo two. Mathematics of Computation, 19(90):201–209.
318
+ Teh, Y. W., Thiery, A. H., and Vollmer, S. J. (2016). Consistency and fluctuations for stochastic gradient Langevin dynamics. Journal of Machine Learning Research, 17.
319
+ Tribble, S. D. (2007). Markov chain Monte Carlo algorithms using completely uniformly distributed driving sequences. PhD thesis, Citeseer.
320
+ Vollmer, S. J., Zygalakis, K. C., and Teh, Y. W. (2016). Exploration of the (non-) asymptotic bias and variance of stochastic gradient Langevin dynamics. The Journal of Machine Learning Research, 17(1):5504–5548.
321
+ Welling, M. and Teh, Y. W. (2011). Bayesian learning via stochastic gradient Langevin dynamics. In Proceedings of the 28th international conference on machine learning (ICML-11), pages 681–688.
322
+ Xu, P., Chen, J., Zou, D., and Gu, Q. (2018). Global convergence of Langevin dynamics based algorithms for nonconvex optimization. Advances in Neural Information Processing Systems, 31.
323
+
324
+ # A Proofs
325
+
326
+ # A.1 Proof of Theorem 4.1
327
+
328
+ We start by decomposing the error $\textstyle { \frac { 1 } { n } } \sum _ { k = 1 } ^ { n } f ( \theta _ { k } ) - \pi ( f ) |$ into three parts
329
+
330
+ $$
331
+ \begin{array} { l } { \displaystyle \sum _ { = 1 } ^ { n } f ( \theta _ { k } ) - \pi ( f ) \bigg | \le \bigg | \frac { 1 } { n } \sum _ { k = \ell + 1 } ^ { n } f ( \theta _ { k } ) - \frac { 1 } { n } \sum _ { k = \ell + 1 } ^ { n } \bar { f } _ { \ell } ( { \mathbf w } _ { k } ^ { ( \ell ) } ) \bigg | + \bigg | \frac { 1 } { n } \sum _ { k = \ell + 1 } ^ { n } \bar { f } _ { \ell } ( { \mathbf w } _ { k } ^ { ( \ell ) } ) - \pi ( f ) \bigg | + \frac { \ell } { n } 2 \| f \| _ { \infty } } \\ { = ( I ) + ( I I ) + \frac { 2 \ell } { n } \| f \| _ { \infty } . } \end{array}
332
+ $$
333
+
334
+ We first upper bound $( I )$ .
335
+
336
+ Lemma 1 (Upper bound of $( I )$ ; adapted from Lemma 6.1.4 of Chen (2011)). If the transition map $\psi$ is a contraction with parameter $\rho$ and if $f$ is $^ { l }$ -Lipschitz, then
337
+
338
+ $$
339
+ \lvert \bar { f } _ { \ell } ( \mathbf w _ { k } ^ { ( \ell ) } ) - f ( \theta _ { k } ) \rvert \le \left( \operatorname* { m a x } _ { 0 \le i \le n } \Vert \theta _ { i } \Vert + \mathbb { E } _ { \pi } \left[ \Vert \theta \Vert \right] \right) \rho ^ { \ell } .
340
+ $$
341
+
342
+ Proof of Lemma $^ { l }$ . Note that
343
+
344
+ $$
345
+ \begin{array} { r l } { | \bar { f } _ { \ell } ( \mathbf w _ { k } ^ { ( \ell ) } ) - f ( \theta _ { k } ) | \le \displaystyle \int | f ( \psi _ { \ell } ( \theta , \mathbf w _ { k } ^ { ( \ell ) } ) ) - f ( \psi _ { \ell } ( \theta _ { k - \ell } , \mathbf w _ { k } ^ { ( \ell ) } ) ) | \pi ( \mathrm d \theta ) } & { } \\ { \displaystyle } & { \le \displaystyle \int \| ( \psi _ { \ell } ( \theta , \mathbf w _ { k } ^ { ( \ell ) } ) ) - ( \psi _ { \ell } ( \theta _ { k - \ell } , \mathbf w _ { k } ^ { ( \ell ) } ) ) \| \pi ( \mathrm d \theta ) } \\ { \displaystyle } & { \le \rho \displaystyle \int \| ( \psi _ { \ell - 1 } ( \theta , \mathbf w _ { k - 1 } ^ { ( \ell - 1 ) } ) ) - ( \psi _ { \ell - 1 } ( \theta _ { k - \ell } , \mathbf w _ { k - 1 } ^ { ( \ell - 1 ) } ) ) \| \pi ( \mathrm d \theta ) } \\ { \displaystyle } & { \le \rho ^ { \ell } \displaystyle \int \| \theta - \theta _ { k - \ell } \| \pi ( \mathrm d \theta ) } \\ { \displaystyle } & { \le \rho ^ { \ell } ( \operatorname* { m a x } _ { 0 \le i \le n } \| \theta _ { i } \| + \mathbb { E } _ { \pi } \left[ \| \theta \| \right] ) . } \end{array}
346
+ $$
347
+
348
+ To bound $( I I )$ , note that $\begin{array} { r } { \frac { 1 } { n - \ell } \sum _ { k = \ell + 1 } ^ { n } \bar { f } _ { \ell } ( \mathbf { w } _ { k } ^ { ( \ell ) } ) } \end{array}$ is estimating
349
+
350
+ $$
351
+ \mathbb { E } \left[ \bar { f } _ { \ell } ( \mathbf { w } ^ { ( \ell ) } ) \right] = \int \psi _ { \ell } ( \boldsymbol { \theta } , \mathbf { w } ^ { ( \ell ) } ) \pi ( \mathrm { d } \boldsymbol { \theta } ) \mathrm { d } \mathbf { w } ^ { ( \ell ) } = : \pi P _ { \ell } ( \boldsymbol { f } ) .
352
+ $$
353
+
354
+ Here, $\pi P _ { \ell }$ denote the distribution of the $\ell$ -step state $\theta _ { \ell }$ starting from $\theta _ { 0 } \sim \pi$ . So we have the further decomposition
355
+
356
+ $$
357
+ \begin{array} { r l } & { ( I I ) \le \displaystyle \left| \frac { 1 } { n - \ell } \sum _ { k = \ell + 1 } ^ { n } \bar { f } _ { \ell } ( \mathbf w _ { k } ^ { ( \ell ) } ) - \pi ( f ) \right| + \frac { \ell } { n - \ell } \| f \| _ { \infty } } \\ & { \quad \le | \pi ( f ) - \pi P _ { \ell } ( f ) | + \displaystyle \left| \frac { 1 } { n - \ell } \sum _ { k = \ell + 1 } ^ { n } \bar { f } _ { \ell } ( \mathbf w _ { k } ^ { ( \ell ) } ) - \pi P _ { \ell } ( f ) \right| + \frac { \ell } { n - \ell } \| f \| _ { \infty } } \\ & { \quad \le ( I I ) ^ { \prime } + ( I I ) ^ { \prime \prime } + \displaystyle \frac { \ell } { n - \ell } \| f \| _ { \infty } . } \end{array}
358
+ $$
359
+
360
+ The first term $( I I ) ^ { \prime }$ is due to the discretization in time. The second term $( I I ) ^ { \prime \prime }$ is the numerical integration error.
361
+
362
+ To bound $( I I ) ^ { \prime }$ , we use the following result.
363
+
364
+ Lemma 2 (Upper bound on discretization error $( I I ) ^ { \prime } $ ). Under Assumption $I$ , we have for $f$ 1- Lipschitz,
365
+
366
+ $$
367
+ | \pi ( f ) - \pi P _ { \ell } ( f ) | \leq \frac { 3 \sqrt { 2 } } { 2 } \frac { L } { M } h ^ { 1 / 2 } d .
368
+ $$
369
+
370
+ Proof of Lemma 2. We let $\theta ( t )$ be the continuous-time Langevin diffusion with $\theta ( 0 ) = \theta _ { 0 } \sim \pi$ , $W _ { t _ { k + 1 } } - W _ { t _ { k } } = \sqrt { h } \xi _ { k + 1 }$ , where $\xi _ { k + 1 } \overset { i i d } { \sim } \mathcal { N } ( 0 , I _ { d } )$ , $t _ { k } = k h$ . So we have
371
+
372
+ $$
373
+ \theta ( t _ { k + 1 } ) = \theta ( t _ { k } ) - \int _ { t _ { k } } ^ { t _ { k + 1 } } \nabla U ( \theta ( s ) ) \mathrm { d } s + \sqrt { 2 h } \xi _ { k + 1 }
374
+ $$
375
+
376
+ and
377
+
378
+ $$
379
+ \theta _ { k + 1 } = \theta _ { k } - h \nabla U ( \theta _ { k } ) + \sqrt { 2 h } \xi _ { k + 1 } .
380
+ $$
381
+
382
+ Combing the previous two equations gives
383
+
384
+ $$
385
+ \theta ( t _ { k + 1 } ) - \theta _ { k + 1 } = \theta ( t _ { k } ) - \theta _ { k } - h [ \nabla U ( \theta ( t _ { k } ) ) - \nabla U ( \theta _ { k } ) ] - \int _ { t _ { k } } ^ { t _ { k + 1 } } \nabla U ( \theta ( s ) ) - \nabla U ( \theta ( t _ { k } ) ) \mathrm { d } s .
386
+ $$
387
+
388
+ Let $\Delta _ { k } = \theta ( t _ { k } ) - \theta _ { k }$ . The last display reads
389
+
390
+ $$
391
+ \Delta _ { k + 1 } = \Delta _ { k } - h [ \nabla U ( \theta _ { k } + \Delta _ { k } ) - \nabla U ( \theta _ { k } ) ] - \int _ { t _ { k } } ^ { t _ { k + 1 } } \nabla U ( \theta ( s ) ) - \nabla U ( \theta ( t _ { k } ) ) \mathrm { d } s .
392
+ $$
393
+
394
+ By the contracting property (6) in the main paper,
395
+
396
+ $$
397
+ \begin{array} { r } { \| \Delta _ { k } - h [ \nabla U ( \theta _ { k } + \Delta _ { k } ) - \nabla U ( \theta _ { k } ) ] \| \le \rho \| \Delta _ { k } \| . } \end{array}
398
+ $$
399
+
400
+ Taking expectation and use $L$ -smoothness of $U$ , we have
401
+
402
+ $$
403
+ \mathbb { E } \left[ \Vert \Delta _ { k + 1 } \Vert \right] \leq \rho \mathbb { E } \left[ \Vert \Delta _ { k } \Vert \right] + L \int _ { t _ { k } } ^ { t _ { k + 1 } } \mathbb { E } \left[ \Vert \theta ( s ) - \theta ( t _ { k } ) \Vert \right] \mathrm { d } s .
404
+ $$
405
+
406
+ By Lemma 3 of Dalalyan and Karagulyan (2019), E√ $\left[ \lVert \nabla U ( \theta ) \rVert _ { 2 } ^ { 2 } \right] \leq L d$ . So we have $\mathbb { E } \left[ \lVert \nabla U ( \theta ) \rVert \right] \leq$ $\sqrt { d \mathbb { E } \left[ \| \nabla U ( \theta ) \| _ { 2 } ^ { 2 } \right] } \leq \sqrt { L } d$ . Because $\theta ( t )$ is a stationary process,
407
+
408
+ $$
409
+ \begin{array} { r l } { \displaystyle \int _ { t _ { k } } ^ { t _ { k + 1 } } \mathbb { E } \left[ \| \theta ( s ) - \theta ( t _ { k } ) \| \right] \mathrm { d } s = } & { \displaystyle \int _ { 0 } ^ { h } \mathbb { E } \left[ \| \theta ( t ) - \theta ( 0 ) \| \right] \mathrm { d } t } \\ & { \quad \quad \quad = \displaystyle \int _ { 0 } ^ { h } \mathbb { E } \left[ \| - \int _ { 0 } ^ { t } \nabla U ( \theta ( s ) ) \mathrm { d } s + \sqrt { 2 } W _ { t } \| \right] \mathrm { d } t } \\ & { \quad \quad \le \displaystyle \int _ { 0 } ^ { h } \int _ { 0 } ^ { t } \mathbb { E } \left[ \| \nabla U ( \theta ( s ) ) \| \right] \mathrm { d } s \mathrm { d } t + \displaystyle \int _ { 0 } ^ { h } \sqrt { 2 } \mathbb { E } \left[ \| W _ { t } \| \right] \mathrm { d } t } \\ & { \quad \quad = \displaystyle \frac { h ^ { 2 } } { 2 } \sqrt { L } d + \displaystyle \int _ { 0 } ^ { h } \sqrt { 2 t } \mathbb { E } \left[ \| \xi _ { 1 } \| \right] \mathrm { d } t . } \end{array}
410
+ $$
411
+
412
+ Note that
413
+
414
+ $$
415
+ \mathbb { E } \left[ \Vert \xi _ { 1 } \Vert \right] = { \sqrt { 2 } } { \frac { \Gamma ( d / 2 + 1 / 2 ) } { \Gamma ( d / 2 ) } } \leq { \sqrt { 2 } } ( { \frac { d + 1 } { 2 } } ) ^ { 1 / 2 } = { \sqrt { d + 1 } } .
416
+ $$
417
+
418
+ Thus,
419
+
420
+ $$
421
+ \begin{array} { r l r } { { \int _ { t _ { k } } ^ { t _ { k + 1 } } \mathbb { E } [ \| \theta ( s ) - \theta ( t _ { k } ) \| ] \mathrm { d } s \le \frac { 1 } { 2 } L ^ { 1 / 2 } h ^ { 2 } d + \frac { 3 \sqrt { 2 } } { 2 } h ^ { 3 / 2 } d ^ { 1 / 2 } } } \\ & { } & { \le \frac { \sqrt { 2 } } { 2 } h ^ { 3 / 2 } d + \frac { 3 \sqrt { 2 } } { 2 } h ^ { 3 / 2 } d ^ { 1 / 2 } } \\ & { } & { \le \frac { 3 \sqrt { 2 } } { 2 } h ^ { 3 / 2 } d . } \end{array}
422
+ $$
423
+
424
+ Denote $\begin{array} { r } { r = \frac { 3 \sqrt { 2 } } { 2 } L h ^ { 3 / 2 } d . } \end{array}$ . So
425
+
426
+ $$
427
+ \begin{array} { l } { \displaystyle \mathbb { E } \left[ \| \Delta _ { k + 1 } \| \right] \leq \rho \mathbb { E } \left[ \| \Delta _ { k } \| \right] + r \leq \rho ^ { k + 1 } \mathbb { E } \left[ \| \Delta _ { 0 } \| \right] + \displaystyle \sum _ { i = 0 } ^ { k } \rho ^ { i } r } \\ { \leq \displaystyle \frac { r } { 1 - \rho } = \frac { 3 \sqrt { 2 } } { 2 } \frac { L } { M } h ^ { 1 / 2 } d } \end{array}
428
+ $$
429
+
430
+ Therefore, for any $k \geq 1$ ,
431
+
432
+ $$
433
+ \begin{array} { r l } & { | \pi ( f ) - \pi P _ { k } ( f ) | = \left| \mathbb { E } \left[ f ( \theta ( t _ { k } ) ) - \mathbb { E } \left[ f ( \theta _ { k } ) \right] \right] \le \mathbb { E } \left[ | f ( \theta ( t _ { k } ) ) - f ( \theta _ { k } ) | \right] \right| } \\ & { \quad \quad \quad \le \mathbb { E } \left[ \left. \Delta _ { k } \right. \right] \le \displaystyle \frac { 3 \sqrt { 2 } } { 2 } \frac { L } { M } h ^ { 1 / 2 } d . } \end{array}
434
+ $$
435
+
436
+ If we use a noisy gradient $\hat { \boldsymbol g } ( \boldsymbol \theta _ { k } ) = \nabla U ( \boldsymbol \theta _ { k } ) + \boldsymbol e _ { k }$ where $e _ { k }$ is the noise with mean zero and bounded variance such that $\mathbb { E } ( | | e _ { k } | | _ { 2 } ^ { 2 } ) \leq \sigma ^ { 2 }$ , then an extra term $2 h \sigma$ will appear in Lemma 2. As $\sigma ^ { 2 }$ is usually expected to be proportional to the dimension , this additional term is of the same order as the other term.
437
+
438
+ Theorem A.1 (Theorem 9.8 of Niederreiter (1992)). Let $v _ { 0 } , v _ { 1 } , \ldots$ be an LFSR with offset s and period $n = 2 ^ { m } - 1$ which satisfy $g c d ( m , n ) = 1$ . Then the sequence $\{ \mathbf { u } _ { i } \} _ { i = 0 } ^ { n - 1 } \subset [ 0 , 1 ] ^ { s }$ with $\mathbf { u } _ { i } = ( v _ { i } , v _ { i + 1 } , \dots , v _ { i + s - 1 } )$ has, on average, star-discrepancy
439
+
440
+ $$
441
+ O ( n ^ { - 1 } ( \log n ) ^ { d + 1 } \log \log n )
442
+ $$
443
+
444
+ with an implied constant depending only on $d$ and the average is taken over all primitive polynomials over $G F ( 2 )$ of degree $m$ .
445
+
446
+ Proof of Theorem 4.1. The error on the left-hand-side is bounded by
447
+
448
+ $$
449
+ ( I ) + ( I I ) ^ { \prime } + ( I I ) ^ { \prime \prime } + \frac { 4 \ell } { n } \| f \| _ { \infty } .
450
+ $$
451
+
452
+ Lemma 1 shows that $\begin{array} { r } { ( I ) \leq ( \operatorname* { m a x } _ { 0 \leq i < n } \| \theta _ { i } \| + \mathbb { E } _ { \pi } \left[ \| \theta \| \right] ) \rho ^ { \ell } \leq ( \operatorname* { m a x } _ { 0 \leq i \leq n } \| \theta _ { i } \| + \mathbb { E } _ { \pi } \left[ \| \theta \| \right] ) h ^ { 1 / 2 } } \end{array}$ since $\ell = \lceil ( 1 / 2 ) \log _ { \rho } h \rceil$ . Lemma 2 shows that $\begin{array} { r } { ( I I ) ^ { \prime } \leq \frac { 3 \sqrt { 2 } } { 2 } \frac { L } { M } d h ^ { 1 / 2 } } \end{array}$ . Denote $C _ { 2 } = \operatorname* { m a x } _ { 0 \leq i \leq n } \left\| \theta _ { i } \right\| +$ $\begin{array} { r } { \mathbb { E } _ { \pi } \left[ \| \theta \| \right] + \frac { 3 \sqrt { 2 } } { 2 } \frac { L } { M } d } \end{array}$ . So $( I ) + ( I I ) ^ { \prime } \leq C _ { 2 } h ^ { 1 / 2 }$ .
453
+
454
+ By Theorem A.1 and the condition that $\operatorname* { g c d } ( d \ell , n ) = 1$ , the star-discrepancy $D ^ { * } \big ( \{ \bar { w } _ { k } ^ { ( \ell ) } \} _ { k \geq 1 } \big )$ is upper bounded by $O ( n ^ { - 1 } ( \log n ) ^ { d \ell + 1 } \log \log n )$ . Finally, by Koksma-Hlawka inequality, we have $( I I ) ^ { \prime \prime } \le \| \bar { f } _ { \ell } \| _ { \mathrm { H K } } \cdot D ^ { * } ( \{ \bar { w } _ { k } ^ { ( \ell ) } \} _ { k \ge 1 } )$ . Thus, $\begin{array} { r } { ( I I ) ^ { \prime \prime } + \frac { 4 \ell } { n } \| f \| _ { \infty } \leq C _ { 1 } n ^ { - 1 + \delta } } \end{array}$ , where $\delta$ hides the polylogarithmic terms in $\log n$ and $C _ { 1 }$ depends on $d , \ell , \| \bar { f } _ { \ell } \| _ { \mathrm { H K } }$ .
455
+
456
+ Therefore, the upper bound becomes
457
+
458
+ $$
459
+ ( I ) + ( I I ) ^ { \prime } + ( I I ) ^ { \prime \prime } + \frac { 4 \ell } { n } \| f \| _ { \infty } \leq C _ { 1 } n ^ { - 1 + \delta } + C _ { 2 } h ^ { 1 / 2 } .
460
+ $$
461
+
462
+ # B Additional numerical results
463
+
464
+ The primary contribution of this work is to improve LMC as a Monte Carlo sampling algorithm, not as an optimization algorithm. Therefore, our main focus is on providing a better estimation of $\pi ( f )$ for some function of interest. Downstream tasks relying on such expectations can also benefit from LQMC. For posterior prediction, it is essential to recognize that the prediction error is not solely determined by the sampling method. Even with infinite perfect samples from the posterior, the prediction error can still arise due to model misspecification, noisy data, biased sampling, etc. So the improvement achieved by LQMC might be less pronounced when assessing the prediction error.
465
+
466
+ To investigate the performance of LQMC in a posterior prediction setting, we conducted experiments similar to those presented in Dubey et al. (2016) using three UCI datasets. Each dataset was split into a training set $( 7 0 \% )$ , a validation set $( 1 0 \% )$ , and a test set $( 2 0 \% )$ . We performed a tuning process for the constant step size on a grid using the validation set and evaluated the prediction error on the test set. Each iteration computes the stochastic gradient using 32 data points sampled at random. Details of the datasets are in Table 1.
467
+
468
+ <table><tr><td>Datasets</td><td>Parkinsons</td><td>Bike</td><td>Protein</td></tr><tr><td>N (number of instances)</td><td>5875</td><td>17379</td><td>45730</td></tr><tr><td>p (number of features)</td><td>21</td><td>12</td><td>9</td></tr></table>
469
+
470
+ Table 1: Summary of datasets used for Bayesian posterior prediction.
471
+
472
+ The results are presented in Figure 6. The $x$ -axes represent the total number of iterations of Langevin algorithm and the $y$ -axes represent the test error. The error bars represent the variation across 10 random replicates. It is evident that LQMC reduced the test error, although the improvement is not substantial. This aligns with our initial expectation, as the proposed method primarily enhances the accuracy of estimating the posterior mean. However, the test error often consists of other sources of error, thus the improvement achieved by the proposed method in reducing the test error might be limited.
473
+
474
+ ![](images/f6acd57f6cfbd7761952326b942ddaeef1cc2dc6b22870c352cfb01ab6a1d5e7.jpg)
475
+ Figure 6: Test error versus number of iterations for the three UCI datasets.
md/dev/1qvx610Cu7/1qvx610Cu7.md ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation
2
+
3
+ Jiawei Liu ∗ Chunqiu Steven Xia ∗ Yuyao Wang Lingming Zhang
4
+
5
+ University of Illinois Urbana-Champaign Nanjing University
6
+
7
+ {jiawei6, chunqiu2, lingming}@illinois.edu yuyao6@outlook.com
8
+
9
+ # Abstract
10
+
11
+ Program synthesis has been long studied with recent approaches focused on directly using the power of Large Language Models (LLMs) to generate code. Programming benchmarks, with curated synthesis problems and test-cases, are used to measure the performance of various LLMs on code synthesis. However, these test-cases can be limited in both quantity and quality for fully assessing the functional correctness of the generated code. Such limitation in the existing benchmarks begs the following question: In the era of LLMs, is the code generated really correct? To answer this, we propose EvalPlus – a code synthesis evaluation framework to rigorously benchmark the functional correctness of LLM-synthesized code. EvalPlus augments a given evaluation dataset with large amounts of test-cases newly produced by an automatic test input generator, powered by both LLM- and mutation-based strategies. While EvalPlus is general, we extend the test-cases of the popular HUMANEVAL benchmark by $8 0 \times$ to build HUMANEVAL+. Our extensive evaluation across 26 popular LLMs (e.g., GPT-4 and ChatGPT) demonstrates that HUMANEVAL+ is able to catch significant amounts of previously undetected wrong code synthesized by LLMs, reducing the pass $@ k$ by up-to $1 9 . 3 \substack { - 2 8 . 9 \% }$ . We also surprisingly found that test insufficiency can lead to mis-ranking. For example, both WizardCoder-CodeLlama and Phind-CodeLlama now outperform ChatGPT on HUMANEVAL+, while none of them could on HUMANEVAL. Our work not only indicates that prior popular code synthesis evaluation results do not accurately reflect the true performance of LLMs for code synthesis, but also opens up a new direction to improve such programming benchmarks through automated testing. We have open-sourced our tools, enhanced datasets as well as all LLM-generated code at https://github.com/evalplus/evalplus to facilitate and accelerate future LLM-for-code research.
12
+
13
+ # 1 Introduction
14
+
15
+ Automatically generating programs that accurately correspond to user intents is a long-standing challenge in computer science known as program synthesis [21]. In the past few decades, classical program synthesis techniques have been developed, including deductive synthesis [19, 39, 62], inductive synthesis [20, 58] and neural-guided synthesis [29]. More recently, with the advent of Large Language Models [61, 6] (LLMs) and the abundance of open codebase, researchers have been focusing on applying LLMs for direct code generation. LLMs like CODEX [11] and CodeGen [46] perform code generation by autoregressively predicting the next token given previous context, in the form of function signature and docstring that denote the desired program functionality. The generated code snippet is then combined with the context to form a complete function that aligns with the user intent. Leveraging both natural language understanding and generative power, LLMs have demonstrated impressive performance in code synthesis [3, 11].
16
+
17
+ ![](images/3123815fc6ee764f610b9ae26921911c0080b9bf9a5fda7fb8f6bb0ec472825d.jpg)
18
+ Figure 1: Exemplary wrong code synthesized by ChatGPT for HUMANEVAL #58.
19
+
20
+ The primary concern when it comes to LLM-generated code is correctness. Because two dramatically different code snippets can be semantically equivalent, classic NLP metrics like BLEU score [50] are no longer reliable in the context of program synthesis. Ideally, we would like to formally verify the correctness of LLM-provided solutions for any input, but verifying domain-specific problems through methods such as translation validation [36, 44, 4] is already challenging enough, let alone building a general verifier with absolute certainty to prove arbitrary problems, including those in code benchmarks. As such, existing code benchmarks (e.g., HUMANEVAL [11]) heavily rely on manually constructed test-cases to evaluate LLM solutions. However, these tests often fall short in capturing all possible scenarios, as crafting high-quality tests is laborious. Consequently, we argue that current programming benchmarks are inadequate for assessing the actual correctness of LLM-generated code, leading to false confidence in the results. Specifically, we have identified the following common limitations in existing LLM-for-code benchmarks:
21
+
22
+ • Insufficient testing. Current programming benchmarks often only include on average less than 10 tests for each coding problem. Furthermore, these tests are relatively too simple to fully explore the functionality of the code or corner cases. Figure 1 shows an incorrect code sample synthesized by ChatGPT [48] to return the sorted unique common elements from two lists. At first glance, the function looks correct and computes the desired output when using the base test inputs from HUMANEVAL. However, in the return statement, it incorrectly converts the intermediate list to a set which no longer preserves the order of the sorted list. This example shows that a logically flawed solution can still pass all simple tests and be misconsidered as correct due to testing inadequacy. Imprecise problem description. The input for code generation includes natural language descriptions in addition to the function signature. These task descriptions in existing benchmarks are oftentimes too vague to fully clarify the expected program behaviors. For example, the input docstring may not specify the expected input domain (e.g., only positive integers) or how the function should handle exceptions. As a result, such programming problems can be interpreted differently by LLMs against the actual tests, leading to capable LLMs misjudged as incapable.
23
+
24
+ These limitations are common across many popular code generation benchmarks [11, 3, 33]. This not only questions the validity of the impressive performance claimed by prior work but also sets a challenge on how to properly evaluate the LLM coders. In this paper, we aim to address this fundamental evaluation challenge and ask the introspective question: Is the code generated by LLMs really correct?
25
+
26
+ Our proposal. In this work, we set out to answer the important question and evaluate the evaluation dataset. Consequently, we build EvalPlus – an evaluation framework to improve existing code benchmarks in order to precisely evaluate the functional correctness of LLM-generated code. At the heart of EvalPlus is an automatic test input generation engine which augments existing code benchmarks by generating interesting test inputs to fully exercise the code solution and check its functional correctness by cross-checking the ground-truth implementation. Specifically, EvalPlus adopts both LLM- and mutation-based [57, 74, 47] methods to automatically generate and diversify additional test inputs. EvalPlus first uses ChatGPT [48] to generate a set of high-quality seed inputs that aim to test difficult corner cases and functionalities of the program within the valid input structure. Using these high-quality seed inputs, EvalPlus then performs type-aware mutation to efficiently generate a large number of additional test inputs. These newly generated test inputs are then used to evaluate the LLM-generated code through differential testing [40] against the ground-truth implementation. Furthermore, as an option to speed up evaluation, EvalPlus also builds minimal test-suites by only including the most valuable test-cases, which are selected by running a greedy set cover algorithm to preserve the same code coverage [24], mutation analysis [7] as well as empirical LLM sample killings.
27
+
28
+ ![](images/db8c3d3ffdb7024ce0d9bfd7ea7adb89d8b708b14a9e41e575743b2eb90d60f0.jpg)
29
+ Figure 2: Overview of EvalPlus
30
+
31
+ Contribution. Our work revisited and proposed to automatically improve code benchmarks for LLMs:
32
+
33
+ • Study: We are the first to study the test inadequacy problem in current programming benchmarks which can lead to largely over-approximated functional correctness. Our study also opens up a new research direction for precisely and rigorously evaluating LLM-synthesized code.
34
+
35
+ • Approach: We propose EvalPlus – an evaluation framework to reveal the real correctness of LLM-synthesized code. The test-case generation approach of EvalPlus combines the emerging LLM-based and traditional mutation-based test input generation. It first uses LLM-based strategy to bootstrap the test generator with high-quality seed inputs and then further extends large amounts of inputs via type-aware mutation. We then optionally “distill” the generated tests to a much smaller yet almost equivalently effective test-suite via greedy set covering. We also propose to annotate each programming tasks using program contracts to filter out invalid inputs.
36
+
37
+ • Results: EvalPlus extends the popular HUMANEVAL benchmark to create HUMANEVAL+, improving the test-case scale by $8 0 \times$ . Through test-suite reduction, we also produce HUMANEVAL+-MINI which distills HUMANEVAL+ tests by $4 7 \times$ while still achieving a similar level of testing effectiveness. Our extensive evaluation over 26 popular LLMs surprisingly finds that the pass $@ k$ on the new dataset is up-to $1 9 . 3 \substack { - 2 8 . 9 \% }$ (for different $k s$ ) lower than the base HUMANEVAL, showing that testing insufficiency can largely affect the result analysis for almost all recent work on LLM-based code generation. Meanwhile, on the original HUMANEVAL both of the 34B WizardCoder-CodeLlama [38] and Phind-CodeLlama [52] models are deemed to be no better than ChatGPT, while HUMANEVAL+ corrected the ranking and shows that the two open-source models are actually better. Additionally, we even found that the ground-truth solutions of HUMANEVAL can be erroneous, further calling into question the quality of code synthesis benchmarks.
38
+
39
+ # 2 Approach
40
+
41
+ Figure 2 shows the overview of EvalPlus. We first take in as input the original dataset containing the ground-truth implementation as well as the base test inputs. EvalPlus starts with constructing a prompt using the original ground-truth, exemplary test inputs as demonstration, and a specialized instruction to query ChatGPT and generate a set of high-quality seed inputs. ChatGPT, by following base input formats and inspecting the ground-truth solution, can serve as a vehicle to generate valid yet rigorous test inputs. Starting from these seed inputs, we then perform type-aware mutation to quickly generate numerous new inputs together with seed inputs to extensively evaluate the functional correctness of LLM-generated code. We use differential testing [40] as the oracle to cross-check the output of the ground-truth and LLM-generated solution. As an option to speed up evaluation, EvalPlus runs set covering to minimize the generated test-suite while preserving the same level of testing effectiveness. As the final output, EvalPlus obtains a augmented benchmark using the generated high-quality test inputs to fully evaluate the functional correctness of LLM-synthesized code.
42
+
43
+ Table 1: List of basic type-aware mutations over input $x$ .
44
+
45
+ <table><tr><td>Type</td><td>Mutation</td><td>Type</td><td>Mutation</td></tr><tr><td>int|float</td><td>Returns x±1</td><td>List</td><td>Remove/repeat a random item x[i] Insert/replace x[i] with Mutate(x[i])</td></tr><tr><td>bool</td><td>Returns a random boolean</td><td>Tuple</td><td>Returns Tuple(Mutate(List(x)))</td></tr><tr><td>NoneType</td><td>Returns None</td><td>Set</td><td>Returns Set(Mutate(List(x)))</td></tr><tr><td>str</td><td>Remove a sub-string s Repeat a sub-string s Replace s with Mutate(s)</td><td>Dict</td><td>Remove a key-value pair k→ U Update k -→v to k-→Mutate(u) Insert Mutate(k)→Mutate(u)</td></tr></table>
46
+
47
+ # 2.1 Automated Test Input Generation
48
+
49
+ Seed initialization via ChatGPT. EvalPlus first uses ChatGPT to generate a set of high-quality seed inputs for later mutation. Following Figure 2, we construct a prompt using $( i )$ the ground-truth solution of the problem for ChatGPT to inspect; (ii) a set of test inputs as demonstration; and (iii) an instruction to encourage ChatGPT to come up with interesting inputs. Specifically, each prompt starts with the ground-truth implementation and then randomly sampled test inputs from the existing dataset. We then finalize the prompt with a selected instruction in Figure 2 and query ChatGPT to produce new inputs. EvalPlus aims to leverage the powerful understanding ability of ChatGPT to learn both the valid input formats (e.g., variable types) as well as the desired functionality of the ground-truth solution in order to produce meaningful test inputs to reveal bugs in incorrectly synthesized code. Programs can have their own expected input formats, where invalid inputs should not be passed into the function as they can incur undefined behaviors to create false-positives in differential testing. As such, we filter out any invalid inputs which violate the input precondition required by the ground-truth implementation.
50
+
51
+ By using ChatGPT as an automated generation engine, we can generate inputs that are valid even under semantic constraints. For example, a programming problem may require the input to conform to a specific structure (e.g., a palindrome). Such semantic constraints can be extremely difficult for traditional input generators to satisfy. However, ChatGPT is unsuitable for large amounts of automated test generation due to undesired speed and cost of querying such a large model. To address this, we perform type-aware input mutation starting from high-quality seed inputs generated by ChatGPT.
52
+
53
+ Type-aware input mutation. We follow a typical mutation-based fuzzing workflow [74, 57] to continuously create inputs: (i) a corpus of seed inputs from ChatGPT are used to initialize the seed pool and bootstrap the generation pipeline; (ii) each time an input (i.e., seed) from the seed pool is randomly selected to be mutated to a new input (i.e., mutant); and (iii) new inputs that comply with the program contract (§2.3) are added to the seed pool and we start over from (ii) to continue the generation process.
54
+
55
+ To efficiently create more valid inputs, we leverage type-aware mutation [66] in step (ii) which inspects the data types of the incoming valid seeds and generates new inputs that are structurally similar to the seeds. In Table 1 we illustrate the basic mutations used for different types of inputs. For simple primitive types such as int and float, the mutation is as simple as incrementing/decrementing the value. For compound types and the string type (i.e., str), besides generally removing or repeating existing elements (or sub-strings for str), the elements and sub-strings can be mutated recursively according to their inner types. Such sub-mutants can then be used to replace existing items or add new items in a finer-grain manner. In addition, to alleviate generating inputs that violate subtle semantic constraints, following [23, 34], we additionally apply an ingredient mechanism to collect appeared data fragments and reuse them during mutation. In short, type-aware input mutation builds on the high-quality seed inputs produced by ChatGPT to generate large amounts of test inputs which we use as the final set of extensive test inputs to evaluate LLM-synthesized code.
56
+
57
+ # 2.2 Test-Suite Reduction
58
+
59
+ While the large number of newly generated tests in EvalPlus are effective in detecting incorrect code, the test execution can be costly. As an option to more efficiently evaluate LLM-generated code, we further investigate test-suite reduction strategies [75, 59], which aim to select a subset of the original test-suite while still maintaining the original test effectiveness. To perform test reduction, it is typically assumed that each test can fulfill a set of testing requirements. The problem can then be formalized as reducing the original test-suite $\tau$ into $\mathcal { T } _ { r e d }$ , such that $\forall r \in \mathcal { R }$ ( $\exists t \in \tau$ , $t$ satisfies $r \implies \exists t ^ { \prime } \in$ $\mathcal { T } _ { r e d } , t ^ { \prime }$ satisfies $r$ ). In other words, any testing requirement $r$ satisfied by the original test-suite should still be satisfied by the reduced one. Finding such minimal representative subset for a given test-suite is equivalent to the set covering problem [17]. To solve this problem effectively, it is crucial to define the testing requirements accurately. In this paper, we focus on the following types of requirements:
60
+
61
+ Code coverage: Code coverage [24] measures the amount of code elements (e.g., statements or branches) executed by each test, and has been widely used in practice to measure test effectiveness. In this strategy, following traditional test-suite reduction [53] we leverage the widely used branch coverage as the testing requirement. In other words, the goal of using this metric is to only preserve a minimal subset of tests which can cover the same set of branches as the full tests.
62
+
63
+ Mutant killings: Coverage measures the extent to which the code has been executed; however, a high-coverage test-case is not necessarily effective in finding critical defects in its covered code. Consequently, researchers have proposed mutation testing [7] (also known as mutation analysis) to more precisely evaluate test effectiveness. In short, mutation testing applies a set of predefined mutation rules (e.g., changing $" < "$ and $\ " \leq \ " \}$ ) to the program under test (i.e., the ground-truth solutions for this case) to create a large number of artificial buggy programs, each of which is called as a mutant and includes exactly one subtle bug seeded. In this way, the ratio of mutation bugs detected by the tests (also called killed) can be used to assess the test effectiveness. In fact, studies have shown that mutation testing can largely outperform code coverage in test effectiveness evaluation [51]. Following prior work [59], we also leverage the set of mutants killed by each test as our testing requirement. Consequently, the goal is to minimize the number of tests while still being able to detect the same set of mutation bugs.
64
+
65
+ LLM sample killings: Different LLMs could fail commonly over certain test-cases. Consequently, besides these theoretical metrics, we also use as a testing requirement by empirically looking at sample killings, i.e., the set of wrong LLM samples that a test-case can detect and falsify. Of course, for a new LLM under evaluation, we do not have any test execution results for its code samples. Therefore, we only use the execution results for samples generated by other LLMs to evaluate test effectiveness for reduction (i.e., leave-one-out cross validation [22]). As such, we minimize the number of tests while making sure that all incorrect samples synthesized by other models can be detected by the reduced test-suite.
66
+
67
+ Besides the above three strategies, we also investigate another strategy that merges all three testing requirements for reduction. That is, the goal is to minimize the number of tests while still maintaining the same branch coverage, mutant killing, and incorrect sample detection results.
68
+
69
+ # 2.3 Program Input Contracts
70
+
71
+ The goal of evaluating code synthesis is to check whether the synthesized code accurately reflects the desired user intent. This is done by using several test inputs and comparing the output of the generated code against that of the ground-truth solution. The prior sections demonstrated how to improve the test inputs used to more rigorously evaluate the synthesized code. However, these user intents (expressed as natural language docstring) can be too vague for LLMs to follow. As such, LLMs might allow for different interpretations of the desired functionality, input formats as well as how to handle corner cases.
72
+
73
+ To this end, we adopt a programming by contract [41] philosophy by systematically annotating function pre-conditions in form of code assertions (e.g., assert $\mathbf { n } > 0$ ), to ensure the test inputs for the function are well-formed. The benefits of the contracts are two-fold: $( i )$ they can complement the automatic input generation steps to filter out any generated invalid inputs that violate the contracts. Such ill-formed inputs can incur undefined behaviors which are unreasonable to use for evaluating LLM-synthesized code; and (ii) they can serve as orthogonal descriptors together with the natural language description in the prompt for further clarification.
74
+
75
+ Table 2: Overview of EvalPlus-improved benchmarks.
76
+
77
+ <table><tr><td rowspan="3"></td><td colspan="4">#Tests</td><td rowspan="3">#Tasks</td></tr><tr><td>Avg.</td><td>Medium</td><td>Min.</td><td>Max.</td></tr><tr><td>HUMANEVAL</td><td>9.6</td><td>7.0</td><td>1</td><td>105²</td><td rowspan="3">164</td></tr><tr><td>HUMANEVAL+</td><td>764.1</td><td>982.5</td><td>12</td><td>1,100</td></tr><tr><td>HUMANEVAL+ -MINI</td><td>16.1</td><td>13.0</td><td>5</td><td>110</td></tr></table>
78
+
79
+ # 3 Evaluation
80
+
81
+ Setup. Our evaluation focuses on using the unbiased version of $\operatorname { p a s s } @ k$ [11] to accurately assess the functional correctness of LLM-synthesized code. For generalizability, we conducted a comprehensive evaluation over 26 popular and state-of-the-art LLMs and a wide range of temperature settings. Specifically, following prior work [11, 46], for each model we perform: $( i )$ random sampling to generate 200 program samples for each of the four temperature settings $( \{ 0 . 2 , 0 . 4 , 0 . 6 , 0 . \bar { 8 } \} )$ ; and $( i i )$ greedy-search decoding. For random sampling, we show the best-performing pass $@ k$ for each $k \in \mathsf { \bar { \{ 1 , 1 0 , 1 0 0 \} } }$ and its corresponding temperature denoted by $T _ { k } ^ { * }$ . For greedy decoding, we only synthesize one deterministic sample for each task and evaluate its pass rate as pass $@ 1 ^ { \star }$ . By default we evaluate models under both setting $( i )$ and $( i i )$ , except for the two commercial models due to time and cost constraints: GPT-4 is only evaluated under greedy decoding, and ChatGPT is additionally evaluated on 0.8-temperature random sampling.
82
+
83
+ While EvalPlus is general, this paper focuses on evaluating its effectiveness on HUMANEVAL [11], one of the most widely-used datasets for code generation3. HUMANEVAL consists of 164 humanwritten programming tasks, each of which provides a Python function signature and a docstring as the input to the LLM. Based on the input, LLMs complete a solution whose functional correctness is judged by a handful of manual test-cases (the first row in Table 2). As such, EvalPlus transforms HUMANEVAL to HUMANEVAL+ by adding $8 0 \times$ unique test-cases and fixing incorrect ground-truth solutions in HUMANEVAL. Specifically, for each task, based on around 30 ChatGPT-generated seed inputs which are produced using 3 separate prompts, we run type-aware mutation to generate 1000 additional inputs using one-hour budget. In HUMANEVAL+, 83 out of the 164 programming tasks are annotated with hand-crafted contracts. Because EvalPlus requires ground-truth solutions to cross-check LLM-generated code, it is crucial to ensure the correctness of the ground-truths. However, by inspecting ground-truths in the original HUMANEVAL, we found over $10 \%$ of them are incorrectly implemented. Therefore, as another contribution we carefully re-implemented and tested all ground-truths for HUMANEVAL+. As an option to speed up evaluation, we build HUMANEVAL+-MINI which is minimized from HUMANEVAL+ (smaller by $4 7 \times$ ) yet preserves similar test effectiveness on the studied models. Lastly, more experimental setups are detailed in Appendix.
84
+
85
+ Evaluation of LLMs. Table 3 shows the pass $@ k$ when evaluating LLMs using both the base HUMANEVAL and HUMANEVAL+. We first observe that across all LLMs, models sizes and $k$ values, using HUMANEVAL+, almost all pass $@ k$ results consistently drop compared to using the base HUMANEVAL. Notably, the performance drop is significant with up-to $2 3 . 1 \%$ $( \mathrm { p a s s } @ 1 ^ { \star } )$ / $1 9 . 3 \%$ (pass $@ 1$ ) $/ 2 4 . 9 \%$ (pass $@ 1 0$ ) $/ 2 8 . 9 \%$ (pass $@ 1 0 0 _ { , }$ ) reduction over the evaluated models. Such performance decrease is not only seen in popular open-source LLMs, such as the widely used CodeGen-16B [46] $( 1 8 . 5 \%$ reduction) as well as the emerging CODELLAMA-34B [54] $( 1 7 . 6 \% )$ and StarCoder [13] ( $1 4 . 1 \%$ reduction), but also observed in state-of-the-art commercial ChatGPT $( 1 2 . 6 \%$ reduction) and GPT-4 $2 3 . 1 \%$ reduction) models. Overall, our results overall confirm our hypothesis that the prior evaluation on HUMANEVAL is not robust enough to detect wrong code synthesized by LLMs. Not only are these LLMs widely used for daily programming but they also serve as common reference points for evaluating new code synthesis techniques. As such, evaluating on a more robust benchmark such as HUMANEVAL+ is highly recommended in order to draw precise conclusions.
86
+
87
+ Table 3: Evaluating LLMs on HUMANEVAL and HUMANEVAL+. All models, except for INCODER, CodeGen2, StarCoder and SantaCoder which perform infilling, use auto-regressive generation. $k { = } 1 ^ { \star }$ marks pass $@ 1$ done with greedy decoding. $T _ { k } ^ { * }$ denotes the optimal pass $@ k$ temperature.
88
+
89
+ <table><tr><td></td><td>Size pass@k</td><td>k=1*</td><td>k=1</td><td>k=10</td><td>k=100</td><td></td><td>T</td><td>T0</td><td>T100</td></tr><tr><td>GPT-4 [49]</td><td>N/A</td><td>base +extra</td><td>88.4 76.2</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Phind-CodeLlama [52]</td><td>34B</td><td>base</td><td>71.3</td><td>71.6</td><td>90.5</td><td>96.2</td><td>2</td><td>.8</td><td>.8</td></tr><tr><td>WizardCoder-CodeLlama [38]</td><td>34B</td><td>+extra base</td><td>67.1 73.2</td><td>67.0 61.6</td><td>85.0 85.2</td><td>92.5 94.5</td><td>2</td><td>.8 .8</td><td>.8 .8</td></tr><tr><td></td><td>N/A</td><td>+extra base</td><td>64.6 73.2 69.4</td><td>54.5</td><td>78.6 88.6</td><td>88.9 94.0</td><td></td><td>.8</td><td>.8</td></tr><tr><td>ChatGPT [48]</td><td>34B</td><td>+extra</td><td>63.4 51.8</td><td>62.5 52.0</td><td>82.1</td><td>91.1</td><td>.2</td><td>.8</td><td>.8</td></tr><tr><td rowspan="3">CODELLAMA [54]</td><td rowspan="3">13B</td><td>base +extra</td><td>42.7 43.1</td><td></td><td>82.4</td><td>95.0</td><td>.2</td><td>.8</td><td>.8</td></tr><tr><td>base</td><td>42.7 44.6</td><td></td><td>73.7 77.6</td><td>89.4</td><td>.4</td><td>.8</td><td>.8</td></tr><tr><td> +extra</td><td>36.6 37.4</td><td>69.4</td><td></td><td>92.7 88.2</td><td>.4</td><td>.8</td><td>.8</td></tr><tr><td></td><td>7B</td><td>base</td><td>37.8</td><td>39.2 69.1</td><td></td><td>89.7</td><td>.2</td><td>.8</td><td>.8</td></tr><tr><td>StarCoder [13]</td><td>15B</td><td>+extra base</td><td>34.1 34.1</td><td>34.5 32.2</td><td>61.4 56.7</td><td>82.9 84.2</td><td>.2 .2</td><td>.8</td><td>.8 .8</td></tr><tr><td></td><td>16B</td><td>+extra base</td><td>29.3 32.9</td><td>27.8 32.2 56.0</td><td>50.3</td><td>75.4 81.5</td><td>.2 .2</td><td>.8 .6</td><td>.8 .8</td></tr><tr><td rowspan="3">CodeGen [46]</td><td rowspan="2">6B</td><td> +extra</td><td>26.8 29.3</td><td>27.2 48.4</td><td></td><td>71.4 .2</td><td>.2</td><td>.6 .6</td><td>.8 .8</td></tr><tr><td>base +extra</td><td>27.7 25.6</td><td>46.9</td><td></td><td>72.7</td><td>.2</td><td>.6</td><td>.8</td></tr><tr><td>base</td><td></td><td>23.6 18.4</td><td>41.0</td><td>64.6</td><td></td><td>.2</td><td>.8</td><td>.8</td></tr><tr><td>CODET5+ [64]</td><td>2B</td><td>+extra</td><td>24.4 20.7</td><td>15.1</td><td>39.8 34.8</td><td>66.8 55.8</td><td>.2</td><td>2</td><td>.8</td></tr><tr><td></td><td>16B</td><td>base +extra</td><td>31.7 26.2</td><td>32.2 27.4</td><td>58.5 51.1</td><td>83.5</td><td>2</td><td>.6 .6</td><td>.8 .8</td></tr><tr><td>MISTRAL [26]</td><td>7B</td><td>base +extra</td><td>28.7 23.8</td><td>28.1</td><td>55.2</td><td>76.4 83.8</td><td>2</td><td></td><td>.8 .8</td></tr><tr><td rowspan="4">CodeGen2 [45]</td><td rowspan="2">16B4</td><td>base</td><td>19.5</td><td>23.7</td><td>48.5</td><td>76.4</td><td></td><td></td><td></td></tr><tr><td> +extra</td><td>16.5</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>7B</td><td>base +extra</td><td>18.3</td><td>17.9 30.9</td><td></td><td>50.9</td><td>2.2.2.2.</td><td>.6 .6</td><td>.8 .8</td></tr><tr><td>3B</td><td>base</td><td>16.5 15.9</td><td>15.9 15.2</td><td>27.1 23.9</td><td>45.4 38.6</td><td></td><td>.4</td><td>.8</td></tr><tr><td rowspan="3"></td><td rowspan="2">1B</td><td> +extra</td><td>12.8</td><td>12.9 21.2</td><td>34.3</td><td></td><td>.2</td><td>.4 .6</td><td>.8 .6</td></tr><tr><td>base</td><td>11.0</td><td>10.2 15.1</td><td></td><td>24.7</td><td>.2</td><td>.6</td><td>.6</td></tr><tr><td>+extra</td><td></td><td>9.1 8.7</td><td>13.7</td><td>21.2</td><td></td><td>.2</td><td>.8</td><td>.8</td></tr><tr><td rowspan="2">VICUNA [12]</td><td rowspan="2">13B</td><td>base +extra</td><td>16.5 15.2</td><td>15.3 13.9</td><td>30.1 25.8</td><td>54.8</td><td>.2</td><td>.8</td><td>.8</td></tr><tr><td>base</td><td>11.6</td><td>10.9</td><td>23.8</td><td>46.7 42.3</td><td>.2 .2</td><td>.6</td><td>.6</td></tr><tr><td>SantaCoder [2]</td><td>7B</td><td>+extra</td><td>11.0</td><td>10.3</td><td>20.3</td><td>35.0</td><td>.4</td><td>.6 .6</td><td>.6 .8</td></tr><tr><td rowspan="2"></td><td rowspan="2">1.1B</td><td>base +extra</td><td>14.6 12.8</td><td>16.6 14.2</td><td>29.2</td><td>45.4 40.6</td><td>.4</td><td>.6</td><td>.8</td></tr><tr><td></td><td>15.9</td><td>26.2 27.7</td><td></td><td>45.0</td><td>.2</td><td>.4</td><td>.6</td></tr><tr><td rowspan="3">INCODER [18]</td><td rowspan="2">6.7B</td><td>base</td><td>12.2</td><td>15.6</td><td></td><td></td><td>.2</td><td>.6</td><td>.6</td></tr><tr><td>+extra base</td><td>12.2</td><td>12.4 10.0</td><td>22.2 15.9</td><td>38.9 25.2</td><td>.2 .2</td><td>.6</td><td>.6</td></tr><tr><td>1.3B</td><td>+extra</td><td>10.4 7.9</td><td>13.5</td><td>20.7</td><td></td><td></td><td>.6</td><td>.4</td></tr><tr><td rowspan="2">GPT-J[63]</td><td rowspan="2">6B</td><td>base</td><td>12.2</td><td>11.3</td><td>17.7</td><td>31.8</td><td>.2 .2</td><td>.6</td><td>.6</td></tr><tr><td>+extra</td><td>10.4</td><td>9.5 15.2</td><td></td><td>25.9</td><td></td><td>.6</td><td>.6</td></tr><tr><td>GPT-NE0 [5]</td><td>2.7B</td><td>base</td><td>7.9</td><td>6.5</td><td>11.8</td><td>20.7</td><td>.2 .2</td><td>.6 .6</td><td>.6 .6</td></tr><tr><td rowspan="2"></td><td rowspan="2"></td><td>+extra</td><td>6.7</td><td>6.0</td><td>9.0</td><td>16.8 17.1</td><td></td><td></td><td>.6</td></tr><tr><td>base</td><td>6.1</td><td>5.9 10.2</td><td></td><td></td><td>2</td><td>.4</td><td>.6 .6</td></tr><tr><td rowspan="2">PolyCoder [70] StableLM[60]</td><td rowspan="2">2.7B 7B</td><td>+extra base</td><td>5.5 2.4</td><td>5.3 2.7</td><td>7.9 7.5</td><td>13.6 15.8</td><td>.2 .2</td><td>.6 .6</td></table>
90
+
91
+ Table 4: Reduced test-suite for HUMANEVAL+. We first show the pass $@ 1 ^ { \star }$ and average #tests (including base HUMANEVAL tests) by only doing set covering over each considered metric separately (§2.2). The Full column then shows the final reduction result by combining all of the three. For reference, the average #tests of original HUMANEVAL and HUMANEVAL+ are 9.6 and 774.8 respectively (Table 2).
92
+
93
+ <table><tr><td rowspan="2"></td><td rowspan="2">Size</td><td colspan="2">Coverage</td><td colspan="2">Killed mutants</td><td colspan="2">Killed samples</td><td colspan="2">Full</td><td colspan="2">Ref. pass@1*</td></tr><tr><td>pass@1*</td><td>#tests</td><td>pass@1*</td><td>#tests</td><td>pass@1*</td><td>#tests</td><td>pass@1*</td><td>#tests</td><td>base</td><td>+extra</td></tr><tr><td>GPT-4</td><td>N/A</td><td>86.0</td><td>11.3</td><td>82.9</td><td>11.4</td><td>78.7</td><td>13.8</td><td>78.0</td><td>16.1</td><td>88.4</td><td>76.2</td></tr><tr><td>ChatGPT</td><td>N/A</td><td>71.3</td><td>11.3</td><td>69.5</td><td>11.4</td><td>65.2</td><td>13.7</td><td>65.2</td><td>16.0</td><td>73.2</td><td>63.4</td></tr><tr><td>StarCoder</td><td>15B</td><td>32.9</td><td>11.3</td><td>32.9</td><td>11.4</td><td>29.3</td><td>13.6</td><td>29.3</td><td>15.9</td><td>34.1</td><td>29.3</td></tr><tr><td rowspan="3">CodeGen</td><td>2B</td><td>23.2</td><td>11.3</td><td>23.8</td><td>11.4</td><td>21.3</td><td>13.2</td><td>21.3</td><td>15.4</td><td>24.4</td><td>20.7</td></tr><tr><td>6B</td><td>28.7</td><td>11.3</td><td>29.3</td><td>11.4</td><td>25.6</td><td>13.2</td><td>25.6</td><td>15.4</td><td>29.3</td><td>25.6</td></tr><tr><td>16B</td><td>31.7</td><td>11.3</td><td>31.1</td><td>11.4</td><td>27.4</td><td>13.2</td><td>27.4</td><td>15.4</td><td>32.9</td><td>26.8</td></tr><tr><td rowspan="4">CodeGen2</td><td>1B</td><td>10.4</td><td>11.3</td><td>11.0</td><td>11.4</td><td>9.1</td><td>13.8</td><td>9.1</td><td>16.0</td><td>11.0</td><td>9.1</td></tr><tr><td>3B</td><td>15.9</td><td>11.3</td><td>15.9</td><td>11.4</td><td>12.8</td><td>13.8</td><td>12.8</td><td>16.0</td><td>15.9</td><td>12.8</td></tr><tr><td>7B</td><td>18.3</td><td>11.3</td><td>18.3</td><td>11.4</td><td>16.5</td><td>13.8</td><td>16.5</td><td>16.0</td><td>18.3</td><td>16.5</td></tr><tr><td>16B</td><td>19.5</td><td>11.3</td><td>18.9</td><td>11.4</td><td>16.5</td><td>13.8</td><td>16.5</td><td>16.0</td><td>19.5</td><td>16.5</td></tr><tr><td rowspan="2">VICUNA</td><td>7B</td><td>11.6</td><td>11.3</td><td>11.6</td><td>11.4</td><td>11.0</td><td>13.8</td><td>11.0</td><td>16.1</td><td>11.6</td><td>10.4</td></tr><tr><td>13B</td><td>16.5</td><td>11.3</td><td>16.5</td><td>11.4</td><td>15.2</td><td>13.8</td><td>15.2</td><td>16.1</td><td>17.1</td><td>15.2</td></tr><tr><td rowspan="2">SantaCoder</td><td>1.1B</td><td>14.6</td><td>11.3</td><td>14.6</td><td>11.4</td><td>12.8</td><td>13.8</td><td>12.8</td><td>16.1</td><td>14.6</td><td>12.8</td></tr><tr><td>1.3B</td><td>12.2</td><td>11.3</td><td>12.2</td><td>11.4</td><td>10.4</td><td>13.6</td><td>10.4</td><td>16.0</td><td>12.2</td><td>10.4</td></tr><tr><td rowspan="2">INCODER GPT-J</td><td>6.7B</td><td>14.6</td><td>11.3</td><td>14.6</td><td>11.4</td><td>12.2</td><td>13.6</td><td>12.2</td><td>16.0</td><td>15.9</td><td>12.2</td></tr><tr><td>6B</td><td>12.2</td><td>11.3</td><td>12.2</td><td>11.4</td><td>10.4</td><td>13.8</td><td>10.4</td><td>16.0</td><td>12.2</td><td>10.4</td></tr><tr><td>GPT-NEO</td><td>2.7B</td><td>7.3</td><td>11.3</td><td>7.3</td><td>11.4</td><td>6.7</td><td>13.8</td><td>6.7</td><td>16.1</td><td>7.9</td><td>6.7</td></tr><tr><td>PolyCoder</td><td>2.7B</td><td>6.1</td><td>11.3</td><td>6.1</td><td>11.4</td><td>5.5</td><td>13.8</td><td>5.5</td><td>16.1</td><td>6.1</td><td>5.5</td></tr><tr><td>StableLM</td><td>7B</td><td>2.4</td><td>11.3</td><td>2.4</td><td>11.4</td><td>2.4</td><td>13.8</td><td>2.4</td><td>16.1</td><td>2.4</td><td>2.4</td></tr></table>
94
+
95
+ We also show that a more rigorous evaluation could yield different or totally contradictory relative results. For example, WizardCoder-CodeLlama and Phind-CodeLlama on the original HUMANEVAL are evaluated to be no better than ChatGPT in terms of pass $@ 1 ^ { \star }$ . However, HUMANEVAL+ demonstrates that the two open-source models can actually outperform the proprietary ChatGPT. Other contrary examples reflected by HUMANEVAL+ include that SantaCoder-1B surpasses INCODER-6.7B and VICUNA-7B outperforms INCODER-1.3B. Table 3 further illustrates the distribution of best-performing temperatures over different $k$ values. Our results conforms with prior findings [11] that a lower temperature tends to perform better for smaller $k$ , while a higher temperature works better for larger $k$ . We also observe that the optimal temperatures seem to stay fairly consistent before and after using HUMANEVAL+; however, slight differences still exist, e.g., best temperature for CodeGen-2B on pass $@ 1 0$ becomes 0.2 from 0.8 after using HUMANEVAL+. Nonetheless, this motivates future research to look more closely on the effect of temperature with respect to the robustness of the evaluation tests, esp. those edge-cases.
96
+
97
+ Effectiveness of test-suite reduction. Based on HUMANEVAL+ which on average obtains 764.1 tests for each programming task (Table 2), our test-suite reducer $( \ S 2 . 2 )$ minimizes it to HUMANEVAL+- MINI which only has 16.1 tests for each task (smaller by $4 7 \times$ ). Table 4 performs leave-one-out cross validation to show the pass $@ 1 ^ { \star }$ differences over a subset of representative models studied in Table 3 (due to time/space constraints). That is, for each evaluated LLM we construct the reduced test-suite without considering its own sample kills. The Full column shows that the reduced test-suite can achieve almost the same pass $@ 1 ^ { \star }$ drop as HUMANEVAL+ by only using $4 7 \times$ fewer test-cases. Taking a closer look, separately performing set covering over each metric can harness the pass $@ 1 ^ { \star }$ of the base HUMANEVAL to certain degree. Specifically, the use of empirical LLM sample killings is the most effective, leading to the same effectiveness as the full approach, but also consumes more tests than other theoretical metrics. While using coverage and mutation analysis seems to be unnecessary in addition to using sample killings, they still serve as the base guarantees for the theoretical test adequacy.
98
+
99
+ Pass rate distribution. Figure 3 shows for each programming task the overall pass rates on HUMANEVAL and HUMANEVAL+ tests. The pass rate gap between HUMANEVAL and HUMANEVAL+ shows overall HUMANEVAL+ can detect solutions that are misidentified by HUMANEVAL for problems of all levels of difficulties. We also observe that problems in HUMANEVAL are not equal, not only in terms of problem difficulty but also the difficulty of generating counter-examples and edge-cases to deeply exercise LLM-generated code. For simple problems such as “adding two numbers” and “length of a string” (i.e., problems with top-2 pass rates), it is easy to solve for LLMs and to test manually. While problems dealing with multiple conditions (e.g., “word splitting”), completeness (e.g., handling negative numbers for “is-prime”) , reasoning ability (e.g., “Tribonacci sequence”) and efficiency requirements (e.g., “n-th prime Fibonacci number”) are the hardest tasks to the evaluated LLMs, positioning future research to improve LLMs for conquering such coding skills.
100
+
101
+ ![](images/8957033a3d75d416829c6f5be232a3f78cb93a579c8114a591c0782819eac96d.jpg)
102
+ Figure 3: Pass rate distribution. X-axis spans bars for all 164 problems, sorted by the HUMANEVAL pass rate. Y-axis shows the log-scale pass rates averaged by all LLM-generated samples.
103
+
104
+ Incorrect “ground-truth” in HUMANEVAL. In addition to detecting wrong code from LLMs using EvalPlus, we also found 18 defects ( $1 1 \%$ of problems) even in the original ground-truth in HUMANEVAL, including (i) Unhandled edge-case: five prior ground-truths fail to handle corner-case inputs (e.g., empty list or string); (ii) Bad logic: 10 prior ground-truths incorrectly implement the desired functionality; and (iii) Performance issue: three inefficient implementations lead to slow performance on reasonably-sized inputs. Among those, bad logic (10) is the most serious as the original “groundtruth” does not accurately reflect the user intent. Such defects are detected also through differential testing but between our own re-implemented ground-truth and the original ground-truth in HUMANEVAL.
105
+
106
+ ![](images/343bed10bdc118b6c4dec60fa0c9e6e3926d4db9f0838f1b97fa215f9f8ee865.jpg)
107
+ Figure 4: Exemplary incorrect-logic ground-truth solution in HUMANEVAL (#124)
108
+
109
+ Figure 4 shows an incorrect ground-truth implementation (validate_date) from HUMANEVAL classified as having bad logic. The desired task is to check if the input date format is correct. We see that in the core logic, the conditions attempt to first check the month condition and then handle the corresponding day conditions. However, this is implemented incorrectly as “and” in Python5 has higher precedence than “or”, leading to the ground-truth function to check if either conditions satisfies instead of the desired both conditions must satisfy. This is exposed via our automatically generated test input of 12-31-1999 where the ground-truth implementation incorrectly labels this as not a valid date. Surprisingly this egregious error is not exposed by any of the base test inputs in HUMANEVAL, further demonstrating the weakness and limited evaluation power of the original test inputs.
110
+
111
+ # 4 Related Work
112
+
113
+ LLMs for code. The use of LLMs for code has gained traction in recent years, owing to the abundance of open codebase and the need for improving developer efficiency. LLMs have demonstrated state-of-the-art performance on various code-related tasks, including code generation [11, 33, 25], program repair [69, 27, 68, 65], automated testing [15, 14, 67, 35, 71], code translation [31, 55] and code summarization [1, 37]. In particular, prominent LLMs including CODEX [11], CodeGen [46], INCODER [18] and PolyCoder [70], have been developed and extensively evaluated for code generation (widely recognized as the holy grail for computer science research since the inception of AI in the 1950s [21]), where the model generates code snippets based on natural language descriptions (e.g., docstring) of the desired functionality.
114
+
115
+ Coding benchmark for LLMs. LLM-based code synthesis is largely evaluated based on functional correctness, which is typically assessed by running test-cases to check the desired outputs. HUMANEVAL [11] is one of the pioneering and most widely studied human-written benchmarks for LLM-based code synthesis, consisting of 164 pairs of Python function signature with docstring and the associated test-cases for correctness checking. Additionally, each HUMANEVAL problem is also equipped with a reference solution. Another Python-focused dataset, MBPP [3], is created by crowd-sourcing participants to write in summation 974 programming problems, each of which is comprised of the problem statement (i.e., docstring), the function signature, as well as three test-cases. Beyond Python, there are other benchmarks targeting additional languages such as Spider [73] (SQL), HUMANEVAL-X [76] $^ { ( \mathrm { C + + } }$ , Javascript and Go), CodeContests [33] ( $\scriptstyle ( + +$ and Java) and MultiPL-E [9] (extending HUMANEVAL and MBPP to 18 programming languages). More recently, researchers have created a more realistic code synthesis benchmark by collecting GitHub issues along with the corresponding code base together with tests to measure the ability of LLMs to perform real-world software engineering tasks [28]. Our work shows for the first time the test inadequacy problem of widely studied benchmarks and addresses the issue via automatic test generation.
116
+
117
+ Automated test generation. Automated test generation is a widely used for finding software bugs with automatically generated tests. Black-box test generation such as fuzz testing [43] feeds random inputs (e.g., random bytes) to the system under test (SUT), without knowing its source code. Traditional black-box techniques can mainly be categorized into generation-based [72, 23, 56] and mutationbased [66, 10, 47] ones. White-box approaches provide better-quality test-cases by analyzing the source code of SUT. For instance, symbolic execution [30, 8] breaks the coverage plateaus by solving symbolic path constraints to generate tests targeting deep paths. As a mid-point, coverage-guided fuzzing [74, 57] (i.e., grey-box) uses the coverage information of SUT as feedback to adjust the input generation and mutation. The discussed traditional methods are inapplicable to generating semantically meaningful inputs for arbitrary problems programmed in a dynamically-typed language. We address this by using ChatGPT to inspect the ground-truth (i.e., white-box) for initializing interesting seeds, based on which type-aware mutation (i.e., black-box) scales the test inputs to a large amount.
118
+
119
+ # 5 Conclusion & Future Work
120
+
121
+ We present EvalPlus – a rigorous evaluation framework for program synthesis, driven by automated test generation. EvalPlus combines both LLM- and mutation-based input generation to obtain a diverse set of test inputs for accurately evaluating the correctness of LLM-generated code. EvalPlus creates HUMANEVAL+, built on top of the popular HUMANEVAL with additional high-quality and automatically generated test inputs. With test-suite reduction, EvalPlus also produces HUMANEVAL+-MINI which is smaller than HUMANEVAL+ by $4 7 \times$ while preserving similar test effectiveness. We extensively evaluate a diverse set of LLMs and show that HUMANEVAL+ can identify a significant amount of previously undetected wrong code generated by LLMs, demonstrating its effectiveness to augment programming benchmarks for more accurate evaluation.
122
+
123
+ Since launched, the EvalPlus PyPI package has been installed by over 6k times in 5 months. We also keep evaluating new models for code and maintain a leaderboard at https://evalplus.github. io/leaderboard.html. In the future, we plan to apply EvalPlus to bring better-quality testing for more code benchmarks such as MBPP. Meanwhile. future work can look into how to integrate EvalPlus with more formal verification (e.g., Dafny [32]) or validation techniques (e.g., translation validation [36]) to provide stronger guarantees of the evaluation results when applicable. Additionally, the core test generation technique behind can be even used to remind developers of potential flaws of the accepted LLM-generated code snippets when doing AI pair-programming (e.g., Copilot [42]).
124
+
125
+ # 6 Acknowledgements
126
+
127
+ This work was partially supported by NSF grants CCF-2131943 and CCF-2141474, as well as Kwai Inc. We thank the reviewers for their invaluable feedback. We further thank Yinlin Deng for providing helpful discussions, as well as Junhao Wang and Songrun Xie for their open-source contributions.
128
+
129
+ References
130
+ [1] T. Ahmed and P. Devanbu. Few-shot training llms for project-specific code-summarization. In 37th IEEE/ACM International Conference on Automated Software Engineering, pages 1–5, 2022.
131
+ [2] L. B. Allal, R. Li, D. Kocetkov, C. Mou, C. Akiki, C. M. Ferrandis, N. Muennighoff, M. Mishra, A. Gu, M. Dey, et al. Santacoder: don’t reach for the stars! arXiv preprint arXiv:2301.03988, 2023.
132
+ [3] J. Austin, A. Odena, M. Nye, M. Bosma, H. Michalewski, D. Dohan, E. Jiang, C. Cai, M. Terry, Q. Le, and C. Sutton. Program synthesis with large language models, 2021.
133
+ [4] S. Bang, S. Nam, I. Chun, H. Y. Jhoo, and J. Lee. Smt-based translation validation for machine learning compiler. In Computer Aided Verification: 34th International Conference, CAV 2022, Haifa, Israel, August 7–10, 2022, Proceedings, Part II, pages 386–407. Springer, 2022.
134
+ [5] S. Black, L. Gao, P. Wang, C. Leahy, and S. Biderman. GPT-Neo: Large Scale Autoregressive Language Modeling with Mesh-Tensorflow, Mar. 2021. If you use this software, please cite it using these metadata.
135
+ [6] T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
136
+ [7] T. A. Budd. Mutation analysis of program test data. Yale University, 1980.
137
+ [8] C. Cadar, D. Dunbar, D. R. Engler, et al. Klee: unassisted and automatic generation of high-coverage tests for complex systems programs. In OSDI, volume 8, pages 209–224, 2008.
138
+ [9] F. Cassano, J. Gouwar, D. Nguyen, S. Nguyen, L. Phipps-Costin, D. Pinckney, M.-H. Yee, Y. Zi, C. J. Anderson, M. Q. Feldman, et al. Multipl-e: A scalable and polyglot approach to benchmarking neural code generation. IEEE Transactions on Software Engineering, 2023.
139
+ [10] S. K. Cha, M. Woo, and D. Brumley. Program-adaptive mutational fuzzing. In 2015 IEEE Symposium on Security and Privacy, pages 725–741. IEEE, 2015.
140
+ [11] M. Chen, J. Tworek, H. Jun, Q. Yuan, H. P. d. O. Pinto, J. Kaplan, H. Edwards, Y. Burda, N. Joseph, G. Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
141
+ [12] W.-L. Chiang, Z. Li, Z. Lin, Y. Sheng, Z. Wu, H. Zhang, L. Zheng, S. Zhuang, Y. Zhuang, J. E. Gonzalez, I. Stoica, and E. P. Xing. Vicuna: An open-source chatbot impressing gpt-4 with $9 0 \% *$ chatgpt quality, March 2023.
142
+ [13] B. Code. Starcoder. https://github.com/bigcode-project/starcoder, 2023.
143
+ [14] Y. Deng, C. S. Xia, H. Peng, C. Yang, and L. Zhang. Large language models are zero-shot fuzzers: Fuzzing deep-learning libraries via large language models. In 32nd International Symposium on Software Testing and Analysis (ISSTA), 2023.
144
+ [15] Y. Deng, C. S. Xia, C. Yang, S. D. Zhang, S. Yang, and L. Zhang. Large language models are edge-case fuzzers: Testing deep learning libraries via fuzzgpt. In 46th International Conference on Software Engineering (ICSE), 2024.
145
+ [16] fauxpilot. Fauxpilot: an open-source alternative to github copilot server. https: //github.com/fauxpilot/fauxpilot, 2022.
146
+ [17] U. Feige. A threshold of ln n for approximating set cover. Journal of the ACM (JACM), 45(4):634–652, 1998.
147
+ [18] D. Fried, A. Aghajanyan, J. Lin, S. Wang, E. Wallace, F. Shi, R. Zhong, S. Yih, L. Zettlemoyer, and M. Lewis. Incoder: A generative model for code infilling and synthesis. In The Eleventh International Conference on Learning Representations, 2023.
148
+ [19] C. Green. Application of theorem proving to problem solving. In Readings in Artificial Intelligence, pages 202–222. Elsevier, 1981.
149
+ [20] S. Gulwani. Automating string processing in spreadsheets using input-output examples. SIGPLAN Not., 46(1):317–330, jan 2011.
150
+ [21] S. Gulwani, O. Polozov, and R. Singh. Program synthesis. Foundations and Trends® in Programming Languages, 4(1-2):1–119, 2017.
151
+ [22] T. Hastie, R. Tibshirani, J. H. Friedman, and J. H. Friedman. The elements of statistical learning: data mining, inference, and prediction, volume 2. Springer, 2009.
152
+ [23] C. Holler, K. Herzig, and A. Zeller. Fuzzing with code fragments. In 21st USENIX Security Symposium (USENIX Security 12), pages 445–458, Bellevue, WA, Aug. 2012. USENIX Association.
153
+ [24] M. Ivankovic, G. Petrovi ´ c, R. Just, and G. Fraser. Code coverage at google. In ´ Proceedings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, pages 955–963, 2019.
154
+ [25] S. Iyer, I. Konstas, A. Cheung, and L. Zettlemoyer. Mapping language to code in programmatic context. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 1643–1652, 2018.
155
+ [26] A. Q. Jiang, A. Sablayrolles, A. Mensch, C. Bamford, D. S. Chaplot, D. d. l. Casas, F. Bressand, G. Lengyel, G. Lample, L. Saulnier, et al. Mistral 7b. arXiv preprint arXiv:2310.06825, 2023.
156
+ [27] N. Jiang, K. Liu, T. Lutellier, and L. Tan. Impact of code language models on automated program repair. arXiv preprint arXiv:2302.05020, 2023.
157
+ [28] C. E. Jimenez, J. Yang, A. Wettig, S. Yao, K. Pei, O. Press, and K. Narasimhan. Swe-bench: Can language models resolve real-world github issues? arXiv preprint arXiv:2310.06770, 2023.
158
+ [29] A. Kalyan, A. Mohta, O. Polozov, D. Batra, P. Jain, and S. Gulwani. Neural-guided deductive search for real-time program synthesis from examples. In International Conference on Learning Representations, 2018.
159
+ [30] J. C. King. Symbolic execution and program testing. Communications of the ACM, 19(7):385–394, 1976.
160
+ [31] M.-A. Lachaux, B. Roziere, L. Chanussot, and G. Lample. Unsupervised translation of programming languages. arXiv preprint arXiv:2006.03511, 2020.
161
+ [32] K. R. M. Leino. Dafny: An automatic program verifier for functional correctness. In International conference on logic for programming artificial intelligence and reasoning, pages 348–370. Springer, 2010.
162
+ [33] Y. Li, D. Choi, J. Chung, N. Kushman, J. Schrittwieser, R. Leblond, T. Eccles, J. Keeling, F. Gimeno, A. Dal Lago, et al. Competition-level code generation with alphacode. Science, 378(6624):1092–1097, 2022.
163
+ [34] J. Liu, Y. Wei, S. Yang, Y. Deng, and L. Zhang. Coverage-guided tensor compiler fuzzing with joint ir-pass mutation. Proceedings of the ACM on Programming Languages, 6(OOPSLA1):1–26, Apr. 2022.
164
+ [35] Z. Liu, C. Chen, J. Wang, X. Che, Y. Huang, J. Hu, and Q. Wang. Fill in the blank: Context-aware automated text input generation for mobile gui testing. In 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE), pages 1355–1367. IEEE, 2023.
165
+ [36] N. P. Lopes, J. Lee, C.-K. Hur, Z. Liu, and J. Regehr. Alive2: bounded translation validation for llvm. In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, pages 65–79, 2021.
166
+ [37] S. Lu, D. Guo, S. Ren, J. Huang, A. Svyatkovskiy, A. Blanco, C. Clement, D. Drain, D. Jiang, D. Tang, et al. Codexglue: A machine learning benchmark dataset for code understanding and generation. arXiv preprint arXiv:2102.04664, 2021.
167
+ [38] Z. Luo, C. Xu, P. Zhao, Q. Sun, X. Geng, W. Hu, C. Tao, J. Ma, Q. Lin, and D. Jiang. Wizardcoder: Empowering code large language models with evol-instruct. arXiv preprint arXiv:2306.08568, 2023.
168
+ [39] Z. Manna and R. J. Waldinger. Toward automatic program synthesis. Communications of the ACM, 14(3):151–165, 1971.
169
+ [40] W. M. McKeeman. Differential testing for software. Digital Technical Journal, 10(1):100–107, 1998.
170
+ [41] B. Meyer. Applying’design by contract’. Computer, 25(10):40–51, 1992.
171
+ [42] Microsoft. GitHub Copilot – Your AI pair programmer. https://github.com/features/ copilot, 2023.
172
+ [43] B. P. Miller, L. Fredriksen, and B. So. An empirical study of the reliability of unix utilities. Communications of the ACM, 33(12):32–44, 1990.
173
+ [44] G. C. Necula. Translation validation for an optimizing compiler. In Proceedings of the ACM SIGPLAN 2000 conference on Programming language design and implementation, pages 83–94, 2000.
174
+ [45] E. Nijkamp, H. Hayashi, C. Xiong, S. Savarese, and Y. Zhou. Codegen2: Lessons for training llms on programming and natural languages. arXiv preprint, 2023.
175
+ [46] E. Nijkamp, B. Pang, H. Hayashi, L. Tu, H. Wang, Y. Zhou, S. Savarese, and C. Xiong. Codegen: An open large language model for code with multi-turn program synthesis. In The Eleventh International Conference on Learning Representations, 2023.
176
+ [47] P. Oehlert. Violating assumptions with fuzzing. IEEE Security & Privacy, 3(2):58–62, 2005.
177
+ [48] OpenAI. Chatgpt: Optimizing language models for dialogue. https://openai.com/blog/ chatgpt/, 2022.
178
+ [49] OpenAI. Gpt-4 technical report. ArXiv, abs/2303.08774, 2023.
179
+ [50] K. Papineni, S. Roukos, T. Ward, and W.-J. Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th annual meeting of the Association for Computational Linguistics, pages 311–318, 2002.
180
+ [51] G. Petrovic and M. Ivankovi ´ c. State of mutation testing at google. In ´ Proceedings of the 40th international conference on software engineering: Software engineering in practice, pages 163–171, 2018.
181
+ [52] Phind. Phind/phind-codellama-34b-v2 $\cdot$ hugging face. https://huggingface.co/Phind/ Phind-CodeLlama-34B-v2, 2023.
182
+ [53] G. Rothermel, M. J. Harrold, J. Von Ronne, and C. Hong. Empirical studies of test-suite reduction. Software Testing, Verification and Reliability, 12(4):219–249, 2002.
183
+ [54] B. Rozière, J. Gehring, F. Gloeckle, S. Sootla, I. Gat, X. E. Tan, Y. Adi, J. Liu, T. Remez, J. Rapin, et al. Code llama: Open foundation models for code. arXiv preprint arXiv:2308.12950, 2023.
184
+ [55] B. Roziere, J. M. Zhang, F. Charton, M. Harman, G. Synnaeve, and G. Lample. Leveraging automated unit tests for unsupervised code translation. arXiv preprint arXiv:2110.06773, 2021.
185
+ [56] M. Security. jsfunfuzz. https://github.com/MozillaSecurity/funfuzz, 2007.
186
+ [57] K. Serebryany. Continuous fuzzing with libfuzzer and addresssanitizer. In 2016 IEEE Cybersecurity Development (SecDev), pages 157–157. IEEE, 2016.
187
+ [58] D. E. Shaw, W. R. Swartout, and C. C. Green. Inferring lisp programs from examples. In IJCAI, volume 75, pages 260–267, 1975.
188
+ [59] A. Shi, A. Gyori, M. Gligoric, A. Zaytsev, and D. Marinov. Balancing trade-offs in test-suite reduction. In Proceedings of the 22nd ACM SIGSOFT international symposium on foundations of software engineering, pages 246–256, 2014.
189
+ [60] Stability-AI. Stablelm: Stability ai language models. https://github.com/Stability-AI/ StableLM, 2023.
190
+ [61] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
191
+ [62] R. J. Waldinger and R. C. Lee. Prow: A step toward automatic program writing. In Proceedings of the 1st international joint conference on Artificial intelligence, pages 241–252, 1969.
192
+ [63] B. Wang and A. Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
193
+ [64] Y. Wang, H. Le, A. D. Gotmare, N. D. Bui, J. Li, and S. C. Hoi. Codet5 $^ +$ : Open code large language models for code understanding and generation. arXiv preprint arXiv:2305.07922, 2023.
194
+ [65] Y. Wei, C. S. Xia, and L. Zhang. Copiloting the copilots: Fusing large language models with completion engines for automated program repair. arXiv preprint arXiv:2309.00608, 2023.
195
+ [66] D. Winterer, C. Zhang, and Z. Su. On the unusual effectiveness of type-aware operator mutations for testing smt solvers. Proceedings of the ACM on Programming Languages, 4(OOPSLA):1–25, 2020.
196
+ [67] C. S. Xia, M. Paltenghi, J. L. Tian, M. Pradel, and L. Zhang. Universal fuzzing via large language models. In 46th International Conference on Software Engineering (ICSE), 2024.
197
+ [68] C. S. Xia, Y. Wei, and L. Zhang. Automated program repair in the era of large pre-trained language models. In Proceedings of the 45th International Conference on Software Engineering (ICSE 2023). Association for Computing Machinery, 2023.
198
+ [69] C. S. Xia and L. Zhang. Less training, more repairing please: revisiting automated program repair via zero-shot learning. In Proceedings of the 30th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering, pages 959–971, 2022.
199
+ [70] F. F. Xu, U. Alon, G. Neubig, and V. J. Hellendoorn. A systematic evaluation of large language models of code. In Proceedings of the 6th ACM SIGPLAN International Symposium on Machine Programming, pages 1–10, 2022.
200
+ [71] C. Yang, Y. Deng, R. Lu, J. Yao, J. Liu, R. Jabbarvand, and L. Zhang. White-box compiler fuzzing empowered by large language models, 2023.
201
+ [72] X. Yang, Y. Chen, E. Eide, and J. Regehr. Finding and understanding bugs in c compilers. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’11, page 283–294, New York, NY, USA, 2011. Association for Computing Machinery.
202
+ [73] T. Yu, R. Zhang, K. Yang, M. Yasunaga, D. Wang, Z. Li, J. Ma, I. Li, Q. Yao, S. Roman, et al. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-sql task. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, 2018.
203
+ [74] M. Zalewski. American fuzzing lop (afl). https://lcamtuf.coredump.cx/afl/, 2018.
204
+ [75] L. Zhang, D. Marinov, L. Zhang, and S. Khurshid. An empirical study of junit test-suite reduction. In 2011 IEEE 22nd International Symposium on Software Reliability Engineering, pages 170–179. IEEE, 2011.
205
+ [76] Q. Zheng, X. Xia, X. Zou, Y. Dong, S. Wang, Y. Xue, Z. Wang, L. Shen, A. Wang, Y. Li, et al. Codegeex: A pre-trained model for code generation with multilingual evaluations on humaneval-x. arXiv preprint arXiv:2303.17568, 2023.
206
+
207
+ Table 5: Overview of evaluated models.
208
+
209
+ <table><tr><td>Model Name</td><td>Sizes</td><td>Release Year</td><td>Open-Source</td></tr><tr><td rowspan="10">Cuipoo</td><td>2B,6B,16B</td><td>2022 2022</td><td>&lt;</td></tr><tr><td>CodeGen [46] INCODER [18]</td><td>1.3B, 6.7B</td><td>√</td></tr><tr><td>PolyCoder [70]</td><td>2.7B</td><td>2022</td></tr><tr><td>SantaCoder [2]</td><td>1.1B 2023</td><td></td></tr><tr><td>CodeGen2 [45]</td><td>1B,3B,7B,16B</td><td>2023</td></tr><tr><td>StarCoder[13]</td><td>15B 2023</td><td></td></tr><tr><td>CODET5+ [64]</td><td>16B 2023</td><td></td></tr><tr><td>CODELLAMA [54]</td><td>7B,13B,34B 2023</td><td></td></tr><tr><td>WizardCoder-CodeLlama [38]</td><td>2023</td><td></td></tr><tr><td>34B Phind-CodeLlama [52] 34B</td><td>2023</td><td></td></tr><tr><td rowspan="7">GPT-J [63] Geeeeer StableLM [60]</td><td>6B</td><td>2021</td><td>√</td></tr><tr><td>GPT-NEO [5]</td><td>2.7B 2021</td><td>【</td></tr><tr><td>ChatGPT[48]</td><td>2022</td><td></td></tr><tr><td>GPT-4 [49]</td><td>N/A N/A</td><td></td></tr><tr><td>VICUNA [12]</td><td>2023 2023</td><td></td></tr><tr><td>7B,13B 7B</td><td>2023</td><td></td></tr><tr><td>MISTRAL [26]</td><td>2023</td><td></td></tr></table>
210
+
211
+ # A Detailed Experimental Setup
212
+
213
+ Evaluation of LLMs. Our goal is to comprehensively evaluate recent and widely used LLMs, both specialized for code generation [46, 70, 18, 2, 52, 38, 64] and general-purpose tasks [49, 48, 12, 60, 63, 5, 26]. Table 5 presents an overview of the studied models, with column Sizes reflecting the model sizes in billions of parameters, Release Year showing when the LLM is released, and Open-Source marking the models whose weights are publicly available. In total, we evaluate 26 of the most representative and popular LLMs with a broad range of configurations to fully demonstrate the generalizability of our results.
214
+
215
+ Our hyper-parameter configurations follow prior work [11, 46]. For each model we randomly sample 200 programs and repeat the experiments over temperature $( \{ 0 . 2 , 0 . 4 , 0 . 6 , 0 . 8 \} )$ and greedy decoding with zero temperature. By default, we let each model generate at most 512 new tokens and truncate the produced code with end-of-string (EOS) identifiers suggested in HUMANEVAL [11], as well as those favoured by certain models (e.g., “<|endoftext $| > ^ { \dag }$ and $\cdots ( n ^ { - , - , 3 } )$ . For conversational models (i.e., ChatGPT and GPT-4), we obtain the code fragments by parsing the code blocks (i.e., within “\`\`\`”) in the output. We found ChatGPT tends to repeat problem description with detailed explanation, which can consume more than 512 new tokens to complete a solution for around $11 \%$ of problems. To align ChatGPT with other models, for tasks with very long problem descriptions, we extend the token limit from 512 to 1024. For model implementation, we run ChatGPT and GPT-4 via OpenAI APIs, and accelerate CodeGen-6B and -16B with NVIDIA FasterTransformer via FauxPilot [16]. All other LLMs are based on the HuggingFace transformers library. By default, we follow the official examples of each LLM (e.g., on HuggingFace model card) to construct their corresponding prompts. Specifically, the prompts used for ChatGPT, GPT-4, and WizardCoder-CodeLlama is instruction-based, i.e., a simple instruction is used to wrap the function signature and docstring to explicitly encourage the LLM for code generation.
216
+
217
+ Test oracles. An LLM-produced solution is regarded to be correct if for all test inputs it returns values that match the expected outputs within a reasonable run time. We perform exact matching by default. For floating-point comparisons, we tolerate absolute differences to the degrees annotated in HUMANEVAL or $1 \bar { 0 } ^ { - 6 }$ if not annotated. In original HUMANEVAL, the default timeout is set to three seconds to run the whole test-suite (i.e., all test-cases) for each programming problem. Such a setting is neither suitable when having more test-cases nor reasonable as each problem could have its own run time characteristics. Consequently, we let the timeout for each test-case to be $\mathrm { m a x } ( 2 0 0 \mathrm { m s } , 4 \times t _ { g t } )$ where $t _ { g t }$ refers to the execution time of the corresponding ground-truth solution. In other words, we expect the LLM-provided solution to be no slower than the ground-truth by four times or use a base 200-millisecond timeout when $4 \times t _ { g t } < 2 0 0 \mathrm { m s }$ to avoid variance caused by performance randomness.
md/dev/1sx0Drq4jfT/1sx0Drq4jfT.md ADDED
@@ -0,0 +1,613 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TRAINING META-SURROGATE MODEL FOR TRANS-FERABLE ADVERSARIAL ATTACK.
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ We consider adversarial attacks to a black-box model when no queries are allowed. In this setting, many methods directly attack surrogate models and transfer the obtained adversarial examples to fool the target model. Plenty of previous works investigated what kind of attacks to the surrogate model can generate more transferable adversarial examples, but their performances are still limited due to the mismatches between surrogate models and the target model. In this paper, we tackle this problem from a novel angle—instead of using the original surrogate models, can we obtain a Meta-Surrogate Model (MSM) such that attacks to this model can be easier transferred to other models? We show that this goal can be mathematically formulated as a well-posed (bi-level-like) optimization problem and design a differentiable attacker to make training feasible. Given one or a set of surrogate models, our method can thus obtain an MSM such that adversarial examples generated on MSM enjoy eximious transferability. Comprehensive experiments on Cifar-10 and ImageNet demonstrate that by attacking the MSM, we can obtain stronger transferable adversarial examples to fool black-box models including adversarially trained ones, with much higher success rates than existing methods.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ The developments of Convolutional Neural Network (CNN) (LeCun et al., 1995; Krizhevsky et al., 2012) have greatly promoted the advancements in Computer Vision (Ren et al., 2016). However, previous works (Goodfellow et al., 2014; Carlini & Wagner, 2017; Croce & Hein, 2020a; Ganeshan et al., 2019) have shown a critical robustness issue that CNN models are vulnerable to humanimperceptible perturbations of input images, also known as adversarial examples (AEs). The design of AEs is useful for revealing the security threats on machine learning systems (Croce & Hein, 2020b) and for understanding the representations learned by CNN models (Ilyas et al., 2019).
12
+
13
+ In this paper, we consider the problem of black-box attack, where the target victim model is entirely hidden from the attacker. In this setting, standard white-box attacks (Moosavi-Dezfooli et al., 2016; Carlini & Wagner, 2017) or even query-based black-box attacks (Ilyas et al., 2018; Cheng et al., 2018; 2020; 2019) cannot be used, and the prevailing way to attack the victim is through transfer attack (Papernot et al., 2017; Wu et al., 2018). In transfer attack (Demontis et al., 2019; Dong et al., 2018), the attackers commonly generate AEs by attacking one or an ensemble of surrogate models and hope the obtained AEs can also successfully fool the victim black-box model.
14
+
15
+ Although great efforts have been made to improve the transferability of adversarial attacks (Tramer\` et al., 2017; Xie et al., 2019; Wu et al., 2020a), the transfer attack-based methods still encounter poor success rates, especially when attacking adversarially trained target models. This is caused by a fundamental limitation of current approaches—they all leverage the surrogate models trained by standard learning tasks (e.g., classification, object detection), while it is not always the case that attacks fooling such models can be easily transferred. We thus pose the following important question on transfer attack that has not been well studied in the literature: Instead of using standard (naturally trained) models as surrogate, can we artificially construct another Meta-Surrogate Model (MSM) such that attacks to this model can be easier transferred to other models?
16
+
17
+ We answer this question in the affirmative by developing a novel black-box attack pipeline called Meta-Transfer Attack (MTA). Assume a set of source models (standard surrogate models) are given, instead of directly attacking these source models, our algorithm aims to obtain a “meta-surrogate model (MSM)”, which is designed in the way that attacks to this model can be easier transferred to fool other models, and conduct attacks on the MSM to obtain transferable AEs. We show that this goal can be mathematically formulated as a well-posed (bi-level-like) training objective by unrolling the attacks on the MSM and defining a loss to measure the transferability of the resulting AEs. To avoid discrete operations in the white-box attack, we propose a Customized PGD attacker that enables back-propagation through the whole procedure. With this bi-level-like optimization (Finn et al., 2017; Qin et al., 2020), the source models supervise the MSM to improve the transferability of the AEs created on it. Through extensive experiments on various models and datasets, we show that the proposed MTA method leads to significantly improved transfer attacks, demonstrating the effectiveness of the MSM.
18
+
19
+ We summarize the main contributions of our work as follows. 1) We propose a novel MTA framework to train an MSM to improve the transferability of AEs. To the best of our knowledge, our work is the first attempt to explore a better surrogate model for producing stronger transferable AEs. 2) We compare MTA with state-of-the-art transfer attack methods (e.g., MI (Dong et al., 2018), DI (Xie et al., 2019), TI (Dong et al., 2019), SGM (Wu et al., 2020a), AEG (Bose et al., 2020), IR (Wang et al., 2021a), SI-NI (Lin et al., 2020)) on Cifar-10 (Krizhevsky et al., 2009) and Imagenet (Deng et al., 2009). The comparisons demonstrate the effectiveness of the proposed MTA—the AEs generated by attacking MSM significantly outperform previous methods, in attacking both naturally trained and adversarially trained black-box target models.
20
+
21
+ # 2 BACKGROUND
22
+
23
+ Adversarial attacks. Szegedy et al. (2014) reveals the interesting phenomenon that CNN models are vunerable to adversarial attacks. After that, many attacks have been developed (Gao et al., 2020; Zhou et al., 2018; Wu et al., 2020b; Li et al., 2020b; Kaidi et al., 2019; Sriramanan et al., 2020). Adversarial attacks can be mainly classified into white-box and black-box attacks (Maksym et al., 2020) according to how much information about the target model is exposed to the attacker. Whitebox attacks (Kurakin et al., 2016) are often more effective than than black-box attacks (Brendel et al., 2017; Cheng et al., 2018; 2020) as they can leverage full knowledge of the target model including the model weights and architecture. For example, Fast Gradient Sign Method (FGSM) (Goodfellow et al., 2014) uses 1-step gradient ascent to produce adversarial examples that enlarge the model’s loss. Projected gradient descent (PGD) attack can be viewed as a multi-step FGSM attack (Madry et al., 2018). Many other white-box attacks have also been developed by leveraging full information of the target model (Moosavi-Dezfooli et al., 2016; Croce & Hein, 2020a). In the black-box setting, query-based black-box attacks (Huang & Zhang, 2020; Du et al., 2020) assume model information is hidden but attackers can query the model and observe the corresponding hard-label or soft-label predictions. Among them, (Chen et al., 2017; Ilyas et al., 2018) considered soft-label probability predictions and (Chen et al., 2020; Huang & Zhang, 2020; Cheng et al., 2018) considered hard-label decision-based predictions. Considering that using a large number of queries to attack an image is impractical, several works try to further reduce the query counts (Li et al., 2020a; Wang et al., 2020).
24
+
25
+ Transferability of adversarial examples. In this paper, we consider the black-box attack scenario when the attacker cannot make any query to the target model (Lin et al., 2020; Huang et al., 2019; Wang et al., 2021b). In this case, the common attack method is based on transfer attack—the attacker generates AEs by attacking one or few surrogate models and hopes the AEs can also fool the target model (Papernot et al., 2016; Liu et al., 2017; Yuan et al., 2021; Zhou et al., 2018). Compared with query-based attacks, crafting AEs from the surrogate model consumes less computational resources and is more realistic in practice. Along this direction, subsequent works have made attempts to improve the transferability of AEs (Guo et al., 2020; Wu et al., 2020c; Naseer et al., 2019; Li et al., $2 0 2 0 \mathrm { c }$ ; Wang & He, 2021). For instance, Dong et al. (2018) boosted the transferability by integrating the momentum term into the iterative process. Other techniques like data augmentations (Xie et al., 2019), exploiting gradients of skip-connection (Wu et al., 2020a), and negative interaction between pixels (Wang et al., 2021a) also contribute to stronger transferable attacks. In addition to using the original surrogate models, AEG (Bose et al., 2020) adversarially trains a robust classifier together with an encoder-decoder-based transferable perturbation generator. After the training, AEG uses the generator to generate transferable AEs to attack a set of classifiers. Compared to all the existing works, our method is the first that meta-trains a new meta-surrogate model (MSM) such that attacks on MSM can be easier transferred to other models. This not only differs from all the previous methods that attack standard surrogate models but also differs from the encoder-decoder based method such as AEG (Bose et al., 2020).
26
+
27
+ # 3 METHODOLOGY
28
+
29
+ We consider the black-box attack setting where the target model is hidden to the attacker and queries are not allowed. This setting is also known as the transfer attack setting (Dong et al., 2018; 2019; Xie et al., 2019; Wang et al., 2021a) and the attacker 1) cannot access the weight, the architecture, and the gradient of the target model; and 2) cannot querying the target model. The attacker can access 1) the dataset used by the target model; and 2) a single or a set of surrogate models (also known as source models) that may share the dataset with the target model. For example, it is common to assume that the attacker can access one or multiple well-performed (pretrained) image classification models. Existing transferable adversarial attack methods conduct various attacks to these models and hope to get transferable AEs that can fool an unknown target model. Instead of proposing another attack method on surrogate models, we propose a novel framework MTA to train a Meta-Surrogate Model (MSM) with the goal that attacking the MSM can generate stronger transferable AEs than directly attacking the original surrogate models. When evaluating, the transferable AEs are generated by attacking the MSM with standard white-box attack methods (e.g., PGD attack). In the following, we will first review exiting attacks and then show how to form a bi-level optimization objective to train the MSM model.
30
+
31
+ # 3.1 REVIEWS OF FGSM AND PGD
32
+
33
+ We follow the settings of existing works (Dong et al., 2018; Xie et al., 2019; Wu et al., 2020a; Wang et al., 2021a) to focus on untargeted attack, where the attack is considered successful as long as the perturbed image is wrongly predicted.
34
+
35
+ FGSM (Goodfellow et al., 2014) conducts one-step gradient ascent to generate AEs to enlarge the prediction loss. The formulation can be written as
36
+
37
+ $$
38
+ \begin{array} { r } { x _ { a d v } = \mathbf { C l i p } \big ( x + \epsilon \cdot \mathrm { s i g n } \big ( \nabla _ { x } L ( f ( x ) , y ) \big ) \big ) , } \end{array}
39
+ $$
40
+
41
+ where $x$ is a clean image and $y$ is the corresponding label; $\epsilon$ is the attack step size that determines the maximum $L _ { \infty }$ perturbation of each pixel; $f$ is the victim model that is transparent to the FGSM attacker; Clip is the function that clipping the values of $x _ { a d v }$ to the legal range (e.g., clipping the RGB AEs to the range of $[ 0 , 2 5 5 ] ,$ ); $L$ is usually the cross-entropy loss.
42
+
43
+ PGD (Kurakin et al., 2016), also known as I-FGSM attack, is a multi-step extension of FGSM. The formulation of PGD is
44
+
45
+ $$
46
+ \boldsymbol { x } _ { a d v } ^ { k } = \mathrm { C l i p } \big ( \boldsymbol { x } _ { a d v } ^ { k - 1 } + \frac { \epsilon } { T } \cdot \mathrm { s i g n } \big ( \nabla _ { \boldsymbol { x } _ { a d v } ^ { k - 1 } } L \big ( f \big ( \boldsymbol { x } _ { a d v } ^ { k - 1 } \big ) , y \big ) \big ) \big ) .
47
+ $$
48
+
49
+ $x _ { a d v } ^ { k }$ is the AEs generated in the $k$ -th gradient ascent step. Note that $x _ { a d v } ^ { 0 }$ is the clean image equals to $x$ . Eq 2 will be run for iterations to obtain $x _ { a d v } ^ { T }$ with perturbation size $\epsilon$ .
50
+
51
+ # 3.2 META-TRANSFER ATTACK
52
+
53
+ How to train the MSM where attacks to this model can be easier transferred to other models? We show this can be formulated as a bi-level training objective. Let $\mathcal { A }$ denote an attack algorithm (e.g., FGSM or PGD) and $\mathcal { M } _ { \theta }$ denote the MSM parameterized by $\theta$ . For a given image $x$ , the AE generated by attacking $\mathcal { M } _ { \theta }$ can be denoted as $\bar { \boldsymbol { A } } ( \mathcal { M } _ { \theta } , x , y )$ . For example, if $\mathcal { A }$ is FGSM, then $\begin{array} { r } { \mathcal { A } ( \mathcal { M } _ { \theta } , x , y ) = x _ { a d v } = \mathbf { C } \mathrm { l i p } \big ( x + \epsilon \cdot \mathrm { s i g n } \big ( \nabla _ { x } L ( \mathcal { M } _ { \theta } ( x ) , y ) ) \big ) } \end{array}$ . Since in the attack time we only have access to a set of source models $\mathcal { F } _ { 1 } , \ldots , \mathcal { F } _ { N }$ , we can evaluate the transferability of the adversarial example $\mathcal { A } ( \mathcal { M } _ { \theta } , x , y )$ on the source models and optimize the MSM via maximizing the adversarial losses of those $N$ source models, leading to the following training objective:
54
+
55
+ $$
56
+ \underset { \ b { \theta } } { \arg \operatorname* { m a x } } \mathbb { E } _ { ( \boldsymbol { x } , \boldsymbol { y } ) \sim D } \big [ \sum _ { i = 1 } ^ { N } L ( \underset { \mathcal { F } _ { i } ^ { \prime } s \mathrm { ~ p r e d i c t i o n ~ f o r ~ A E } } \overbrace { \mathcal { F } _ { i } ( \overbrace { A ( \mathcal { M } _ { \theta } , \boldsymbol { x } , \boldsymbol { y } ) } ) } , \boldsymbol { y } ) \big ] ,
57
+ $$
58
+
59
+ where $D$ is the distribution of training data. The structure of this objective and the training procedure can be illustrated in Figure 1, where we can view it as a meta-learning or bi-level optimization method. At the lower level, the AE is generated by a white-box attack (usually gradient ascent) on MSM, while at the higher level, we feed the AE to the source models to compute the robust loss. Solving Eq 3 will find an MSM where attacking it leads to stronger transferable AEs. The optimization steps of $\operatorname { E q } 3$ are detailed below.
60
+
61
+ First, $\mathcal { A }$ should be some strong white-box attacks, such as FGSM or PGD. However, directly using those attacks will make the gradient of meta training objective Eq 3 ill-defined since the sign function in both FGSM and PGD introduce a discrete operation. This results in that the gradient back-propagating through sign be zero and further prohibits the training of the MSM.
62
+
63
+ To overcome this challenge, we design $\mathcal { A }$ as an approximation of PGD and denote it as Customized PGD. Section 3.3 will show more explanation about how the sign function in PGD prohibits backpropagation and how Customized PGD enables the back-propagation. The crucial difference between PGD and the Customized PGD is the operation to the gradient $\nabla _ { x _ { a d v } ^ { k - 1 } } L ( \mathcal { M } _ { \theta } ( x _ { a d v } ^ { \bar { k } - 1 } ) , y )$ , where $L$ is the cross entropy loss. For simplicity, we denote the vanilla gradient $\mathrm { \dot { \nabla } } _ { x _ { a d v } ^ { k } } \dot { L } ( \mathcal { M } _ { \theta } ( x _ { a d v } ^ { k } ) , y )$ at the $k$ -th step as $g ^ { k }$ , and generate another map $g _ { e n s } ^ { k }$ via Eq 4:
64
+
65
+ $$
66
+ \left\{ \begin{array} { l l } { g _ { 1 } ^ { k } = \frac { g ^ { k } } { \mathrm { s u m } ( \mathrm { a b s } ( g ^ { k } ) ) } } \\ { g _ { t } ^ { k } = \frac { 2 } { \pi } \cdot \arctan ( \frac { g ^ { k } } { \mathrm { m e a n } ( \mathrm { a b s } ( g ^ { k } ) ) } ) } \\ { g _ { s } ^ { k } = \mathrm { s i g n } ( g ^ { k } ) } \\ { g _ { e n s } ^ { k } = g _ { 1 } ^ { k } + \gamma _ { 1 } \cdot g _ { t } ^ { k } + \gamma _ { 2 } \cdot g _ { s } ^ { k } } \end{array} \right.
67
+ $$
68
+
69
+ ![](images/8428e7ac823ab1dc2d285fe8dfad7603251a7b1a1e7fee0e2a64addb41e7763c.jpg)
70
+ Figure 1: The framework of the proposed MTA when T = 1 and A(Mθ(x)) = x1adv. The clean image $x$ is first feed into the MSM $\mathcal { M } _ { \theta }$ and obtain the loss $L ( \mathcal { M } _ { \theta } ( x ) , y )$ . Next we back-propagate the loss and use Eq 4 to obtain the noise g0ens. Then, via $\operatorname { E q } 5$ , we obtain the adversarial example x1adv which will be feed into the source models $\mathcal { F } _ { 1 }$ $\mathbf { \Phi } _ { 1 } , \mathcal { F } _ { 2 } , \mathbf { \Phi } .$ .., and $\mathcal { F } _ { N }$ . Finally, by maximizing the source models’ loss, we can optimize the MSM to learn a particular weight so that the adversarial example $x _ { a d v } ^ { 1 }$ attacking it can fool source models.
71
+
72
+ Note that we set $\gamma _ { 1 } = \gamma _ { 2 } = 0 . 0 1$ as default
73
+
74
+ for all the experiments. Both $g _ { 1 } ^ { k }$ and $g _ { t } ^ { k }$ ensure the objective in $\operatorname { E q } 3$ be differentiable with respect to the MSM’s weight $\theta$ ; arctan $( \cdot )$ is a smooth approximation of sign and mean(abs(gk)) prevents arctan from falling into the saturation or linear region. The item $\gamma _ { 2 } \cdot g _ { s } ^ { k }$ provides the lower-bound for each pixel’s perturbation in $g _ { e n s } ^ { k }$ . The experiments in Section 4.3 will demonstrate the importances of $\mathbf { \bar { { g } } } _ { t } ^ { k }$ and $\overset { \cdot } { g } _ { s } ^ { k }$ for Customized PGD. With Eq 4, the Customized PGD conducts the following update to generate AE:
75
+
76
+ $$
77
+ x _ { a d v } ^ { k } = \mathrm { C l i p } ( x _ { a d v } ^ { k - 1 } + \frac { \epsilon _ { c } } { T } \cdot g _ { e n s } ^ { k - 1 } ) .
78
+ $$
79
+
80
+ Note that $\epsilon _ { c }$ differs from the perturbation $\epsilon$ in FGSM and PGD because $g _ { e n s } ^ { k - 1 }$ in our update is not a sign vector and its size will depend on the magnitude of the original gradient. Finally, we get $x _ { a d v } ^ { T }$ after $T$ iterations of $\operatorname { E q } 5$ .
81
+
82
+ Second, we feed $x _ { a d v } ^ { T }$ into $N$ source models and calculate the corresponding adversarial losses $L ( \mathcal { F } _ { i } ( x _ { a d v } ^ { T } ) , y )$ for all $i = 1 , \ldots , N$ . Larger losses of the $N$ source models indicate a higher advlikelihood that $x _ { a d v } ^ { T }$ fooling the MSM can transfer to other models.
83
+
84
+ Third, we optimize the MSM by maximizing the objective function defined in Eq 3. The update rule can be written as
85
+
86
+ $$
87
+ \begin{array} { r } { \boldsymbol { \theta } ^ { ' } = \boldsymbol { \theta } + \alpha \cdot \sum _ { i = 1 } ^ { N } \nabla _ { \boldsymbol { \theta } } L ( \mathcal { F } _ { i } ( x _ { a d v } ^ { T } ) , y ) , } \end{array}
88
+ $$
89
+
90
+ where xTadv can be written as a function of $\theta$ by unrolling the attack update rule $\mathrm { E q } 5 T$ times. We will show how to explicitly compute the gradient in Section 3.3. With this training procedure, the MSM is trained to learn a particular weight with which the white-box AEs fooling it can also fool other models. We summarize the training and testing of MTA in Algorithm 1 and Section A.1, respectively. Each capitalized notation represents a batch of the variable denoted with lower case. For example, $X$ denotes a batch of $x$ . Note that Customized PGD is just a continuous approximation of PGD used to train the MSM. In the inference phase, we use standard attacks such as PGD to craft AEs on the MSM.
91
+
92
+ # 3.3 GRADIENT CALCULATION
93
+
94
+ In the calculation we set both $N$ and $T$ in $\operatorname { E q } 6$ to 1, so the gradient in $\operatorname { E q } 6$ is $\nabla _ { \theta } L ( \mathcal { F } _ { 1 } ( x _ { a d v } ^ { 1 } ) , y )$ According to $\operatorname { E q } 5$ , we can replace $x _ { a d v } ^ { 1 }$ in Eq 6 with $\mathrm { C l i p } ( \bar { x } _ { a d v } ^ { 0 } + \epsilon _ { c } \cdot g _ { e n s } ^ { \bar { 0 } } )$ , where $x _ { a d v } ^ { 0 }$ equals to $x$ . For simplicity, we ignore the clip function in the analysis and simplify the derivation as $\nabla _ { \boldsymbol { \theta } } L ( \mathcal { F } _ { 1 } ( \boldsymbol { x } + \dot { \epsilon _ { c } } \cdot \boldsymbol { g } _ { e n s } ^ { 0 } ) , y )$ . By chain rule and since $x$ is independent to $\theta$ , we can further rewrite this
95
+
96
+ as
97
+
98
+ $$
99
+ \frac { \partial L ( \mathcal { F } _ { 1 } ( x + \epsilon _ { c } \cdot g _ { e n s } ^ { 0 } ) , y ) } { \partial g _ { e n s } ^ { 0 } } \cdot \frac { \partial g _ { e n s } ^ { 0 } } { \partial \theta } .
100
+ $$
101
+
102
+ By replacing $g _ { e n s } ^ { 0 }$ with $\mathrm { E q } 4$ , the second term of $\operatorname { E q } 7$ can be expanded as
103
+
104
+ $$
105
+ \nabla _ { \boldsymbol { \theta } } g _ { e n s } ^ { 0 } = \nabla _ { \boldsymbol { \theta } } g _ { 1 } ^ { 0 } + \gamma _ { 1 } \cdot \nabla _ { \boldsymbol { \theta } } g _ { t } ^ { 0 } + \gamma _ { 2 } \cdot \nabla _ { \boldsymbol { \theta } } g _ { s } ^ { 0 } .
106
+ $$
107
+
108
+ Note that $g _ { s } ^ { 0 }$ equals to $\mathrm { s i g n } ( g ^ { 0 } )$ and the sign function introduces discrete operation so that the gradient of $g _ { s } ^ { 0 }$ with respect to $\theta$ becomes 0 (unless $g ^ { 0 } = 0 \array$ ). Therefore, $\nabla _ { \theta } g _ { e n s } ^ { 0 }$ can be further written as
109
+
110
+ $$
111
+ \begin{array} { r l r } { { \nabla _ { \theta } g _ { e n s } ^ { 0 } = \nabla _ { \theta } g _ { 1 } ^ { 0 } + \gamma _ { 1 } \cdot \nabla _ { \theta } g _ { t } ^ { 0 } } } \\ & { } & { = \nabla _ { \theta } ( \frac { \nabla _ { x } L ( M _ { \theta } ( x ) , y ) } { \operatorname { s u m } ( \mathrm { a b s } ( \nabla _ { x } L ( M _ { \theta } ( x ) , Y ) ) ) } ) + \gamma _ { 1 } \cdot \nabla _ { \theta } ( \arctan ( \frac { \nabla _ { x } L ( M _ { \theta } ( x ) , y ) } { \operatorname { m e a n } ( \mathrm { a b s } ( \nabla _ { x } L ( M _ { \theta } ( x ) , y ) ) ) } ) ) . } \end{array}
112
+ $$
113
+
114
+ In this formulation, $\nabla _ { x } L ( \mathcal { M } _ { \theta } ( x ) , y )$ depends on $\theta$ and the second-order derivative of $\nabla _ { x } L ( \mathcal { M } _ { \theta } ( x ) , y )$ $w . r . t \theta$ can be obtained with lots of deep learning libraries (Abadi et al., 2016; Paszke et al., 2017). In summary, by integrating Eqs.6-9, the MSM can be optimized by an SGD-based optimizer.
115
+
116
+ # 4 EXPERIMENT
117
+
118
+ We conduct experiments to show that the proposed method, under the same set of source models, can generate stronger transferable AEs than existing transfer attack methods.
119
+
120
+ We first present our general experimental settings. 1) We conduct experiments on both Cifar10 (Krizhevsky et al., 2009) and ImageNet (Deng et al., 2009). 2) We compare the proposed MTA with seven state-of-the-art transferable adversarial attack methods, including MI (Dong et al., 2018), DI (Xie et al., 2019), TI (Dong et al., 2019), SGM (Wu et al., 2020a), SI-NI (Lin et al., 2020), AEG (Bose et al.,
121
+
122
+ # Algorithm 1 Training of Meta-Transfer Attack
123
+
124
+ input: $N$ source models $\mathcal { F } _ { 1 } , \ldots , \mathcal { F } _ { N }$ , Training set $\mathbb { D }$ , batch size $b$ , initialized MSM $\mathcal { M } _ { \theta }$ .
125
+ output: Optimized weight $\theta$ .
126
+ $\textbf { 1 : }$ while not done do
127
+ 2 : sample data $( X = [ x _ { 1 } , \dots , x _ { b } ] , Y = [ y _ { 1 } , \dots , y _ { b } ] ) \in \mathbb { D }$ 3 : X0adv = X
128
+ 4 : for $\mathrm { k }$ in [1, 2, ..., T]:
129
+ 5 : 0 $G ^ { k } = \mathsf { \bar { V } } _ { X _ { a d v } ^ { k - 1 } } L ( \mathcal { M } _ { \theta } ( X _ { a d v } ^ { k - 1 } ) , Y )$
130
+ 6 : advobtain Gkens v ia Eq 4
131
+ 7 : obtain $X _ { a d v } ^ { k ^ { - } }$ via Eq 5
132
+ $\mathbf { 8 : }$ end for
133
+ 9 : for each source model $\mathcal { F } _ { i } \in [ \mathcal { F } _ { 1 } , \mathcal { F } _ { 2 } , \ldots , \mathcal { F } _ { N } ]$ , do 10: evaluate XT on ${ \mathcal { F } } _ { i }$ and obtain $L ( \mathcal { F } _ { i } ( X _ { a d v } ^ { T } ) , Y )$ 11: end for
134
+ 12: $\theta = \theta + \alpha \cdot \nabla _ { \theta } \sum _ { i } ^ { N } L ( \mathcal { F } _ { i } ( X _ { a d v } ^ { T } ) , Y )$
135
+ 13: return θ
136
+
137
+ 2020), IR (Wang et al., 2021a), and FIA (Wang et al., 2021b). Note that since SGM is based on enlarging the gradient of skip connections, we only include this method on ImageNet experiments when the source models have sufficient skip connections. AEG is compared only on Cifar-10 because the official AEG is evaluated only on small scale datasets (Mnist and Cifar-10), and it is computational costly to train the perturbation generator on large-scale datasets. FIA is implemented only on ImageNet using the same intermediate feature layers introduces in (Wang et al., 2021b). 3) Since the number of attack iterations $T$ is different between training and testing, we denote it as $T _ { t }$ in training and $T _ { v }$ in testing respectively to avoid confusion. 4) When training the MSM, we use the Customized PGD with $\gamma _ { 1 } = \gamma _ { 2 } = 0 . 0 1$ to attack the MSM. When evaluating, we use PGD with ${ \mathit { T } } _ { v } { = } 1 0$ and $\epsilon { = } 1 5$ to attack the MSM. 5) When using the baseline methods to generate AEs on multiple source models, we follow Dong et al. (2018) to ensemble the logits of the source models before loss calculation. 6) We use source and target models to train and to evaluate the MSM, respectively. 7) For fair comparisons between MTA and baselines, we implement baselines with the number of iterations $T { = } 1 0$ and $\epsilon { = } 1 5$ , and other hyper-parameters are tuned for their best possible performances (implementations are detailed in Section A.8). 8) More experiments (e.g., targeted transfer attack, attacks with smaller $\epsilon$ , more comparisons between MTA and baselines) will be shown in Section A.3.
138
+
139
+ # 4.1 EXPERIMENTS ON CIFAR-10
140
+
141
+ # 4.1.1 EXPERIMENTAL CONFIGURATIONS
142
+
143
+ On Cifar-10, we use 8 source models including ResNet-10, -18, -34 (He et al., 2016), SeResNet-14, -26, -50 (Hu et al., 2018), MobileNet-V1 (Howard et al., 2017), and -V2 (Sandler et al., 2018) to train the MSM. To ensure mismatches between the source and target models and to avoid saturated transfer attack performances (i.e., attack success rates close to $100 \%$ ), we select the 8 target models including MobileNet-V3 (Howard et al., 2019), ShuffleNet-V1, -V2 (Zhang et al., 2018), SqueezeNetA, -B (Iandola et al., 2016), and adversarially trained ResNet-18, -34, and SeResNet-50. The network architectures of all 16 models are defined on public GitHub repositories1,2,3. We train all the source and target models and describe the training details of these models in Section A.2. The trained models and the code will be released to the community for reproducibility.
144
+
145
+ Table 1: Transfer attack success rates on eight target networks on Cifar-10. The MSM is trained with eight source models. From left to right, the eight target models are MobileNet-V3 (MN-V3), ShuffleNet-V1 (SN-V1), -V2 (SN-V2), SqueezeNet-A (SN-A), -B (SN-B), and adversarially trained ResNet-18 $( \mathrm { R e s - } 1 8 _ { a d v } )$ ), ResNet-34 $( \mathsf { R e s } - 3 4 _ { a d v } )$ , and SeResNet-50 $( \mathrm { S e R e s } – \mathsf { I } 0 _ { a d v } )$ .
146
+
147
+ <table><tr><td>Method</td><td>MN-V3</td><td>SN-V1</td><td>SN-V2</td><td>SN-A</td><td>SN-B</td><td>Res-18adu</td><td>Res-34adu</td><td>SE-50adu</td></tr><tr><td>PGD</td><td>51.8%</td><td>64.1%</td><td>49.4%</td><td>57.2%</td><td>56.3%</td><td>67.7%</td><td>63.9%</td><td>63.4%</td></tr><tr><td>DI</td><td>57.8%</td><td>72.5%</td><td>56.4%</td><td>65.7%</td><td>64.6%</td><td>80.7%</td><td>73.1%</td><td>71.0%</td></tr><tr><td>MI</td><td>70.2%</td><td>85.6%</td><td>72.6%</td><td>83.7%</td><td>83.0%</td><td>92.9%</td><td>90.9%</td><td>89.1%</td></tr><tr><td>A-PGD</td><td>74.1%</td><td>88.9%</td><td>75.8%</td><td>84.2%</td><td>83.6%</td><td>90.7%</td><td>89.3%</td><td>89.1%</td></tr><tr><td>TI</td><td>54.5%</td><td>59.9%</td><td>54.2%</td><td>71.8%</td><td>71.4%</td><td>57.6%</td><td>46.3%</td><td>46.6%</td></tr><tr><td>AEG</td><td>90.8%</td><td>92.5%</td><td>85.8%</td><td>91.3%</td><td>91.0%</td><td>96.1%</td><td>93.6%</td><td>93.1%</td></tr><tr><td>IR</td><td>59.3%</td><td>77.9%</td><td>62.5%</td><td>71.6%</td><td>69.1%</td><td>79.8%</td><td>73.7%</td><td>72.1%</td></tr><tr><td>MTA</td><td>91.8%</td><td>98.4%</td><td>90.9%</td><td>94.9%</td><td>93.8%</td><td>98.4%</td><td>96.5%</td><td>97.1%</td></tr><tr><td>MTAγ1=0</td><td>70.0%</td><td>80.9%</td><td>68.5%</td><td>58.5%</td><td>59.4%</td><td>67.7%</td><td>59.2%</td><td>68.9%</td></tr><tr><td>MTAγ2=0</td><td>90.0%</td><td>98.2%</td><td>90.5%</td><td>93.9%</td><td>93.1%</td><td>97.6%</td><td>96.0%</td><td>96.3%</td></tr><tr><td>MTAdense</td><td>86.9%</td><td>96.2%</td><td>87.1%</td><td>89.0%</td><td>87.6%</td><td>96.2%</td><td>91.3%</td><td>93.6%</td></tr></table>
148
+
149
+ ![](images/39ac7fe8f9e261e1db855162b6660542b13843cf18af6ccb682c26d2b0acda40.jpg)
150
+ Figure 2: (a) The structures of ResNet-13 and -19. ResNet-13 contains the top four blocks in the solid-line box and the classifier. ResNet-19 contains all the six blocks and the classifier. The parameter $M *$ of each block denotes the number of filters of its convolution layers. (b) The detailed structure of residual block. The orange cube is the convolution layer and the number on it denotes its number of filters. Pool in the sixth block is global-average pooling while all the other pool is max-pooling with both stride and kernel size of $2 \times 2$ . The convolution layer in the shortcut path uses $1 \times 1$ kernel size while all the other convolution layers use $3 \times 3$ .
151
+
152
+ Training the MSM. The default network architecture of the MSM is ResNet-13 shown in Figure 2, with $M 1$ , $M 2$ , $M 3$ , and $M 4$ set to 64, 128, 256, and 512, respectively. We use the 8 source models to train the MSM for 60 epochs with the number of attack steps $T _ { t }$ of 7. $\epsilon _ { c }$ of the Customized PGD is initialized to 1,600 and is exponentially decayed by $0 . 9 \times$ for every 4,000 iterations. The learning rate $\alpha$ and the batch size are set to 0.001 and 64, respectively.
153
+
154
+ Evaluating the MSM. On each target model, we only attack the correctly classified test images because attacking wrongly classified clean images is less meaningful.
155
+
156
+ # 4.1.2 EXPERIMENTAL RESULTS
157
+
158
+ Table 1 shows the experimental results. The recently proposed white-box attack method APGD (Croce & Hein, 2020b) is also treated as a compared method here. Apparently, MTA performs much better than all the previous methods with significantly increased transfer attack success rates. For example, compared with IR (Wang et al., 2021a), MTA improves the success rates by $5 4 . 8 \%$ , $2 6 . 3 \%$ , $4 5 . 4 \%$ , $3 2 . 5 \%$ , $3 5 . 7 \%$ , $2 3 . 3 \%$ , $3 0 . 9 \%$ , and $3 4 . 7 \%$ on the eight target models. The results of $\mathrm { M T A } _ { \gamma _ { 1 } = 0 }$ , $\mathrm { M T A } _ { \gamma _ { 2 } = 0 }$ , and $\mathbf { M T A } _ { d e n s e }$ will be discussed in ablation study (Section 4.3).
159
+
160
+ Table 2: Transfer attack results on seven black-box networks when using one source model.
161
+
162
+ <table><tr><td>Source</td><td>Method</td><td>Inc-V3</td><td>Inc-V4</td><td>IncRes-V2</td><td>Res-152</td><td>Inc-V3 ens3</td><td>Inc-V3 ens4</td><td>IncRes-V2 ens</td></tr><tr><td rowspan="8">Inc-V3</td><td>DI</td><td>/</td><td>35.2%</td><td>28.2%</td><td>22.3%</td><td>5.1%</td><td>4.3%</td><td>2.5%</td></tr><tr><td>MI</td><td>/</td><td>38.1%</td><td>35.8%</td><td>29.6%</td><td>9.1%</td><td>8.8%</td><td>4.5%</td></tr><tr><td>MI-DI</td><td>/</td><td>61.7%</td><td>57.3%</td><td>48.0%</td><td>13.6%</td><td>12.0%</td><td>6.5%</td></tr><tr><td>SI-NI</td><td>/</td><td>63.8%</td><td>62.0%</td><td>51.7%</td><td>25.5%</td><td>25.2%</td><td>12.4%</td></tr><tr><td>IR</td><td>/</td><td>33.6%</td><td>28.1%</td><td>15.9%</td><td>5.1%</td><td>5.5%</td><td>3.0%</td></tr><tr><td>FIA</td><td>/</td><td>69.0%</td><td>66.8%</td><td>52.5%</td><td>29.3%</td><td>27.7%</td><td>14.9%</td></tr><tr><td>MTA</td><td>99.9%</td><td>90.9%</td><td>87.3%</td><td>74.1%</td><td>67.7%</td><td>39.3%</td><td>26.1%</td></tr><tr><td>MTA-IR</td><td>/</td><td>95.5%</td><td>93.2%</td><td>85.0%</td><td>83.5%</td><td>56.9%</td><td>40.7%</td></tr><tr><td rowspan="7">Inc-V4</td><td>DI</td><td>44.9%</td><td>/</td><td>30.5%</td><td>26.7%</td><td>5.9%</td><td>5.5%</td><td>3.3%</td></tr><tr><td>MI</td><td>52.7%</td><td>/</td><td>41.8%</td><td>37.3%</td><td>12.4%</td><td>11.0%</td><td>5.8%</td></tr><tr><td>MI-DI</td><td>69.1%</td><td>/</td><td>58.7%</td><td>49.3%</td><td>16.6%</td><td>14.1%</td><td>8.2%</td></tr><tr><td>SI-NI</td><td>74.6%</td><td>/</td><td>67.3%</td><td>61.6%</td><td>39.2%</td><td>35.9%</td><td>22.0%</td></tr><tr><td>IR</td><td>46.5%</td><td>/</td><td>33.2%</td><td>18.9%</td><td>8.1%</td><td>8.8%</td><td>4.9%</td></tr><tr><td>FIA</td><td>63.6%</td><td>/</td><td>55.2%</td><td>45.9%</td><td>28.5%</td><td>26.1%</td><td>16.8%</td></tr><tr><td>MTA</td><td>87.3%</td><td>99.9%</td><td>84.7%</td><td>73.1%</td><td>61.7%</td><td>38.2%</td><td>29.0%</td></tr><tr><td rowspan="8">IncRes-V2</td><td>MTA-IR</td><td>93.3%</td><td>/</td><td>90.5%</td><td>82.0%</td><td>77.2%</td><td>57.7%</td><td>44.9%</td></tr><tr><td>DI</td><td>46.9%</td><td>42.0%</td><td>/</td><td>29.5%</td><td>8.6%</td><td>6.5%</td><td>5.5%</td></tr><tr><td>MI</td><td>53.2%</td><td>45.2%</td><td>/</td><td>38.8%</td><td>16.2%</td><td>13.3%</td><td>9.7%</td></tr><tr><td>MI-DI</td><td>64.7%</td><td>61.7%</td><td>/</td><td>50.6%</td><td>23.7%</td><td>18.6%</td><td>13.6%</td></tr><tr><td>SI-NI</td><td>78.2%</td><td>70.7%</td><td>/</td><td>63.8%</td><td>45.2%</td><td>38.8%</td><td>32.9%</td></tr><tr><td>IR</td><td>49.7%</td><td>44.9%</td><td>/</td><td>25.2%</td><td>13.6%</td><td>11.2%</td><td>10.9%</td></tr><tr><td>FIA</td><td>63.2%</td><td>57.8%</td><td>/</td><td>51.3%</td><td>35.1%</td><td>30.3%</td><td>25.0%</td></tr><tr><td>MTA</td><td>44.7%</td><td>41.7%</td><td>98.0%</td><td>57.9%</td><td>23.5%</td><td>19.4%</td><td>17.5%</td></tr><tr><td></td><td>MTAInc</td><td>64.3%</td><td>51.7%</td><td>/</td><td>76.0%</td><td>46.2%</td><td>39.3%</td><td>27.5%</td></tr><tr><td rowspan="11">Res-152</td><td>MTA-IRInc</td><td>66.2%</td><td>52.3%</td><td>/</td><td>78.3%</td><td>49.0%</td><td>42.2%</td><td>31.7%</td></tr><tr><td>DI</td><td>51.8%</td><td>48.1%</td><td>40.6%</td><td>/</td><td>9.7%</td><td>8.3%</td><td>6.2%</td></tr><tr><td>MI</td><td>50.2%</td><td>44.9%</td><td>39.4%</td><td>/</td><td>13.9%</td><td>12.0%</td><td>7.8%</td></tr><tr><td>MI-DI</td><td>76.2%</td><td>73.3%</td><td>69.5%</td><td>/</td><td>24.6%</td><td>21.1%</td><td>12.7%</td></tr><tr><td>SI-NI</td><td>59.6%</td><td>50.1%</td><td>51.3%</td><td>/</td><td>37.9%</td><td>34.0%</td><td>20.7%</td></tr><tr><td>IR</td><td>42.3%</td><td>33.8%</td><td>34.1%</td><td>/</td><td>22.0%</td><td>20.6%</td><td>16.2%</td></tr><tr><td>FIA</td><td>73.8%</td><td>67.2%</td><td>67.9%</td><td>/</td><td>48.0%</td><td>43.7%</td><td>30.4%</td></tr><tr><td>MTA</td><td>70.7%</td><td>77.5%</td><td>62.8%</td><td>99.1%</td><td>53.0%</td><td>59.2%</td><td>56.3%</td></tr><tr><td>MTA-IR</td><td>72.8%</td><td>78.0%</td><td>64.3%</td><td>/</td><td>54.9%</td><td>63.0%</td><td>59.3%</td></tr><tr><td>SGM=16</td><td>57.2%</td><td>48.6%</td><td>45.4%</td><td>/</td><td>31.6%</td><td>27.8%</td><td>20.0%</td></tr><tr><td>IR=16</td><td>53.6%</td><td>50.6%</td><td>46.0%</td><td>/</td><td>/</td><td>/</td><td>/</td></tr><tr><td></td><td>MTAe=16</td><td>76.0%</td><td>80.5%</td><td>67.6%</td><td>/</td><td>60.5%</td><td>68.4%</td><td>62.6%</td></tr></table>
163
+
164
+ # 4.2 EXPERIMENTS ON IMAGENET
165
+
166
+ # 4.2.1 EXPERIMENTAL CONFIGURATIONS
167
+
168
+ We directly use the public trained ImageNet models4,5,6 including ResNet-50, -101, -152 (He et al., 2016), DenseNet-121, -161 (Huang et al., 2017), Inception-V3 (Szegedy et al., 2016), -V4 (Szegedy et al., 2017), Inception-ResNet-V2, Inception- $\mathrm { V } 3 _ { e n s 3 }$ , Inception- $. \mathrm { V } 3 _ { e n s 4 }$ , and Inception-ResNet$\mathrm { V } 2 _ { e n s }$ . The former eight models are normally trained models while the latter three are secure models trained by ensemble adversarial training (Tramer et al., 2017). We shorten these models as Res-50,\` Res-101, Res-152, DN-121, DN-161, Inc-V3, Inc-V4, IncRes-V2, Inc- $\mathrm { V } 3 _ { e n s 3 }$ , Inc- $\mathbf { V } 3 _ { e n s 4 }$ , and IncRes- $. \mathrm { V } 3 _ { e n s }$ .
169
+
170
+ Training the MSM. The default network architecture of the MSM is ResNet-19 shown in Figure 2, with $M 1$ , $M 2$ , $M 3$ , and $M 4$ set to 32, 80, 200, and 500, respectively. We follow previous works (Dong et al., 2018; Wu et al., 2020a) to evaluate the transferability of AEs in two settings: using a single source model and using multiple source models. We set the input resolution of the MSM to $2 2 4 \times 2 2 4$ . Note that, when the resolution of the source model differs from that of the MSM, we resize the AE $x _ { a d v } ^ { T }$ to the resolution of the source model before feeding it into the source model. More details about training the MSM will be shown in Section A.4.
171
+
172
+ Evaluating the MSM. Following the official testing data settings in the papers of DI (Xie et al., 2019) and SGM (Wu et al., 2020a), we also randomly choose 5,000 validation images from ImageNet that are correctly classified by all models for evaluation. Note that, when the resolutions of the MSM and the target model are different, we resize the AE $x _ { a d v } ^ { T }$ to the resolution of the target model. For instance, when attacking Inc-V3 whose resolution is $2 9 9 \times 2 9 9$ , we first resize $x _ { a d v } ^ { T }$ from $2 2 4 \times 2 2 4$ to $2 9 9 \times 2 9 9$ and then use the resized $x _ { a d v } ^ { T }$ to attack Inc-V3.
173
+
174
+ Table 3: Transfer attack results on seven black-box models when using multiple source models.
175
+
176
+ <table><tr><td>Source</td><td>Method</td><td>Inc-V3</td><td>Inc-V4</td><td>IncRes-V2</td><td>Res-101</td><td>Inc-V3ens3</td><td>Inc-V3ens4</td><td>IncRes-V2ens</td></tr><tr><td rowspan="6">Res-50 + Res-152 + DN-161</td><td>DI MI</td><td>86.9% 82.0%</td><td>84.3%</td><td>81.8%</td><td>96.7%</td><td>59.7%</td><td>55.1%</td><td>41.9%</td></tr><tr><td></td><td></td><td>76.1%</td><td>76.0%</td><td>98.0%</td><td>63.6%</td><td>60.3%</td><td>49.6%</td></tr><tr><td>TI-DI</td><td>60.6%</td><td>59.2%</td><td>50.2%</td><td>86.8%</td><td>54.9%</td><td>56.2%</td><td>46.9%</td></tr><tr><td>SGM</td><td>81.8%</td><td>74.7%</td><td>73.9%</td><td>98.7%</td><td>54.9%</td><td>50.1%</td><td>38.7%</td></tr><tr><td>SGM-DI</td><td>86.2%</td><td>83.9%</td><td>81.6%</td><td>98.3%</td><td>69.8%</td><td>64.9%</td><td>54.4%</td></tr><tr><td>SGM-MI</td><td>86.5%</td><td>84.3%</td><td>82.7%</td><td>98.2%</td><td>71.1%</td><td>67.4%</td><td>60.8%</td></tr><tr><td>IR</td><td>75.2%</td><td>70.3%</td><td>67.9%</td><td>90.6%</td><td>51.7%</td><td>49.1%</td><td>37.5%</td></tr><tr><td>MTA</td><td>90.4%</td><td>94.3%</td><td>87.6%</td><td>97.5%</td><td>75.5%</td><td>79.7%</td><td>79.0%</td></tr><tr><td>MTA-IR</td><td>93.1%</td><td>95.8%</td><td>90.5%</td><td>98.3%</td><td>83.6%</td><td>87.2%</td><td>85.0%</td></tr><tr><td>DI</td><td>84.1%</td><td>82.3%</td><td>79.4%</td><td>93.9%</td><td>56.3%</td><td>50.1%</td><td>35.2%</td></tr><tr><td rowspan="8">Res-50 + Inc-V1 + DN-121</td><td>MI</td><td>79.9%</td><td>73.6%</td><td>72.3%</td><td>93.7%</td><td>59.3%</td><td>56.0%</td><td>42.7%</td></tr><tr><td>TI-DI</td><td>61.9%</td><td>58.5%</td><td>49.0%</td><td>79.7%</td><td>53.1%</td><td>54.1%</td><td>41.9%</td></tr><tr><td>SGM</td><td>62.7%</td><td>53.5%</td><td>50.9%</td><td>89.1%</td><td>33.8%</td><td>30.4%</td><td>19.3%</td></tr><tr><td>SGM-DI</td><td>87.2%</td><td>83.6%</td><td>79.5%</td><td>95.1%</td><td>59.6%</td><td>54.9%</td><td>37.9%</td></tr><tr><td>SGM-MI</td><td>82.8%</td><td>76.0%</td><td>74.3%</td><td>95.9%</td><td>62.2%</td><td>59.7%</td><td>45.3%</td></tr><tr><td>IR</td><td>76.5%</td><td>70.9%</td><td>64.0%</td><td>92.1%</td><td>51.3%</td><td>44.9%</td><td>31.5%</td></tr><tr><td>MTA</td><td>91.7%</td><td>86.4%</td><td>76.0%</td><td>93.6%</td><td>81.7%</td><td>79.6%</td><td>61.6%</td></tr><tr><td>MTA-IR</td><td>92.8%</td><td>87.9%</td><td>77.2%</td><td>93.8%</td><td>82.6%</td><td>79.3%</td><td>61.5%</td></tr><tr><td rowspan="8">Res-50 + Inc-V1</td><td>DI</td><td>76.1%</td><td>69.3%</td><td>66.3%</td><td>90.0%</td><td>43.5%</td><td>39.2%</td><td>25.5%</td></tr><tr><td>MI</td><td>69.5%</td><td>60.1%</td><td>59.5%</td><td>91.5%</td><td>47.1%</td><td>44.7%</td><td>32.5%</td></tr><tr><td>TI-DI</td><td>51.6%</td><td>46.9%</td><td>38.4%</td><td>73.4%</td><td>43.4%</td><td>44.2%</td><td>32.8%</td></tr><tr><td>SGM</td><td>46.1%</td><td>35.6%</td><td>33.3%</td><td>82.0%</td><td>22.1%</td><td>19.5%</td><td>12.3%</td></tr><tr><td>SGM-DI</td><td>79.2%</td><td>70.6%</td><td>68.7%</td><td>91.9%</td><td>47.9%</td><td>42.0%</td><td>28.1%</td></tr><tr><td>SGM-MI</td><td>71.9%</td><td>62.0%</td><td>61.3%</td><td>94.3%</td><td>49.6%</td><td>47.2%</td><td>33.8%</td></tr><tr><td>IR</td><td>60.2%</td><td>49.0%</td><td>46.2%</td><td>93.0%</td><td>36.5%</td><td>30.6%</td><td>21.0%</td></tr><tr><td>MTA</td><td>84.1%</td><td>88.8%</td><td>78.4%</td><td>93.9%</td><td>60.6%</td><td>61.1%</td><td>55.1%</td></tr><tr><td>MTA-IR</td><td>87.6%</td><td>91.8%</td><td>83.9%</td><td>95.2%</td><td></td><td>71.5%</td><td>72.6%</td><td>63.7%</td></tr></table>
177
+
178
+ # 4.2.2 USING ONE SOURCE MODEL
179
+
180
+ Table 2 reports the experimental results of using one source model. Note that, in this work, we only focus on the transfer attack testing scene and neglect the white-box attack testing scene. So we left the results of the testing scenes where the target model is the source model itself to $/$ . MI-DI is a combination of MI and DI. IR is our re-implementation with $\epsilon { = } 1 5$ and the implementation details will be shown in Section A.8. Obviously, MTA outperforms the baselines on almost all testing scenes with great margins, especially when attacking adversarially trained models. For example, compared with FIA, MTA improves the transfer attack success rates by about $3 1 . 7 \%$ , $3 0 . 7 \%$ , $4 1 . 1 \%$ , $1 3 1 . 1 \%$ , $4 1 . 9 \%$ , and $7 5 . 2 \%$ when using the Inc-V3 source model and attacking the target models (Inc-V4, IncRes-152, Res-152, Inc- $. \mathrm { V } 3 _ { e n s 3 }$ , Inc- $. \mathrm { V } 3 _ { e n s 4 }$ , IncRes- $. \mathrm { V } 2 _ { e n s }$ ). MTA-IR combines MTA with IR. Instead of attacking the MSM using PGD, MTA-IR generates AEs by attacking the MSM using IR. Compared with MTA, MTA-IR improves the attack success rates by about $5 . 1 \%$ , $6 . 8 \%$ , $1 4 . 7 \%$ , $2 3 . 3 \%$ , $4 4 . 8 \%$ , and $5 5 . 9 \%$ when using the Inc-V3 source model and attacking the target models, indicating that existing transferable attack methods can further improve MTA.
181
+
182
+ Recall that SGM only works for source models with lots of skip connections (e.g., ResNet). And the original paper sets $\epsilon$ to 16, which differs from most of the other methods. The official IR also sets $\epsilon$ to 16. Therefore, we copy their results with $\epsilon = 1 6$ from their official paper to Table 2 and denote them as $\mathbf { S G M } _ { \epsilon = 1 6 } ^ { * }$ and $\mathrm { I R } _ { \epsilon = 1 6 } ^ { \ast }$ , respectively. To compare MTA with them, we further set $\epsilon$ to 16 for MTA and denote the new result as $\mathbf { M T A } _ { \epsilon = 1 6 }$ . The comparisons show that $\mathbf { M T A } _ { \epsilon = 1 6 }$ outperforms $\mathbf { S G M } _ { \epsilon = 1 6 } ^ { * }$ and $\mathrm { I R } _ { \epsilon = 1 6 } ^ { \ast }$ significantly.
183
+
184
+ When using IncRes-V2 source model, MTA sometimes performs slightly worse than MI-DI, possibly because the MSM with ResNet-19 backbone is not suitable to be trained to attack IncRes-V2. We then replace the backbone from ResNet-19 with another simplified Inception network (the architecture will be shown in Section A.6) and retrain the MSM. The newly trained MSM is denoted as $\mathbf { M T A } _ { I n c }$ Compared with ResNet-19, the simplified Inception backbone is more similar to IncRes-V2 so that $\mathbf { M T A } _ { I n c }$ turns to be easier to generate adversarial attacks to fool IncRes-V2 than MTA, leading to easier convergence of $\mathbf { M T A } _ { I n c }$ . The experimental results show that $\mathbf { M T A } _ { I n c }$ outperforms not only MTA but also the compared methods in most testing scenes, indicating 1) the advantage of the proposed MTA framework and 2) MTA can be further improved by using more suitable backbones.
185
+
186
+ # 4.2.3 USING MULTIPLE SOURCE MODELS
187
+
188
+ The experimental results of using multiple source models are reported in Table 3. We use three source model groups $( \mathrm { R e s } { - } 5 0 { + } \mathrm { R e s } { - } 1 5 2 { + } \mathrm { D N } 1 6 1$ , Res-50+Inc-V1+DN-121, Res-50+Inc-V1) to train the MSM, respectively, and use seven target models (Inc-V3, Inc-V4, InvRes-V2, Res-101, Inc- $\mathrm { V } 3 _ { e n s 3 }$
189
+
190
+ Inc- $\mathbf { V } 3 _ { e n s 4 }$ , IncRes- $\mathrm { V } 2 _ { e n s }$ ) to evaluate the transferability of the attacks to the MSM. SGM-X is the combination of SGM and X $\mathrm { X = D I }$ or MI). TI-DI is the combination of TI and DI, which is also known as TI-DIM (Dong et al., 2019). The results show that MTA outperforms the baselines in almost all testing scenes, especially when attacking defensive models. For instance, compared with SGM-DI, MTA improves the transfer attack success rates by $6 . 2 \%$ , $2 5 . 8 \%$ , $1 4 . 1 \%$ , $2 . 2 \%$ , $2 6 . 5 \%$ , $4 5 . 5 \%$ , and $9 6 . 1 \%$ on the seven target models when using Res-50 and Inc-V1 source models. Besides, MTA-IR outperforms MTA.
191
+
192
+ # 4.3 ABLATION STUDY
193
+
194
+ Network structure The comparison between MTA and $\mathbf { M T A } _ { I n c }$ shown in Table 2 has validated the effect of backbone on the MSM. Here we conduct another experiment on Cifar-10 to further verify the effect of backbone by replacing the backbone from ResNet-13 to DenseNet-22BC (the structure of DenseNet-22BC will be shown in Section A.6). We denote the MSM using DenseNet-22BC backbone as $\mathbf { M T A } _ { d e n s e }$ and report its experimental results in Table 1. The comparisons among MTA, $\mathbf { M T A } _ { d e n s e }$ , and the other compared methods indicate that 1) the backbone affects the performance of MTA; 2) MTA outperforms the compared methods with various backbones. This also inspires us to design more suitable backbones to improve MTA as future work.
195
+
196
+ Number of attack iterations We perform several experiments on Cifar-10 to validate how the number of attack iterations $T _ { t }$ affects the performance. $T _ { t }$ is set to 7 by default on Cifar-10. Here we set $T _ { t }$ to 1, 3, 5, 9, and 11 and keep all the other settings be consistent with the default settings. Figure 3 shows the corresponding performances of MTA. It is observed that when $T _ { t } < 7$ , the performances of MTA will be improved with the increase of $T _ { t }$ while when $T _ { t } > 7$ , the performance tends to drop. We think this is due to the difficulty of unrolling too many attack steps when training the MSM. We also verify how $T _ { v }$ affects the performance by changing $T _ { v }$ . $T _ { v }$ is default set to 10 in all our experiments. Figure 3 shows the experimental results using different numbers of $T _ { v }$ . When $T _ { v } = 1$ , the performances can be denoted as MTA-FGSM (one-step PGD). With the increase of $T _ { v }$ , the transfer attack success rates are clearly increased.
197
+
198
+ The effects of $\gamma _ { 1 }$ and $\gamma _ { 2 }$ We perform two experiments on Cifar-10 to verify how the parameters $\gamma _ { 1 }$ and $\gamma _ { 2 }$ in Eq 5 affect the transfer attack performance. In the two experiments, we set $\gamma _ { 1 }$ and $\gamma _ { 2 }$ to zero respectively, and amplify $\epsilon _ { c }$ appropriately to offset the decrease of the training perturbation size caused by zeroing $\gamma _ { 1 }$ or $\gamma _ { 2 }$ . We denote the two newly performed MTA as $\mathrm { M T A } _ { \gamma _ { 1 } = 0 }$ and $\mathrm { M T A } _ { \gamma _ { 2 } = 0 }$ . Table 1 shows the experimental results. The results show that by setting $\gamma _ { 1 }$
199
+
200
+ ![](images/d60090523363ad6df108d4eb9dbc616aae91d5e96f96a4f57e2382d28e5731e5.jpg)
201
+ Figure 3: Transfer attack performances of MTA on the eight target models of Cifar-10. Left: Attack success rates with different $T _ { t }$ . Right: Attack success rates with different $T _ { v }$ . yaxis denotes the attack success rate.
202
+
203
+ to zero, the performances of MTA are greatly damaged on all target models, indicating the indispensability of the arctan component in the Customized PGD. Setting $\gamma _ { 2 }$ to zero also decreases MTA’s performances, but the effect is much smaller than that of $\gamma _ { 1 }$ . Overall, the two experiments demonstrate the indispensability of Customized PGD for the proposed MTA framework. Further, both the arctan and sign components in Customized PGD are important to train the MSM, especially arctan.
204
+
205
+ # 5 CONCLUSION
206
+
207
+ Existing query free black-box adversarial attack methods directly use image classification models as surrogate models to generate transferable adversarial attacks to attack black-box models neglecting the study of surrogate models. In this paper, we propose a novel framework called meta-transfer attack (MTA) to improve the transferability of adversarial attacks via training an MSM using these surrogate models. The MSM is a particular model trained to learn how to make the adversarial attacks to it can fool the surrogate models. To enable and improve the training of the MSM, a novel Customized PGD is also developed. Through extensive experiments, we validate that by attacking the trained MSM, we can get transferable adversarial attacks that are generalizable to attack black-box target models with much higher success rates than existing methods, demonstrating the effectiveness of the proposed MTA framework.
208
+
209
+ # 6 ETHICS STATEMENT
210
+
211
+ Our work is promising to evaluate and improve the security of deep models, and has no potential negative societal impacts.
212
+
213
+ # 7 REPRODUCIBILITY STATEMENT
214
+
215
+ We provide our code in supplemental material and describe all the experimental settings in Sections 4.1.1, 4.2.1, and Appendix. The hyperparameter settings and the network structure are clear. The training details of source and target models used on Cifar-10 are described in Section A.2, and the network architecture descriptions of these models can be found in Section 4.1.1 and our code. The source and target models used on ImageNet can be found in the repositories described in Section 4.2.1. We include a very simple code example of our method at the end of Appendix, which also helps readers to understand and to reproduce our results. Overall, our work is easy to reproduce and follow.
216
+
217
+ # REFERENCES
218
+
219
+ Mart´ın Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, et al. Tensorflow: A system for large-scale machine learning. In 12th {USENIX} symposium on operating systems design and implementation ({OSDI} 16), pp. 265–283, 2016.
220
+
221
+ Avishek Joey Bose, Gauthier Gidel, Hugo Berrard, Andre Cianflone, Pascal Vincent, Simon LacosteJulien, and William L Hamilton. Adversarial example games. Advances in neural information processing systems, 2020.
222
+
223
+ Wieland Brendel, Jonas Rauber, and Matthias Bethge. Decision-based adversarial attacks: Reliable attacks against black-box machine learning models. arXiv preprint arXiv:1712.04248, 2017.
224
+
225
+ Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. In 2017 ieee symposium on security and privacy (sp), pp. 39–57. IEEE, 2017.
226
+
227
+ Jianbo Chen, Michael I Jordan, and Martin J Wainwright. HopSkipJumpAttack: a query-efficient decision-based adversarial attack. In 2020 IEEE Symposium on Security and Privacy (SP). IEEE, 2020.
228
+
229
+ Pin-Yu Chen, Huan Zhang, Yash Sharma, Jinfeng Yi, and Cho-Jui Hsieh. Zoo: Zeroth order optimization based black-box attacks to deep neural networks without training substitute models. In Proceedings of the 10th ACM workshop on artificial intelligence and security, pp. 15–26, 2017.
230
+
231
+ Minhao Cheng, Thong Le, Pin-Yu Chen, Jinfeng Yi, Huan Zhang, and Cho-Jui Hsieh. Query-efficient hard-label black-box attack: An optimization-based approach. arXiv preprint arXiv:1807.04457, 2018.
232
+
233
+ Minhao Cheng, Simranjit Singh, Patrick H. Chen, Pin-Yu Chen, Sijia Liu, and Cho-Jui Hsieh. Sign-opt: A query-efficient hard-label adversarial attack. In international conference on learning representations, 2020.
234
+
235
+ Shuyu Cheng, Yinpeng Dong, Tianyu Pang, Hang Su, and Jun Zhu. Improving black-box adversarial attacks with a transfer-based prior. pp. 10932–10942, 2019.
236
+
237
+ Francesco Croce and Matthias Hein. Minimally distorted adversarial examples with a fast adaptive boundary attack. In International Conference on Machine Learning, pp. 2196–2205. PMLR, 2020a.
238
+
239
+ Francesco Croce and Matthias Hein. Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks. In International Conference on Machine Learning, pp. 2206–2216. PMLR, 2020b.
240
+
241
+ Ambra Demontis, Marco Melis, Maura Pintor, Matthew Jagielski, Battista Biggio, Alina Oprea, Cristina Nita-Rotaru, and Fabio Roli. Why do adversarial attacks transfer? explaining transferability of evasion and poisoning attacks. USENIX Security Symposium, pp. 321–338, 2019.
242
+
243
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
244
+
245
+ Yinpeng Dong, Fangzhou Liao, Tianyu Pang, Hang Su, Jun Zhu, Xiaolin Hu, and Jianguo Li. Boosting adversarial attacks with momentum. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 9185–9193, 2018.
246
+
247
+ Yinpeng Dong, Tianyu Pang, Hang Su, and Jun Zhu. Evading defenses to transferable adversarial examples by translation-invariant attacks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4312–4321, 2019.
248
+
249
+ Jiawei Du, Hu Zhang, Tianyi Joey Zhou, Yi Yang, and Jiashi Feng. Query-efficient meta attack to deep neural networks. International Conference on Learning Representations, 2020.
250
+
251
+ Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In International Conference on Machine Learning, pp. 1126–1135. PMLR, 2017.
252
+
253
+ Aditya Ganeshan, Vivek BS, and R Venkatesh Babu. Fda: Feature disruptive attack. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 8069–8079, 2019.
254
+
255
+ Lianli Gao, Qilong Zhang, Jingkuan Song, Xianglong Liu, and Heng Tao Shen. Patch-wise attack for fooling deep neural network. In European Conference on Computer Vision, pp. 307–322. Springer, 2020.
256
+
257
+ Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. international conference on learning representations, 2014.
258
+
259
+ Yiwen Guo, Qizhang Li, and Hao Chen. Backpropagating linearly improves transferability of adversarial examples. In Advances in neural information processing systems 33 (NIPS 2020), 2020.
260
+
261
+ 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.
262
+
263
+ Andrew Howard, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang, Yukun Zhu, Ruoming Pang, Vijay Vasudevan, et al. Searching for mobilenetv3. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 1314–1324, 2019.
264
+
265
+ Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017.
266
+
267
+ Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7132–7141, 2018.
268
+
269
+ 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.
270
+
271
+ Qian Huang, Isay Katsman, Horace He, Zeqi Gu, Serge Belongie, and Ser-Nam Lim. Enhancing adversarial example transferability with an intermediate level attack. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 4733–4742, 2019.
272
+
273
+ Zhichao Huang and Tong Zhang. Black-box adversarial attack with transferable model-based embedding. International Conference on Learning Representations, 2020.
274
+
275
+ Forrest N Iandola, Song Han, Matthew W Moskewicz, Khalid Ashraf, William J Dally, and Kurt Keutzer. Squeezenet: Alexnet-level accuracy with 50x fewer parameters and¡ $0 . 5 \mathrm { m b }$ model size. arXiv preprint arXiv:1602.07360, 2016.
276
+
277
+ Andrew Ilyas, Logan Engstrom, Anish Athalye, and Jessy Lin. Black-box adversarial attacks with limited queries and information. In International Conference on Machine Learning, pp. 2137–2146. PMLR, 2018.
278
+
279
+ Andrew Ilyas, Shibani Santurkar, Dimitris Tsipras, Logan Engstrom, Brandon Tran, and Aleksander Madry. Adversarial examples are not bugs, they are features. arXiv preprint arXiv:1905.02175, 2019.
280
+
281
+ Xu Kaidi, Liu Sijia, Zhao Pu, Chen Pin-Yu, Zhang Huan, Fan Quanfu, Erdogmus Deniz, Wang Yanzhi, and Lin Xue. Structured adversarial attack: Towards general implementation and better interpretability. International Conference on Learning Representations, 2019.
282
+
283
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
284
+
285
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems, 25:1097–1105, 2012.
286
+
287
+ Alexey Kurakin, Ian Goodfellow, Samy Bengio, et al. Adversarial examples in the physical world, 2016.
288
+
289
+ Yann LeCun, Yoshua Bengio, et al. Convolutional networks for images, speech, and time series. The handbook of brain theory and neural networks, 3361(10):1995, 1995.
290
+
291
+ Huichen Li, Xiaojun Xu, Xiaolu Zhang, Shuang Yang, and Bo Li. Qeba: Query-efficient boundarybased blackbox attack. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1221–1230, 2020a.
292
+
293
+ Qizhang Li, Yiwen Guo, and Hao Chen. Practical no-box adversarial attacks against dnns. Advances In Neural Information Processing Systems 2020, 2020b.
294
+
295
+ Yingwei Li, Song Bai, Yuyin Zhou, Cihang Xie, Zhishuai Zhang, and Alan Yuille. Learning transferable adversarial examples via ghost networks. AAAI, pp. 11458–11465, 2020c.
296
+
297
+ Jiadong Lin, Chuanbiao Song, Kun He, Liwei Wang, and John E Hopcroft. Nesterov accelerated gradient and scale invariance for adversarial attacks. International Conference on Learning Representations, 2020.
298
+
299
+ Yanpei Liu, Xinyun Chen, Chang Liu, and Dawn Song. Delving into transferable adversarial examples and black-box attacks. international conference on learning representations, 2017.
300
+
301
+ Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. international conference on learning representations, 2018.
302
+
303
+ Andriushchenko Maksym, Croce Francesco, Flammarion Nicolas, and Hein Matthias. Square attack: a query-efficient black-box adversarial attack via random search. european conference on computer vision, pp. 484–501, 2020.
304
+
305
+ Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard. Deepfool: a simple and accurate method to fool deep neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2574–2582, 2016.
306
+
307
+ Muhammad Muzammal Naseer, Salman H Khan, Muhammad Haris Khan, Fahad Shahbaz Khan, and Fatih Porikli. Cross-domain transferability of adversarial perturbations. Advances in Neural Information Processing Systems, 32:12905–12915, 2019.
308
+
309
+ Nicolas Papernot, Patrick McDaniel, and Ian Goodfellow. Transferability in machine learning: from phenomena to black-box attacks using adversarial samples. arXiv preprint arXiv:1605.07277, 2016.
310
+
311
+ Nicolas Papernot, Patrick McDaniel, Ian Goodfellow, Somesh Jha, Z Berkay Celik, and Ananthram Swami. Practical black-box attacks against machine learning. In Proceedings of the 2017 ACM on Asia conference on computer and communications security, pp. 506–519, 2017.
312
+
313
+ Adam Paszke, Sam Gross, Soumith Chintala, Gregory Chanan, Edward Yang, Zachary DeVito, Zeming Lin, Alban Desmaison, Luca Antiga, and Adam Lerer. Automatic differentiation in pytorch. 2017.
314
+
315
+ Yunxiao Qin, Weiguo Zhang, Zezheng Wang, Chenxu Zhao, and Jingping Shi. Layer-wise adaptive updating for few-shot image classification. IEEE Signal Processing Letters, 27:2044–2048, 2020.
316
+
317
+ Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: towards real-time object detection with region proposal networks. IEEE transactions on pattern analysis and machine intelligence, 39(6):1137–1149, 2016.
318
+
319
+ Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4510–4520, 2018.
320
+
321
+ Gaurang Sriramanan, Sravanti Addepalli, Arya Baburaj, and Venkatesh R. Babu. Guided adversarial attack for evaluating and enhancing adversarial defenses. Advances In Neural Information Processing Systems, 2020.
322
+
323
+ Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, J. Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. international conference on learning representations, 2014.
324
+
325
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818–2826, 2016.
326
+
327
+ Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, and Alexander Alemi. Inception-v4, inceptionresnet and the impact of residual connections on learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 31, 2017.
328
+
329
+ Florian Tramer, Alexey Kurakin, Nicolas Papernot, Ian Goodfellow, Dan Boneh, and Patrick Mc- \` Daniel. Ensemble adversarial training: Attacks and defenses. arXiv preprint arXiv:1705.07204, 2017.
330
+
331
+ Lu Wang, Huan Zhang, Jinfeng Yi, Cho-Jui Hsieh, and Yuan Jiang. Spanning attack: reinforce black-box attacks with unlabeled data. Machine Learning, 109(12):2349–2368, 2020.
332
+
333
+ Xiaosen Wang and Kun He. Enhancing the transferability of adversarial attacks through variance tuning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1924–1933, 2021.
334
+
335
+ Xin Wang, Jie Ren, Shuyun Lin, Xiangming Zhu, Yisen Wang, and Quanshi Zhang. A unified approach to interpreting and boosting adversarial transferability. International Conference on Learning Representations, 2021a.
336
+
337
+ Zhibo Wang, Hengchang Guo, Zhifei Zhang, Wenxin Liu, Zhan Qin, and Kui Ren. Feature importanceaware transferable adversarial attacks. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2021b.
338
+
339
+ Dongxian Wu, Yisen Wang, Shu-Tao Xia, James Bailey, and Xingjun Ma. Skip connections matter: On the transferability of adversarial examples generated with resnets. international conference on learning representations, 2020a.
340
+
341
+ Kaiwen Wu, Allen Wang, and Yaoliang Yu. Stronger and faster wasserstein adversarial attacks. International Conference on Machine Learning, pp. 10377–10387, 2020b.
342
+
343
+ Lei Wu, Zhanxing Zhu, Cheng Tai, et al. Understanding and enhancing the transferability of adversarial examples. arXiv preprint arXiv:1802.09707, 2018.
344
+
345
+ Weibin Wu, Yuxin Su, Xixian Chen, Shenglin Zhao, Irwin King, R. Michael Lyu, and Yu-Wing Tai. Boosting the transferability of adversarial samples via attention. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1158–1167, 2020c.
346
+
347
+ Cihang Xie, Zhishuai Zhang, Yuyin Zhou, Song Bai, Jianyu Wang, Zhou Ren, and Alan L Yuille. Improving transferability of adversarial examples with input diversity. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2730–2739, 2019.
348
+
349
+ Zheng Yuan, Jie Zhang, Yunpei Jia, Chuanqi Tan, Tao Xue, and Shiguang Shan. Meta gradient adversarial attack. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2021.
350
+
351
+ Xiangyu Zhang, Xinyu Zhou, Mengxiao Lin, and Jian Sun. Shufflenet: An extremely efficient convolutional neural network for mobile devices. computer vision and pattern recognition, 2018.
352
+
353
+ Wen Zhou, Xin Hou, Yongjun Chen, Mengyun Tang, Xiangqi Huang, Xiang Gan, and Yong Yang. Transferable adversarial perturbations. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 452–467, 2018.
354
+
355
+ # A APPENDIX
356
+
357
+ # A.1 TESTING PSEUDO CODE OF MTA
358
+
359
+ We summarize the testing pseudo code of MTA in Algorithm.2, where $\hat { \mathcal { F } }$ is the target model and $\tilde { y }$ is the target model’s prediction for the adversarial example $x _ { a d v } ^ { T }$ . Note that all the clean examples in $\hat { \mathbb { D } }$ are correctly classified by the target model. Len $( \hat { \mathbb { D } } )$ denotes the number of examples in $\hat { \mathbb { D } }$ .
360
+
361
+ # A.2 TRAINING THE SOURCE AND TARGET MODELS ON CIFAR-10
362
+
363
+ On Cifar-10, we use 16 source and target models to train and test the metasurrogate model (MSM). The 8 source models are ResNet-10, -18, -34, SeResNet-14, -26, -50, MobileNetV1, and -V2. The 8 target models are MobileNet-V3, ShuffleNet-V1, -V2, SqueezeNet-A, -B, and adversarially trained ResNet-18, -34 and SeResNet50. It is not easy to collect the 16 trained Cifar-10 models on the internet. Therefore, before the experiments of MTA, we first use consistent hyperparameters to train the 16 models on Cifar-10 for 200 epochs. The learning rate, L2 weight decay, and batch size are set to 0.01, 1e-5, and 128, respectively. For each adversarially trained model, we first use FGSM and the normally trained model to generate one
364
+
365
+ # Algorithm 2 Testing of Meta-Transfer Attack
366
+
367
+ input: Black-box target model $\hat { \mathcal { F } }$ , Testing examples $\hat { \mathbb { D } }$ that are correctly classified by the target model, Optimized metasurrogate model $\mathcal { M } _ { \theta }$ .
368
+ output: Transfer attack success rate.
369
+ $\mathbf { 1 } : P = 0$
370
+ 2 : for $( x , y ) \in { \hat { \mathbb { D } } }$ do
371
+ 3 : $x _ { a d v } ^ { 0 } = x$
372
+ 4 : for $\mathrm { k }$ in [1, 2, ..., T] do
373
+ 5 : $g ^ { k } = \bar { \nabla } _ { x _ { a d v } ^ { k - 1 } } L ( \bar { \mathcal { M } } _ { \theta } ( x _ { a d v } ^ { k - 1 } ) , y )$
374
+ xadv
375
+ 6 : $\scriptstyle x _ { a d v } ^ { k } = \mathrm { C l i p } \left( x _ { a d v } ^ { k - 1 } + { \frac { \epsilon } { T } } \cdot \mathrm { s i g n } ( g ^ { k } ) \right)$
376
+ 7 :8 : end forevaluate $x _ { a d v } ^ { T }$ on $\hat { \mathcal { F } }$ and obtain $\tilde { y } = \hat { \mathcal { F } } ( x _ { a d v } ^ { T } )$
377
+ 9 : if $y \ne \tilde { y }$ do
378
+ 10: P+ = 1
379
+ 11: end if
380
+ 12: return Len(Dˆ) P
381
+
382
+ adversarial example for each training image with $\epsilon = 3$ , and then train the model on both clean and adversarial images. The 8 source models obtain $9 0 . 0 \%$ , $9 1 . 8 \%$ , $9 2 . 6 \%$ , $8 5 . 6 \%$ , $8 8 . 3 \%$ , $9 0 . 5 \%$ , $8 2 . 0 \%$ , and $8 1 . 8 \%$ accuracies on the test set, and the 8 target models obtain $8 0 . 0 \%$ , $8 2 . 5 \%$ , $7 6 . 4 \%$ , $8 6 . 4 \%$ , $8 6 . 9 \%$ , $8 8 . 9 \%$ , $9 0 . 5 \%$ , and $8 7 . 5 \%$ accuracies.
383
+
384
+ # A.3 MORE EXPERIMENTS ON CIFAR-10
385
+
386
+ Here we show more experiments on Cifar-10.
387
+
388
+ # A.3.1 TARGETED TRANSFER ATTACK
389
+
390
+ We conduct targeted transfer attack and show the experimental results in Table 4. MTA has a great advantage over the compared methods in the targeted transfer attack setting.
391
+
392
+ # A.3.2 TRANSFER ATTACK WITH SMALLER $\epsilon$
393
+
394
+ We set $\epsilon$ to 8 to evaluate how does MTA perform with smaller $\epsilon$ . The results shown in Table 5 indicate that MTA outperforms the compared methods no matter the value of $\epsilon$ .
395
+
396
+ # A.3.3 COMPARISON BETWEEN MTA AND METAATTACK
397
+
398
+ MetaAttack[14] is developed for query-based black-box adversarial attack but not for transfer attack. We implement MetaAttack in the transfer attack scene on Cifar-10 and compare it with MTA in Table 6. The comparison indicates that MTA greatly outperforms MetaAttack in transfer attack.
399
+
400
+ # A.3.4 MORE EXPERIMENTS ABOUT THE CUSTOMIZED PGD
401
+
402
+ As introduced in Section 3, the sign function in the vanilla PGD with $\mathrm { L } _ { \infty }$ constraint introduces a discrete operation. This results in that the gradient back-propagating through sign be zero and further prohibits the training of the MSM. We propose the Customized PGD to enable the training of the MSM. Here we conduct other four experiments to validate the indispensability and the effect of the Customized PGD on the proposed MTA framework.
403
+
404
+ Table 4: Targeted transfer attack results on Cifar-10.
405
+
406
+ <table><tr><td>Method</td><td>MN-V3</td><td>SN-V1</td><td>SN-V2</td><td>SN-A</td><td>SN-B</td></tr><tr><td>DI</td><td>16.3%</td><td>26.4%</td><td>17.2%</td><td>22.3%</td><td>21.6%</td></tr><tr><td>MI</td><td>29.6%</td><td>43.6%</td><td>29.8%</td><td>37.1%</td><td>35.4%</td></tr><tr><td>TI</td><td>17.6%</td><td>21.1%</td><td>16.5%</td><td>26.1%</td><td>25.8%</td></tr><tr><td>IR</td><td>10.8%</td><td>19.6%</td><td>9.5%</td><td>13.7%</td><td>12.5%</td></tr><tr><td>AEG</td><td>47.2%</td><td>53.8%</td><td>36.5%</td><td>42.6%</td><td>41.0%</td></tr><tr><td>MTA</td><td>49.0%</td><td>70.3%</td><td>47.7%</td><td>60.3%</td><td>58.5%</td></tr></table>
407
+
408
+ Table 5: Transfer attack results with $\epsilon = 8 / 2 5 5$ on Cifar-10.
409
+
410
+ <table><tr><td>Method</td><td>MN-V3</td><td>SN-V1</td><td>SN-V2</td><td>SN-A</td><td>SN-B</td></tr><tr><td>DI</td><td>31.5%</td><td>42.1%</td><td>30.0%</td><td>38.2%</td><td>36.9%</td></tr><tr><td>MI</td><td>44.2%</td><td>59.8%</td><td>43.2%</td><td>55.7%</td><td>54.9%</td></tr><tr><td>TI</td><td>29.5%</td><td>31.3%</td><td>29.6%</td><td>37.7%</td><td>36.8%</td></tr><tr><td>IR</td><td>29.2%</td><td>51.1%</td><td>35.3%</td><td>38.5%</td><td>37.4%</td></tr><tr><td>AEG</td><td>58.0%</td><td>66.5%</td><td>50.4%</td><td>61.9%</td><td>59.6%</td></tr><tr><td>MTA</td><td>62.5%</td><td>79.6%</td><td>58.2%</td><td>70.5%</td><td>69.3%</td></tr></table>
411
+
412
+ As PGD with L2 constraint contains no sign, in the first experiment, we use PGD with L2 constraint $( P G D _ { L 2 } )$ instead of the Customized PGD to attack the MSM in the training phase and denote the trained MSM as MTAP GDL2.
413
+
414
+ PGD with L1 constraint also contains no sign. In the second experiment, we use PGD with L1 constraint $( P G D _ { L 1 } )$ to attack the MSM in the training phase and denote the trained MSM as MTAP GDL1.
415
+
416
+ Both $\gamma _ { 1 }$ and $\gamma _ { 2 }$ of the Customized PGD are set to 0.01 by default. In the third experiment, we set $\gamma _ { 1 }$ to 0.05. Note that we decrease $\epsilon _ { c }$ appropriately to offset the increase of the training perturbation size caused by setting $\gamma _ { 1 }$ to 0.05. All the other experimental settings are consistent with the default settings. We denote the MSM trained in this experiment as $\mathrm { M T A } _ { \gamma _ { 1 } = 0 . 0 5 }$ .
417
+
418
+ In the fourth experiment, we set $\gamma _ { 2 }$ to 0.05 and denote the trained MSM as $\mathrm { M T A } _ { \gamma _ { 2 } = 0 . 0 5 }$
419
+
420
+ Table 6 reports all the four experimental results. We can get three conclusions. First, directly using $P G D _ { L 1 }$ or $P G D _ { L 2 }$ in MTA’s training stage is also effective to train the MSM but leads to limited performance. Second, the proposed Customized PGD is important for the proposed MTA framework to achieve superior performance. Third, larger $\gamma _ { 1 }$ or $\gamma _ { 2 }$ damages the performances of MTA.
421
+
422
+ # A.3.5 MORE EXPERIMENTS ABOUT SOURCE AND TARGET MODELS
423
+
424
+ Here we change the setting of source and target models, and evaluate MTA under this new setting. In this setting, the source models are MobileNet-V2, ShuffleNet-V1, ShuffleNet-V2, SqueezeNet-A, and SqueezeNet-B, and the target models are ResNet-10, ResNet-18, ResNet-34, SeResNet-14, SeResNet-26, SeResNet-50, MobileNet-V1, and MobileNet-V2. All the other experimental settings are consistent with those introduced before. The experimental results are summarized in Table 7, where MTA still shows its advantage in the transfer attack problem.
425
+
426
+ A.3.6 THE EXPERIMENT WHERE SOURCE MODELS DO NOT SHARE TRAINING SAMPLES WITHTARGET MODELS.
427
+
428
+ In our previous experiment, the source and target models are all trained on the same training set. Here we conduct a new experiment, where we train the source and target models on different training samples, and use the new trained models to perform transfer attack. This experiment is performed on Cifar-10, which contains 10 categories and each category in the training set contains 5000 images.
429
+
430
+ Table 6: More transfer attack experimental results on Cifar-10.
431
+
432
+ <table><tr><td>Method</td><td>MN-V3</td><td>SN-V1</td><td>SN-V2</td><td>SN-A</td><td>SN-B</td></tr><tr><td>MetaAttack</td><td>39.2%</td><td>43.9%</td><td>32.1%</td><td>38.6%</td><td>37.8%</td></tr><tr><td>MTAPGD L2</td><td>80.8%</td><td>92.7%</td><td>83.5%</td><td>89.0%</td><td>86.8%</td></tr><tr><td>MTAPGD L1</td><td>81.5%</td><td>91.3%</td><td>82.4%</td><td>85.3%</td><td>83.7%</td></tr><tr><td>MTAγ1=0.05</td><td>90.5%</td><td>98.0%</td><td>90.2%</td><td>94.5%</td><td>93.1%</td></tr><tr><td>MTAγ2=0.05</td><td>86.7%</td><td>95.3%</td><td>85.8%</td><td>89.5%</td><td>88.4%</td></tr><tr><td>MTA</td><td>91.8%</td><td>98.4%</td><td>90.9%</td><td>94.9%</td><td>93.8%</td></tr></table>
433
+
434
+ Table 7: The MSM is trained with source models MobileNet-V3, ShuffleNet-V1, ShuffleNet-V2, SqueezeNet-A, and SqueezeNet-B. From left to right, the target models are ResNet-10 (Res-10), ResNet-18 (Res-18), ResNet-34 (Res-34), SeResNet-14 (SE-14), SeResNet-26 (SE-26), SeResNet-50 (Res-18), MobileNet-V1 (MB-V1), and MobileNet-V2 (MB-V2).
435
+
436
+ <table><tr><td>Method</td><td>Res-10</td><td>Res-18</td><td>Res-34</td><td>SE-14</td><td>SE-26</td><td>SE-50</td><td>MB-V1</td><td>MB-V2</td></tr><tr><td>PGD</td><td>46.9%</td><td>42.5%</td><td>50.1%</td><td>49.6%</td><td>50.2%</td><td>45.9%</td><td>47.9%</td><td>54.5%</td></tr><tr><td>DI</td><td>65.2%</td><td>56.9%</td><td>69.6%</td><td>70.2%</td><td>71.5%</td><td>65.7%</td><td>69.5%</td><td>71.2%</td></tr><tr><td>MI</td><td>89.5%</td><td>86.1%</td><td>90.7%</td><td>88.3%</td><td>91.0%</td><td>89.1%</td><td>86.6%</td><td>88.8%</td></tr><tr><td>TI</td><td>48.1%</td><td>39.2%</td><td>49.9%</td><td>53.8%</td><td>55.6%</td><td>47.8%</td><td>63.9%</td><td>60.8%</td></tr><tr><td>MTA</td><td>96.7%</td><td>94.6%</td><td>98.3%</td><td>98.7%</td><td>98.8%</td><td>97.5%</td><td>96.7%</td><td>98.7%</td></tr></table>
437
+
438
+ In this experiment, we split the training set into two sub-training sets and each of the sub-training set contains all the 10 categories. Every category in the first sub-training set contains 2500 images and every category in the second sub-training set contains the remaining 2500 images. Therefore, there is no overlapping samples between the two sub-training sets, and the two sub-training sets share only the label set. We use the first sub-training set to train the source models and the meta-surrogate model, and use the second sub-training set to train the target models. Thus the source models and the meta-surrogate model does not use the training images of the target models. The source models are ResNet-10, ResNet-18, ResNet-34, SeResNet-14, SeResNet-26, SeResNet-50, MobileNet-V1, MobileNet-V2 with testing accuracies of $8 6 . 8 \%$ , $8 6 . 7 \%$ , $8 7 . 2 \%$ , $8 4 . 2 \%$ , $8 5 . 4 \%$ , $8 7 . 7 \%$ , $8 0 . 7 \%$ , and $8 0 . 9 \%$ , respectively. The target models are MobileNet-V3, ShuffleNet-V1, ShuffleNet-V2, SqueezeNet-A, and SqueezeNet-B with testing accuracies of $7 3 . 9 \%$ , $8 1 . 1 \%$ , $7 2 . 6 \%$ , $8 2 . 3 \%$ , and $8 3 . 0 \%$ , respectively. Then we use the source models and the trained meta-surrogate model to attack the target models. The experimental results are reported in Table 8. It is clear that when we know the label set but do not know the training images of the target models, MTA still outperforms the baselines with clear margins.
439
+
440
+ # A.4 THE SUPPLEMENTAL EXPERIMENTAL SETTINGS OF MTA ON IMAGENET.
441
+
442
+ In our experiment on ImageNet, we found that the MSM directly trained on the resolution of $2 2 4 \times 2 2 4$ often suffers from slow and unstable convergence due to the high dimensionality. Therefore, we develop a three-stage training strategy for gradually and stably training the MSM. The first training stage only trains the top 4 blocks and the classifier of the MSM. The input data $x _ { a d v } ^ { k - 1 }$ is down-sampled by $4 \times$ and is fed into the 3rd block skipping the 1st and 2nd blocks. The perturbation $g _ { e n s } ^ { k - 1 }$ is first up-sampled by $4 \times$ and is then added to $x _ { a d v } ^ { k - 1 }$ to obtain $x _ { a d v } ^ { k }$ . The second stage trains the top 5 blocks and the classifier. The input $x _ { a d v } ^ { k - 1 }$ is down-sampled by $2 \times$ and is fed into the 2nd block skipping the 1st block. The third stage trains all layers. Note that, except for the newly added block in the second or third stage and the layers directly connected with the newly added block, all the other layers inherit the weights trained in the previous stage. Due to memory limitation, we set $T _ { t }$ to a small number of 2.
443
+
444
+ The first, second, and third training stages take 100,000, 50,000, and 50,000 iterations, with the batch size of 50, 36, and 24, respectively. Both the second and the third stages train the newly added blocks and the layers directly connected with them in the first 20,000 iterations and fine-tune all the blocks in the later 30,000 iterations. The learning rate $\alpha$ and the number of iterations $T _ { t }$ are set to 0.001 and 2, respectively. In the first, second, and third training stages, $\epsilon _ { c }$ is initialized to 3, 000, 1, 200, and 1, 200 respectively, and is exponentially decayed by $0 . 9 \times$ for every $4 , 0 0 0 , 3 , 0 0 0$ , and 3, 000 iterations, respectively.
445
+
446
+ ![](images/45fa236b3deaa279be1b0a8deb3250cfb09b9280a17edefa31677aef610e74db.jpg)
447
+ Figure 4: (a) DenseNet-22-BC. Orange cube is convolution layer with $3 \times 3$ kernel size. Pink cube is convolution layer with $1 \times 1$ kernel size. ‘Bottle Neck $( M _ { 2 }$ ) $\ast 3 ^ { \ast }$ denotes three cascaded ‘Bottle Neck $( M _ { 2 } ) '$ . The number (e.g., $M _ { 1 }$ , $4 * M , M )$ on each convolution layer denotes its number of filters. ‘Pool’ in the Transition block is Max Pooling with both stride and kernel size of $2 \times 2$ , and the last ‘Pool’ before the classifier is Global Average Pooling. (b) The detailed structure of Bottle Neck. (c) The detailed structure of Transition.
448
+
449
+ We refer to the data pre-processing methods in the repository7 on GitHub to pre-process the data used in our experiments on ImageNet. When the resolution of the source model is $2 2 4 \times 2 2 4$ , we refer to ‘vgg preprocessing.py’ while when the resolution is $2 9 9 \times 2 9 9$ , we refer to ‘inception preprocessing.py’.
450
+
451
+ # A.5 ATTACKING TRANSFORMER
452
+
453
+ We also conduct an experiment on ImageNet to evaluate how the proposed MTA performs in attacking Vision Transformer (ViT). In this experiment, the source model is Inception-V3, and the target model is Vit base patch $1 6 . 2 2 4 ^ { 8 }$ . Experimental results are reported in Table 9. It is clear that MTA performs the best in attacking ViT.
454
+
455
+ # A.6 THE NETWORK ARCHITECTURE
456
+
457
+ Table 8: The transfer attack results on Cifar-10 when the source models do not share training images with target models. The source models are ResNet-10 (Res-10), ResNet-18 (Res-18), ResNet-34 (Res34), SeResNet-14 (SE-14), SeResNet-26 (SE-26), SeResNet-50 (Res-18), MobileNet-V1 (MB-V1), and MobileNet-V2 (MB-V2). The target models are MobileNet-V2, ShuffleNet-V1, ShuffleNet-V2, SqueezeNet-A, and SqueezeNet-B.
458
+ Table 9: Transfer attack performances of MTA on ViT.
459
+
460
+ <table><tr><td>Method</td><td>PGD</td><td>TI</td><td>DI</td><td>MI</td><td>MTA</td></tr><tr><td>Success Rate</td><td>5.5%</td><td>8.6%</td><td>7.0%</td><td>15.6%</td><td>21.3%</td></tr></table>
461
+
462
+ DenseNet-22BC is shown in Figure 4. $M _ { 1 }$ , $M _ { 2 }$ , $M _ { 3 }$ , and $M _ { 4 }$ are set to 80, 40, 100, and 110, respectively. We denote MTA with DenseNet-22BC backbone as $\mathbf { M T A } _ { d e n s e }$ and show its performances in Table 1 of the main-body.
463
+
464
+ The simplified Inception network is a much shallower and thinner version of the official InceptionResNet-V2. Figure 5 shows the structure of the simplified Inception. The official Inception-ResNet
465
+
466
+ Figure 5: The simplified Inception network. All the blocks have the same inner structures with those of Inception-ResNet-V2.
467
+
468
+ ![](images/e8875fc6574a2f9d76ed945c62390b81f2c98b71f19f43c9f5db3be3cb04af3e.jpg)
469
+ Figure 6: Transfer attack success rates of MTA on the eight black-box Cifar-10 models, across the training process.
470
+
471
+ V2 repeats each Indeption-resnet1-A, -B, or -C block for several times while the simplified Inception does not repeat them. We denote MTA with this backbone as $\mathbf { M T A } _ { I n c }$ and show its performances in Table 2 of the main-body.
472
+
473
+ # A.7 DEFINITION OF ATTACK SUCCESS RATE.
474
+
475
+ The formulation of attack success rate is $\begin{array} { r } { R a t e \mathrm { ~ = ~ } \frac { C a r d ( \{ x \| x \in D _ { t } , M ( x ) = y \neq M ( x _ { a d v } ) \} ) } { C a r d ( \{ x \| x \in D _ { t } , M ( x ) = y \} ) } } \end{array}$ , where $D _ { t }$ is the test set, $x$ is a test image and $x _ { a d v }$ is the adversarial image generated for $x$ , $y$ is the groundtruth label for $x$ , $M$ is the target model and $M ( x )$ is the prediction of the target model for $x$ . $\{ x \| x \in D _ { t } , M ( x ) = y \}$ is the set containing all clean images that are correctly classified by model $M$ . $\{ x \| x \in D _ { t } , M ( x ) = y \neq M ( x _ { a d v } ) \}$ is the set containing all clean images that not only are correctly classified by model $M$ but also the corresponding adversarial images are misclassified by model $M$ . $C a r d ( \{ x \| x \in D _ { t } , M ( x ) = y \}$ ) denotes the number of elements in the set $\{ x \| x \in D _ { t } , M ( x ) = y \}$ .
476
+
477
+ # A.8 IMPLEMENTATIONS OF THE COMPARED METHODS.
478
+
479
+ For fair comparisons between MTA and the compared methods, we tune the compared methods for their best possible performances in our re-implementation. $\epsilon$ is set to 15 by default for all methods and $T _ { v }$ is set to 10 for all PGD-based methods.
480
+
481
+ MI utilizes gradient momentum to make the generated adversarial examples more transferable. The most important hyper-parameter of MI is $\mu$ . In our implementation, we found that setting $\mu$ to 1 can achieve the best transfer attack performance.
482
+
483
+ DI. We follow the available public code9 of DI to implement it in Tables 1, 2, and 3. As to the experiments on ImageNet, we set ’FLAGS.image width’ and ’FLAGS.image resize’ (two parameters of the input diversity function in the official code9) to 224 and 256 respectively. On Cifar-10, we set ’FLAGS.image width’ and ’FLAGS.image resize’ to 32 and 36, respectively. For all experiments, we set $p$ to 0.8.
484
+
485
+ TI. We directly utilize the public code10 to implement TI and TI-DI in Tables 1, and 3, respectively.
486
+
487
+ SGM uses a parameter $\gamma$ to reduce the gradient from all residual modules of ResNet or DenseNet. We utilize grid search to tune $\gamma$ for each ResNet and DenseNet source model shown in Table 3. We denote $\gamma$ for the source model of Res-50, Res-152, DN-161, and DN-121 as $\gamma _ { r e s 5 0 }$ , γres152, γdn161, and $\gamma _ { d n 1 2 1 }$ , respectively. The tuned best $\gamma _ { r e s 5 0 }$ , $\gamma _ { r e s 1 5 2 }$ , and $\gamma _ { d e n s e }$ for the source model group $\mathrm { R e s } { - } 5 0 { + } \mathrm { R e s } { - } 1 5 2 { + } \mathrm { D N } { - } 1 6 1$ are 0.20, 0.45, and 0.70, respectively. The tuned best $\gamma _ { r e s 5 0 }$ and $\gamma _ { d n 1 2 1 }$ for the source model group Res-50+Inc-V1+DN-121 are 0.60 and 0.85, respectively. The tuned best $\gamma _ { r e s 5 0 }$ for the source model group Res-50+Inc-V1 is 0.65.
488
+
489
+ A-PGD. We directly utilize the public public code11 of A-PGD to implement it in Table 1.
490
+
491
+ AEG. By referring to the AEG’s paper and code12, we re-implement AEG on Cifar-10 and train the generator and the critic for 500 epochs with the learning rate of 0.001. The architecture of the generator is the encoder-decoder defined in Tab.7 of AEG’s paper. We do not implement AEG on ImageNet because training the generator and critic is expensive on ImageNet.
492
+
493
+ IR. We directly utilize the public code13 of IR to implement it on ImageNet. When implementing IR on Cifar-10, we set the hyper-parameter ‘args.grid scale’ to 1.
494
+
495
+ # A.9 TRAINING CURVES
496
+
497
+ In the training process of the MSM, we evaluate MTA’s transfer attack performances on the target models for every 250 iterations. Figure 6 visualizes the performance curves on eight Cifar-10 target models. It is observed that with the training going on, the transfer attack success rates on the target models rise gradually. The periodic fluctuations of the performances are caused by the periodic decay of the hyper-parameter $\epsilon _ { c }$ described in Section 4.1.1.
498
+
499
+ # A.10 COMPUTATIONAL COST
500
+
501
+ We conduct all experiments on Tesla P40 GPU. The computational cost can be summarized into training cost and inference cost happened in the training and the inference phases, respectively. The training cost of the proposed MTA depends mainly on the backbone of MSM, the used source models, the dataset, the batch size, $T _ { t }$ , and etc.. On Cifar-10, the default backbone of the MSM is ResNet-13, the batch size is 64, $T _ { t } = 7$ , and we use 8 source models to train the MSM. The training costs one P40 GPU and approximately $2 . 5 \mathrm { T }$ FLOPs per iteration. On ImageNet, the default backbone of the MSM is ResNet-19, $T _ { t } = 2$ , the batch size is 24 in the third training stage. When using the Inc-V3 source model to train the MSM, the third training stage costs one P40 and approximately 3.2T FLOPs per iteration. When using the Res-152, Res-50, and DN-161 source models to train the MSM, the third training stage costs three P40 GPUs and approximately 6.5T FLOPs per iteration.
502
+
503
+ In the inference phase (generating adversarial examples and attack the target models), the cost of MTA depends mainly on the backbone of MSM and $T _ { v }$ . The inference cost of baselines depend on the source models and $T _ { v }$ . On ImageNet, when using the Res-152, Res-50, and DN-161 source models, the PGD-based baselines (DI, MI, TI, SGM) cost about 124.1 GFLOPs per gradient ascent step per image, and cost about 109.1M parameters. As a comparison, the inference cost of MTA is only 11.3 GFLOPs per gradient ascent step per image and the parameter the MTA needed is only 6.77M. Obviously, both the inference cost and the parameter the MTA used is much smaller than those of the PGD-based baselines, and this is another advantage of the proposed MTA over the PGD-based baselines.
504
+
505
+ # A.11 VISUALIZATION OF ADVERSARIAL EXAMPLES
506
+
507
+ Figure 7 visualizes the adversarial examples and the noises generated for the corresponding clean images via MI, DI, TI, SGM, IR, and MTA. All the clean images are sampled from the testing set of ImageNet.
508
+
509
+ # A.12 THE TENSORFLOW CODE
510
+
511
+ We show the simplified core code of MTA on the last two pages for a better understanding of our work. Note that the showed code is used for the experiments on Cifar-10 but not on ImageNet. The code used on ImageNet differs slightly from the showed code.
512
+
513
+ ![](images/3f1413f838ac21701f0b98dec38f25fe345a7b3f385c8f69f013066ec3f94363.jpg)
514
+ Figure 7: The adversarial examples and the noises generated via MI, DI, TI, SGM, IR, and MTA. The corresponding clean images are shown in the left most column. The source model is Res-152.
515
+
516
+ 1 import tensorflow as tf
517
+ 2
518
+ 3 class Meta_Transfer_Attack:
519
+ 4 def _init__(self):
520
+ 5 # Define some hyperparameters
521
+ 6 self.lr $=$ tf.placeholder_with_default(0.001, ())
522
+ 7 self.epsilon_c $=$ tf.placeholder_with_default(1, ())
523
+ 8 # Define the meta-surrogate model
524
+ 9 self.MSM $=$ ResNet13()
525
+ 10 # Define the source models
526
+ 11 self.source_models $=$ [ResNet(10), ..., MobileNet_V2()]
527
+ 12 # Define the input data and the label
528
+ 13 self.image $=$ tf.placeholder(tf.float32, shape $=$ [None, 32, 32, 3])
529
+ 14 self.label $=$ tf.placeholder(tf.float32, shape $=$ [None, 10])
530
+ 15
531
+ 16 def build_training_graph(self, T):
532
+ 17 # The initial adversarial examples are the clean images
533
+ 18 attack $=$ self.image
534
+ 19 with tf.variable_scope('surrogate', reuse $=$ tf.AUTO_REUSE):
535
+ 20 for k in range(T):
536
+ 21 # Predict the adversarial examples
537
+ 22 surrogate_logits $=$ self.MSM.predict(attack)
538
+ 23
539
+ 24 # meta-surrogate models' loss on the adversarial examples.
540
+ 25 surrogate_loss $=$ Cross_entropy(logits $=$ surrogate_logits,
541
+ 26 labels $=$ self.label)
542
+ 27
543
+ 28 # calculate Gˆk
544
+ 29 grad $=$ tf.gradients(surrogate_loss, attack)[0]
545
+ 30
546
+ 31 # calculate Gˆk_1
547
+ 32 grad_1 $=$ grad / tf.reduce_sum(tf.abs(grad), axis $=$ [1,2,3],
548
+ 33 keep_dims $=$ True)
549
+ 34
550
+ 35 # calculate Gˆk_t
551
+ 36 mean_abs_grad $=$ tf.reduce_mean(tf.abs(grad), axis $=$ [1,2,3],
552
+ 37 keep_dims $=$ True)
553
+ 38 norm_one_grad $=$ grad / mean_abs_grad
554
+ 39 grad_atan $=$ tf.atan(norm_one_grad) $\star$ (2 / 3.1415926)
555
+ 40
556
+ 41 # calculate Gˆk_s
557
+ 42 grad_sign $=$ tf.sign(grad)
558
+ 43
559
+ 44 # calculate Gˆk_ens
560
+ 45 grad_ens $=$ grad_1 $^ +$ 0.01 $\star$ grad_sign $^ +$ 0.01 $\star$ grad_atan
561
+ 46
562
+ 47 # Obtain the adversarial examples Xˆk_adv
563
+ 48 attack_temp $=$ attack $^ +$ (self.epsilon_c / T) $\star$ grad_ens
564
+ 49 attack $=$ tf.clip_by_value(attack, 0.0, 1.0)
565
+ 50
566
+ 51 # Evaluate the adversarial examples $X ^ { \wedge }$ T_adv on the source models
567
+ 52 with tf.variable_scope('Source', reuse $: =$ tf.AUTO_REUSE):
568
+ 53 for model in self.source_models:
569
+ 54 logits $=$ model.predict(attack)
570
+ 55 loss $=$ Cross_entropy(logits $=$ logits, labels $=$ self.label)
571
+ 56 self.source_loss $+ =$ tf.reduce_mean(loss)/len(self.source_models)
572
+ 57
573
+ 58
574
+ 59 def build_optimizing_graph(self):
575
+ 60 opt $=$ tf.train.AdamOptimizer(self.lr)
576
+ 61 $\#$ Optimize the MSM via maximizing the source models' loss.
577
+ 62 gvs $=$ opt.compute_gradients(-self.source_loss, self.MSM.weight)
578
+ 63 gvs $=$ [(tf.clip_by_value(grad, -15, 15), var) for grad, var in gvs]
579
+ 64 self.train_op $=$ optimizer.apply_gradients(gvs)
580
+ 65
581
+ 66 def main():
582
+ 67 # Initialize the settings.
583
+ 68 Batch_size $=$ 64
584
+ 69 Init_eps_c $=$ 1600 / 255
585
+ 70
586
+ 71 # Define the graph
587
+ 72 MTA $=$ Meta_Transfer_Attack()
588
+ 73 MTA.build_training_graph(7)
589
+ 74 MTA.build_optimizing_graph()
590
+ 75
591
+ 76 # Define the data loader
592
+ 77 Cifar10_dataloader $=$ DataSet('Cifar10')
593
+ 78
594
+ 79 sess $=$ tf.InteractiveSession()
595
+ 80 tf.global_variables_initializer().run()
596
+ 81
597
+ 82 # Restore the weights of all source models
598
+ 83 restore_source_weights(MTA.source_models, sess)
599
+ 84
600
+ 85 for iter in range(47000):
601
+ 86 # Exponentially decay eps_c by 0. $9 \times$ for every 4000 iterations.
602
+ 87 eps_c $=$ Init_eps_c $\star$ ( 0.9 \*\* int(iter / 4000) )
603
+ 88
604
+ 89 images, labels $=$ Cifar10_dataloader.get_data(Batch_size)
605
+ 90
606
+ 91 feed_dict $\begin{array} { r l } { = } & { } \left\{ \begin{array} { l } { \right\} } \end{array} \end{array}$
607
+ 92 feed_dict[MTA.image] $=$ images
608
+ 93 feed_dict[MTA.label] $=$ labels
609
+ 94 feed_dict[MTA.lr] $=$ 0.001
610
+ 95 feed_dict[MTA.epsilon_c] $=$ eps_c
611
+ 96
612
+ 97 # Train the MSM
613
+ 98 sess.run(MTA.train_op, feed_dict)
md/dev/1wVvweK3oIb/1wVvweK3oIb.md ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SIMPLE GNN REGULARISATION FOR 3D MOLECULARPROPERTY PREDICTION & BEYOND
2
+
3
+ Jonathan Godwin, Michael Schaarschmidt, Alexander Gaunt, Alvaro Sanchez-Gonzales, Yulia Rubanova, Petar Velickovi ˇ c,´ James Kirkpatrick & Peter Battaglia
4
+
5
+ DeepMind, London {jonathangodwin}@deepmind.com
6
+
7
+ # ABSTRACT
8
+
9
+ In this paper we show that simple noisy regularisation can be an effective way to address oversmoothing. We argue that regularisers addressing oversmoothing should both penalise node latent similarity and encourage meaningful node representations. From this observation we derive “Noisy Nodes”, a simple technique in which we corrupt the input graph with noise, and add a noise correcting node-level loss. The diverse node level loss encourages latent node diversity, and the denoising objective encourages graph manifold learning. Our regulariser applies well-studied methods in simple, straightforward ways which allow even generic architectures to overcome oversmoothing and achieve state of the art results on quantum chemistry tasks, and improve results significantly on Open Graph Benchmark (OGB) datasets. Our results suggest Noisy Nodes can serve as a complementary building block in the GNN toolkit.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Graph Neural Networks (GNNs) are a family of neural networks that operate on graph structured data by iteratively passing learned messages over the graph’s structure (Scarselli et al., 2009; Bronstein et al., 2017; Gilmer et al., 2017; Battaglia et al., 2018; Shlomi et al., 2021). While Graph Neural Networks have demonstrated success in a wide variety of tasks (Zhou et al., 2020a; Wu et al., 2020; Bapst et al., 2020; Schütt et al., 2017; Klicpera et al., 2020a), it has been proposed that in practice “oversmoothing” limits their ability to benefit from overparametrization.
14
+
15
+ Oversmoothing is a phenomenon where a GNN’s latent node representations become increasing indistinguishable over successive steps of message passing (Chen et al., 2019). Once these representations are oversmoothed, the relational structure of the representation is lost, and further message-passing cannot improve expressive capacity. We argue that the challenges of overcoming oversmoothing are two fold. First, finding a way to encourage node latent diversity; second, to encourage the diverse node latents to encode meaningful graph representations. Here we propose a simple noise regulariser, Noisy Nodes, and demonstrate how it overcomes these challenges across a range of datasets and architectures, achieving top results on OC20 IS2RS & IS2RE direct, QM9 and OGBG-PCQM4Mv1.
16
+
17
+ Our “Noisy Nodes” method is a simple technique for regularising GNNs and associated training procedures. During training, our noise regularisation approach corrupts the input graph’s attributes with noise, and adds a per-node noise correction term. We posit that our Noisy Nodes approach is effective because the model is rewarded for maintaining and refining distinct node representations through message passing to the final output, which causes it to resist oversmoothing. Like denoising autoencoders, it encourages the model to explicitly learn the manifold on which the uncorrupted input graph’s features lie, analogous to a form of representation learning. When applied to 3D molecular prediction tasks, it encourages the model to distinguish between low and high energy states. We find that applying Noisy Nodes reduces oversmoothing for shallower networks, and allows us to see improvements with added depth, even on tasks for which depth was assumed to be unhelpful.
18
+
19
+ This study’s approach is to investigate the combination of Noisy Nodes with generic, popular baseline GNN architectures. For 3D Molecular prediction we use a standard architecture working on 3D point clouds developed for particle fluid simulations, the Graph Net Simulator (GNS) (Sanchez-Gonzalez\* et al., 2020), which has also been used for molecular property prediction (Hu et al., 2021b). Without using Noisy Nodes the GNS is not a competitive model, but using Noisy Nodes allows the GNS to achieve top performance on three 3D molecular property prediction tasks: the OC20 IS2RE direct task by $43 \%$ over previous work, $12 \%$ on OC20 IS2RS direct, and top results on 3 out of 12 of the QM9 tasks. For non-spatial GNN benchmarks we test a MPNN (Gilmer et al., 2017) on OGBG-MOLPCBA and OGBG-PCQM4M (Hu et al., 2021a) and again see significant improvements. Finally, we applied Noisy Nodes to a GCN (Kipf & Welling, 2016), arguably the most popular and simple GNN, trained on OGBN-Arxiv and see similar results. These results suggest Noisy Nodes can serve as a complementary GNN building block.
20
+
21
+ # 2 PRELIMINARIES: GRAPH PREDICTION PROBLEM
22
+
23
+ Let $G = ( V , E , g )$ be an input graph. The nodes are $V = \{ v _ { 1 } , \ldots , v _ { | V | } \}$ , where $v _ { i } \in \mathbb { R } ^ { d _ { v } }$ . The directed, attributed edges are $E = \left\{ e _ { 1 } , \dots , e _ { | E | } \right\}$ : each edge includes a sender node index, receiver node index, and edge attribute, $\boldsymbol { e } _ { k } = \left( \boldsymbol { s } _ { k } , r _ { k } , \boldsymbol { e } _ { k } \right)$ , respectively, where $s _ { k } , r _ { k } \in \{ 1 , \dots , | V | \}$ and $e _ { k } \in \mathbb { R } ^ { d _ { e } }$ . The graph-level property is $g \in \mathbb { R } ^ { d _ { g } }$ .
24
+
25
+ The goal is to predict a target graph, $G ^ { \prime }$ , with the same structure as $G$ , but different node, edge, and/or graph-level attributes. We denote $\hat { G } ^ { \prime }$ as a model’s prediction of $G ^ { \prime }$ . Some error metric defines quality of $\hat { G } ^ { \prime }$ with respect to the target $G ^ { \prime }$ , $\mathrm { E r r o r } ( \hat { G } ^ { \prime } , G ^ { \prime } )$ , which the training loss terms are defined to optimize. In this paper the phrase “message passing steps” is synonymous with “GNN layers”.
26
+
27
+ # 3 OVERSMOOTHING
28
+
29
+ “Oversmoothing” is when the node latent vectors of a GNN become very similar after successive layers of message passing. Once nodes are identical there is no relational information contained in the nodes, and no higher-order latent graph representations can be learned. It is easiest to see this effect with the update function of a Graph Convolutional Network with no adjacency normalization $\begin{array} { r } { v _ { i } ^ { k } = \sum _ { j } W v _ { j } ^ { k - 1 } } \end{array}$ with $j \in N e i g h b o r h o o d _ { v _ { i } }$ , $W \in \mathbb { R } ^ { d _ { g } \times d _ { g } }$ and $k$ the layer index. As the number of applications increases, the averaging effect of the summation forces the nodes to become almost identical. However, as soon as residual connections are added we can construct a network that need not suffer from oversmoothing by setting the residual updates to zero at a similarity threshold. Similarly, multi-head attention Vaswani et al. (2017); Velickovi ˇ c et al. (2018) and GNNs with edge ´ updates (Battaglia et al., 2018; Gilmer et al., 2017) can modulate node updates. As such for modern GNNs oversmoothing is primarily a “training” problem - i.e. how to choose model architectures and regularisers to encourage and preserve meaningful latent relational representations.
30
+
31
+ We can discern two desiderata for a regulariser or loss that addresses oversmoothing. First, it should penalise identical node latents. Second, it should encourage meaningful latent representations of the data. One such example may be the auto-regressive loss of transformer based language models (Brown et al. (2020)). In this case, each word (equivalent to node) prediction must be distinct, and the auto-regressive loss encourages relational dependence upon prior words. We can take inspiration from this observation to derive auxiliary losses that both have diverse node targets and encourage relational representation learning. In the following section we derive one such regulariser, Noisy Nodes.
32
+
33
+ # 4 NOISY NODES
34
+
35
+ Noisy Nodes tackles the oversmoothing problem by adding a diverse noise correction target, modifying the original graph prediction problem definition in several ways. It introduces a graph corrupted by noise, $\bar { \tilde { G } } = \tilde { ( V , E , g ) }$ , where $\tilde { v } _ { i } \in \tilde { V }$ is constructed by adding noise, $\sigma _ { i }$ , to the input nodes, $\tilde { v } _ { i } = v _ { i } + \sigma _ { i }$ . The edges, $\tilde { E }$ , and graph-level attribute, $\tilde { g }$ , can either be uncorrupted by noise (i.e., $\tilde { E } = E , \tilde { g } = g )$ , calculated from the noisy nodes (for example in a nearest neighbors graph), or corrupted independent of the nodes—these are minor choices that can be informed by the specific problem setting.
36
+
37
+ $$
38
+ \begin{array} { c } { { \displaystyle \binom { \zeta _ { i } } { \upsilon _ { i } } { \cdots } _ { { \bf \bar { \Phi } } _ { i } } ; } } \\ { { + \Delta _ { i } \left[ \begin{array} { c } { { { \bf \bar { \Phi } } _ { \bar { i } } } } \\ { { { \bf \bar { \Phi } } _ { \bar { i } } } } \end{array} \right] ^ { \prime } { \bf \bar { \Phi } } _ { \bar { { { + } } } \Delta _ { i } } - \sigma _ { i } } } \\ { { \displaystyle \binom { \bf \bar { \bf \Phi } _ { \bar { i } } } { \bf \bar { \Phi } } ^ { \prime } { \bf \bar { \Phi } } ^ { \prime } { \bf \bar { \Phi } } _ { \bar { { { + } } } \Delta _ { i } } } } \end{array}
39
+ $$
40
+
41
+ ![](images/9092527f228fe1aca776680174ed12f46f8bd5366238138d84754289aa2e0519.jpg)
42
+ Figure 2: Per layer node latent diversity, measured by MAD on a 16 layer MPNN trained on OGBGMOLPCBA. Noisy Nodes maintains a higher level of diversity throughout the network than competing methods.
43
+
44
+ Figure 1: Noisy Node mechanics during training. Input positions are corrupted with noise $\sigma$ , and the training objective is the node-level difference between target positions and the noisy inputs.
45
+
46
+ Our method requires a noise correction target to prevent oversmoothing by enforcing diversity in the last layers of the GNN, which can be achieved with an auxiliary denoising autoencoder loss. For example, where the Error is defined with respect to graph-level predictions (e.g., predict the minimum energy value of some molecular system), a second output head can be added to the GNN architecture which requires denoising the inputs as targets. Alternatively, if the inputs and targets are in the same real domain as is the case for physical simulations we can adjust the target for the noise. Figure 1 demonstrates this Noisy Nodes set up. The auxiliary loss is weighted by a constant coefficient $\lambda \in \mathbb { R }$
47
+
48
+ In Figure 2 we illustrate the impact of Noisy Nodes on oversmoothing by plotting the Mean Absolute Distance (MAD) (Chen et al., 2020) of the residual updates of each layer of an MPNN trained on the QM9 (Ramakrishnan et al., 2014) dataset, and compare it to alternative methods DropEdge (Rong et al., 2019) and DropNode (Do et al., 2021). MAD is a measure of the diversity of graph node features, often used to quantify oversmoothing, the higher the number the more diverse the node features, the lower the number the less diverse. In this plot we can see that for Noisy Nodes the node updates remain diverse for all of the layers, whereas without Noisy Nodes diversity is lost. Further analysis of MAD across seeds and with sorted layers can be seen in Appendix Figures 7 and 6 for models applied to 3D point clouds.
49
+
50
+ The Graph Manifold Learning Perspective. By using an implicit mapping from corrupted data to clean data, the Noisy Nodes objective encourages the model to learn the manifold on which the clean data lies— we speculate that the GNN learns to go from low probability graphs to high probability graphs. In the autoencoder case the GNN learns the manifold of the input data. When node targets are provided, the GNN learns the manifold of the target data (e.g. the manifold of atoms at equilibrium). We speculate that such a manifold may include commonly repeated substructures that are useful for downstream prediction tasks. A similar motivation can be found for denoising in (Vincent et al., 2010; Song & Ermon, 2019).
51
+
52
+ The Energy Perspective for Molecular Property Prediction. Local, random distortions of the geometry of a molecule at a local energy minimum are almost certainly higher energy configurations. As such, a task that maps from a noised molecule to a local energy minimum is learning a mapping from high energy to low energy. Data such as QM9 contains molecules at local minima.
53
+
54
+ Some problems have input data that is already high energy, and targets that are at equilibrium. For these datasets we can generate new high energy states by adding noise to the inputs but keeping the equilibrium target the same, Figure 1 demonstrates this approach. To preserve translation invariance we use displacements between input and target $\Delta$ , the corrected target after noise is $\Delta - \sigma$ .
55
+
56
+ # 5 RELATED WORK
57
+
58
+ Oversmoothing. Recent work has aimed to understand why it is challenging to realise the benefits of training deeper GNNs (Wu et al., 2020). Since first being noted in ((Li et al., 2018)) oversmoothing has been studied extensively and regularisation techniques have been suggested to overcome it (Chen et al., 2019; Cai & Wang, 2020; Rong et al., 2019; Zhou et al., 2020b; Yang et al., 2020; Do et al., 2021; Zhao & Akoglu, 2020). A recent paper, (Li et al., 2021), finds, as in previous work, (Li et al., 2019; 2020), the optimal depth for some datasets they evaluate on to be far lower (5 for OGBN-Arxiv from the Open Graph Benchmark (Hu et al., 2020a), for example) than the 1000 layers possible.
59
+
60
+ Denoising & Noise Models. Training neural networks with noise has a long history (Sietsma & Dow, 1991; Bishop, 1995). Of particular relevance are Denoising Autoencoders (Vincent et al., 2008) in which an autoencoder is trained to map corrupted inputs $\tilde { \mathbf { x } }$ to uncorrupted inputs $\mathbf { X }$ . Denoising Autoencoders have found particular success as a form of pre-training for representation learning (Vincent et al., 2010). More recently, in research applying GNNs to simulation (Sanchez-Gonzalez et al., 2018; Sanchez-Gonzalez\* et al., 2020; Pfaff et al., 2020) Gaussian noise is added during training to input positions of a ground truth simulator to mimic the distribution of errors of the learned simulator. Pre-training methods (Devlin et al., 2019; You et al., 2020; Thakoor et al., 2021) are another similar approach; most similarly to our method Hu et al. (2020b) apply a reconstruction loss to graphs with masked nodes to generate graph embeddings for use in downstream tasks. FLAG (Kong et al., 2020) adds adversarial noise during training to input node features as a form of data augmentation for GNNs that demonstrates improved performance for many tasks. It does not add an additional auxiliary loss, which we find is essential for addressing oversmoothing. In other related GNN work, (Sato et al., 2021) use random input features to improve generalisation of graph neaural networks. Adding noise to help input node disambiguation has also been covered in (Dasoulas et al., 2019; Loukas, 2020; Vignac et al., 2020; Murphy et al., 2019), but there is no auxiliary loss.
61
+
62
+ Finally, we take inspiration from (Vincent et al., 2008; 2010; Vincent, 2011; Song & Ermon, 2019) which use the observation that noised data lies off the data manifold for representation learning and generative modelling.
63
+
64
+ Machine Learning for 3D Molecular Property Prediction. One application of GNNs is to speed up quantum chemistry calculations which operate on 3D positions of a molecule (Duvenaud et al., 2015; Gilmer et al., 2017; Schütt et al., 2017; Hu et al., 2021b). Common goals are the prediction of molecular properties (Ramakrishnan et al., 2014), forces (Chmiela et al., 2017), energies (Chanussot\* et al., 2020) and charges (Unke & Meuwly, 2019).
65
+
66
+ A common approach to embed physical symmetries is to design a network that predicts a rotation and translation invariant energy (Schütt et al., 2017; Klicpera et al., 2020a; Liu et al., 2021). The input features of such models include distances (Schütt et al., 2017), angles (Klicpera et al., 2020b;a) or torsions and higher order terms (Liu et al., 2021). An alternative approach to embedding symmetries is to design a rotation equivariant neural network that use equivariant representations (Thomas et al., 2018; Köhler et al., 2019; Kondor et al., 2018; Fuchs et al., 2020; Batzner et al., 2021; Anderson et al., 2019; Satorras et al., 2021).
67
+
68
+ Machine Learning for Bond and Atom Molecular Graphs. Predicting properties from molecular graphs without 3D points, such as graphs of bonds and atoms, is studied separately and often used to benchmark generic graph property prediction models such as GCNs (Hu et al., 2020a) or GATs (Velickovi ˇ c et al., 2018). Models developed for 3D molecular property prediction cannot be applied ´ to bond and atom graphs. Common datasets that contain such data are OGBG-MOLPCBA and OGBG-MOLHIV.
69
+
70
+ # 6 3D MOLECULAR PROPERTY PREDICTION EXPERIMENTS AND RESULTS
71
+
72
+ In this section we evaluate how a popular, simple model, the GNS (Sanchez-Gonzalez\* et al., 2020) performs on 3D molecular prediction tasks when combined with Noisy Nodes. The GNS was originally developed for particle fluid simulations, but has recently been adapted for molecular property prediction (Hu et al., 2021b). We find that Without Noisy Nodes the GNS architecture is not competitive, but by using Noisy Nodes we see improved performance comparable to the use of specialised architectures.
73
+
74
+ We made minor changes to the GNS architecture. We featurise the distance input features using radial basis functions. We group layer weights, similar to grouped layers used in Jumper et al. (2021) for reduced parameter counts; for a group size of $n$ the first $n$ layer weights are repeated, i.e. the first layer with a group size of 10 has the same weights as the $1 1 ^ { t h }$ , $2 1 ^ { s t }$ , $3 1 ^ { s t }$ layers and so on. $n$ contiguous blocks of layers are considered a single group. Finally we find that decoding the intermediate latents and adding a loss after each group aids training stability. The decoder is shared across groups.
75
+
76
+ ![](images/5efaa6e41a8dc4e467e193db6b0773e8c0e5b0fe814b747533de08946897ae36.jpg)
77
+ Figure 3: Validation curves, OC20 IS2RE ID. A) Without any node targets our model has poor performance and realises no benefit from depth. B) After adding a position node loss, performance improves as depth increases. C) As we add Noisy Nodes and parameters the model achieves SOTA, even with 3 layers, and stops overfitting. D) Adding Noisy Nodes allows a model with even fully shared weights to achieve SOTA.
78
+
79
+ We tested this architecture on three challenging molecular property prediction benchmarks: OC20 (Chanussot\* et al., 2020) IS2RS & IS2RE, and QM9 (Ramakrishnan et al., 2014). These benchmarks are detailed below, but as general distinctions, OC20 tasks use graphs $2 \mathrm { - } 2 0 \mathrm { x }$ larger than QM9. While QM9 always requires graph-level prediction, one of OC20’s two tasks (IS2RS) requires node-level predictions while the other (IS2RE) requires graph-level predictions. All training details may be found in the Appendix.
80
+
81
+ # 6.1 OPEN CATALYST 2020
82
+
83
+ Dataset. The OC20 dataset (Chanussot\* et al., 2020) (CC Attribution 4.0) describes the interaction of a small molecule (the adsorbate) and a large slab (the catalyst), with total systems consisting of 20-200 atoms simulated until equilibrium is reached.
84
+
85
+ We focus on two tasks; the Initial Structure to Resulting Energy (IS2RE) task which takes the initial structure of the simulation and predicts the final energy, and the Initial Structure to Resulting Structure (IS2RS) which takes the initial structure and predicts the relaxed structure. Note that we train the more common “direct” prediction task that map directly from initial positions to target in a single forward pass, and compare against other models trained for direct prediction.
86
+
87
+ Models are evaluated on 4 held out test sets. Four canonical validation datasets are also provided. Test sets are evaluated on a remote server hosted by the dataset authors with a very limited number of submissions per team.
88
+
89
+ Noisy Nodes in this case consists of a random jump between the initial position and relaxed position. During training we first sample uniformly from a point in the relaxation trajectory or interpolate uniformly between the initial and final positions $( v _ { i } - \tilde { v } _ { i } ) \gamma , \gamma \sim \mathrm { U } ( 0 , 1 )$ , and then add I.I.D Gaussian noise with mean zero and $\sigma = 0 . 3$ . The Noisy Node target is the relaxed structure.
90
+
91
+ Table 1: OC20 ISRE Validation, eV MAE, ↓. “GNS-Shared” indicates shared weights. “GNS-10” indicates a group size of 10.
92
+
93
+ <table><tr><td>Model</td><td>Layers</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>GNS</td><td>50</td><td>0.59 ±0.01</td><td>0.65 ±0.01</td><td>0.55 ±0.00</td><td>0.54 ±0.00</td></tr><tr><td>GNS-Shared + Noisy Nodes</td><td>50</td><td>0.49 ±0.00</td><td>0.54 ±0.00</td><td>0.51 ±0.01</td><td>0.51 ±0.01</td></tr><tr><td>GNS + Noisy Nodes</td><td>50</td><td>0.48 ±0.00</td><td>0.53 ±0.00</td><td>0.49 ±0.01</td><td>0.48 ±0.00</td></tr><tr><td>GNS-10 + Noisy Nodes</td><td>100</td><td>0.46±0.00</td><td>0.51 ±0.00</td><td>0.48 ±0.00</td><td>0.47 ±0.00</td></tr></table>
94
+
95
+ Table 2: Results OC20 IS2RE Test
96
+
97
+ <table><tr><td colspan="6">eV MAE↓</td></tr><tr><td></td><td>SchNet</td><td>DimeNet++</td><td>SpinConv</td><td>SphereNet</td><td>GNS + Noisy Nodes</td></tr><tr><td>OOD Both</td><td>0.704</td><td>0.661</td><td>0.674</td><td>0.638</td><td>0.465 (-24.0%)</td></tr><tr><td>OOD Adsorbate</td><td>0.734</td><td>0.725</td><td>0.723</td><td>0.703</td><td>0.565 (-22.8%)</td></tr><tr><td>OOD Catalyst</td><td>0.662</td><td>0.576</td><td>0.569</td><td>0.571</td><td>0.437 (-17.2%)</td></tr><tr><td>ID</td><td>0.639</td><td>0.562</td><td>0.558</td><td>0.563</td><td>0.422 (-18.8%)</td></tr><tr><td colspan="6">Average Energy within Threshold (AEwT) ↑</td></tr><tr><td></td><td>SchNet</td><td>DimeNet++</td><td>SpinConv</td><td>SphereNet</td><td>GNS + Noisy Nodes</td></tr><tr><td>OOD Both</td><td>0.0221</td><td>0.0241</td><td>0.0233</td><td>0.0241</td><td>0.047 (+95.8%)</td></tr><tr><td>OOD Adsorbate</td><td>0.0233</td><td>0.0207</td><td>0.026</td><td>0.0229</td><td>0.035 (+89.5%)</td></tr><tr><td>OOD Catalyst</td><td>0.0294</td><td>0.0410</td><td>0.0382</td><td>0.0409</td><td>0.080 (+95.1%)</td></tr><tr><td>ID</td><td>0.0296</td><td>0.0425</td><td>0.0408</td><td>0.0447</td><td>0.091 (+102.0%)</td></tr></table>
98
+
99
+ We first convert to fractional coordinates (i.e. use the periodic unit cell as the basis) which render the predictions of our model invariant to rotations, and append the following rotation and translation invariant vector $( \alpha \beta ^ { T } , \beta \gamma ^ { T } , \alpha \gamma ^ { T } , | \alpha | , | \beta | , | \gamma | ) \in \mathbb { R } ^ { 6 }$ to the edge features where $\alpha , \beta , \gamma$ are vectors of the unit cell. This additional vector provides rotation invariant angular and extent information to the GNN.
100
+
101
+ IS2RE Results. In Figure 3 we show how using Noisy Nodes allows the GNS to achieve state of the art performance. Figure $_ { 3 \mathrm { ~ A ~ } }$ shows that without any auxiliary node target, an IS2RE GNS achieves poor performance even with increased depth. The fact that increased depth does not result in improvement supports the hypothesis that GNS suffers from oversmoothing. As we add a node level position target in B) we see better performance, and improvement as depth increases, validating our hypothesis that node level targets are key to addressing oversmoothing. In C) we add noisy nodes and parameters, and see that the increased diversity of the node level predictions leads to very significant improvements and SOTA, even for a shallow 3 layer network. D) demonstrates this effect is not just due to increased parameters - SOTA can still be achieve with shared layer weights .
102
+
103
+ In Table 1 we conduct an ablation on our hyperparameters, and again demonstrate the improved performance of using Noisy Nodes. Results were averaged over 3 seeds and standard errors on the best obtained checkpoint show little sensitivity to initialisation. All results in the table are reported using sampling states from trajectories. We conducted an ablation on ID comparing sampling from a relaxation trajectory and interpolating between initial & final positions which found that interpolation improved our score from 0.47 to 0.45.
104
+
105
+ Our best hyperparameter setting was 100 layers which achieved a $9 5 . 6 \%$ relative performance improvement against SOTA results (Table 2) on the AEwT benchmark. Due to limited permitted test submissions, results presented here were from one test upload of our best performing validation seed.
106
+
107
+ IS2RS Results. In Table 4 we see that GNS $^ +$ Noisy Nodes is significantly better than the only other reported IS2RS direct result, ForceNet, itself a GNS variant.
108
+
109
+ Table 3: OC20 IS2RS Validation, ADwT, ↑
110
+
111
+ <table><tr><td>Model</td><td>Layers</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>GNS</td><td>50</td><td>43.0%±0.0</td><td>38.0%±0.0</td><td>37.5% 0.0</td><td>40.0%±0.0</td></tr><tr><td>GNS + Noisy Nodes</td><td>50</td><td>50.1%±0.0</td><td>44.3%±0.0</td><td>44.1%±0.0</td><td>46.1% ±0.0</td></tr><tr><td>GNS-10 + Noisy Nodes</td><td>50</td><td>52.0%±0.0</td><td>46.2%±0.0</td><td>46.1% ±0.0</td><td>48.3% ±0.0</td></tr><tr><td>GNS-10 + Noisy Nodes + Pos only</td><td>100</td><td>54.3%±0.0</td><td>48.3%±0.0</td><td>48.2% ±0.0</td><td>50.0% ±0.0</td></tr></table>
112
+
113
+ Table 4: OC20 IS2RS Test, ADwT, ↑
114
+
115
+ <table><tr><td>Model</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>ForceNet</td><td>46.9%</td><td>37.7%</td><td>43.7%</td><td>44.9%</td></tr><tr><td>GNS + Noisy Nodes</td><td> 52.7%</td><td>43.9%</td><td>48.4%</td><td> 50.9%</td></tr><tr><td>Relative Improvement</td><td>+12.4%</td><td>+16.4%</td><td>+10.7%</td><td>+13.3%</td></tr></table>
116
+
117
+ # 6.2 QM9
118
+
119
+ Dataset. The QM9 benchmark (Ramakrishnan et al., 2014) contains $1 3 4 \mathrm { k }$ molecules in equilibrium with up to 9 heavy C, O, N and F atoms, targeting 12 associated chemical properties (License: CCBY 4.0). We use 114k molecules for training, 10k for validation and 10k for test. All results are on the test set. We subtract a fixed per atom energy from the target values computed from linear regression to reduce variance. We perform training in $\mathbf { e V }$ units for energetic targets, and evaluate using MAE. We summarise the results across the targets using mean standardised MAE (std. MAE) in which MAEs are normalised by their standard deviation, and mean standardised logMAE. Std. MAE is dominated by targets with high relative error such as $\Delta \epsilon$ , whereas logMAE is sensitive to outliers such as $\left. R ^ { 2 } \right.$ . As is standard for this dataset, a model is trained separately for each target.
120
+
121
+ For this dataset we add I.I.D Gaussian noise with mean zero and $\sigma = 0 . 0 2$ to the input atom positions.
122
+ A denoising autoencoder loss is used.
123
+
124
+ Results In Table 6 we can see that adding Noisy Nodes significantly improves results by $2 3 . 1 \%$ relative for GNS, making it competitive with specialised architectures. To understand the effect of adding a denoising loss, we tried just adding noise and found no where near the same improvement (Table 6).
125
+
126
+ A GNS- $1 0 +$ Noisy Nodes with 30 layers achieves top results on 3 of the 12 targets and comparable performance on the remainder (Table 6). On the std. MAE aggregate metric $\mathrm { G N S + }$ Noisy Nodes performs better than all other reported results, showing that Noisy Nodes can make even a generic model competitive with models hand-crafted for molecular property prediction. The same trend is repeated for an rotation invariant version of this network that uses the principle axes of inertia ordered by eigenvalue as the co-ordinate frame (Table 5).
127
+
128
+ $\left. R ^ { 2 } \right.$ , the electronic spatial extent, is an outlier for GNS + Noisy Nodes. Interestingly, we found that without noise GNS- $^ { 1 0 + }$ Noisy Nodes achieves 0.33 for this target. We speculate that this target is particularly sensitive to noise, and the best noise value for this target would be significantly lower than for the dataset as a whole.
129
+
130
+ Table 5: QM9, Impact of Noisy Nodes on GNS architecture.
131
+
132
+ <table><tr><td></td><td>Layers</td><td>std. MAE</td><td>% Change</td><td>logMAE</td></tr><tr><td>GNS</td><td>10</td><td>1.17</td><td>=</td><td>-5.39</td></tr><tr><td>GNS + Noise But No Node Target</td><td>10</td><td>1.16</td><td>-0.9%</td><td>-5.32</td></tr><tr><td>GNS + Noisy Nodes</td><td>10</td><td>0.90</td><td>-23.1%</td><td>-5.58</td></tr><tr><td>GNS-10 + Noisy Nodes</td><td>20</td><td>0.89</td><td>-23.9%</td><td>-5.59</td></tr><tr><td>GNS-1O + Noisy Nodes + Invariance</td><td>30</td><td>0.92</td><td>-21.4%</td><td>-5.57</td></tr><tr><td>GNS-10 + Noisy Nodes</td><td>30</td><td>0.88</td><td>-24.8%</td><td>-5.60</td></tr></table>
133
+
134
+ Table 6: QM9, Test MAE, Mean & Standard Deviation of 3 Seeds Reported.
135
+
136
+ <table><tr><td>Target</td><td>Unit</td><td>SchNet</td><td>E(n)GNN</td><td>DimeNet++</td><td>SphereNet</td><td>PaiNN</td><td>GNS + Noisy Nodes</td></tr><tr><td>μ</td><td>D</td><td>0.033</td><td>0.029</td><td>0.030</td><td>0.027</td><td>0.012</td><td>0.025 ±0.01</td></tr><tr><td>α</td><td>a03</td><td>0.235</td><td>0.071</td><td>0.043</td><td>0.047</td><td>0.045</td><td>0.052 ±0.00</td></tr><tr><td>EHOMO</td><td>meV</td><td>41</td><td>29.0</td><td>24.6</td><td>23.6</td><td>27.6</td><td>20.4 ±0.2</td></tr><tr><td>ELUMO</td><td>meV</td><td>34</td><td>25.0</td><td>19.5</td><td>18.9</td><td>20.4</td><td>18.6 ±0.4</td></tr><tr><td>△</td><td>meV</td><td>63</td><td>48.0</td><td>32.6</td><td>32.3</td><td>45.7</td><td>28.6 ±0.1</td></tr><tr><td>(R²&gt;</td><td>a02</td><td>0.07</td><td>0.11</td><td>0.33</td><td>0.29</td><td>0.07</td><td>0.70 ±0.01</td></tr><tr><td>ZPVE</td><td>meV</td><td>1.7</td><td>1.55</td><td>1.21</td><td>1.12</td><td>1.28</td><td>1.16 ±0.01</td></tr><tr><td>Uo</td><td>meV</td><td>14.00</td><td>11.00</td><td>6.32</td><td>6.26</td><td>5.85</td><td>7.30 ±0.12</td></tr><tr><td>U</td><td>meV</td><td>19.00</td><td>12.00</td><td>6.28</td><td>7.33</td><td>5.83</td><td>7.57 ±0.03</td></tr><tr><td>H</td><td>meV</td><td>14.00</td><td>12.00</td><td>6.53</td><td>6.40</td><td>5.98</td><td>7.43±0.06</td></tr><tr><td>G</td><td>meV cal</td><td>14.00</td><td>12.00</td><td>7.56</td><td>8.0</td><td>7.35</td><td>8.30 ±0.14</td></tr><tr><td>Cv</td><td>molK</td><td>0.033</td><td>0.031</td><td>0.023</td><td>0.022</td><td>0.024</td><td>0.025 ±0.00</td></tr><tr><td>std. MAE</td><td>%</td><td>1.76</td><td>1.22</td><td>0.98</td><td>0.94</td><td>1.00</td><td>0.88</td></tr><tr><td>logMAE</td><td></td><td>-5.17</td><td>-5.43</td><td>-5.67</td><td>-5.68</td><td>-5.85</td><td>-5.60</td></tr></table>
137
+
138
+ Table 7: OGBG-PCQM4M Results
139
+
140
+ <table><tr><td>Model</td><td>Number of Layers</td><td>Using I Noisy Nodes</td><td>MAE</td></tr><tr><td>MPNN + Virtual Node</td><td>16</td><td>Yes</td><td>0.1249 ± 0.0003</td></tr><tr><td>MPNN+Virtual Node</td><td>50</td><td>No</td><td>0.1236 ± 0.0001</td></tr><tr><td>Graphormer (Ying et al., 2021)</td><td>1</td><td>1</td><td>0.1234</td></tr><tr><td>MPNN + Virtual Node</td><td>50</td><td>Yes</td><td>0.1218 ± 0.0001</td></tr></table>
141
+
142
+ # 7 NON-SPATIAL TASKS
143
+
144
+ The previous experiments use the 3D geometries of atoms, and models that operate on 3D points. However, the recipe of adding a denoising auxiliary loss can be applied to other graphs with different types of features. In this section we apply Noisy Nodes to additional datasets with no 3D points, using different GNNs, and show analagous effects to the 3D case. Details of the hyperparameters, models and training details can be found in the appendix.
145
+
146
+ # 7.1 OGBG-PCQM4M
147
+
148
+ This dataset from the OGB benchmarks consists of molecular graphs which consist of bonds and atom types, and no 3D or 2D coordinates. To adapt Noisy Nodes to this setting, we randomly flip node and edge features at a rate of $5 \%$ and add a reconstruction loss. We evaluate Noisy Nodes using an MPNN $^ +$ Virtual Node (Gilmer et al., 2017). The test set is not currently available for this dataset.
149
+
150
+ In Table 7 we see that for this task Noisy Nodes enables a 50 layer MPNN to reach state of the art results. Before adding Noisy Nodes, adding capacity beyond 16 layers did not improve results.
151
+
152
+ # 7.2 OGBG-MOLPCBA
153
+
154
+ The OGBG-MOLPCBA dataset contains molecular graphs with no 3D points, with the goal of classifying 128 biological activities. On the OGBG-MOLPCBA dataset we again use an $\mathbf { M P N N + }$ Virtual Node and random flipping noise. In Figure 4 we see that adding Noisy Nodes improves the performance of the base model, accentuated for deeper networks. Our 16 layer MPNN improved from $2 7 . 6 \% \pm 0 . 0 0 4$ to $2 8 . 1 \% \pm 0 . 0 0 2$ Mean Average Precision (“Mean AP”). Figure 5 demonstrates how Noisy Nodes improves performance during training. Of the reported results, our MPNN is most similar to $\mathrm { G C N ^ { 1 } \Sigma + }$ Virtual Node and $\mathrm { G I N } +$ Virtual Node (Xu et al., 2018) which report results of $2 4 . 2 \% \pm 0 . 0 0 3$ and $2 7 . 0 3 \% \pm 0 . 0 0 3$ respectively. We evaluate alternative methods for oversmoothing, DropNode and DropEdge in Figure 2 and find that Noisy Nodes is more effective at address oversmoothing, although all 3 methods can be combined favourably (results in appendix).
155
+
156
+ ![](images/57ba876e022cd007dd51858c1a902699202bbf32b42279871e90436d20b8f8ca.jpg)
157
+ Figure 4: Adding Noisy Nodes with random flipping of input categories improves the performance of MPNNs, and the effect is accentuated with depth.
158
+
159
+ ![](images/7bfe2ea3e2eda99fc6bd566bd30c775ccfd387055396f4da3a1e2401fb68e4f8.jpg)
160
+ Figure 5: Validation curve comparing with and without noisy nodes. Using Noisy Nodes leads to a consistent improvement.
161
+
162
+ # 7.3 OGBN-ARXIV
163
+
164
+ The above results use models with explicit edge updates, and are reported for graph prediction. To test the effectiveness with Noisy Nodes with GCNs, arguably the simplest and most popular GNN, we use OGBN-ARXIV, a citation network with the goal of predicting the arxiv category of each paper. Adding Noisy Nodes, with noise as input dropout of 0.1, to 4 layer GCN with residual connections improves from $7 2 . 3 9 \% \pm 0 . 0 0 2$ accuracy to $7 2 . 5 2 \% \pm 0 . 0 0 3$ accuracy. A baseline 4 layer GCN on this dataset reports $7 1 . 7 1 \% \pm 0 . 0 0 2$ . The SOTA for this dataset is $7 4 . 3 1 \%$ (Sun & Wu, 2020).
165
+
166
+ # 7.4 LIMITATIONS
167
+
168
+ We have not demonstrated the effectiveness of Noisy Nodes in small data regimes, which may be important for learning from experimental data. The representation learning perspective requires access to a local minimum configuration, which is not the case for all quantum modeling datasets. We have also not demonstrated the combination of Noisy Nodes with more sophisticated 3D molecular property prediction models such as DimeNet++(Klicpera et al., 2020a), such models may require an alternative reconstruction loss to position change, such as pairwise interatomic distances. We leave this to future work.
169
+
170
+ Noisy Nodes requires careful selection of the form of noise, and a balance between the auxiliary and primary losses. This can require hyper parameter tuning, and models can be sensitive to the choice of these parameters. Noisy Nodes has a particular effect for deep GNNs, but depth is not always an advantage. There are situations, for example molecular dynamics, which place a premium on very fast inference time. However even at 3 layers (a comparable depth to alternative architectures) the GNS architecture achieves state of the art validation OC20 IS2RE predictions (Figure 3). Finally, returns diminish as depth increases indicating depth is not the only answer (Table 1).
171
+
172
+ # 8 CONCLUSIONS
173
+
174
+ In this work we present Noisy Nodes, a novel regularisation technique for GNNs with particular focus on 3D molecular property prediction. Noisy nodes helps address common challenges around oversmoothed node representations, shows benefits for GNNs of all depths, but in particular improves performance for deeper GNNs. We demonstrate results on challenging 3D molecular property prediction tasks, and some generic GNN benchmark datasets. We believe these results demonstrate Noisy Nodes could be a useful building block for GNNs for molecular property prediction and beyond.
175
+
176
+ # 9 REPRODUCIBILITY STATEMENT
177
+
178
+ Code for reproducing OGB-PCQM4M results using Noisy Nodes is available on github, and was prepared as part of a leaderboard submission. https://github.com/deepmind/ deepmind-research/tree/master/ogb_lsc/pcq.
179
+
180
+ We provide detailed hyper parameter settings for all our experiments in the appendix, in addition to formulae for computing the encoder and decoder stages of the GNS.
181
+
182
+ # 10 ETHICS STATEMENT
183
+
184
+ Who may benefit from this work? Molecular property prediction with GNNs is a fast-growing area with applications across domains such as drug design, catalyst discovery, synthetic biology, and chemical engineering. Noisy Nodes could aid models applied to these domains. We also demonstrate on OC20 that our direct state prediction approach is nearly as accurate as learned relaxed approaches at a small fraction of the computational cost, which may support material design which requires many predictions.
185
+
186
+ Finally, Noisy Nodes could be adapted and applied to many areas in which GNNs are used—for example, knowledge base completion, physical simulation or traffic prediction.
187
+
188
+ Potential negative impact and reflection. Noisy Nodes sees improved performance from depth, but the training of very deep GNNs could contribute to global warming. Care should be taken when utilising depth, and we note that Noisy Nodes settings can be calibrated at shallow depth.
189
+
190
+ # REFERENCES
191
+
192
+ Brandon M. Anderson, T. Hy, and R. Kondor. Cormorant: Covariant molecular neural networks. In NeurIPS, 2019.
193
+
194
+ Igor Babuschkin, Kate Baumli, Alison Bell, Surya Bhupatiraju, Jake Bruce, Peter Buchlovsky, David Budden, Trevor Cai, Aidan Clark, Ivo Danihelka, Claudio Fantacci, Jonathan Godwin, Chris Jones, Tom Hennigan, Matteo Hessel, Steven Kapturowski, Thomas Keck, Iurii Kemaev, Michael King, Lena Martens, Vladimir Mikulik, Tamara Norman, John Quan, George Papamakarios, Roman Ring, Francisco Ruiz, Alvaro Sanchez, Rosalia Schneider, Eren Sezener, Stephen Spencer, Srivatsan Srinivasan, Wojciech Stokowiec, and Fabio Viola. The DeepMind JAX Ecosystem, 2020. URL http://github.com/deepmind.
195
+
196
+ V. Bapst, T. Keck, Agnieszka Grabska-Barwinska, C. Donner, E. D. Cubuk, S. Schoenholz, A. Obika, Alexander W. R. Nelson, T. Back, D. Hassabis, and P. Kohli. Unveiling the predictive power of static structure in glassy systems. Nature Physics, 16:448–454, 2020.
197
+
198
+ P. Battaglia, Jessica B. Hamrick, V. Bapst, A. Sanchez-Gonzalez, V. Zambaldi, Mateusz Malinowski, Andrea Tacchetti, David Raposo, A. Santoro, R. Faulkner, Çaglar Gülçehre, H. Song, A. J. Ballard, J. Gilmer, George E. Dahl, Ashish Vaswani, Kelsey R. Allen, Charlie Nash, Victoria Langston, Chris Dyer, N. Heess, Daan Wierstra, P. Kohli, M. Botvinick, Oriol Vinyals, Y. Li, and Razvan Pascanu. Relational inductive biases, deep learning, and graph networks. ArXiv, abs/1806.01261, 2018.
199
+
200
+ Simon Batzner, T. Smidt, L. Sun, J. Mailoa, M. Kornbluth, N. Molinari, and B. Kozinsky. Se(3)- equivariant graph neural networks for data-efficient and accurate interatomic potentials. ArXiv, abs/2101.03164, 2021.
201
+
202
+ Charles M. Bishop. Training with noise is equivalent to tikhonov regularization. Neural Computation, 7:108–116, 1995.
203
+
204
+ James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/google/jax.
205
+
206
+ Michael M Bronstein, Joan Bruna, Yann LeCun, Arthur Szlam, and Pierre Vandergheynst. Geometric deep learning: going beyond euclidean data. IEEE Signal Processing Magazine, 34(4):18–42, 2017.
207
+
208
+ T. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, J. Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, T. Henighan, R. Child, A. Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, J. Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. ArXiv, abs/2005.14165, 2020.
209
+
210
+ Chen Cai and Yusu Wang. A note on over-smoothing for graph neural networks. CoRR, abs/2006.13318, 2020. URL https://arxiv.org/abs/2006.13318.
211
+
212
+ Lowik Chanussot\*, Abhishek Das\*, Siddharth Goyal\*, Thibaut Lavril\*, Muhammed Shuaibi\*, Morgane Riviere, Kevin Tran, Javier Heras-Domingo, Caleb Ho, Weihua Hu, Aini Palizhati, Anuroop Sriram, Brandon Wood, Junwoong Yoon, Devi Parikh, C. Lawrence Zitnick, and Zachary Ulissi. Open catalyst 2020 (oc20) dataset and community challenges. ACS Catalysis, 0(0): 6059–6072, 2020. doi: 10.1021/acscatal.0c04525. URL https://doi.org/10.1021/ acscatal.0c04525.
213
+
214
+ Deli Chen, Yankai Lin, Wei Li, Peng Li, Jie Zhou, and Xu Sun. Measuring and relieving the oversmoothing problem for graph neural networks from the topological view. CoRR, abs/1909.03211, 2019. URL http://arxiv.org/abs/1909.03211.
215
+
216
+ Deli Chen, Yankai Lin, W. Li, Peng Li, J. Zhou, and Xu Sun. Measuring and relieving the oversmoothing problem for graph neural networks from the topological view. In AAAI, 2020.
217
+
218
+ Stefan Chmiela, A. Tkatchenko, H. E. Sauceda, I. Poltavsky, Kristof T. Schütt, and K. Müller. Machine learning of accurate energy-conserving molecular force fields. Science Advances, 3, 2017.
219
+
220
+ George Dasoulas, Ludovic Dos Santos, Kevin Scaman, and Aladin Virmaux. Coloring graph neural networks for node disambiguation. ArXiv, abs/1912.06058, 2019.
221
+
222
+ J. Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT, 2019.
223
+
224
+ Tien Huu Do, Duc Minh Nguyen, Giannis Bekoulis, Adrian Munteanu, and N. Deligiannis. Graph convolutional neural networks with node transition probability-based message passing and dropnode regularization. Expert Syst. Appl., 174:114711, 2021.
225
+
226
+ David Duvenaud, Dougal Maclaurin, Jorge Aguilera-Iparraguirre, Rafael Gómez-Bombarelli, Timothy Hirzel, Alán Aspuru-Guzik, and Ryan P. Adams. Convolutional networks on graphs for learning molecular fingerprints. In Proceedings of the 28th International Conference on Neural Information Processing Systems - Volume 2, NIPS’15, pp. 2224–2232, Cambridge, MA, USA, 2015. MIT Press.
227
+
228
+ F. Fuchs, Daniel E. Worrall, Volker Fischer, and M. Welling. Se(3)-transformers: 3d roto-translation equivariant attention networks. ArXiv, abs/2006.10503, 2020.
229
+
230
+ J. Gilmer, S. Schoenholz, Patrick F. Riley, Oriol Vinyals, and George E. Dahl. Neural message passing for quantum chemistry. ArXiv, abs/1704.01212, 2017.
231
+
232
+ Jonathan Godwin\*, Thomas Keck\*, Peter Battaglia, Victor Bapst, Thomas Kipf, Yujia Li, Kimberly Stachenfeld, Petar Velickovi ˇ c, and Alvaro Sanchez-Gonzalez. Jraph: A library for graph neural ´ networks in jax., 2020. URL http://github.com/deepmind/jraph.
233
+
234
+ Tom Hennigan, Trevor Cai, Tamara Norman, and Igor Babuschkin. Haiku: Sonnet for JAX, 2020. URL http://github.com/deepmind/dm-haiku.
235
+
236
+ Weihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong, Hongyu Ren, Bowen Liu, Michele Catasta, and Jure Leskovec. Open graph benchmark: Datasets for machine learning on graphs. ArXiv, abs/2005.00687, 2020a.
237
+
238
+ Weihua Hu, Bowen Liu, Joseph Gomes, M. Zitnik, Percy Liang, V. Pande, and J. Leskovec. Strategies for pre-training graph neural networks. arXiv: Learning, 2020b.
239
+
240
+ Weihua Hu, Matthias Fey, Hongyu Ren, Maho Nakata, Yuxiao Dong, and Jure Leskovec. Ogb-lsc: A large-scale challenge for machine learning on graphs. arXiv preprint arXiv:2103.09430, 2021a.
241
+
242
+ Weihua Hu, Muhammed Shuaibi, Abhishek Das, Siddharth Goyal, Anuroop Sriram, J. Leskovec, Devi Parikh, and C. L. Zitnick. Forcenet: A graph neural network for large-scale quantum calculations. ArXiv, abs/2103.01436, 2021b.
243
+
244
+ John M. Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Zídek, Anna Potapenko, Alex Bridgland, Clemens Meyer, Simon A A Kohl, Andy Ballard, Andrew Cowie, Bernardino RomeraParedes, Stanislav Nikolov, Rishub Jain, Jonas Adler, Trevor Back, Stig Petersen, David A. Reiman, Ellen Clancy, Michal Zielinski, Martin Steinegger, Michalina Pacholska, Tamas Berghammer, Sebastian Bodenstein, David Silver, Oriol Vinyals, Andrew W. Senior, Koray Kavukcuoglu, Pushmeet Kohli, and Demis Hassabis. Highly accurate protein structure prediction with alphafold. Nature, 596:583 – 589, 2021.
245
+
246
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. CoRR, abs/1412.6980, 2015.
247
+
248
+ Thomas N. Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. CoRR, abs/1609.02907, 2016. URL http://arxiv.org/abs/1609.02907.
249
+
250
+ Johannes Klicpera, Shankari Giri, Johannes T. Margraf, and Stephan Günnemann. Fast and uncertainty-aware directional message passing for non-equilibrium molecules. CoRR, abs/2011.14115, 2020a. URL https://arxiv.org/abs/2011.14115.
251
+
252
+ Johannes Klicpera, Janek Groß, and Stephan Günnemann. Directional message passing for molecular graphs. ArXiv, abs/2003.03123, 2020b.
253
+
254
+ Risi Kondor, Hy Truong Son, Horace Pan, Brandon M. Anderson, and Shubhendu Trivedi. Covariant compositional networks for learning graphs. CoRR, abs/1801.02144, 2018. URL http:// arxiv.org/abs/1801.02144.
255
+
256
+ Kezhi Kong, Guohao Li, Mucong Ding, Zuxuan Wu, Chen Zhu, Bernard Ghanem, G. Taylor, and T. Goldstein. Flag: Adversarial data augmentation for graph neural networks. ArXiv, abs/2010.09891, 2020.
257
+
258
+ Jonas Köhler, Leon Klein, and Frank Noé. Equivariant flows: sampling configurations for multi-body systems with symmetric energies, 2019.
259
+
260
+ G. Li, M. Müller, Ali K. Thabet, and Bernard Ghanem. Deepgcns: Can gcns go as deep as cnns? 2019 IEEE/CVF International Conference on Computer Vision (ICCV), pp. 9266–9275, 2019.
261
+
262
+ Guohao Li, C. Xiong, Ali K. Thabet, and Bernard Ghanem. Deepergcn: All you need to train deeper gcns. ArXiv, abs/2006.07739, 2020.
263
+
264
+ Guohao Li, Matthias Müller, Bernard Ghanem, and Vladlen Koltun. Training graph neural networks with 1000 layers. CoRR, abs/2106.07476, 2021. URL https://arxiv.org/abs/2106. 07476.
265
+
266
+ Qimai Li, Zhichao Han, and Xiao-Ming Wu. Deeper insights into graph convolutional networks for semi-supervised learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
267
+
268
+ Yi Liu, Limei Wang, Meng Liu, Xuan Zhang, Bora Oztekin, and Shuiwang Ji. Spherical message passing for 3d graph networks. arXiv preprint arXiv:2102.05013, 2021.
269
+
270
+ Andreas Loukas. How hard is to distinguish graphs with graph neural networks? arXiv: Learning, 2020.
271
+
272
+ Ryan L. Murphy, Balasubramaniam Srinivasan, Vinayak A. Rao, and Bruno Ribeiro. Relational pooling for graph representations. In ICML, 2019.
273
+ T. Pfaff, Meire Fortunato, Alvaro Sanchez-Gonzalez, and P. Battaglia. Learning mesh-based simulation with graph networks. ArXiv, abs/2010.03409, 2020.
274
+ R. Ramakrishnan, Pavlo O. Dral, M. Rupp, and O. A. von Lilienfeld. Quantum chemistry structures and properties of 134 kilo molecules. Scientific Data, 1, 2014.
275
+ Yu Rong, Wenbing Huang, Tingyang Xu, and Junzhou Huang. The truly deep graph convolutional networks for node classification. CoRR, abs/1907.10903, 2019. URL http://arxiv.org/ abs/1907.10903.
276
+ Alvaro Sanchez-Gonzalez, N. Heess, Jost Tobias Springenberg, J. Merel, Martin A. Riedmiller, R. Hadsell, and P. Battaglia. Graph networks as learnable physics engines for inference and control. ArXiv, abs/1806.01242, 2018.
277
+ Alvaro Sanchez-Gonzalez\*, Jonathan Godwin\*, Tobias Pfaff\*, Rex Ying\*, Jure Leskovec, and Peter Battaglia. Learning to simulate complex physics with graph networks. In Hal Daumé III and Aarti Singh (eds.), Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pp. 8459–8468. PMLR, 13–18 Jul 2020. URL http://proceedings.mlr.press/v119/sanchez-gonzalez20a.html.
278
+ R. Sato, Makoto Yamada, and Hisashi Kashima. Random features strengthen graph neural networks. In SDM, 2021.
279
+ Victor Garcia Satorras, Emiel Hoogeboom, and Max Welling. E(n) equivariant graph neural networks, 2021.
280
+ Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE Transactions on Neural Networks, 20(1):61–80, 2009. doi: 10.1109/TNN.2008.2005605.
281
+ Kristof Schütt, Pieter-Jan Kindermans, Huziel Enoc Sauceda Felix, Stefan Chmiela, A. Tkatchenko, and K. Müller. Schnet: A continuous-filter convolutional neural network for modeling quantum interactions. In NIPS, 2017.
282
+ Jonathan Shlomi, Peter Battaglia, and Jean-Roch Vlimant. Graph neural networks in particle physics. Machine Learning: Science and Technology, 2(2):021001, Jan 2021. ISSN 2632-2153. doi: 10.1088/2632-2153/abbf9a. URL http://dx.doi.org/10.1088/2632-2153/abbf9a.
283
+ J. Sietsma and Robert J. F. Dow. Creating artificial neural networks that generalize. Neural Networks, 4:67–79, 1991.
284
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. ArXiv, abs/1907.05600, 2019.
285
+ Chuxiong Sun and Guoshi Wu. Adaptive graph diffusion networks with hop-wise attention. ArXiv, abs/2012.15024, 2020.
286
+ Shantanu Thakoor, C. Tallec, M. G. Azar, R. Munos, Petar Velivckovi’c, and Michal Valko. Bootstrapped representation learning on graphs. ArXiv, abs/2102.06514, 2021.
287
+ Nathaniel Thomas, Tess Smidt, Steven M. Kearnes, Lusann Yang, Li Li, Kai Kohlhoff, and Patrick Riley. Tensor field networks: Rotation- and translation-equivariant neural networks for 3d point clouds. CoRR, abs/1802.08219, 2018. URL http://arxiv.org/abs/1802.08219.
288
+ Oliver T. Unke and Markus Meuwly. Physnet: A neural network for predicting energies, forces, dipole moments, and partial charges. Journal of Chemical Theory and Computation, 15(6):3678–3693, May 2019. ISSN 1549-9626. doi: 10.1021/acs.jctc.9b00181. URL http://dx.doi.org/10. 1021/acs.jctc.9b00181.
289
+ Ashish Vaswani, Noam M. Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. ArXiv, abs/1706.03762, 2017.
290
+ Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Liò, and Yoshua ´ Bengio. Graph attention networks, 2018.
291
+ Cl’ement Vignac, Andreas Loukas, and Pascal Frossard. Building powerful and equivariant graph neural networks with structural message-passing. arXiv: Learning, 2020.
292
+ Pascal Vincent. A connection between score matching and denoising autoencoders. Neural Computation, 23:1661–1674, 2011.
293
+ Pascal Vincent, H. Larochelle, Yoshua Bengio, and Pierre-Antoine Manzagol. Extracting and composing robust features with denoising autoencoders. In ICML ’08, 2008.
294
+ Pascal Vincent, H. Larochelle, Isabelle Lajoie, Yoshua Bengio, and Pierre-Antoine Manzagol. Stacked denoising autoencoders: Learning useful representations in a deep network with a local denoising criterion. J. Mach. Learn. Res., 11:3371–3408, 2010.
295
+ Zonghan Wu, Shirui Pan, Fengwen Chen, Guodong Long, Chengqi Zhang, and S Yu Philip. A comprehensive survey on graph neural networks. IEEE transactions on neural networks and learning systems, 2020.
296
+ Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? CoRR, abs/1810.00826, 2018. URL http://arxiv.org/abs/1810.00826.
297
+ Chaoqi Yang, Ruijie Wang, Shuochao Yao, Shengzhong Liu, and Tarek Abdelzaher. Revisiting" over-smoothing" in deep gcns. arXiv preprint arXiv:2003.13663, 2020.
298
+ Chengxuan Ying, Tianle Cai, Shengjie Luo, Shuxin Zheng, Guolin Ke, Di He, Yanming Shen, and Tie-Yan Liu. Do transformers really perform bad for graph representation? ArXiv, abs/2106.05234, 2021.
299
+ Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, and Yang Shen. Graph contrastive learning with augmentations. ArXiv, abs/2010.13902, 2020.
300
+ L. Zhao and Leman Akoglu. Pairnorm: Tackling oversmoothing in gnns. ArXiv, abs/1909.12223, 2020.
301
+ Jie Zhou, Ganqu Cui, Shengding Hu, Zhengyan Zhang, Cheng Yang, Zhiyuan Liu, Lifeng Wang, Changcheng Li, and Maosong Sun. Graph neural networks: A review of methods and applications. AI Open, 1:57–81, 2020a.
302
+ Kuangqi Zhou, Yanfei Dong, Wee Sun Lee, Bryan Hooi, Huan Xu, and Jiashi Feng. Effective training strategies for deep graph neural networks. CoRR, abs/2006.07107, 2020b. URL https: //arxiv.org/abs/2006.07107.
303
+
304
+ # A APPENDIX
305
+
306
+ The following sections include details on training setup, hyper-parameters, input processing, as well as additional experimental results.
307
+
308
+ # A.1 ADDITIONAL METRICS FOR OPEN CATALYST IS2RS TEST SET
309
+
310
+ Relaxation approaches to IS2RS minimise forces with respect to positions, with the expectation that forces at the minimum are close to zero. One metric of such a model’s success is to evaluate the forces at the converged structure using ground truth Density Functional Theory calculations and see how close they are to zero. Two metrics are provided by OC20 (Chanussot\* et al., 2020) on the IS2RS test set: Force below Threshold (FbT), which is the percentage of structures that have forces below 0.05 eV/Angstrom, and Average Force below Threshold (AFbT) which is FbT calculated at multiple thresholds.
311
+
312
+ The OC20 project computes test DFT calculations on the evaluation server and presents a summary result for all IS2RS position predictions. Such calculations take 10-12 hours and they are not available for the validation set. Thus, we are not able to analyse the results in Tables 8 and 9 in any further detail. Before application to catalyst screening further work may be needed for direct approaches to ensure forces do not explode from atoms being too close together.
313
+
314
+ Table 8: OC20 IS2RS Test, Average Force below Threshold $\%$ , ↑
315
+
316
+ <table><tr><td>Model</td><td>Method</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>Noisy Nodes</td><td>Direct</td><td>0.09%</td><td>0.00%</td><td>0.29%</td><td>0.54%</td></tr></table>
317
+
318
+ Table 9: OC20 IS2RS Test, Force below Threshold %, ↑
319
+
320
+ <table><tr><td>Model</td><td>Method</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>Noisy Nodes</td><td>Direct</td><td>0.0%</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr></table>
321
+
322
+ A.2 MORE DETAILS ON GNS ADAPTATIONS FOR MOLECULAR PROPERTY PREDICTION.
323
+
324
+ # Encoder.
325
+
326
+ The node features are a learned embedding lookup of the atom type, and in the case of OC20 two additional binary features representing whether the atom is part of the adsorbate or catalyst and whether the atom remains fixed during the quantum chemistry simulation.
327
+
328
+ The edge features, $e _ { k }$ are the distances $| d |$ featurised using $c$ Radial Bessel basis functions, $\tilde { e } _ { R B F , c } =$ ${ \sqrt { \frac { 2 } { R } } } { \frac { \sin ( { \frac { c \pi } { R } } d ) } { d } }$ , and the edge vector displacements, $d$ , normalised by the edge distance:
329
+
330
+ $$
331
+ e _ { k } = { \mathrm { C o n c a t } } ( { \tilde { e } } _ { R B F , 1 } ( | d | ) , . . . , { \tilde { e } } _ { R B F , c } ( | d | ) , \frac { d } { | d | } )
332
+ $$
333
+
334
+ Our conversion to fractional coordinates only applied to the vector quantities, i.e. $\frac { d } { | d | }$
335
+
336
+ # Decoder
337
+
338
+ The decoder consists of two parts, a graph-level decoder which predicts a single output for the input graph, and a node-level decoder which predicts individual outputs for each node. The graph-level decoder implements the following equation:
339
+
340
+ $$
341
+ y = W ^ { \mathrm { P r o c } } \sum _ { i = 1 } ^ { | V | } \mathrm { M L P } _ { \mathrm { P r o c } } ( a _ { i } ^ { \mathrm { P r o c } } ) + b ^ { \mathrm { P r o c } } + W ^ { \mathrm { E n c } } \sum _ { i = 1 } ^ { | V | } \mathrm { M L P } _ { \mathrm { E n c } } ( a _ { i } ^ { \mathrm { E n c } } ) + b ^ { \mathrm { E n c } }
342
+ $$
343
+
344
+ Where $a _ { i } ^ { \mathrm { P r o c } }$ are node latents from the Processor, $a _ { i } ^ { \mathrm { E n c } }$ are node latents from the Encoder, $W ^ { \mathrm { E n c } }$ and $W ^ { \mathrm { P r o c } }$ are linear layers, $b ^ { \mathrm { E n c } }$ and $b ^ { \mathrm { P r o c } }$ are biases, and $| V |$ is the number of nodes. The node-level decoder is simply an MLP applied to each $a _ { i } ^ { \mathrm { P r o c } }$ which predicts $a _ { i } ^ { \Delta }$ .
345
+
346
+ # A.3 MORE DETAILS ON MPNN FOR OGBG-PCQM4M AND OGBG-MOLPCBA
347
+
348
+ Our MPNN follows the blueprint of Gilmer et al. (2017). We use $\vec { h } _ { v } ^ { ( t ) }$ to denote the latent vector of node $v$ at message passing step $t$ , and $\vec { m } _ { u v } ^ { ( t ) }$ to be the computed message vector for the edge between nodes $u$ and $v$ at message passing step $t$ . We define the update functions as:
349
+
350
+ $$
351
+ \begin{array} { l } { { \displaystyle { \vec { m } } _ { u v } ^ { ( t + 1 ) } = \psi _ { t + 1 } \left( { \vec { h } } _ { u } ^ { ( t ) } , { \vec { h } } _ { v } ^ { ( t ) } , { \vec { m } } _ { u v } ^ { ( t ) } + { \vec { m } } _ { u v } ^ { ( t - 1 ) } \right) } } \\ { { \displaystyle { \vec { h } } _ { u } ^ { ( t + 1 ) } = \phi _ { t + 1 } \left( \vec { h } _ { u } ^ { ( t ) } , \sum _ { u \in \mathcal { N } _ { v } } { \vec { m } } _ { v u } ^ { ( t + 1 ) } , \sum _ { v \in \mathcal { N } _ { u } } { \vec { m } } _ { u v } ^ { ( t + 1 ) } \right) + { \vec { h } } _ { u } ^ { t } } } \end{array}
352
+ $$
353
+
354
+ Where the message function $\psi _ { t + 1 }$ and the update function $\phi _ { t + 1 }$ are MLPs. We use a “Virtual Node” which is connected to all other nodes to enable long range communication. Out readout function is an MLP. No spatial features are used.
355
+
356
+ ![](images/c7eaa426764d4dbb01365e7083e172b81b885cc891f5b42cdc12a2b5286b2fcf.jpg)
357
+ Figure 6: GNS Unsorted MAD per Layer Averaged Over 3 Random Seeds. Evidence of oversmoothing is clear. Model trained on QM9.
358
+
359
+ ![](images/eef81f0e6873634d5070ad73ccea49c007d1978eea1981e9416189db3816b3be.jpg)
360
+ Figure 7: GNS Sorted MAD per Layer Averaged Over 3 Random Seeds. The trend is clearer when the MAD values have been sorted. Model trained on QM9.
361
+
362
+ # A.4 EXPERIMENT SETUP FOR 3D MOLECULAR MODELING
363
+
364
+ Open Catalyst. All training experiments were ran on a cluster of TPU devices. For the Open Catalyst experiments, each individual run (i.e. a single random seed) utilised 8 TPU devices on 2 hosts (4 per host) for training, and 4 V100 GPU devices for evaluation (1 per dataset).
365
+
366
+ Each Open Catalyst experiment was ran until convergence for up to 200 hours. Our best result, the large 100 layer model requires 7 days of training using the above setting. Each configuration was run at least 3 times in this hardware configuration, including all ablation settings.
367
+
368
+ We further note that making effective use of our regulariser requires sweeping noise values. These sweeps are dataset dependent and can be carried out using few message passing steps.
369
+
370
+ QM9. Experiments were also run on TPU devices. Each seed was run using 8 TPU devices on a single host for training, and 2 V100 GPU devices for evaluation. QM9 targets were trained between 12-24 hours per experiment.
371
+
372
+ Following Klicpera et al. (2020b) we define std. MAE as :
373
+
374
+ $$
375
+ \mathrm { s t d . ~ } \mathrm { M A E } = \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \left( \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \frac { | f _ { \theta } ^ { ( m ) } ( X _ { i } , z _ { i } ) - \hat { t } _ { i } ^ { ( m ) } | } { \sigma _ { m } } \right)
376
+ $$
377
+
378
+ and logMAE as:
379
+
380
+ $$
381
+ \log \mathrm { M A E } = \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \log \left( \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \frac { | f _ { \theta } ^ { ( m ) } ( X _ { i } , z _ { i } ) - \hat { t } _ { i } ^ { ( m ) } | } { \sigma _ { m } } \right)
382
+ $$
383
+
384
+ with target index $m$ , number of targets $M = 1 2$ , dataset size $N$ , ground truth values $\hat { t } ^ { ( m ) }$ , model $f _ { \theta } ^ { ( m ) }$ , inputs $X _ { i }$ and $z _ { i }$ , and standard deviation $\sigma _ { m }$ of $\hat { t } ^ { ( m ) }$ .
385
+
386
+ # A.5 OVER SMOOTHING ANALYSIS FOR GNS
387
+
388
+ In addition to Figure 2, we repeat the analysis with a mean MAD over 3 seeds 7. Furthermore we remove the sorting layer by MAD value and find the trend holds.
389
+
390
+ # A.6 NOISE ABLATIONS FOR OGBG-MOLPCBA
391
+
392
+ We conduct a noise ablation on the random flipping noise for OGBG-MOLPCBA with an 8 layer MPNN $^ +$ Virtual Node, and find that our model is not very sensitive to the noise value (Table 10), but degrades from 0.1.
393
+
394
+ Table 10: OGBG-MOLPCBA Noise Ablation
395
+
396
+ <table><tr><td>Flip Probability</td><td>Mean AP</td></tr><tr><td>0.01</td><td>27.8% +- 0.002</td></tr><tr><td>0.03</td><td>27.9% +- 0.003</td></tr><tr><td>0.05</td><td>28.1% +- 0.001</td></tr><tr><td>0.1</td><td>28.0% +- 0.003</td></tr><tr><td>0.2</td><td>27.7% +- 0.002</td></tr></table>
397
+
398
+ Table 11: OGBG-MOLPCBA DropEdge Ablation
399
+
400
+ <table><tr><td></td><td>Mean AP</td></tr><tr><td>MPNN Without DropEdge</td><td>27.4% ± 0.002</td></tr><tr><td>MPNN With DropEdge</td><td>27.5% ± 0.001</td></tr><tr><td>MPNN + DropEdge + Noisy Nodes</td><td>27.8% ± 0.002</td></tr></table>
401
+
402
+ A.7 DROPEDGE & DROPNODE ABLATIONS FOR OGBG-MOLPCBA
403
+
404
+ We conduct an ablation with our 16 layer MPNN using DropEdge at a rate of 0.1 as an alternative approach to improving oversmoothing and find it does not improve performance for ogbg-molpcba (Table 11), similarly we find DropNode (Table 12) does not improve performance. In addition, we find that these two methods can’t be combined well together, reaching a performance of $2 7 . 0 \% \pm$ 0.003. However, both methods can be combined advantageously with Noisy Nodes.
405
+
406
+ We also measure the MAD of the node latents for each layer and find the indeed Noisy Nodes is more effective at addressing oversmoothing in Figure 8.
407
+
408
+ A.8 TRAINING CURVES FOR OC20 NOISY NODES ABLATIONS DEMONSTRATING OVERFITTING
409
+
410
+ Figure 9
411
+
412
+ Table 12: OGBG-MOLPCBA DropNode Ablation
413
+
414
+ <table><tr><td>一</td><td>Mean AP</td></tr><tr><td>MPNN With DropNode</td><td>27.5% ± 0.001</td></tr><tr><td>MPNN Without DropNode</td><td>27.5% ± 0.004</td></tr><tr><td>MPNN + DropNode + Noisy Nodes</td><td>28.2% ±0.005</td></tr></table>
415
+
416
+ ![](images/0f0f48f21c0bc15b691e20d800d9179b61b0e2909b24b9c5cd2fcdafc6808e86.jpg)
417
+ Figure 8: Comparison of the effect of techniques to address oversmoothing on MPNNs. Whilst Some effect can be seen from DropEdge and DropNode, Noisy Nodes is significantly better at preserving per node diversity.
418
+
419
+ A.9 PSEUDOCODE FOR 3D MOLECULAR PREDICTION TRAINING STEP
420
+
421
+ <table><tr><td>Algorithm 1: Noisy Nodes Training Step</td></tr><tr><td>G=(V,E,g) // Input graph</td></tr><tr><td>G=G// Initialize noisy graph λ// Noisy Nodes Weight</td></tr><tr><td>if not_provided(V&#x27;) then</td></tr><tr><td>-V←V end</td></tr><tr><td>if predict_differences then</td></tr><tr><td> △={u&#x27;- vili ∈1,...,|Vl}</td></tr><tr><td>end for each i∈1,...,|V| do</td></tr><tr><td></td></tr><tr><td>Oi = sample_node_noise(shape_of(ui));</td></tr><tr><td>Vi=Ui+Oi;</td></tr><tr><td>if predict_differences then</td></tr><tr><td>△i=△i-Oi;</td></tr><tr><td>end</td></tr><tr><td>endfor</td></tr><tr><td></td></tr><tr><td>E = recompute_edges(V);</td></tr><tr><td>G&#x27; = GNN(G);</td></tr><tr><td></td></tr><tr><td>if predict_differences then</td></tr><tr><td>V&#x27;=△i;</td></tr><tr><td>end</td></tr><tr><td></td></tr><tr><td></td></tr><tr><td>Loss = λ NoisyNodesLoss(G&#x27;, V&#x27;) + PrimaryLos(G&#x27;, V/&#x27;); Loss.minimise()</td></tr></table>
422
+
423
+ ![](images/8c69d25563ff26c9fdb7456b6c7e432192e7ec9d31f1d6f84b386ea31a771df0.jpg)
424
+ Figure 9: Training curves to accompany Figure 3. This demonstrates that even as the validation performance is getting worse, training loss is going down, indicating overfitting.
425
+
426
+ Table 13: Open Catalyst training parameters.
427
+
428
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser</td><td>Adam with warm up and cosine cycling</td></tr><tr><td>β1</td><td>0.9</td></tr><tr><td>β</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>5e5</td></tr><tr><td>Warm up start learning rate</td><td>le-5</td></tr><tr><td>Warm up/cosine max learning rate</td><td>le-4</td></tr><tr><td>Cosine cycle length</td><td>5e6</td></tr><tr><td>Loss type</td><td>Mean squared error</td></tr><tr><td>Batch size</td><td>Dynamic to max edge/node/graph count</td></tr><tr><td>Max nodes in batch</td><td>1024</td></tr><tr><td>Max edges in batch</td><td>12800</td></tr><tr><td>Max graphs in batch</td><td>10</td></tr><tr><td>MLP number of layers</td><td>3</td></tr><tr><td>MLP hidden sizes</td><td>512</td></tr><tr><td>Number Bessel Functions</td><td>512</td></tr><tr><td>Activation</td><td>shifted softplus</td></tr><tr><td>message passing layers</td><td>50</td></tr><tr><td>Group size</td><td>10</td></tr><tr><td>Node/Edge latent vector sizes</td><td>512</td></tr><tr><td>Position noise</td><td>Gaussian (μ = O,σ = 0.3)</td></tr><tr><td>Parameter update</td><td>Exponentially moving average (EMA) smoothing</td></tr><tr><td>EMA decay</td><td>0.9999</td></tr><tr><td>Position Loss Co-efficient</td><td>1.0</td></tr></table>
429
+
430
+ # A.10 TRAINING DETAILS
431
+
432
+ Our code base is implemented in JAX using Haiku and Jraph for GNNs, and Optax for training (Bradbury et al., 2018; Babuschkin et al., 2020; Godwin\* et al., 2020; Hennigan et al., 2020). Model selection used early stopping.
433
+
434
+ All results reported as an average of 10 random seeds. OGBG-PCQM4M & OGBG-MOLPCBA were trained with 16 TPUs and evaluated with a single V100 GPU. OGBN-Arxiv was trained and evalated with a single TPU
435
+
436
+ # 3D Molecular Prediction
437
+
438
+ We minimise the mean squared error loss on mean and standard deviation normalised targets and use the Adam (Kingma & Ba, 2015) optimiser with warmup and cosine decay. For OC20 IS2RE energy prediction we subtract a learned reference energy, computed using an MLP with atom types as input.
439
+
440
+ For the GNS model the node and edge latents as well as MLP hidden layers were sized 512, with 3 layers per MLP and using shifted softplus activations throughout. OC20 & QM9 Models were trained on 8 TPU devices and evaluated on a single V100 GPUs. We provide the full set of hyper-parameters and computational resources used separately for each dataset in the Appendix. All noise levels were determined by sweeping a small range of values $( \approx 1 0 )$ ) informed by the noised feature covariance.
441
+
442
+ # Non Spatial Tasks
443
+
444
+ # A.11 HYPER-PARAMETERS
445
+
446
+ Open Catalyst. We list the hyper-parameters used to train the default Open Catalyst experiment. If not specified otherwise (e.g. in ablations of these parameters), experiments were ran with this configuration.
447
+
448
+ Table 14: QM9 training parameters.
449
+
450
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser</td><td>Adam with warm up and cosine cycling</td></tr><tr><td>β1</td><td>0.9</td></tr><tr><td>β</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>1e4</td></tr><tr><td>Warm up start learning rate</td><td>3e-7</td></tr><tr><td>Warm up/cosine max learning rate</td><td>le-4</td></tr><tr><td>Cosine cycle length</td><td>2e6</td></tr><tr><td>Loss type</td><td>Mean squared error</td></tr><tr><td>Batch size</td><td>Dynamic to max edge/node/graph count</td></tr><tr><td>Max nodes in batch</td><td>256</td></tr><tr><td>Max edges in batch</td><td>4096</td></tr><tr><td>Max graphs in batch</td><td>8</td></tr><tr><td>MLP number of layers</td><td>3</td></tr><tr><td>MLPhidden sizes</td><td>1024</td></tr><tr><td>Number Bessel Funtions</td><td>512</td></tr><tr><td>Activation</td><td>shifted softplus</td></tr><tr><td>message passing layers</td><td>10</td></tr><tr><td>Group Size</td><td>10</td></tr><tr><td>Node/Edge latent vector sizes</td><td>512</td></tr><tr><td>Position noise</td><td>Gaussian (μ= O,σ = 0.02)</td></tr><tr><td>Parameter update</td><td>Exponentially moving average (EMA) smoothing</td></tr><tr><td>EMA decay</td><td>0.9999</td></tr><tr><td>Position Loss Coefficient</td><td>0.1</td></tr></table>
451
+
452
+ Dynamic batch sizes refers to constructing batches by specifying maximum node, edge and graph counts (as opposed to only graph counts) to better balance computational load. Batches are constructed until one of the limits is reached.
453
+
454
+ Parameter updates were smoothed using an EMA for the current training step with the current decay value computed through $d e c a y = m \bar { i } n ( d e c a y , ( 1 . 0 + s t e p ) / ( 1 0 . 0 + \bar { s t e p } )$ . As discussed in the evaluation, best results on Open Catalyst were obtained by utilising a 100 layer network with group size 10.
455
+
456
+ QM9 Table 14 lists QM9 hyper-parameters which primarily reflect the smaller dataset and geometries with fewer long range interactions. For $U _ { 0 }$ , $U$ , $H$ and $G$ we use a slightly larger number of graphs per batch - 16 - and a smaller position loss co-efficient of 0.01.
457
+
458
+ OGBG-PCQM4M Table 15 provides the hyper parameters for OGBG-PCQM4M.
459
+
460
+ OGBG-MOLPCBA Table 16 provides the hyper parameters for the OGBG-MOLPCBA experiments
461
+
462
+ OGBN-ARXIV Table 17 provides the hyper parameters for the OGBN-Arxiv experiments.
463
+
464
+ Table 15: OGBG-PCQM4M Training Parameters.
465
+
466
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser</td><td>Adam with warm up and cosine cycling</td></tr><tr><td>β1</td><td>0.9</td></tr><tr><td>β</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>5e4</td></tr><tr><td>Warm up start learning rate</td><td>le-5</td></tr><tr><td>Warm up/cosine max learning rate</td><td>le-4</td></tr><tr><td>Cosine cycle length</td><td>5e5</td></tr><tr><td>Loss type</td><td>Mean absolute error</td></tr><tr><td>Reconstruction type</td><td>Softmax Cross Entropy</td></tr><tr><td>Batch size</td><td>Dynamic to max edge/node/graph count</td></tr><tr><td>Max nodes in batch</td><td>20,480</td></tr><tr><td>Max edges in batch</td><td>8,192</td></tr><tr><td>Max graphs in batch</td><td>512</td></tr><tr><td>MLP number of layers</td><td>2</td></tr><tr><td>MLP hidden sizes</td><td>512</td></tr><tr><td>Activation</td><td>relu</td></tr><tr><td>Node/Edge latent vector sizes</td><td>512</td></tr><tr><td>Noisy Nodes Category Flip Fate</td><td>0.05</td></tr><tr><td>Parameter update</td><td>Exponentially moving average (EMA) smoothing</td></tr><tr><td>EMA decay</td><td>0.999</td></tr><tr><td>Reconstruction Loss Coefficient</td><td>0.1</td></tr></table>
467
+
468
+ Table 16: OGBG-MOLPCBA Training Parameters.
469
+
470
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser β</td><td>Adam with warm up and cosine cycling 0.9</td></tr><tr><td>β2</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>1e4</td></tr><tr><td></td><td></td></tr><tr><td>Warm up start learning rate</td><td>1e-5</td></tr><tr><td>Warm up/cosine max learning rate</td><td>le-4</td></tr><tr><td>Cosine cycle length</td><td>1e5</td></tr><tr><td>Loss type</td><td>Softmax Cross Entropy</td></tr><tr><td>Reconstruction loss type</td><td>Softmax Cross Entropy</td></tr><tr><td>Batch size</td><td>Dynamic to max edge/node/graph count</td></tr><tr><td>Max nodes in batch</td><td>20,480</td></tr><tr><td>Max edges in batch</td><td>8,192</td></tr><tr><td>Max graphs in batch</td><td>512</td></tr><tr><td></td><td>2</td></tr><tr><td>MLP number of layers MLP hidden sizes</td><td>512</td></tr><tr><td>Activation</td><td>relu</td></tr><tr><td>BatchNormalization</td><td>Yes,after every hidden layer</td></tr><tr><td>Node/Edge latent vector sizes</td><td>512</td></tr><tr><td>Dropnode Rate</td><td></td></tr><tr><td></td><td>0.1 0.1</td></tr><tr><td>Dropout Rate</td><td></td></tr><tr><td>Noisy Nodes Category Flip Fate Parameter update</td><td>0.05 Exponentially moving average (EMA) smoothing</td></tr><tr><td>EMA decay</td><td>0.999</td></tr><tr><td>Reconstruction Loss Coefficient</td><td>0.1</td></tr></table>
471
+
472
+ Table 17: OGBG-ARXIV Training Parameters.
473
+
474
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser</td><td>Adam with warm up and cosine cycling</td></tr><tr><td>β</td><td>0.9</td></tr><tr><td>β</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>50</td></tr><tr><td>Warm up start learning rate</td><td>le-5</td></tr><tr><td>Warm up/cosine max learning rate</td><td>1e-3</td></tr><tr><td>Cosine cycle length</td><td>12,000</td></tr><tr><td>Loss type</td><td>Softmax Cross Entropy</td></tr><tr><td>Reconstruction loss type</td><td>Mean Squared Error</td></tr><tr><td>Batch size</td><td>Full graph</td></tr><tr><td>MLP number of layers</td><td>1</td></tr><tr><td>Activation</td><td>relu</td></tr><tr><td>Batch Normalization</td><td>Yes,after every hidden layer</td></tr><tr><td>Node/Edge latent vector sizes</td><td>256</td></tr><tr><td>Dropout Rate</td><td>0.5</td></tr><tr><td>Noisy Nodes Input Dropout</td><td>0.05</td></tr><tr><td>Reconstruction Loss Coefficient</td><td>0.1</td></tr></table>
md/dev/2-REuflJDT/2-REuflJDT.md ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images
2
+
3
+ Zhi Tian1, Xiangxiang $\mathbf { C h u ^ { 1 } }$ , Xiaoming Wang2∗, Xiaolin Wei1, Chunhua Shen3†
4
+
5
+ 1 Meituan Inc. 2 Northwestern Polytechnical University 3 Zhejiang University 1 {tianzhi02,chuxiangxiang,weixiaolin02}@meituan.com 2 chunhua@me.com 3 xiaomingwang80@163.com
6
+
7
+ # Abstract
8
+
9
+ We present a simple yet effective fully convolutional one-stage 3D object detector for LiDAR point clouds of autonomous driving scenes, termed FCOS-LiDAR. Unlike the dominant methods that use the bird-eye view (BEV), our proposed detector detects objects from the range view (RV, a.k.a. range image) of the LiDAR points. Due to the range view’s compactness and compatibility with the LiDAR sensors’ sampling process on self-driving cars, the range view-based object detector can be realized by solely exploiting the vanilla 2D convolutions, departing from the BEV-based methods which often involve complicated voxelization operations and sparse convolutions.
10
+
11
+ For the first time, we show that an RV-based 3D detector with standard 2D convolutions alone can achieve comparable performance to state-of-the-art BEV-based detectors while being significantly faster and simpler. More importantly, almost all previous range view-based detectors only focus on single-frame point clouds, since it is challenging to fuse multi-frame point clouds into a single range view. In this work, we tackle this challenging issue with a novel range view projection mechanism, and for the first time demonstrate the benefits of fusing multi-frame point clouds for a range-view based detector. Extensive experiments on nuScenes show the superiority of our proposed method and we believe that our work can be strong evidence that an RV-based 3D detector can compare favourably with the current mainstream BEV-based detectors. Code will be made publicly available.
12
+
13
+ # 1 Introduction
14
+
15
+ With the rise of autonomous driving, 3D object detection from the LiDAR point cloud has been recently drawing increasing attention. Similar to the 2D image object detection [RHGS15, TSCH19, $\mathrm { L A E ^ { + } } \dot { 1 } 6$ , RF17, RDGF16], 3D object detection requires the model to predict the (3D) locations of the objects of interest and the associated properties (e.g., categories, sizes, heading, and the state of motion). In spite of the unprecedented success that the computer vision community has attained on the 2D image object detection, it is still intractable to transfer the success to the 3D object detection task.
16
+
17
+ Most previous 3D object detection methods consider that the point cloud is amorphous and consists of a set of unordered points. Thus, this task is considered significantly different from its 2D detection counterpart, which works on structured RGB images. Moreover, the cornerstones of modern computer vision—CNNs or CNN-like vision transformers (e.g., Swin Transformers $[ \mathrm { L L C ^ { + } } 2 1 ]$ ) also assume that the inputs are well-organized as grids, which poses another difficulty of accurate 3D object detection in point clouds. As a result, in order to adopt these well-developed techniques, almost all top-performing point cloud object detection methods first partition the 3D space into structured voxels (or pillars) [ZT18, YZK21, YML18, $\mathrm { L V C ^ { + } } 1 9$ , Li17] and then follow a paradigm similar to that of 2D object detectors [RHGS15, ZWK19]. Additionally, given the prior that it is very rare two objects being stacked along with the elevation axis in autonomous driving scenes, most methods only carry out the detection task on the bird-eye view (BEV) of the point cloud, which can reduce the exponentially increasing complexity resulted from the third dimension. However, owing to incompatibility with the LiDAR’s sampling process in the autonomous driving scenes, BEV-based solutions often suffer from the following shortcomings. 1) In fact, the points in autonomous driving are regularly sampled in the spherical coordinate system with the origin being the LiDAR sensor. The BEV disregards this regularity, and causes the issue that the voxels far away from the origin have much fewer points than the ones near the origin; and a large number of voxels are even empty. This results in the need for sparse convolutions [YML18, YZK21, Gra14], significantly complicating the system, particularly for on-device applications. 2) The points in a voxel have to be sampled or padded so that every voxel has the same number of points. The sampling decimates a large number of points, leading to the loss of information before the model see anything. 3) From the BEV, some objects such as “pedestrian” and “traffic cone” become very small. Accurately detecting these objects requires a fine-grained voxel size, dramatically increasing the price of computation.
18
+
19
+ ![](images/5ccb15a4cbae5ca572ff95c413d6e171bd32db353762a8db1c5dccf03cb27248.jpg)
20
+ Figure 1: The range image of the point cloud (right). The size of the range image is $m \times n$ , where $m$ is the number of beams and $n$ is the number of measurements (i.e., sampling frequency) per scan cycle. A 3D point’s coordinates on the range image are computed by discretizing the azimuthal angle $\theta$ and the inclination angle $\phi$ in the spherical coordinate system (left). The $m , n$ , and $\Delta \phi$ depend on the LiDAR specifications.
21
+
22
+ In this work, we advocate a new solution for 3D object detection that works on the range view (RV). As noted by many previous works $[ \mathrm { F X W ^ { + } } 2 1$ , $\mathrm { S K D } ^ { + } 2 0$ , $\mathbf { M } \mathbf { L } \mathbf { K } ^ { + } \mathbf { 1 9 } ]$ , if we consider these points in the spherical coordinate system and project them in terms of their inclination and azimuth angles, they can form a compact 2D image with size being $m \times n$ (shown in Fig. 1), where $m$ is the number of beams (i.e., channels) of the LiDAR sensor and $n$ is the sampling frequency per scan cycle. The resulting image is referred to as “range image” or “range view” of the point cloud. Compared to the aforementioned BEV, the range image is nearly dense and compatible with the LiDAR sampling process, eliminating the need for sparse convolutions and alleviating the loss of points. In addition, the range image closely resembles the common RGB image, minimizing the cost of transferring the 2D detection methods to 3D ones. In the literature, some works attempted to detect objects on the range view such as RangeDet $[ \mathrm { F X W } ^ { + } 2 1 ]$ and LaserNet $[ \mathrm { M L K ^ { + } } 1 9 ]$ . These works have shown that RV-based methods can also achieve decent detection performance, showing the promise. However, previous RV-based methods only focus on the single-frame point cloud as the aforementioned range view structure does not hold anymore if the ego (and the origin) moves between the multiple frames. Additionally, the range image of a single-frame point cloud is already nearly dense so that there are not many vacancies the points from other frames can populate. These issues make the range-view based detectors difficult to benefit from the multi-frame fusion. In sharp contrast, the multi-frame fusion can dramatically improve the performance in the BEV-based detectors, as shown in [YZK21, $\mathrm { L V C ^ { + } } 1 9 ]$ . This makes the performance of RV-based detectors largely lag behind that of the BEV-based ones, hampering their development and application. In this work, we show this issue can be largely remedied with a well-designed Multi-round Range View (MRV) projection mechanism. The proposed MRV makes the RV-based detectors be able to enjoy the gain of multi-frame fusion and thus achieve competitive performance with multi-frame BEV-based detectors.
23
+
24
+ Here, we summarize our main contributions as follows.
25
+
26
+ • We propose a fully convolutional one-stage 3D object detector, termed FCOS-LiDAR. FCOS-LiDAR works on the LiDAR range images and minimizes the gap between the 3D and 2D detectors, while being substantially simpler than current mainstream BEV-based 3D detectors [YZK21, ZT18].
27
+ Compared to previous BEV-based detectors [ZT18, YZK21], FCOS-LiDAR sidesteps the complicated voxelization process and eliminates the need for sparse convolutions due to the highly compact range view representation of the point cloud. In the setting of only using the single-frame point cloud as inputs, FCOS-LiDAR can outperform the state-of-the-art BEV-based detector CenterPoint [YZK21] while being faster.
28
+ • We also present a well-designed Multi-round Range View (MRV) projection mechanism, making RV-based detectors be able to benefit from the multi-frame fusion of point clouds as well, and achieve competitive performance compared to the multi-frame BEV-based detectors. To our knowledge, we are the first one approaching the challenge of the RV-based multi-frame point clouds fusion and showing that RV-based detectors can also be boosted by the multi-frame fusion of point clouds.
29
+ • We believe that our excellent performance of the RV-based detector can be a strong evidence that RV-based detectors compare favorably against the mainstream BEV-based detectors and encourage the community to pay attention to this promising solution.
30
+
31
+ # 2 Related Work
32
+
33
+ Bird-view based 3D Detection. Most top-performing LiDAR-based 3D detectors $[ \mathrm { F P Z ^ { + } } 2 1$ , YML18, YZK21, $\mathrm { L V C ^ { + } } 1 9$ , ZT18] fall into this category, which first convert the point cloud into BEV images. VoxelNet [ZT18] is the first end-to-end BEV-based detector, which employs PointNet [QSMG17] to handle the representation within a voxel and 3D convolutions to generate high-level features for the region proposal network (RPN). SECOND [YML18] proposes to use sparse convolutions, which can save the computing burden of 3D convolutions. Another popular approach is to eliminate the voxelization along the elevation axis and convert the point cloud into the pillars $[ \mathrm { L V C ^ { + } } 1 9 ]$ . Based on the voxel-based or pillar-based BEV representation, CenterPoint [YZK21] achieves state-of-the-art performance by using the anchor-free pipelines.
34
+
35
+ Range-view based 3D Detection. Due to the compactness of the RV representation, some methods $[ \bar { \mathrm { S } } \mathrm { W } \mathrm { C } ^ { + } 2 1$ , $\mathrm { B S M ^ { + } } 2 1$ , $\mathrm { M L K ^ { + } } 1 9$ , $\mathrm { M L K ^ { + } } 1 9 ]$ also attempt to perform detection based on the representation. VeloFCN [LZX16] is the pioneering work to perform 3D objection using the range view, which transforms point cloud to the range image and then applies 2D convolution to detect 3D objects. After that, some following works $[ \mathrm { M L K ^ { + } } 1 9$ , $\mathrm { F X W } ^ { + } \bar { 2 } \bar { 1 } ]$ are proposed to narrow the performance gap between RV-based and BEV-based detectors. LaserNet $[ \mathrm { M L K ^ { + } } 1 9 ]$ models the distribution of 3D box corners to capture their uncertainty, resulting in more accurate defections. RCD $[ \mathbf { B } \mathbf { S } \mathbf { M } ^ { + } 2 1 ]$ introduces the range-conditioned dilation mechanism to dynamically adjust the dilation rate in terms of the measured range, which can alleviate the scale-sensitivity issue of the RV-based detectors. RangeDet $[ \mathrm { F X W } ^ { + } 2 1 ]$ further proposes the Range Conditioned Pyramid to mitigate the scale-variation issue and utilizes the Meta-Kernel convolution to better exploit the 3D geometric information of the points. To our knowledge, these existing RV-based detectors only take into consideration the single frame point cloud and neglect the substantial improvements brought by the multi-frame fusion as shown in BEV-based detectors.
36
+
37
+ # 3 Our Approach
38
+
39
+ # 3.1 Range View Representation
40
+
41
+ Given a LiDAR point $( x , y , z )$ in the Cartesian coordinate system with the $z$ -axis pointing upward, it can be uniquely transformed to the spherical coordinates $( r , \theta , \phi )$ with
42
+
43
+ $$
44
+ r = \sqrt { x ^ { 2 } + y ^ { 2 } + z ^ { 2 } } , \theta = \mathrm { a t a n 2 } ( y , x ) , \phi = \mathrm { a t a n 2 } ( z , \sqrt { x ^ { 2 } + y ^ { 2 } } ) ,
45
+ $$
46
+
47
+ where $r , \theta$ , and $\phi$ are the range, azimuthal angle, and inclination angle, respectively, as shown in Fig. 1(left). The LiDAR samples the points with a fixed number of beams (denoted by $m$ ), each of which has a fixed inclination angle. These LiDAR beams synchronously rotate around the $z$ -axis uniformly to obtain a $3 6 0 ^ { \circ }$ horizontal field of view and the LiDAR measures a certain number of times (denoted by $n$ ) per scan cycle (i.e., per frame). Thus, the difference of adjacent measurements’ azimuthal angles is $3 6 0 / n ^ { \circ }$ . For example, on the nuScenes dataset, the LiDAR measures $n = 1 0 8 6$ times per scan cycle and has $m = 3 2$ beams. The inclination angles of these beams are evenly spaced from $- 3 0 . 6 7 ^ { \circ }$ to $1 0 . 6 7 ^ { \circ }$ , inclusive. Note that the inclination angles are not always evenly spaced and subject to the specifications of the LiDAR.
48
+
49
+ Given the regularity of the azimuthal and inclination angles for a given LiDAR, we can discretize the azimuthal angles with $n$ bins, and inclination angles with $m$ bins, respectively. Let $( i , j )$ be the indices of the bins for azimuthal and inclination angles, respectively. By computing all the pairs of $( i , j )$ of the points in a single scan cycle, we can fill these points into a 2D image $\bar { I } \bar { \in } \mathbb { R } ^ { m \times n \bar { \times } C }$ (i.e., the range image), where $C = 9$ consists of the original Cartesian coordinates $( x , y , z )$ , the spherical coordinates $( r , \theta , \phi )$ , the reflected intensity $i$ , the existence $e$ of the point, and a relative timestamp $t$ The existence denotes whether or not the location is filled by a point, and the relative timestamp is only valid in the multi-frame point cloud inputs and denotes the time difference between the frame containing this point and the current frame. In practice, the vehicle itself is often in motion, and this causes that some points might be projected to the same bins on the range image. In this case, we keep the one with the minimal distance to the vehicle.
50
+
51
+ # 3.2 Multi-round Range View Projection (MRV)
52
+
53
+ The point cloud of a single frame is often sparse in the 3D space and of low resolutions. In order to improve the detection performance, the current frame is often combined with several previous frames as the network’s inputs [YZK21, ZT18]. Taking the nuScenes dataset as an example, the methods on this dataset often take as the inputs 10 frames, which is composed of the current frame and previous 9 frames, including ${ \sim } 2 4 0 \mathrm { K }$ points in total. The crucial issue of the range view representation is the collision that multiple points fall into the same bin happens much more frequently in the multi-frame case. For instance, on nuScenes, only ${ \sim } 2 8 \mathrm { K }$ points are finally kept in the range image and ${ \sim } 9 0 \%$ of the points are discarded due to the collision. The decimation makes the multi-frame point cloud have almost the same number of valid points with the single-frame version, which is the dominant reason that RV-based methods cannot enjoy the benefit of multi-frame inputs.
54
+
55
+ In order to cope with this crucial issue, we propose the Multi-round Range View (MRV) projection mechanism. To be specific, we first project the points with the method in Sec. 3.1. Then, instead of discarding the rejected points, we project them again with the same process and put them in another group of nine channels. This projection process is repeated until a sufficient number of points are kept. On the nuScenes dataset, this is repeated five times and the percentage of the retained points can be improved from ${ \sim } 1 0 \%$ to more than $50 \%$ . In theory, as long as we continue the process, all points can be kept. However, we found that the performance is saturated after 5 repetitions on the nuScenes dataset. Finally, the resulting range images of the five rounds are concatenated along the channel dimension and used as the inputs. Additionally, one caveat is that the points of the current frame should have the highest priority wherever the collision happens because the points of previous frames are stale and might not reflect the current status of the world. Despite being a very simple treatment, it significantly affects the effectiveness of the multi-frame fusion as shown in our experiments.
56
+
57
+ # 3.3 Modality-wise Convolutions
58
+
59
+ As mentioned before, each pixel on the single-frame range image contains nine channels. Different the RGB image, whose three channels are of the same modality (i.e., in the color space) and correlated for the manifold of natural images, the nine channels of the range image are not like that and belong to five modalities, i.e., $[ x , y , z ]$ , $[ r , \theta , \phi ]$ , [i], $[ e ]$ and $[ t ]$ , respectively, where the channels in the one pair of square brackets are of the same modality. For example, the correlation between the reflected intensity $i$ and the coordinate $x$ does not make sense. Further, even the different channel types in the same modality are orthogonal and less correlated as well. For instance, it is difficult to say there is a relationship between the azimuthal angle $\theta$ and the range $r$ of a point. As a result, one channel type should be viewed as an individual “modality”. By default, the conv. layer simultaneously computes spatial correlations and cross-channel correlations. However, as shown before, the channels of the range image are less correlated, and thus, it is not reasonable to use the default conv. layer here, and the channels of the range image should be processed separately. This can be easily implemented with the grouped convolutions. Here, we term it modality-wise convolution because it is based on the “modalities”. Once the high-level semantic features of these modalities are individually obtained, we can aggregate the features of these modalities with a $1 \times 1$ conv. layer (i.e., point-wise convolution) for further abstract analysis.
60
+
61
+ ![](images/67aad4d18ca4e000364946778b787a418ea050c0876b322f7af004777961aeda.jpg)
62
+ Figure 2: Modality-wise convolutions with a multi-frame range image. As we can see, we first rearrange the channels of the multi-frame range image so that the channels with the same type from different frames (e.g., $x _ { 0 }$ , $x _ { 1 }$ , ... $x _ { T - 1 } )$ are adjacent. Then, two successive 2D conv. layers with the number of groups being 9 (which is equal to the number of different channel types) are used to process these channels separately, mapping each channel type to a 32-channel features. Finally, the features of these channel types are merged by a $1 \times 1$ conv. layer.
63
+
64
+ In this way, the modality-wise convolution is analogous to the widely-used depth-wise convolution, but we highlight that the underlying nature is distinct. Our modality-wise convolution instantiates a reasonable inductive bias based on the prior that different modalities are less relevant, and thus it is expected to simultaneously improve both the effectiveness and efficiency, as shown in our experiments. This also leads to the fact that the modality-wise convolution can only be placed at the beginning of the network, where the channels are interpretable and have an explicit modality. In contrast, the depth-wise convolution (together with the point-wise convolution) is often viewed as an efficient approximation of the full conv. layer and thus it does not usually yield improved performance and can appear anywhere. Lastly, when it comes to the multi-frame point clouds, the channels of the same type from different frames should be handled together because they are closely correlated. The whole procedure of the modality-wise convolution is illustrated in Fig. 2.
65
+
66
+ # 3.4 Overall Architecture
67
+
68
+ The overall architecture of FCOS-LiDAR is shown in Fig. 3. FCOS-LiDAR follows the spirit of the anchor-free detector FCOS [TSCH19] in the image-based object detection and is a standard fully convolutional network [LSD15].
69
+
70
+ Taking a (multi-frame) range image $I \in \mathbb { R } ^ { m \times n \times ( T \times C ) }$ as an example, where $T$ is the number of the used frames, we first forward the range image through our backbone network, termed LiDAR-Net. LiDAR-Net is adapted from ResNet-50 [HZRS16]. Specifically, before the first conv. layer of ResNet50, we insert three branches of the modality-wise convolutions with three dilation rates being 1, 3, and 6, respectively. The branches with various dilation rates aim to capture the multi-scale context, whose outputs are summed up. Then, the first two $2 \times$ downsamplings of ResNet-50 are removed, which is of great importance due to the low resolutions of the range images. Moreover, we change the numbers of blocks of ResNet-50’s four stages from $( 3 , 4 , 6 , 3 )$ to $( 4 , 4 , 1 , 1 )$ and stop doubling the number of channels in the third and fourth stages because we found that the final performance is not sensitive to the capacity of the later stages but quite sensitive to that of the early stages. This ravels one of the important difference between the LiDAR-based and image-based object detection tasks. For object detection in RGB images, more convolutions in the later stages are often required to transform the RGB pixels into the highly semantic and abstract features that can be used to obtain the geometries of the objects. However, the LiDAR points themselves are already geometric points and thus that many convolutions in the later stages are no longer needed. Thus, we can instead allocate the capacity in the later stages to the early stages (before any downsampling) to better incorporate the geometric information carried by the raw points. Finally, the four levels of feature maps from LiDAR-Net’s four stages are used, denoted by $C _ { 2 }$ , $C _ { 3 }$ , $C _ { 4 }$ , and $C _ { 5 }$ , respectively.
71
+
72
+ ![](images/ccc7a5ad0561507b5fc76d7c684bc309f1ceec7dbcca626196036e4658e76911.jpg)
73
+ Figure 3: Overall architecture. The overall architecture of FCOS-LiDAR resembles the 2D imagebased detector FCOS [TSCH19]. By taking as input an range image, the network obtains the multi-level FPN features, and then the classification and regression branches are attached to these feature levels to predict the final 3D boxes. Different from FCOS, the weights of the detection heads are not shared between the FPN levels as mentioned in Sec. 3.4. In addition, the class-specific regression heads are used instead of the class-agnostic ones in FCOS.
74
+
75
+ Next, following FCOS, the four levels of feature maps are sent into a feature pyramid network (FPN) $[ \mathrm { L D G ^ { + } i } \bar { 7 } ]$ to obtain six levels of pyramid feature maps denoted by $P _ { 2 }$ , $P _ { 3 }$ , $P _ { 4 }$ , $P _ { 5 }$ , $P _ { 6 }$ , and $P _ { 7 }$ . Their spatial downsampling ratios to the input are $1 / 1 , \bar { 1 / 2 } , \bar { 1 / 4 } , \bar { 1 / 8 } , \bar { 1 / } \bar { 1 6 }$ , and $^ { 1 / 3 2 }$ , respectively. Then, similar to FCOS, the classification and regression heads, each with four $3 \times 3$ conv. layers of channel 64 and a final prediction conv. layer (for the classification or regression), are attached to these feature levels. Unlike the heads in image-based detectors, whose weights are shared between these feature levels, it is important in the LiDAR-based detector to untie these weights. This is another important difference between image-based and LiDAR-based detectors. In image-based detectors, different sizes of objects can be normalized to similar sizes of objects by the downsampling the image with corresponding factors. That is what the “pyramid” means in the FPN. Thus, the image-based detectors can share the weights of the detection heads because the objects have been normalized to similar sizes after the FPN. However, in LiDAR-based detection, the objects’ sizes cannot be normalized in this way because the sizes of the objects are determined by the 3D points’ coordinate values in them and downsampling the range images cannot alter their real sizes in the 3D space. Therefore, it is no longer reasonable to share the detection heads between these FPN levels. This is also confirmed in our experiments.
76
+
77
+ Training Targets Computation. Similar to FCOS [TSCH19], we need to assign the training targets to each location of the feature maps computed with the range image. The training targets computation is described using the nuScenes dataset as an example. On nuScenes, an object’s ground-truth 3D box is parameterized by $( c _ { x } ^ { * } , c _ { y } ^ { * } , c _ { z } ^ { * } , w ^ { * } , h ^ { * } , l ^ { * } , \alpha ^ { * } )$ , where $( c _ { x } ^ { * } , c _ { y } ^ { * } , c _ { z } ^ { * } )$ is the 3D center of the box, and $w , h , l$ , and respectively are the width, height, length, and the yaw angle around the axis. First, each location on the feature maps is mapped to the pixel location on the range image by multiplying them by the feature maps’ downsampling ratio. Next, we use the 3D LiDAR point projected by the first-round MRV projection as the 3D point of the pixel. If the pixel’s 3D point is contained in an object’s 3D box, the feature location is responsible for the object and predicts its category, 3D box and etc.. Here, the 3D box regression targets of the feature location are relative to the 3D point coordinates of the pixel and are defined as
78
+
79
+ $$
80
+ \Delta c _ { x } = c _ { x } ^ { * } - x _ { 0 } , \Delta c _ { y } = c _ { y } ^ { * } - y _ { 0 } , \Delta c _ { z } = c _ { z } ^ { * } - z _ { 0 } , t _ { w } = \log ( w ^ { * } ) , t _ { h } = \log ( h ^ { * } ) , t _ { l } = \log ( l ^ { * } ) ,
81
+ $$
82
+
83
+ where $( x _ { 0 } , y _ { 0 } , z _ { 0 } )$ are the 3D point coordinates of the range image pixel. Similarly, the regression targets of the yaw angle $\alpha$ are also relative to the azimuthal angle of the pixel, and following the convention [YZK21], we decouple the relative azimuthal angle into $( \sin \Delta \alpha , \cos \Delta \alpha )$ . On nuScenes, we also need to predict the velocity vector $( v _ { x } ^ { * } , v _ { y } ^ { * } )$ of the object, which are used as the training targets as is. Other locations on the feature maps that correspond to 3D points not in any 3D box are used as the negative samples. Note that all the pixels within a object’s 3D box actually form a 2D mask on the range image.
84
+
85
+ Network Outputs. The nuScenes dataset has $C = 1 0$ classes of interest, which is predicted by the classification head followed by a softmax layer (the upper head in Fig. 3). The other regression targets are predicted by four sibling output heads of the regression branch, respectively, as shown in Fig. 3. Here, we use the class-specific regression predictions and thus the number of the output channels is amplified by $C$ times. Moreover, following $[ \mathrm { G L W ^ { + } } 2 1$ , RDGF16], each positive pixel also predicts the intersection-over-union (IoU) between the predicted 3D box and ground-truth one, which is multiplied to the classification score before the non-maximum suppression (NMS).
86
+
87
+ Loss Functions. The classification predictions are supervised with the cross entropy (CE) loss. Following $[ \mathrm { G L L ^ { + } } 2 1 ]$ , we dynamically reassign the classification labels during training. Specifically, for a ground-truth 3D box, only the top $K$ pixels whose predicted 3D boxes have the lowest costs with the ground-truth box are assigned with the positive labels and other pixels are considered negative, where the cost is defined as the summation of the classification loss and the opposite of the IoU between the predicted boxes and the ground-truth box, and $K$ is dynamically calculated, being the summation (rounded to an integer) of the highest $Q = 2 0$ IoUs between the predicted boxes and the ground-truth box. For the 3D box regression, we make use of both the IoU loss $[ \mathrm { Y } \mathrm { J } \mathrm { W } ^ { + } 1 6 ]$ and $L _ { 1 }$ loss. Following [TSCH19], the IoU predictions are penalized with the binary cross entropy (BCE) loss since they are in the range $[ 0 , 1 ]$ .
88
+
89
+ Inference. The inference is very similar to that of the 2D image-based detector FCOS. To be specific, the range images are forwarded through the network and the aforementioned predictions are obtained. The predictions are filtered in terms of the classification scores and only the predictions with the score greater than 0.01 are kept. The 3D boxes are restored by inverting the computation of the training targets. Then, the NMS on the 3D boxes is applied with threshold 0.2 to remove the duplications. Finally, the top 500 predictions with the highest scores are used as the final predictions.
90
+
91
+ # 4 Experiments
92
+
93
+ We conduct experiments on the nuScenes dataset $[ \mathrm { C B L ^ { + } } 2 0 ]$ , which contains 1000 scenes with 700, 150, and 150 scenes for training, validation, and testing, respectively. The training, validation, and testing sets have 28K, 6K, 6K keyframes annotated with 10 classes, respectively. For all ablation experiments, we train the models on the training set and report the performance on the validation set unless specified. The metrics of the 3D detection task are mean Average Precision (mAP) and the nuScenes detection score (NDS). The LiDAR sensor of the nuScenes dataset has $m = 3 2$ beams and $n = 1 0 8 6$ measurements per scan cycle. The mAP is based the center distances on the bird-eye view at thresholds $0 . 5 \mathrm { m }$ , 1m, $2 \mathrm { m }$ , $4 \mathrm { m }$ in place of the box IoUs. NDS is a weighted average of mAP, the translation error, the scale error, the orientation error, the velocity error, and the box attributes error.
94
+
95
+ Implementation Details. Unless specified, following [YZK21], FCOS-LiDAR is trained by 40 epochs with the AdamW [LH17] optimizer under the MMDetection3D framework [Con20], which takes ${ \sim } 2 6$ hours on 8 A100 GPUs. The one-cycle learning rate policy [ST19] with initial learning rate $1 0 ^ { - 3 }$ is used. The learning rate gradually increases to 0.01 in the first $40 \%$ epochs and then gradually decreases to $1 0 ^ { - 7 }$ in the rest of the training process. The weight decay is 0.01, and the momentum ranges from 0.85 to 0.95. In addition, due to the low vertical resolution of the range image on the nuScenes dataset, we upscale the range image in the vertical direction by 2 with the nearest interpolation. During training, the point cloud is randomly flipped along both the $x$ and $y$ axes and rotated in the range $[ - \pi , \pi ]$ , as well as globally scaled by a random factor from [0.95, 1.05]. The ground-truth copy-paste data augmentation from [YML18] is also used. For multi-frame point cloud, we use 10 sweeps in total, as in previous works [YZK21, $\mathrm { L V C ^ { + } } 1 9 ]$ . The inference time is measured on a 3090Ti GPU with batch size 1.
96
+
97
+ Table 1: Multi-round range view (MRV) projection. Time: the elapsed time of MRV.
98
+
99
+ <table><tr><td colspan="3">Single-frame</td><td colspan="3">Multi-frame</td></tr><tr><td>#Rounds</td><td>Time (ms)</td><td>mAP (%)</td><td>NDS (%)</td><td>mAP (%)</td><td>NDS (%)</td></tr><tr><td>1</td><td>0.66</td><td>53.14</td><td>51.52</td><td>55.02</td><td>61.27</td></tr><tr><td>3</td><td>0.72</td><td>53.76</td><td>53.62</td><td>56.01</td><td>62.82</td></tr><tr><td>5</td><td>0.76</td><td>53.42</td><td>53.40</td><td>57.08</td><td>63.15</td></tr><tr><td>7</td><td>0.76</td><td>53.06</td><td>53.10</td><td>56.99</td><td>63.47</td></tr></table>
100
+
101
+ Table 2: Whether to make the points of the current frame have the highest priority. The per-category mAP results are reported. “C.V.”, “Ped.” and “C.T.” indicate “construction vehicle”, “pedestrian” and “traffic cone”, respectively.
102
+
103
+ <table><tr><td>Prioritized? mAP(%) NDS(%)</td><td></td><td></td><td>Car</td><td>Truck</td><td>Bus</td><td>Trailer</td><td></td><td></td><td>C.V.Ped. Motor</td><td>Bicycle</td><td>T.C.</td><td>Barrier</td></tr><tr><td></td><td>54.29</td><td>62.31</td><td>76.8</td><td>47.3</td><td>62.0</td><td>32.0</td><td>16.5</td><td>80.3</td><td>53.8</td><td>38.2</td><td>70.1</td><td>65.9</td></tr><tr><td>√</td><td>57.08</td><td>63.15</td><td>82.1</td><td>52.3</td><td>65.2</td><td>33.6</td><td>18.3 84.1</td><td></td><td>58.5</td><td>35.3</td><td>73.4</td><td>67.9</td></tr></table>
104
+
105
+ # 4.1 Multi-round Range View Projection
106
+
107
+ Here, we conduct experiments to demonstrate the effectiveness of the proposed multi-round range view (MRV) projection. As shown in Table 1, in the single-frame settings, MRV is also helpful, for example, by increasing the number of rounds from 1 to 3, the mAP can be boosted by $0 . 6 2 \%$ . This is due to the fact that the vehicle is often in motion and the aforementioned collisions happen within a single frame as well. As you can see, if one round is used, the multi-frame fusion can improve the mAP by a substantial margin ${ \sim } 1 . 9 \%$ (from $5 3 . 1 4 \%$ to $5 5 . 0 2 \%$ ). The improvement can be dramatically increased to $3 . 9 \%$ mAP if we use 5 rounds in MRV $( 5 7 . 8 \%$ mAP), due to the fact that 5-round MRV can keep much more points in the multi-frame point clouds as mentioned in Sec. 3.2. This confirmed the effectiveness of MRV. Note that elapsed time of MRV is insensitive to the number of rounds as shown in Table 1.
108
+
109
+ More importantly, in the RV-based multi-frame settings, it is crucial to assign the highest priority to the points from the current frame when the collision happens. As shown in Table 2, without this treatment, the performance of the multi-frame fusion is significantly dropped from $5 7 . 0 8 \%$ to $5 4 . 2 9 \%$ in mAP. Note that the single-frame counterpart can already achieve mAP $5 3 . 4 2 \%$ . We argue that the neglect of this point in previous works is one of the main reasons that RV-based detectors can barely enjoy the benefit of multi-frame fusion.
110
+
111
+ # 4.2 Modality-wise Convolutions
112
+
113
+ Table 3: Modality-wise convolutions. “Multi-round”: whether to group together the channels with the same type from multiple projection rounds. Note that all the items here are with the multi-frame fusion and multi-round projections. The only difference is the way to group the channels. Time: the latency of this module.
114
+
115
+ <table><tr><td>Modality groups</td><td>Multi-round</td><td>Time (ms)</td><td>mAP (%)</td><td>NDS (%)</td></tr><tr><td>[x,y,z,r,0,Φ,i,t,e]</td><td>√</td><td>6.0</td><td>56.35</td><td>62.65</td></tr><tr><td>[x,y,z],[r,0,],[i],[t],[e]</td><td>√</td><td>4.2</td><td>56.34</td><td>63.07</td></tr><tr><td>[x],[y],[2],[r],[0],[],[],[,[e]</td><td>√</td><td>3.2</td><td>57.08</td><td>63.15</td></tr><tr><td>[x],[],[2],,[r],[0],,[],,[],[],[e]</td><td></td><td>3.8</td><td>56.83</td><td>63.15</td></tr></table>
116
+
117
+ The experimental results of our modality-wise convolutions are shown in Table 3. If we use the full convolutions here, which compute the correlation between all the channels of the range image, FCOS-LiDAR can achieve $5 6 . 3 5 \%$ in mAP. By splitting the channels into various modalities (2nd row), the performance can be slightly improved, i.e., from NDS $6 2 . 6 5 \%$ to $6 3 . 0 7 \%$ . Moreover, due to the fact that even the different channel types of the same modality are orthogonal and less correlated, we process each channel type individually. As shown in the table, the performance can be further boosted from mAP $5 6 . 3 4 \%$ to $5 7 . 0 8 \%$ (3rd row) while the lowest latency is achieved. Finally, the last row shows the results if we do not consider the channels with the same type from multiple rounds together, where the mAP is slightly worse. In Table 4, we vary the number of the conv. layers in the modality-wise convolutions. As we can see, using two conv. layers achieves the best performance here.
118
+
119
+ Table 4: Varying the number of the conv. layers in the modality-wise convolutions. Time: the latency of the modality-wise convolutions.
120
+
121
+ <table><tr><td>#Conv. Time (ms) mAP(%) NDS(%) Car Truck Bus Trailer C.V. Ped. Motor Bicycle T.C. Barrier</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>1</td><td>2.0</td><td>55.81</td><td>61.98</td><td></td><td>81.8 51.4</td><td>65.2</td><td>30.7</td><td>16.9 83.4</td><td>56.0</td><td>32.8 71.9</td><td>68.1</td></tr><tr><td>2</td><td>3.2</td><td>57.08</td><td>63.15</td><td></td><td>82.1 52.3 65.2</td><td></td><td>33.6</td><td>18.3 84.1</td><td>58.5</td><td>35.3 73.4</td><td>67.9</td></tr><tr><td>3</td><td>4.3</td><td>56.71</td><td>63.25</td><td>82.6 51.4 65.3</td><td></td><td></td><td>31.9</td><td>18.5 83.9</td><td>57.3 34.9</td><td>72.9</td><td>68.4</td></tr></table>
122
+
123
+ Table 5: Multi-scale context aggregation.
124
+
125
+ <table><tr><td>Dilations mAP(%)</td><td></td><td>NDS(%)</td><td>Car</td><td>Truck</td><td>Bus</td><td>Trailer</td><td>C.V.</td><td>Ped.</td><td>Motor</td><td>Bicycle</td><td>T.C.</td><td>Barrier</td></tr><tr><td>(1,)</td><td>55.87</td><td>62.68</td><td>81.8</td><td>51.0</td><td>64.1</td><td>32.6</td><td>16.9</td><td>83.8</td><td>56.3</td><td>31.2</td><td>72.7</td><td>68.3</td></tr><tr><td>(1,3)</td><td>56.39</td><td>62.96</td><td>82.3</td><td>52.1</td><td>65.3</td><td>32.8</td><td>17.1</td><td>83.7</td><td>58.2</td><td>32.5</td><td>72.0</td><td>67.8</td></tr><tr><td>(1,3,6)</td><td>57.08</td><td>63.15</td><td>82.1</td><td>52.3</td><td>65.2</td><td>33.6</td><td>18.3</td><td>84.1</td><td>58.5</td><td>35.3</td><td>73.4</td><td>67.9</td></tr><tr><td>(1,1,1)</td><td>56.63</td><td>63.12</td><td>82.1</td><td>51.5</td><td>65.2</td><td>32.9</td><td>17.1</td><td>83.7</td><td>58.8</td><td>33.7</td><td>73.1</td><td>68.0</td></tr></table>
126
+
127
+ In addition, as mentioned before, we employ multiple modality-wise convolution branches with various dilation rates in parallel to capture the multi-scale context. The experiments are shown in Table 5. As we can see, compared with the one using only one dilation rate, using multiple dilation rates can improve the performance by more than $1 \%$ in mAP (from $5 5 . 8 7 \%$ to $5 7 . 0 8 \%$ ).
128
+
129
+ # 4.3 Untied Weights of Detection Heads
130
+
131
+ Table 6: Whether to untie the weights of the detection heads.
132
+
133
+ <table><tr><td>Untied? mAP(%)</td><td></td><td>NDS(%)</td><td>Car</td><td>Truck</td><td>Bus</td><td>Trailer</td><td>C.V.</td><td>Ped.</td><td>Motor</td><td>Bicycle</td><td>T.C.</td><td>Barrier</td></tr><tr><td></td><td>56.44</td><td>63.09</td><td>82.0</td><td>51.1</td><td>64.3</td><td>31.1</td><td>18.3</td><td>83.8</td><td>57.9</td><td>34.7</td><td>72.9</td><td>68.4</td></tr><tr><td>√</td><td>57.08</td><td>63.15</td><td>82.1</td><td>52.3</td><td>65.2</td><td>33.6</td><td>18.3</td><td>84.1</td><td>58.5</td><td>35.3</td><td>73.4</td><td>67.9</td></tr></table>
134
+
135
+ As mentioned before, it is better to untie the weights of the detection heads between the FPN levels in the LiDAR-based detector. This is confirmed in Table 6. As we can see, by untying the weights, the performance can be improved from mAP $5 6 . 4 4 \%$ to $5 7 . 0 8 \%$ . This ravels one of the interesting differences between image-based and LiDAR-based detectors because the shared detection heads between FPN levels often achieve better performance in image-based detectors [TSCH19, $\mathrm { L D G ^ { + } } 1 7 ]$ .
136
+
137
+ Table 7: Inference time breakdowns. We compare against the state-of-the-art BEV-based CenterPoint [YZK21], which is trained with exactly the same strategies. We use the CenterPoint implementation in MMDetection3D [Con20] with sparse convolution version 1.2.1 [SPC21]. FCOS-LiDAR is faster as well as competitive in the multi-frame setting (and superior in the single-frame setting).
138
+
139
+ <table><tr><td colspan="7">Method Voxel/MRV(ms) Backbone(ms) Heads(ms) Overall(ms) mAP(%) NDS(%)</td></tr><tr><td>single-frame point cloud</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>CenterPoint [YZK21]</td><td>1.62</td><td>41</td><td>8</td><td>50.62</td><td>52.83</td><td>53.86</td></tr><tr><td>FCOS-LiDAR (Ours)</td><td>0.63</td><td>31</td><td>7</td><td>38.63</td><td>53.42</td><td>53.40</td></tr><tr><td>multi-frame point cloud</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>CenterPoint [YZK21]</td><td>1.95</td><td>63</td><td>9</td><td>73.95</td><td>60.40</td><td>67.25</td></tr><tr><td>FCOS-LiDAR(Ours)</td><td>0.76</td><td>31</td><td>7</td><td>38.76</td><td>57.08</td><td>63.15</td></tr></table>
140
+
141
+ Table 8: Comparisons with state-of-the-art methods on the nuScenes test set. The results are directly quoted from their original papers. All other methods on nuScenes rely on BEV or multiple views because previous RV-only methods are unable to handle the multi-frame fusion on this dataset. As you can see, our RV-based FCOS-LiDAR can achieve competitive performance with state-of-the-art BEV-based detectors.
142
+
143
+ <table><tr><td>Method mAP(%)NDS(%) Car Truck Bus TrailerC.V.Ped.Motor Bicycle T.C.Barrier</td></tr><tr><td></td><td>45.3</td><td></td><td></td><td>68.4 23.0 28.2 23.4</td><td>4.1 59.7 27.4 1.1 30.8</td></tr><tr><td>PointPillars [LVC+ 19] SSN [ZMW+20]</td><td>30.5 46.3 56.9</td><td>80.7 37.5 39.9</td><td>43.9 14.672.3 43.7</td></tr><tr><td>CVCNet [CSCY20] 55.3 64.4</td><td>82.7 46.1 46.6 49.4 22.679.8 59.1</td></tr><tr><td>CBGS[YZK21] 52.8 63.3</td><td>31.4 81.1 48.5 54.9 42.9 10.580.1 51.5</td></tr><tr><td>CenterPoint [YZK21] 58.0</td><td>22.3 70.9</td></tr><tr><td>AFDetV2 [HDG+22] 62.4 68.5 S2M2-SSD [ZHJF22] 62.9 69.3 86.3 56.0</td><td>65.5 84.6 51.0 60.2 53.2 17.583.4 53.7 23.7 76.7 86.3 54.2 62.5 58.9 26.785.8 63.8 34.3 80.1</td></tr></table>
144
+
145
+ # 4.4 Inference Time Comparisons
146
+
147
+ We compare the inference time of FCOS-LiDAR and the state-of-the-art BEV-based detector CenterPoint [YZK21]. As shown in Table 7, the proposed MRV is faster than the voxelization in CenterPoint. It is worth noting that the voxelization algorithm reported here is nondeterministic, which cannot yield stable results but being significantly faster. In the official code of MMDetection3D [Con20], the deterministic voxelization takes ${ \sim } 1 0 0 \mathrm { m s }$ for the multi-frame point clouds. In sharp contrast, the proposed MRV is always deterministic and highly efficient. Moreover, due to the compactness of the range image, our network can be implemented with the standard convolutions alone, thus being much more efficient than CenterPoint using the sparse convolutions as shown in the table. The elapsed time of the post-processing is omitted here as it is closely similar in both methods.
148
+
149
+ # 4.5 Comparisons with State-of-the-art Methods
150
+
151
+ We further compare FCOS-LiDAR with other state-of-the-art methods on the nuScenes test set. For the model on the test set, we increase the number of channels in the detection heads from 64 to 128, which improve the validation mAP by ${ \sim } 0 . 6 \%$ with slightly longer latency. Additionally, we remove the copy-paste data augmentation in the last 5 epochs during training as in [WMZY21] (termed as the “fade strategy” in [WMZY21]). This can improve the performance by about $2 \%$ mAP. As shown in Table 8, FCOS-LiDAR achieves competitive performance with other state-of-the-art BEV-based methods. Note that in order to leverage the multi-frame fusion on nuScenes, all other methods on nuScenes rely on BEV (or the multi-view fusion). FCOS-LiDAR is the first RV-only method that is able to benefit from the multi-frame fusion.
152
+
153
+ # 5 Conclusion
154
+
155
+ We have presented an efficient range-view-based 3D object detector FCOS-LiDAR. FCOS-LiDAR shows the challenging LiDAR-based object detection can also be solved with the standard convolutions alone, similar to what we have done in the image-based 2D object detection. We also for the first time show the RV-based 3D detector can also enjoy the benefit of the multi-frame fusion with the proposed MRV. We hope our strong results can encourage the community to pay more attention to this promising direction.
156
+
157
+ Societal Impacts. This paper presents a method that can locate the 3D location of the objects of interest in LiDAR point clouds. This technique might be abused for military purposes, for example, on lethal autonomous weapons.
158
+
159
+ Acknowledgments. C. Shen’s participation was in part supported by a major grant from Zhejiang Provincial Government.
160
+
161
+ # References
162
+
163
+ $[ \mathbf { B } \mathbf { S } \mathbf { M } ^ { + } 2 1 ]$ Alex Bewley, Pei Sun, Thomas Mensink, Dragomir Anguelov, and Cristian Sminchisescu. Range conditioned dilated convolutions for scale invariant 3d object detection. In Proc. Conf. Robot Learning, pages 627–641. PMLR, 2021.
164
+ $[ \mathrm { C B L } ^ { + } 2 0 ]$ Holger Caesar, Varun Bankiti, Alex Lang, Sourabh Vora, Venice Erin Liong, Qiang Xu, Anush Krishnan, Yu Pan, Giancarlo Baldan, and Oscar Beijbom. Nuscenes: A multimodal dataset for autonomous driving. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 11621–11631, 2020. [Con20] MMDetection3D Contributors. MMDetection3D: OpenMMLab next-generation platform for general 3D object detection. https://github.com/open-mmlab/mmdetection3d, 2020.
165
+ [CSCY20] Qi Chen, Lin Sun, Ernest Cheung, and Alan Yuille. Every view counts: Cross-view consistency in 3d object detection with hybrid-cylindrical-spherical voxelization. In Proc. Advances in Neural Inf. Process. Syst., volume 33, pages 21224–21235, 2020.
166
+ [DLSJ22] Shengheng Deng, Zhihao Liang, Lin Sun, and Kui Jia. Vista: Boosting 3d object detection via dual cross-view spatial attention. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 8448–8457, June 2022.
167
+ $[ \mathrm { F P Z } ^ { + } 2 1 ]$ Lue Fan, Ziqi Pang, Tianyuan Zhang, Yu-Xiong Wang, Hang Zhao, Feng Wang, Naiyan Wang, and Zhaoxiang Zhang. Embracing single stride 3d object detector with sparse transformer. arXiv preprint arXiv:2112.06375, 2021.
168
+ $[ \mathrm { F X W } ^ { + } 2 1 ]$ Lue Fan, Xuan Xiong, Feng Wang, Naiyan Wang, and Zhaoxiang Zhang. Rangedet: In defense of range view for lidar-based 3d object detection. In Proc. IEEE Int. Conf. Comp. Vis., pages 2918–2927, 2021.
169
+ $[ \mathrm { G L L ^ { + } } 2 1 ]$ Zheng Ge, Songtao Liu, Zeming Li, Osamu Yoshie, and Jian Sun. OTA: Optimal transport assignment for object detection. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 303–312, 2021.
170
+ $[ \mathrm { G L W } ^ { + } 2 1 ]$ Zheng Ge, Songtao Liu, Feng Wang, Zeming Li, and Jian Sun. Yolox: Exceeding yolo series in 2021. arXiv preprint arXiv:2107.08430, 2021. [Gra14] Benjamin Graham. Spatially-sparse convolutional neural networks. arXiv preprint arXiv:1409.6070, 2014.
171
+ $[ \mathrm { H D G } ^ { + } 2 2 ]$ Yihan Hu, Zhuangzhuang Ding, Runzhou Ge, Wenxin Shao, Li Huang, Kun Li, and Qiang Liu. Afdetv2: Rethinking the necessity of the second stage for object detection from point clouds. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 36, pages 969–979, 2022.
172
+ [HZRS16] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 770–778, 2016.
173
+ $[ \mathrm { L A E ^ { + } } 1 6 ]$ Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, and Alexander Berg. SSD: Single shot multibox detector. In Proc. Eur. Conf. Comp. Vis., pages 21–37. Springer, 2016.
174
+ $[ \mathrm { L D G ^ { + } } 1 7 ]$ Tsung-Yi Lin, Piotr Dollár, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. Feature pyramid networks for object detection. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 2117–2125, 2017. [LH17] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. [Li17] Bo Li. 3d fully convolutional network for vehicle detection in point cloud. In Proc. IEEE/RSJ Int. Conf. Intelligent Robots and Systems, pages 1513–1518, 2017.
175
+ $[ \mathrm { L L C } ^ { + } 2 1 ]$ Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In Proc. IEEE Int. Conf. Comp. Vis., pages 10012–10022, 2021. [LSD15] Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 3431–3440, 2015.
176
+ $[ \mathrm { L V C ^ { + } } 1 9 ]$ Alex Lang, Sourabh Vora, Holger Caesar, Lubing Zhou, Jiong Yang, and Oscar Beijbom. Pointpillars: Fast encoders for object detection from point clouds. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 12697–12705, 2019. [LZX16] Bo Li, Tianlei Zhang, and Tian Xia. Vehicle detection from 3d lidar using fully convolutional network. arXiv preprint arXiv:1608.07916, 2016.
177
+ $[ \mathrm { M L K ^ { + } } 1 9 ]$ Gregory P Meyer, Ankit Laddha, Eric Kee, Carlos Vallespi-Gonzalez, and Carl Wellington. Lasernet: An efficient probabilistic 3d object detector for autonomous driving. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 12677–12686, 2019.
178
+ [QSMG17] Charles R Qi, Hao Su, Kaichun Mo, and Leonidas J Guibas. Pointnet: Deep learning on point sets for 3d classification and segmentation. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 652–660, 2017.
179
+ [RDGF16] Joseph Redmon, Santosh Divvala, Ross Girshick, and Ali Farhadi. You only look once: Unified, real-time object detection. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 779–788, 2016. [RF17] Joseph Redmon and Ali Farhadi. Yolo9000: Better, faster, stronger. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 7263–7271, 2017.
180
+ [RHGS15] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster R-CNN: Towards real-time object detection with region proposal networks. In Proc. Advances in Neural Inf. Process. Syst., pages 91–99, 2015.
181
+ $[ \mathrm { S K D } ^ { + } 2 0 ]$ Pei Sun, Henrik Kretzschmar, Xerxes Dotiwalla, Aurelien Chouard, Vijaysai Patnaik, Paul Tsui, James Guo, Yin Zhou, Yuning Chai, Benjamin Caine, et al. Scalability in perception for autonomous driving: Waymo open dataset. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 2446–2454, 2020. [SPC21] https://github.com/traveller59/spconv/tree/v1.2.1, 2021. [ST19] Leslie Smith and Nicholay Topin. Super-convergence: Very fast training of neural networks using large learning rates. In Artificial Intelligence and Machine Learning for Multi-domain Operations Applications, 2019.
182
+ $[ \mathrm { S W C } ^ { + } 2 1 ]$ Pei Sun, Weiyue Wang, Yuning Chai, Gamaleldin Elsayed, Alex Bewley, Xiao Zhang, Cristian Sminchisescu, and Dragomir Anguelov. RSN: Range sparse net for efficient, accurate lidar 3d object detection. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 5725–5734, 2021.
183
+ [TSCH19] Zhi Tian, Chunhua Shen, Hao Chen, and Tong He. FCOS: Fully convolutional one-stage object detection. In Proc. IEEE Int. Conf. Comp. Vis., pages 9627–9636, 2019.
184
+ [WMZY21] Chunwei Wang, Chao Ma, Ming Zhu, and Xiaokang Yang. PointAugmenting: Cross-modal augmentation for 3d object detection. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 11794–11803, 2021. [XBT22] Xinge Zhu Qingqiu Huang Yilun Chen Hongbo Fu Xuyang Bai, Zeyu Hu and Chiew-Lan Tai. TransFusion: Robust Lidar-Camera Fusion for 3d Object Detection with Transformers. CVPR, 2022.
185
+ $[ \mathrm { Y J W ^ { + } } 1 6 ]$ Jiahui Yu, Yuning Jiang, Zhangyang Wang, Zhimin Cao, and Thomas Huang. Unitbox: An advanced object detection network. In Proc. ACM Int. Conf. Multimedia, pages 516–520, 2016. [YML18] Yan Yan, Yuxing Mao, and Bo Li. Second: Sparsely embedded convolutional detection. Sensors, 18(10):3337, 2018. [YZK21] Tianwei Yin, Xingyi Zhou, and Philipp Krahenbuhl. Center-based 3d object detection and tracking. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 11784–11793, 2021. [ZHJF22] Wu Zheng, Mingxuan Hong, Li Jiang, and Chi-Wing Fu. Boosting 3d object detection by simulating multimodality on point clouds. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 13638–13647, 2022.
186
+ $[ Z \mathrm { M W } ^ { + } 2 0 ]$ Xinge Zhu, Yuexin Ma, Tai Wang, Yan Xu, Jianping Shi, and Dahua Lin. SSN: shape signature networks for multi-class object detection from point clouds. In European Conference on Computer Vision, pages 581–597. Springer, 2020. [ZT18] Yin Zhou and Oncel Tuzel. Voxelnet: End-to-end learning for point cloud based 3d object detection. In Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pages 4490–4499, 2018. [ZWK19] Xingyi Zhou, Dequan Wang, and Philipp Krähenbühl. Objects as points. arXiv: Comp. Res. Repository, 2019.
187
+
188
+ # Checklist
189
+
190
+ 1. For all authors...
191
+
192
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
193
+ (b) Did you describe the limitations of your work? [Yes] ] In multi-frame settings, the RV-based detector still cannot outperform the BEV-based ones despite being faster.
194
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See the conclusion section.
195
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
196
+
197
+ 2. If you are including theoretical results...
198
+
199
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
200
+
201
+ 3. If you ran experiments...
202
+
203
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] We will release our code and models on GitHub soon.
204
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
205
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] The used dataset is relatively large and none of the previous works reports the error bars on this dataset.
206
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See implementation details.
207
+
208
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
209
+
210
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
211
+ (b) Did you mention the license of the assets? [N/A]
212
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
213
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
214
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
215
+
216
+ 5. If you used crowdsourcing or conducted research with human subjects...
217
+
218
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
219
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
220
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/2EDqbSCnmF/2EDqbSCnmF.md ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Any-to-Any Generation via Composable Diffusion
2
+
3
+ # Zineng Tang1∗
4
+
5
+ # Mohit Bansal1†
6
+
7
+ Ziyi Yang2† Chenguang ${ \bf Z } { \bf h } { \bf u } ^ { 2 \ddagger }$ Michael Zeng2 1University of North Carolina at Chapel Hill 2Microsoft Azure Cognitive Services Research https://codi-gen.github.io
8
+
9
+ # Abstract
10
+
11
+ We present Composable Diffusion (CoDi), a novel generative model capable of generating any combination of output modalities, such as language, image, video, or audio, from any combination of input modalities. Unlike existing generative AI systems, CoDi can generate multiple modalities in parallel and its input is not limited to a subset of modalities like text or image. Despite the absence of training datasets for many combinations of modalities, we propose to align modalities in both the input and output space. This allows CoDi to freely condition on any input combination and generate any group of modalities, even if they are not present in the training data. CoDi employs a novel composable generation strategy which involves building a shared multimodal space by bridging alignment in the diffusion process, enabling the synchronized generation of intertwined modalities, such as temporally aligned video and audio. Highly customizable and flexible, CoDi achieves strong joint-modality generation quality, and outperforms or is on par with the unimodal state-of-the-art for single-modality synthesis. The project page with demonstrations and code is at https://codi-gen.github.io/
12
+
13
+ ![](images/f6d7a60ecba1b89ddec9c2b8b8bfea37a1e8ff89e67fccf04a7b8dcb4427834d.jpg)
14
+ Figure 1: CoDi can generate various (joint) combinations of output modalities from diverse (joint) sets of inputs: video, image, audio, and text (example combinations depicted by the colored arrows).
15
+
16
+ # 1 Introduction
17
+
18
+ Recent years have seen the rise of powerful cross-modal models that can generate one modality from another, e.g. text-to-text [6, 37], text-to-image [13, 19, 22, 41, 44], or text-to-audio [23, 33]. However, these models are restricted in their real-world applicability where multiple modalities coexist and interact. While one can chain together modality-specific generative models in a multi-step generation setting, the generation power of each step remains inherently limited, and a serial, multistep process can be cumbersome and slow. Moreover, independently generated unimodal streams will not be consistent and aligned when stitched together in a post-processing way (e.g., synchronized video and audio). The development of a comprehensive and versatile model that can generate any combination of modalities from any set of input conditions has been eagerly anticipated, as it would more accurately capture the multimodal nature of the world and human comprehension, seamlessly consolidate information from a wide range of sources, and enable strong immersion in human-AI interactions (for example, by generating coherent video, audio, and text description at the same time).
19
+
20
+ In pursuit of this goal, we propose Composable Diffusion, or CoDi, the first model capable of simultaneously processing and generating arbitrary combinations of modalities as shown in Fig. 1. Training a model to take any mixture of input modalities and flexibly generate any mixture of outputs presents significant computational and data requirements, as the number of combinations for the input and output modalities scales exponentially. Also aligned training data for many groups of modalities is scarce or even non-existent, making it infeasible to train with all possible input-output combinations. To address this challenge, we propose to align multiple modalities in both the input conditioning (Section 3.2) and generation diffusion step (Section 3.4). Furthermore, a proposed “Bridging Alignment” strategy for contrastive learning (Section 3.2) allows us to efficiently model the exponential number of input-output combinations with a linear number of training objectives.
21
+
22
+ Building a model with any-to-any generation capacity with exceptional generation quality requires comprehensive model design and training on diverse data resources. Therefore, we build CoDi in an integrative way. First, we train a latent diffusion model (LDM) for each modality, e.g., text, image, video, and audio. These models can be trained in parallel independently, ensuring exceptional singlemodality generation quality using widely available modality-specific training data (i.e., data with one or more modalities as input and one modality as output). For conditional cross-modality generation, such as generating images using audio+language prompts, the input modalities are projected into a shared feature space (Section 3.2), and the output LDM attends to the combination of input features. This multimodal conditioning mechanism prepares the diffusion model to condition on any modality or combination of modalities without directly training for such settings.
23
+
24
+ The second stage of training enables the model to handle many-to-many generation strategies that involve simultaneously generating arbitrary combinations of output modalities. To the best of our knowledge, CoDi is the first AI model with this capability. This is achieved by adding a crossattention module to each diffuser, and an environment encoder $V$ to project the latent variable of different LDMs into a shared latent space (Section 3.4). Next, we freeze the parameters of the LDM, training only the cross-attention parameters and $V$ . Since the environment encoder of different modalities are aligned, an LDM can cross-attend with any group of co-generated modalities by interpolating the representation’s output by $V$ . This enables CoDi to seamlessly generate any group of modalities, without training on all possible generation combinations. This reduces the number of training objectives from exponential to linear.
25
+
26
+ We demonstrate the any-to-any generation capability of CoDi, including single-to-single modality generation, multi-condition generation, and the novel capacity of joint generation of multiple modalities. For example, generating synchronized video and audio given the text input prompt; or generating video given a prompt image and audio. We also provide a quantitative evaluation of CoDi using eight multimodal datasets. As the latest work from Project i-Code [55] towards Composable AI, CoDi exhibits exceptional generation quality across assorted scenarios, with synthesis quality on par or even better than single to single modality SOTA, e.g., audio generation and audio captioning.
27
+
28
+ # 2 Related Works
29
+
30
+ Diffusion models (DMs) learn the data distribution by denoising and recovering the original data. Deep Diffusion Process (DDP) [45] adopts a sequence of reversible diffusion steps to model image probability distribution. It uses a reversible encoder to map the input image to a latent space and a decoder to map the latent variables to an output image. Denoising diffusion probabilistic model (DDPM) [20] uses a cascade of diffusion processes to gradually increase the complexity of the probability density function model. At each step, the model adds noise to the input image and estimates the corresponding noise level using an autoregressive model. This allows the model to capture the dependencies between adjacent pixels and generate high-quality images. Score-based generative models (SOG) [46] use the score function to model the diffusion process. [40] generates high-fidelity images conditioned on CLIP representations of text prompts. Latent diffusion model (LDM) [41] uses a VAE to encode inputs into latent space to reduce modeling dimension and improves efficiency. The motivation is that image compression can be separated into semantic space by a diffusion model and perceptual space by an autoencoder. By incorporating temporal modeling modules and cascading model architectures, video diffusion models have been built upon image diffusers to generate temporally consistent and inherent frames[14, 19, 21, 44]. Diffusion models have also been applied to other domains, such as generating audio from text and vision prompts[23, 33].
31
+
32
+ ![](images/fd34f6f54041b6f9329e8b6d950176f23a2bd0ce1819fa8d9711a4b7d903ec66.jpg)
33
+ Figure 2: CoDi model architecture: (a) We first train individual diffusion model with aligned prompt encoder by “Bridging Alignment”; (b) Diffusion models learn to attend with each other via “Latent Alignment”; (c) CoDi achieves any-to-any generation with a linear number of training objectives.
34
+
35
+ Multimodal modeling has experienced rapid advancement recently, with researchers striving to build uniform representations of multiple modalities using a single model to achieve more comprehensive cross-modal understanding. Vision transformers [11], featuring diverse model architectures and training techniques, have been applied to various downstream tasks such as vision Q&A and image captioning. Multimodal encoders have also proven successful in vision-language [1, 8, 57], videoaudio [47] and video-speech-language [55, 56] domains. Aligning data from different modalities is an active research area [12, 38], with promising applications in cross-modality retrieval and building uniform multimodal representations [33, 35, 41].
36
+
37
+ # 3 Methodology
38
+
39
+ # 3.1 Preliminary: Latent Diffusion Model
40
+
41
+ Diffusion models (DM) represent a class of generative models that learn data distributions $p ( { \pmb x } )$ by simulating the diffusion of information over time. During training, random noise is iteratively added to $_ { \textbf { \em x } }$ , while the model learns to denoise the examples. For inference, the model denoises data points sampled from simple distributions such as Gaussian. Latent diffusion models (LDM) [41] learn the distribution of the latent variable $_ { z }$ corresponding to $_ { \textbf { \em x } }$ , significantly reducing computational cost by decreasing the data dimension.
42
+
43
+ In LDM, an autoencoder is first trained to reconstruct $_ { \textbf { \em x } }$ , i.e., $\hat { \pmb { x } } = D ( E ( \pmb { x } ) )$ , where $E$ and $D$ denote the encoder and decoder, respectively. The latent variable $z = E ( { \pmb x } )$ is iteratively diffused over time steps $t$ based on a variance schedule $\beta _ { 1 } , \ldots , \beta _ { T }$ , i.e., $q ( z _ { t } | z _ { t - 1 } ) = \mathcal { N } ( z _ { t } ; \sqrt { 1 - \beta _ { t } } z _ { t - 1 } , \beta _ { t } I )$ [20, 45].
44
+
45
+ The forward process allows the random sampling of ${ \boldsymbol { z } } _ { t }$ at any timestep in a closed form [20, 45]: $\boldsymbol { z } _ { t } = \alpha _ { t } \boldsymbol { z } + \sigma _ { t } \boldsymbol { \epsilon }$ , where $\epsilon \sim \mathcal { N } ( 0 , I )$ , $\alpha _ { t } : = 1 - \beta _ { t }$ and $\begin{array} { r } { \sigma _ { t } : = \dot { 1 } - \prod _ { s = 1 } ^ { t } \dot { \alpha } _ { s } } \end{array}$ . The diffuser learns how to denoise from $\left\{ { z } _ { t } \right\}$ to recover $_ z$ . Following the reparameterization method proposed in [20], the denoising training objective can be expressed as [41]:
46
+
47
+ $$
48
+ \begin{array} { r } { \mathcal { L } _ { D } = \mathbb { E } _ { z , \epsilon , t } \Vert \epsilon - \epsilon _ { \theta } ( z _ { t } , t , C ( \pmb { y } ) ) \Vert _ { 2 } ^ { 2 } . } \end{array}
49
+ $$
50
+
51
+ In data generation, the denoising process can be realized through reparameterized Gaussian sampling:
52
+
53
+ $$
54
+ p ( z _ { t - 1 } | z _ { t } ) = \mathcal { N } \left( z _ { t - 1 } ; \frac { 1 } { \sqrt { \alpha _ { t } } } \left( z _ { t } - \frac { \beta _ { t } } { \sqrt { \sigma _ { t } } } \epsilon _ { \theta } \right) , \beta _ { t } I \right) .
55
+ $$
56
+
57
+ In $\mathcal { L } _ { D }$ , the diffusion time step $t \sim \mathcal { U } [ 1 , T ]$ ; $\epsilon _ { \theta }$ is a denoising model with UNet backbone parameterized by $\theta ; { \boldsymbol { y } }$ represents the conditional variable that can be used to control generation; $C$ is the prompt encoder. The conditioning mechanism is implemented by first featurizing $\textbf { { y } }$ into $C ( \boldsymbol { y } )$ , then the UNet $\epsilon _ { \theta }$ conditions on $C ( \boldsymbol { y } )$ via cross-attention, as described in [41]. Distinct from previous works, our model can condition on any combinations of modalities of text, image, video and audio. Details are presented in the following section.
58
+
59
+ # 3.2 Composable Multimodal Conditioning
60
+
61
+ To enable our model to condition on any combination of input/prompt modalities, we align the prompt encoder of text, image, video and audio (denoted by $C _ { t }$ , $C _ { i }$ , $C _ { v }$ , and $C _ { a }$ , respectively) to project the input from any modality into the same space. Multimodal conditioning can then be conveniently achieved by interpolating the representations of each modality $m$ : $\begin{array} { r } { C ( x _ { t } , \bar { x _ { i } } , x _ { v } , x _ { a } ) = \sum _ { m } \alpha _ { m } C ( \bar { m } ) } \end{array}$ for $m \in \ b { x } _ { t } , \ b { x } _ { i } , \ b { x } _ { v } , \ b { x } _ { a }$ , with $\textstyle \sum _ { m } \alpha _ { m } = 1$ . Through simple weighted interpolation of aligned embeddings, we enable models trained with single-conditioning (i.e., with only one input) to perform zero-shot multi-conditioning (i.e., with multiple inputs). This process is illustrated in Fig. 2 (a)(2).
62
+
63
+ Optimizing all four prompt encoders simultaneously in a combinatorial manner is computationally heavy, with $\mathcal { O } ( n ^ { 2 } )$ pairs. Additionally, for certain dual modalities, well-aligned paired datasets are limited or unavailable e.g., image-audio pairs. To address this challenge, we propose a simple and effective technique called "Bridging Alignment" to efficiently align conditional encoders. As shown in Fig. 2 (a)(1), we choose the text modality as the "bridging" modality due to its ubiquitous presence in paired data, such as text-image, text-video, and text-audio pairs. We begin with a pretrained text-image paired encoder, i.e., CLIP [38]. We then train audio and video prompt encoders on audio-text and video-text paired datasets using contrastive learning, with text and image encoder weights frozen.
64
+
65
+ In this way, all four modalities are aligned in the feature space. As shown in Section 5.2, CoDi can effectively leverage and combine the complementary information present in any combination of modalities to generate more accurate and comprehensive outputs. The high generation quality remains unaffected with respect to the number of prompt modalities. As we will discuss in subsequent sections, we continue to apply Bridging Alignment to align the latent space of LDMs with different modalities to achieve joint multimodal generation.
66
+
67
+ # 3.3 Composable Diffusion
68
+
69
+ Training an end-to-end anything-to-anything model requires extensive learning on various data resources. The model also needs to maintain generation quality for all synthesis flows. To address these challenges, CoDi is designed to be composable and integrative, allowing individual modalityspecific models to be built independently and then smoothly integrated later. Specifically, we start by independently training image, video, audio, and text LDMs. These diffusion models then efficiently learn to attend across modalities for joint multimodal generation (Section 3.4) by a novel mechanism named “latent alignment”.
70
+
71
+ Image Diffusion Model. The image LDM follows the same structure as Stable Diffusion 1.5 [41] and is initialized with the same weights. Reusing the weights transfers the knowledge and exceptional generation fidelity of Stable Diffusion trained on large-scale high-quality image datasets to CoDi.
72
+
73
+ Video Diffusion Model. To model the temporal properties of videos and simultaneously maintain vision generation quality, we construct the video diffuser by extending the image diffuser with temporal modules. Specifically, we insert pseudo-temporal attention before the residual block [13]. However, we argue that pseudo-temporal attention only enables video frames to globally attend to each other by flattening the pixels (height, width dimension) to batch dimension, resulting in a lack of cross-frame interaction between local pixels. We argue that this results in the common temporal-inconsistency issue in video generation that locations, shapes, colors, etc. of objects can be inconsistent across generated frames. To address this problem, we propose adapting the latent shift method [2] that performs temporal-spatial shifts on latent features in accordance with temporal attention. We divide the video by the hidden dimension into $k = 8$ chunks, and for each chunk $i = 0$ to 7, we shift the temporal dimension forward by $i$ positions. Further details will be provided in the appendix.
74
+
75
+ Audio Diffusion Model. To enable flexible cross-modality attention in joint generation, the audio diffuser is designed to have a similar architecture to vision diffusers, where the mel-spectrogram can be naturally viewed as an image with 1 channel. We use a VAE encoder to encode the melspectrogram of audio to a compressed latent space. In audio synthesis, a VAE decoder maps the latent variable to the mel-spectrogram, and a vocoder generates the audio sample from the mel-spectrogram. We employ the audio VAE from [33] and the vocoder from [27].
76
+
77
+ Text Diffusion Model. The VAE of the text LDM is OPTIMUS [29], and its encoder and decoder are [9] and GPT-2 [39], respectively. For the denoising UNet, unlike the one in image diffusion, the 2D convolution in residual blocks is replaced with 1D convolution [53].
78
+
79
+ # 3.4 Joint Multimodal Generation by Latent Alignment
80
+
81
+ The final step is to enable cross-attention between diffusion flows in joint generation, i.e., generating two or more modalities simultaneously. This is achieved by adding cross-modal attention sublayers to the UNet $\epsilon _ { \theta }$ (Fig. 2 (b)(2)). Specifically, consider a diffusion model of modality $A$ that cross-attends with another modality $B$ . Let the latent variables of modalities $m _ { A }$ and $m _ { B }$ at diffusion step $t$ be denoted as $ { \boldsymbol { z } } _ { t } ^ { A }$ and $\hat { z _ { t } ^ { B } }$ , respectively. The proposed “Latent Alignment” technique is such that a modality-specific environment encoder $V _ { B }$ first projects $ { \boldsymbol { z } } _ { t } ^ { B }$ into a shared latent space for different modalities. Then, in each layer of the UNet for modality $A$ , a cross-attention sublayer attends to $V _ { B } \big ( z _ { t } ^ { B } \big )$ . For the diffusion model of modality $A$ , the training objective in Eq. (1) now becomes:
82
+
83
+ $$
84
+ \mathcal { L } _ { C r o s s } ^ { A } = \mathbb { E } _ { z , \epsilon , t } \Vert \epsilon - \epsilon _ { \theta _ { c } } ( z _ { t } ^ { A } , V _ { B } ( z _ { t } ^ { B } ) , t , C ( \pmb { y } ) ) \Vert _ { 2 } ^ { 2 } ,
85
+ $$
86
+
87
+ where $\theta _ { c }$ denotes the weights of cross-attention modules in the UNet.
88
+
89
+ The training objective of $A + B$ joint generation is $\mathcal { L } _ { C r o s s } ^ { A } + \mathcal { L } _ { C r o s s } ^ { B }$ . $V ( \cdot )$ of different modalities are trained to be aligned with contrastive learning. Since $z _ { t } ^ { A }$ and $z _ { t } ^ { B }$ at any time step can be sampled with closed form in the diffusion process Section 3.1, one can conveniently train the contrastive learning together with $\mathcal { L } _ { C r o s s }$ . The purpose of $V$ is to achieve the generation of any combination of modalities (in polynomial) by training on a linear number of joint-generation tasks. For example, if we have trained the joint generation of modalities $A , B$ , and $B$ , $C$ independently, then we have $V _ { A } ( z _ { t } ^ { A } )$ , $V _ { B } \big ( z _ { t } ^ { B } \big )$ , and $V _ { C } ( z _ { t } ^ { C } )$ aligned. Therefore, CoDi can seamlessly achieve joint generation of modalities $A$ and $C$ without any additional training. Moreover, such design automatically effortlessly enables joint generation of modalities $A$ , $B$ , and $C$ concurrently. Specifically, UNet of $A$ can cross-attend with the interpolation of $V _ { B } \big ( z _ { t } ^ { B } \big )$ , and $V _ { C } ( z _ { t } ^ { C } )$ , although CoDi has not been trained with such task.
90
+
91
+ As shown in Fig. 2(b)(3), we follow similar designs to the "Bridging Alignment" in training joint generation: (1) We first train the cross-attention weights in the image and text diffusers, as well as their environment encoders $V$ , on text-image paired data. (2) We freeze the weights of the text diffuser and train the environment encoder and cross-attention weights of the audio diffuser on text-audio paired data. (3) Finally we freeze the audio diffuser and its environment encoder, and train the joint generation of the video modality on audio-video paired data. As demonstrated in Section 5.3, although only trained on three paired joint generation tasks (i.e, Text $^ +$ Audio, Text+Image, and Video+Audio), CoDi is capable of generating assorted combinations of modalities simultaneously that are unseen in training, e.g., joint image-text-audio generation in Fig. 5.
92
+
93
+ Table 1: Training tasks (CT stands for “contrastive learning” to align prompt encoders) and datasets with corresponding statistics. \* denotes the number of accessible examples in the original datasets.
94
+
95
+ <table><tr><td>Categories</td><td>Tasks</td><td>Datasets</td><td># of samples</td><td>Domain</td></tr><tr><td>Image + Text</td><td>Image-→Text,Text-→Image Text-→Image+Text</td><td>Laion400M [42]</td><td>400M</td><td>Open</td></tr><tr><td>Audio + Text</td><td>Text→Audio,Audio-→Text, Text-→Audio+Text,Audio-Text CT</td><td>AudioSet [16] AudioCaps [24] Freesound 500K BBC Sound Effect</td><td>900K* 46K 2.5M 30K</td><td>YouTube YouTube Public audio samples Authentic natural sound</td></tr><tr><td>Audiovisual</td><td>Image→Audio,Image→Video+Audio</td><td>AudioSet SoundNet [3]</td><td>900K* 1.0M*</td><td>YouTube Flickr, natural sound</td></tr><tr><td>Video</td><td>Text-→Video,Image→Video, Video-Text CT</td><td>Webvid10M[4] HD-Villa-100M [54]</td><td>10.7M 100M</td><td>Short videos YouTube</td></tr></table>
96
+
97
+ ![](images/493f24169a89b5450efae4d85c3805ebc13a132fcf5e28a3a488cbd564530264.jpg)
98
+ Figure 3: Single-to-single modality generation. Clockwise from top left: text image, image text, image video, audio image.
99
+
100
+ # 4 Experiments
101
+
102
+ # 4.1 Training Objectives and Datasets
103
+
104
+ We list training tasks of CoDi in Table 1, including single modality synthesis, joint multimodal generation, and contrastive learning to align prompt encoders. Table 1 provides an overview of the datasets, tasks, number of samples, and domain. Datasets are from the following domains: image $^ +$ text (e.g. image with caption), audio $^ +$ text (e.g. audio with description), audio $^ +$ video (e.g. video with sound), and video $^ +$ text (e.g. video with description). As one may have noticed, the language modality appears in most datasets and domains. This echos the idea of using text as the bridge modality to be able to extrapolate and generate new unseen combinations such as audio and image bridged by text, as mentioned in Section 3.2 and Section 3.4. Due to space limit, more details on training datasets and can be found in Appendix C, model architecture details in Appendix Appendix A.1, and training details in Appendix B.
105
+
106
+ Image $^ +$ Text. We use a recently developed large-scale image caption dataset, Laion400M [42]. This image-text paired data allows us to train with tasks text image, image text, and the joint generation of image and text. For the joint generation task, we propose to train with text image+text, where the prompt text is the truncated image caption, and the output text is the original caption. Since the condition information is incomplete, the text and image diffuser will need to learn to attend with each other through the joint generation process.
107
+
108
+ Table 2: COCO-caption [32] FID scores for text-to-image generation.
109
+
110
+ <table><tr><td>Method</td><td>FID↓</td></tr><tr><td>CogView [10]</td><td>27.10</td></tr><tr><td>GLIDE [36]</td><td>12.24</td></tr><tr><td>Make-a-Scene [15]</td><td>11.84</td></tr><tr><td>LDM [41]</td><td>12.63</td></tr><tr><td>Stable Diffusion-1.4</td><td>11.21</td></tr><tr><td>Stable Diffusion-1.5</td><td>11.12</td></tr><tr><td>Versatile Diffusion [53]</td><td>11.10</td></tr><tr><td>CoDi (Ours)</td><td>11.26</td></tr></table>
111
+
112
+ Table 3: MSR-VTT text-to-video Table 4: UCF-101 text-to-video generation performance. generation performance.
113
+
114
+ <table><tr><td>Method</td><td>Zero-Shot</td><td>CLIPSIM ↑</td></tr><tr><td>GODIVA [50]</td><td>No</td><td>0.2402</td></tr><tr><td>NUWA [51]</td><td>No</td><td>0.2439</td></tr><tr><td>CogVideo [22]</td><td>Yes</td><td>0.2631</td></tr><tr><td>Make-A-Video [44]</td><td>Yes</td><td>0.3049</td></tr><tr><td>Video LDM[5]</td><td>Yes</td><td>0.2929</td></tr><tr><td>CoDi(Ours)</td><td>Yes</td><td>0.2890</td></tr></table>
115
+
116
+ <table><tr><td>Method</td><td>IS(1)</td><td>FVD (↑)</td></tr><tr><td>Cog Video (Chinese)</td><td>23.55</td><td>751.34</td></tr><tr><td>CogVideo (English)</td><td>25.27</td><td>701.59</td></tr><tr><td>Make-A-Video</td><td>33.00</td><td>367.23</td></tr><tr><td>Video LDM</td><td>33.45</td><td>550.61</td></tr><tr><td>CoDi(Ours)</td><td>32.88</td><td>596.34</td></tr></table>
117
+
118
+ Table 5: The comparison between our audio diffuser and baseline TTA generation models. Evaluation is conducted on AudioCaps test set. AS, AC, FSD, BBC, and SDN stand for AudioSet, AudioCaps, Freesound, BBC Sound Effect, and Soundnet.
119
+
120
+ <table><tr><td>Model</td><td>Datasets</td><td>FD↓</td><td>IS个</td><td>KL←</td><td>FAD↓</td><td>OVL ↑</td><td>REL个</td></tr><tr><td>Ground truth</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>83.61</td><td>80.11</td></tr><tr><td>DiffSound</td><td>AS+AC</td><td>47.68</td><td>4.01</td><td>2.52</td><td>7.75</td><td>45.00</td><td>43.83</td></tr><tr><td>AudioGen</td><td>AS +AC+8others</td><td>=</td><td>-</td><td>2.09</td><td>3.13</td><td>-</td><td>=</td></tr><tr><td>AudioLDM-L-Full</td><td>AS+AC+FSD+BBC</td><td>23.31</td><td>8.13</td><td>1.59</td><td>1.96</td><td>65.91</td><td>65.97</td></tr><tr><td>CoDi(Ours)</td><td>AS+AC+FSD+BBC+SDN</td><td>22.90</td><td>8.77</td><td>1.40</td><td>1.80</td><td>66.87</td><td>67.60</td></tr></table>
121
+
122
+ Table 6: COCO image captioning scores comparison.
123
+
124
+ <table><tr><td>Model</td><td>B@4</td><td>METEOR</td><td>CIDEr</td></tr><tr><td colspan="4">Autoregressive Model</td></tr><tr><td>Oscar [31]</td><td>36.58</td><td>30.4</td><td>124.12</td></tr><tr><td>ClipCap [35]</td><td>32.15</td><td>27.1</td><td>108.35</td></tr><tr><td>OFA [49]</td><td>44.9</td><td>32.5</td><td>154.9</td></tr><tr><td>BLIP2 [30]</td><td>43.7</td><td>-</td><td>145.8</td></tr><tr><td colspan="4">Diffusion Model</td></tr><tr><td>DDCap [59]</td><td>35.0</td><td>28.2</td><td>117.8</td></tr><tr><td>SCD-Net [34]</td><td>39.4</td><td>29.2</td><td>131.6</td></tr><tr><td>CoDi (Ours)</td><td>40.2</td><td>31.0</td><td>149.9</td></tr></table>
125
+
126
+ Table 7: AudioCaps audio captioning scores comparison.
127
+
128
+ <table><tr><td>Model</td><td>SPIDEr</td><td>CIDEr</td><td>SPICE</td></tr><tr><td>AudioCaps [24]</td><td>0.369</td><td>0.593</td><td>0.144</td></tr><tr><td>BART-Finetune [17]</td><td>0.465</td><td>0.753</td><td>0.176</td></tr><tr><td>VALOR[7]</td><td></td><td>0.741</td><td></td></tr><tr><td>AL-MixGen [25]</td><td>0.466</td><td>0.755</td><td>0.177</td></tr><tr><td>CoDi (Ours)</td><td>0.480</td><td>0.789</td><td>0.182</td></tr></table>
129
+
130
+ Table 8: MSRVTT video captioning scores comparison.
131
+
132
+ <table><tr><td>Model</td><td>B@4</td><td>METEOR</td><td>CIDEr</td></tr><tr><td>ORG-TRL[58]</td><td>43.6</td><td>28.8</td><td>50.9</td></tr><tr><td>MV-GPT[43]</td><td>48.9</td><td>38.7</td><td>60.0</td></tr><tr><td>GIT[48]</td><td>54.8</td><td>33.1</td><td>75.9</td></tr><tr><td>mPLUG-2 [52]</td><td>57.8</td><td>34.9</td><td>80.3</td></tr><tr><td>CoDi(Ours)</td><td>52.1</td><td>32.5</td><td>74.4</td></tr></table>
133
+
134
+ Audio $^ +$ Text. We curated a new dataset, Freesound 500K, by crawling 500K audio samples together with tags and descriptions from the Freesound website. We also use AudioSet [42] with 2 million human-labeled 10-second sound clips from YouTube videos and AudioCaps [24] with 46K audiotext pairs derived from the AudioSet dataset. Audio samples are clipped into 10-second segments for training purposes. The paired audio $^ +$ text data enables us to train text audio, audio text, text audio $^ +$ text generation, and audio-text contrastive learning. Similar to image $^ +$ text joint generation, in text audio $^ +$ text, text prompt is the truncated text, and the output is the original text.
135
+
136
+ Video. We use the following diverse and high-quality video datasets to train video generation and video prompt encoder. WebVid [4], a large-scale dataset of web videos together with descriptions; HD-Villa-100M [54] with high resolution YouTube videos of at least 720P. We perform text video and video-text contrastive learning task with WebVid. We use HD-Villa-100M for image video generation where the middle frame is the input image.
137
+
138
+ Audiovisual. Web videos are a natural aligned audio-video data resource. However, many existing datasets, e.g., ACAV100M [28], feature heavily on videos of human speech rather than natural sounds. Therefore, we leverage sound-oriented datasets AudioSet and SoundNet [3] for joint audio-video generation. For image audio $^ +$ video, we use the middle frame of the target video as the input prompt image. We also use the middle frame as the prompt input to train the model to generate the audio, i.e., image audio.
139
+
140
+ ![](images/dc63eb6c668a08077a3c76c77a471ccad92d8b97c381a63765856efb970b42b0.jpg)
141
+ Figure 4: Generation with multiple input modality conditions. Top to bottom: text+audio image, text+audio video, video+audio text.
142
+
143
+ # 5 Evaluation Results
144
+
145
+ In this section, we will evaluate the model generation quality in different settings including single modality generation, multi-condition generation, and multi-output joint generation. We provide both quantitative benchmarking on evaluation datasets as well as qualitative visualization demonstrations.
146
+
147
+ # 5.1 Single Modality Generation Results
148
+
149
+ We first show example demo in Fig. 3, where we present various single to single modality generation. Then, we evaluate the synthesis quality of the unimodal generation on text, image, video, and audio. CoDi achieves SOTA on audio captions and audio generation, as shown in Table 7 and Table 5. Notably for the first time in the field, CoDi, a diffusion-base model, exhibits comparable performance on image captioning with autoregressive transformer-based SOTA (Table 6). CoDi is the first diffusion-model based for video captioning Table 8. On image and video generation, CoDi performs competitively with state-of-the-art (Tables 2 to 4). This gives us strong starting points for multi-condition and multi-output generation that will be presented next in Section 5.2 and Section 5.3.
150
+
151
+ We demonstrate in Section 3.2 that CoDi is capable of integrating representation from different modalities in the generation. Thus, we first show multi-condition generation demo as shown in Fig. 4.
152
+
153
+ # 5.2 Multi-Condition Generation Results
154
+
155
+ For quantitative evaluation, we focus on multiple inputs to image synthesis output since the evaluation metric for this case (FID) does not require specific modality inputs like text. We test with several input combinations including text $^ +$ image, text $^ +$ audio, image $^ +$ audio, text $^ +$ video, as well as three inputs text $^ +$ audio $^ +$ image. We test on the validation set of AudioCaps [24] since all four modalities are present in this dataset. The prompt image input is the middle frame of the video. As shown in
156
+
157
+ Table 9: CoDi is capable of generating high quality output (image in this case) from various combinations of prompt modalities.
158
+
159
+ <table><tr><td>Inputs</td><td>FID↓</td></tr><tr><td> Single-modality Prompt</td><td></td></tr><tr><td>Text</td><td>14.2</td></tr><tr><td>Audio</td><td>14.3</td></tr><tr><td> Dual-modality Prompt</td><td></td></tr><tr><td>Text+Audio</td><td>14.9</td></tr></table>
160
+
161
+ Table 10: MSR-VTT text-to-video generation performance.
162
+
163
+ <table><tr><td>Inputs</td><td>CLIPSIM个</td></tr><tr><td> Single-modality Prompt</td><td></td></tr><tr><td>Text</td><td>0.2890</td></tr><tr><td> Dual-modality Prompt</td><td></td></tr><tr><td>Text+Audio</td><td>0.2912</td></tr><tr><td>Text+Image</td><td>0.2891</td></tr><tr><td>Text+Audio+Image</td><td>0.2923</td></tr></table>
164
+
165
+ ![](images/570523fa62e48124b6e7ee0927d72eb815a36ea17ca483b39355fc5b79c4dd8d.jpg)
166
+ Figure 5: Joint generation of multiple output modalities by CoDi. From top to bottom: text video+audio, tex image+text+audio, text+audio+image video+audio.
167
+
168
+ Table 9, CoDi achieves high image generation quality given assorted groups of input modalities. We also test with several input combinations with video as output including text, text $^ +$ audio, image $^ +$ image, as well as text $^ +$ audio $^ +$ image. We also test on MSRVTT [24] since all four modalities are present in this dataset. Similarly, the prompt image input is the middle frame of the video. As shown in Table 10, CoDi achieves high video and ground truth text similarity given assorted groups of input modalities. Again our model does not need to train on multi-condition generation like text $^ +$ audio or text $^ +$ image. Through bridging alignment and composable multimodal conditioning as proposed in Section 3.2, our model trained on single condition can zero-shot infer on multiple conditions.
169
+
170
+ # 5.3 Multi-Output Joint Generation Results
171
+
172
+ For joint multimodal generation, we first demonstrate high-quality multimodal output joint generation demo as shown in Fig. 5. For quantitative evaluation, there is no existing evaluation metric since we are the first model that can simultaneously generate across all 4 modalities. Therefore, we propose the following metric SIM that quantifies the coherence and consistency between the two generated modalities by cosine similarity of embeddings:
173
+
174
+ $$
175
+ \operatorname { S I M } ( A , B ) = \cos { ( C _ { A } ( A ) , C _ { B } ( B ) ) }
176
+ $$
177
+
178
+ Table 11: Similarity scores between generated modalities. The number on the left of $" / "$ represents the similarity score of independent generation, and the right it represents the case of joint generation. Jointly generated outputs consistently show stronger coherence.
179
+
180
+ <table><tr><td>Inputs</td><td>SIM-IT</td><td>SIM-AT</td><td>SIM-VT</td><td>SIM-VA</td></tr><tr><td colspan="5"> Two Joint Outputs</td></tr><tr><td>Audio → Image+Text</td><td>0.251 / 0.260</td><td></td><td></td><td></td></tr><tr><td>Image→Audio+Text</td><td>■</td><td>0.244 / 0.256</td><td></td><td></td></tr><tr><td>Text →Video+Audio</td><td></td><td></td><td></td><td>0.240 / 0.255</td></tr><tr><td>Audio →Video+Text</td><td></td><td></td><td>0.256 / 0.261</td><td></td></tr><tr><td colspan="5"> Three Joint Outputs</td></tr><tr><td>Text-→ Video+Image+Audio 0.256/0.270 0.240/0.257</td><td></td><td></td><td></td><td>0.240 / 0.257</td></tr><tr><td colspan="5"> Multi-Inputs-Outputs</td></tr><tr><td>Text+Image -→ Video+Audio</td><td></td><td></td><td></td><td>0.247 / 0.259</td></tr></table>
181
+
182
+ where $A$ , $B$ are the generated modalities, and $C _ { A }$ and $C _ { B }$ are aligned encoders that project $A$ and $B$ to the same space. We use the prompt encoder as described in Section 3.2. This metric aims to compute the cosine similarity of the embedding of two modalities using contrastive learned prompt encoders. Thus, the higher the metric, the more aligned and similar the generated modalities are.
183
+
184
+ To demonstrate the effectiveness of joint generation, assume the prompt modality is $P$ , we compare $\mathrm { S I M } ( A , B )$ of $A$ and $B$ generated separately vs. jointly, i.e., $\{ P \ { \overset { - } { \to } } \ A , \ P \ { \overset { - } { \to } } \ B \}$ vs. $\{ P $ $A + B \}$ . The benchmark is the validation set of AudioCaps [24]. We test on the following settings, audio image+text, image audio+text, and text video+audio, image video+audio. audio video+text, audio text+video+image, text video+image+audio, where the image prompt is the middle frame of the video clip. As shown in Table 11, joint generation (similarity shown on the right side of $" / "$ ) consistently outperforms independent generation (on the left side of $" / "$ ).
185
+
186
+ # 6 Conclusion
187
+
188
+ In this paper, we present Composable Diffusion (CoDi), a groundbreaking model in multimodal generation that is capable of processing and simultaneously generating modalities across text, image, video, and audio. Our approach enables the synergistic generation of high-quality and coherent outputs spanning various modalities, from assorted combinations of input modalities. Through extensive experiments, we demonstrate CoDi’s remarkable capabilities in flexibly generating single or multiple modalities from a wide range of inputs. Our work marks a significant step towards more engaging and holistic human-computer interactions, establishing a solid foundation for future investigations in generative artificial intelligence.
189
+
190
+ Limitations & Broader Impacts. See Appendix D for the discussion.
191
+
192
+ # Acknowledgement
193
+
194
+ We would like to thank Bei Liu for HD-VILA-100M data support. We also thank Shi Dong, Mahmoud Khademi, Junheng Hao, Yuwei Fang, Yichong Xu and Azure Cognitive Services Research team members for their feedback.
195
+
196
+ # References
197
+
198
+ [1] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. Advances in Neural Information Processing Systems, 35:23716–23736, 2022. 3
199
+ [2] Jie An, Songyang Zhang, Harry Yang, Sonal Gupta, Jia-Bin Huang, Jiebo Luo, and Xi Yin. Latent-shift: Latent diffusion with temporal shift for efficient text-to-video generation. arXiv preprint arXiv:2304.08477, 2023. 5, 15, 16
200
+
201
+ [3] Yusuf Aytar, Carl Vondrick, and Antonio Torralba. Soundnet: Learning sound representations from unlabeled video. Advances in neural information processing systems, 29, 2016. 6, 7
202
+
203
+ [4] Max Bain, Arsha Nagrani, Gül Varol, and Andrew Zisserman. Frozen in time: A joint video and image encoder for end-to-end retrieval. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1728–1738, 2021. 6, 7, 16
204
+
205
+ [5] Andreas Blattmann, Robin Rombach, Huan Ling, Tim Dockhorn, Seung Wook Kim, Sanja Fidler, and Karsten Kreis. Align your latents: High-resolution video synthesis with latent diffusion models. arXiv preprint arXiv:2304.08818, 2023. 7
206
+
207
+ [6] Sébastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott Lundberg, et al. Sparks of artificial general intelligence: Early experiments with gpt-4. arXiv preprint arXiv:2303.12712, 2023. 2
208
+
209
+ [7] Sihan Chen, Xingjian He, Longteng Guo, Xinxin Zhu, Weining Wang, Jinhui Tang, and Jing Liu. Valor: Vision-audio-language omni-perception pretraining model and dataset. arXiv preprint arXiv:2304.08345, 2023. 7
210
+
211
+ [8] Jaemin Cho, Jie Lei, Hao Tan, and Mohit Bansal. Unifying vision-and-language tasks via text generation. In International Conference on Machine Learning, pages 1931–1942. PMLR, 2021. 3
212
+
213
+ [9] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018. 5
214
+
215
+ [10] Ming Ding, Zhuoyi Yang, Wenyi Hong, Wendi Zheng, Chang Zhou, Da Yin, Junyang Lin, Xu Zou, Zhou Shao, Hongxia Yang, and Jie Tang. Cogview: Mastering text-to-image generation via transformers. arXiv preprint arXiv:2105.13290, 2021. 7
216
+
217
+ [11] 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 Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10687–10696, 2021. 3
218
+
219
+ [12] Benjamin Elizalde, Soham Deshmukh, Mahmoud Al Ismail, and Huaming Wang. Clap: Learning audio concepts from natural language supervision. arXiv preprint arXiv:2206.04769, 2022. 3
220
+
221
+ [13] Patrick Esser, Johnathan Chiu, Parmida Atighehchian, Jonathan Granskog, and Anastasis Germanidis. Structure and content-guided video synthesis with diffusion models. arXiv preprint arXiv:2302.03011, 2023. 2, 5
222
+
223
+ [14] Patrick Esser, Johnathan Chiu, Parmida Atighehchian, Jonathan Granskog, and Anastasis Germanidis. Structure and content-guided video synthesis with diffusion models. arXiv preprint arXiv:2302.03011, 2023. 3
224
+
225
+ [15] Oran Gafni, Adam Polyak, Oron Ashual, Shelly Sheynin, Devi Parikh, and Yaniv Taigman. Make-a-scene: Scene-based text-to-image generation with human priors. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XV, pages 89–106. Springer, 2022. 7 [16] Jort F Gemmeke, Daniel PW Ellis, Dylan Freedman, Aren Jansen, Wade Lawrence, R Channing Moore, Manoj Plakal, and Marvin Ritter. Audio set: An ontology and human-labeled dataset for audio events. In 2017 IEEE international conference on acoustics, speech and signal processing (ICASSP), pages 776–780. IEEE, 2017. 6
226
+
227
+ [17] Félix Gontier, Romain Serizel, and Christophe Cerisara. Automated audio captioning by fine-tuning bart with audioset tags. In Detection and Classification of Acoustic Scenes and Events-DCASE 2021, 2021. 7 [18] 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, pages 770–778, 2016. 15
228
+
229
+ [19] Jonathan Ho, William Chan, Chitwan Saharia, Jay Whang, Ruiqi Gao, Alexey Gritsenko, Diederik P Kingma, Ben Poole, Mohammad Norouzi, David J Fleet, et al. Imagen video: High definition video generation with diffusion models. arXiv preprint arXiv:2210.02303, 2022. 2, 3
230
+
231
+ [20] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020. 3, 4
232
+
233
+ [21] Jonathan Ho, Tim Salimans, Alexey Gritsenko, William Chan, Mohammad Norouzi, and David J Fleet. Video diffusion models. arXiv preprint arXiv:2204.03458, 2022. 3, 15
234
+
235
+ [22] Wenyi Hong, Ming Ding, Wendi Zheng, Xinghan Liu, and Jie Tang. Cogvideo: Large-scale pretraining for text-to-video generation via transformers. arXiv preprint arXiv:2205.15868, 2022. 2, 7
236
+
237
+ [23] Rongjie Huang, Jiawei Huang, Dongchao Yang, Yi Ren, Luping Liu, Mingze Li, Zhenhui Ye, Jinglin Liu, Xiang Yin, and Zhou Zhao. Make-an-audio: Text-to-audio generation with prompt-enhanced diffusion models. arXiv preprint arXiv:2301.12661, 2023. 2, 3
238
+
239
+ [24] Chris Dongjoo Kim, Byeongchang Kim, Hyunmin Lee, and Gunhee Kim. Audiocaps: Generating captions for audios in the wild. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 119–132, 2019. 6, 7, 8, 9, 10
240
+
241
+ [25] Eungbeom Kim, Jinhee Kim, Yoori Oh, Kyungsu Kim, Minju Park, Jaeheon Sim, Jinwoo Lee, and Kyogu Lee. Improving audio-language learning with mixgen and multi-level test-time augmentation. arXiv preprint arXiv:2210.17143, 2022. 7
242
+
243
+ [26] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. 15
244
+
245
+ [27] Jungil Kong, Jaehyeon Kim, and Jaekyoung Bae. Hifi-gan: Generative adversarial networks for efficient and high fidelity speech synthesis. Advances in Neural Information Processing Systems, 33:17022–17033, 2020. 5
246
+
247
+ [28] Sangho Lee, Jiwan Chung, Youngjae Yu, Gunhee Kim, Thomas Breuel, Gal Chechik, and Yale Song. Acav $1 0 0 \mathrm { m }$ : Automatic curation of large-scale datasets for audio-visual video representation learning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10274–10284, 2021. 7 [29] Chunyuan Li, Xiang Gao, Yuan Li, Baolin Peng, Xiujun Li, Yizhe Zhang, and Jianfeng Gao. Optimus: Organizing sentences via pre-trained modeling of a latent space. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 4678–4699, 2020. 5
248
+
249
+ [30] Junnan Li, Dongxu Li, Silvio Savarese, and Steven Hoi. Blip-2: Bootstrapping language-image pre-training with frozen image encoders and large language models. arXiv preprint arXiv:2301.12597, 2023. 7
250
+
251
+ [31] Xiujun Li, Xi Yin, Chunyuan Li, Pengchuan Zhang, Xiaowei Hu, Lei Zhang, Lijuan Wang, Houdong Hu, Li Dong, Furu Wei, et al. Oscar: Object-semantics aligned pre-training for vision-language tasks. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part XXX 16, pages 121–137. Springer, 2020. 7
252
+
253
+ [32] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, 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, pages 740–755. Springer, 2014. 7
254
+
255
+ [33] Haohe Liu, Zehua Chen, Yi Yuan, Xinhao Mei, Xubo Liu, Danilo Mandic, Wenwu Wang, and Mark D Plumbley. Audioldm: Text-to-audio generation with latent diffusion models. arXiv preprint arXiv:2301.12503, 2023. 2, 3, 5
256
+
257
+ [34] Jianjie Luo, Yehao Li, Yingwei Pan, Ting Yao, Jianlin Feng, Hongyang Chao, and Tao Mei. Semanticconditional diffusion networks for image captioning. arXiv preprint arXiv:2212.03099, 2022. 7
258
+
259
+ [35] Ron Mokady, Amir Hertz, and Amit H Bermano. Clipcap: Clip prefix for image captioning. arXiv preprint arXiv:2111.09734, 2021. 3, 7
260
+
261
+ [36] Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741, 2021. 7
262
+
263
+ [37] Reid Pryzant, Dan Iter, Jerry Li, Yin Tat Lee, Chenguang Zhu, and Michael Zeng. Automatic prompt optimization with" gradient descent" and beam search. arXiv preprint arXiv:2305.03495, 2023. 2
264
+
265
+ [38] 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 International conference on machine learning, pages 8748–8763. PMLR, 2021. 3, 4
266
+
267
+ [39] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019. 5
268
+
269
+ [40] Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022. 3
270
+
271
+ [41] 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, pages 10684–10695, 2022. 2, 3, 4, 5, 7
272
+
273
+ [42] Christoph Schuhmann, Romain Beaumont, Richard Vencu, Cade W Gordon, Ross Wightman, Mehdi Cherti, Theo Coombes, Aarush Katta, Clayton Mullis, Mitchell Wortsman, Patrick Schramowski, Srivatsa R Kundurthy, Katherine Crowson, Ludwig Schmidt, Robert Kaczmarczyk, and Jenia Jitsev. LAION-5b: An open large-scale dataset for training next generation image-text models. In Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2022. 6, 7
274
+
275
+ [43] Paul Hongsuck Seo, Arsha Nagrani, Anurag Arnab, and Cordelia Schmid. End-to-end generative pretraining for multimodal video captioning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 17959–17968, 2022. 7
276
+
277
+ [44] Uriel Singer, Adam Polyak, Thomas Hayes, Xi Yin, Jie An, Songyang Zhang, Qiyuan Hu, Harry Yang, Oron Ashual, Oran Gafni, et al. Make-a-video: Text-to-video generation without text-video data. arXiv preprint arXiv:2209.14792, 2022. 2, 3, 7
278
+
279
+ [45] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pages 2256–2265. PMLR, 2015. 2, 4
280
+
281
+ [46] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2021. 3
282
+
283
+ [47] Zineng Tang, Jaemin Cho, Yixin Nie, and Mohit Bansal. TVLT: Textless vision-language transformer. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho, editors, Advances in Neural Information Processing Systems, 2022. 3
284
+
285
+ [48] Jianfeng Wang, Zhengyuan Yang, Xiaowei Hu, Linjie Li, Kevin Lin, Zhe Gan, Zicheng Liu, Ce Liu, and Lijuan Wang. Git: A generative image-to-text transformer for vision and language. arXiv preprint arXiv:2205.14100, 2022. 7
286
+
287
+ [49] Peng Wang, An Yang, Rui Men, Junyang Lin, Shuai Bai, Zhikang Li, Jianxin Ma, Chang Zhou, Jingren Zhou, and Hongxia Yang. Unifying architectures, tasks, and modalities through a simple sequence-tosequence learning framework. arXiv preprint arXiv:2202.03052, 2022. 7
288
+
289
+ [50] Chenfei Wu, Lun Huang, Qianxi Zhang, Binyang Li, Lei Ji, Fan Yang, Guillermo Sapiro, and Nan Duan. Godiva: Generating open-domain videos from natural descriptions. arXiv preprint arXiv:2104.14806, 2021. 7
290
+
291
+ [51] Chenfei Wu, Jian Liang, Lei Ji, Fan Yang, Yuejian Fang, Daxin Jiang, and Nan Duan. Nüwa: Visual synthesis pre-training for neural visual world creation. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XVI, pages 720–736. Springer, 2022. 7
292
+
293
+ [52] Haiyang Xu, Qinghao Ye, Ming Yan, Yaya Shi, Jiabo Ye, Yuanhong Xu, Chenliang Li, Bin Bi, Qi Qian, Wei Wang, et al. mplug-2: A modularized multi-modal foundation model across text, image and video. arXiv preprint arXiv:2302.00402, 2023. 7
294
+
295
+ [53] Xingqian Xu, Zhangyang Wang, Eric Zhang, Kai Wang, and Humphrey Shi. Versatile diffusion: Text, images and variations all in one diffusion model. arXiv preprint arXiv:2211.08332, 2022. 5, 7
296
+
297
+ [54] Hongwei Xue, Tiankai Hang, Yanhong Zeng, Yuchong Sun, Bei Liu, Huan Yang, Jianlong Fu, and Baining Guo. Advancing high-resolution video-language representation with large-scale video transcriptions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5036–5045, 2022. 6, 7, 16
298
+
299
+ [55] Ziyi Yang, Yuwei Fang, Chenguang Zhu, Reid Pryzant, Dongdong Chen, Yu Shi, Yichong Xu, Yao Qian, Mei Gao, Yi-Ling Chen, et al. i-code: An integrative and composable multimodal learning framework. arXiv preprint arXiv:2205.01818, 2022. 2, 3
300
+
301
+ [56] Rowan Zellers, Jiasen Lu, Ximing Lu, Youngjae Yu, Yanpeng Zhao, Mohammadreza Salehi, Aditya Kusupati, Jack Hessel, Ali Farhadi, and Yejin Choi. Merlot reserve: Neural script knowledge through vision and language and sound. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16375–16387, 2022. 3
302
+ [57] Rowan Zellers, Ximing Lu, Jack Hessel, Youngjae Yu, Jae Sung Park, Jize Cao, Ali Farhadi, and Yejin Choi. Merlot: Multimodal neural script knowledge models. Advances in Neural Information Processing Systems, 34:23634–23651, 2021. 3
303
+ [58] Ziqi Zhang, Yaya Shi, Chunfeng Yuan, Bing Li, Peijin Wang, Weiming Hu, and Zheng-Jun Zha. Object relational graph with teacher-recommended learning for video captioning. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 13278–13288, 2020. 7
304
+ [59] Zixin Zhu, Yixuan Wei, Jianfeng Wang, Zhe Gan, Zheng Zhang, Le Wang, Gang Hua, Lijuan Wang, Zicheng Liu, and Han Hu. Exploring discrete diffusion models for image captioning. arXiv preprint arXiv:2211.11694, 2022. 7
305
+
306
+ # A Model Architecture and Configuration
307
+
308
+ # A.1 Overview
309
+
310
+ In this section, we provide more details on the model architecture as shown in Table 12, where each modality specific diffuser is based on UNet architecture with different variations detailed in the table. Another notable difference is the video architecture where we add temporal attention and temporal shift as discussed in Section 3.3 and we will discuss its detail in the next section.
311
+
312
+ Table 12: Hyperparameters for our diffusion models. Note the video and image generation uses the same diffuser.
313
+
314
+ <table><tr><td>Modality</td><td>Video (Image) LDM</td><td>Audio LDM</td><td>Text LDM</td></tr><tr><td colspan="4">Hyperparameter</td></tr><tr><td>Architecture</td><td>LDM</td><td>LDM</td><td>LDM</td></tr><tr><td>z-shape</td><td>4× #frames × 64× 64</td><td>8× 256×16</td><td>768×1×1</td></tr><tr><td>Channels</td><td>320</td><td>320</td><td>320</td></tr><tr><td>Depth</td><td>4</td><td>2</td><td>2</td></tr><tr><td>Channel multiplier</td><td>1,2,4,4</td><td>1,2,4,4</td><td>1,2,4,4</td></tr><tr><td>Attention resolutions</td><td>64,32,16</td><td>64,32,16</td><td>64,32,16</td></tr><tr><td>Head channels</td><td>32</td><td>32</td><td>32</td></tr><tr><td>Number of heads</td><td>8</td><td>8</td><td>8</td></tr><tr><td>CA embed dim</td><td>768</td><td>768</td><td>768</td></tr><tr><td>CA resolutions</td><td>64,32,16</td><td>64,32,16</td><td>64,32,16</td></tr><tr><td>Autoencoders</td><td>AutoKL</td><td>AudioLDM</td><td>Optimus</td></tr><tr><td>Weight initialization</td><td>Stable Diffusion-1.4</td><td>-</td><td>Versatile Diffusion</td></tr><tr><td>Parameterization</td><td>E</td><td>E</td><td>E</td></tr><tr><td>Learning rate</td><td>2e-5</td><td>5e-6</td><td>5e-5</td></tr><tr><td>Total batch size</td><td>256</td><td>1024</td><td>1024</td></tr><tr><td colspan="4">Diffusion Setup</td></tr><tr><td>Diffusion steps</td><td>1000</td><td>1000</td><td>1000</td></tr><tr><td>Noise schedule</td><td>Linear</td><td>Linear</td><td>Linear</td></tr><tr><td>β</td><td>0.00085</td><td>0.00085</td><td>0.00085</td></tr><tr><td>阳</td><td>0.0120</td><td>0.0120</td><td>0.0120</td></tr><tr><td colspan="4">Sampling Parameters</td></tr><tr><td>Sampler</td><td>DDIM</td><td>DDIM</td><td>DDIM</td></tr><tr><td>Steps</td><td>50</td><td>50</td><td>50</td></tr><tr><td>n</td><td>1.0</td><td>1.0</td><td>1.0</td></tr><tr><td>Guidance scale</td><td>2.0</td><td>7.5</td><td>2.0</td></tr></table>
315
+
316
+ # A.2 Video LDM Architecture
317
+
318
+ Except for the base image UNet architecture, we also add temporal attention and temporal shift [2] before each residual block. Following VDM [21], the temporal attention is a transformer attention module where we flatten the height and width dimension to batch size dimension and the self-attention is performed on the time dimension. The temporal shift is illustrated in Fig. 6 where we first split channels into $k$ chunks. Then, we shift the channel dimension numbered 0 to $k - 1$ by temporal dimension from 0 to $k - 1$ times respectively. Eventually, we concatenate the shifted chunks by the hidden dimension. Note that we use $k = 3$ in the illustration for simplicity but $k = 8$ in our implementation. We then add a convolution layer before the temporal shift module. Finally, we use residual connection [18] and add the output to the input before the convolution layer. The complete video UNet layer is shown in Fig. 7.
319
+
320
+ # B Model Training
321
+
322
+ Prompt Encoders Training. As discussed in Section 3.2, we use bridging alignment to perform contrastive learning between all prompt encoders. We use Adam [26] optimizer with learning rate 1e-4 and weight decay 1e-4.
323
+
324
+ ![](images/e11082636d4b4499d75ad6f7451413683dac74d3ebb613e652b9ea9f4c995784.jpg)
325
+ Figure 6: Temporal shift [2] illustration. $C , H .$ , $W$ represent channel, height, width, respectively. The vertical line represents time steps from $t - 1 , t$ , and $t + 1$ . The grey blocks denote “padding tensors”.
326
+
327
+ ![](images/4409bc09bf832575915923690ca96fa4e7ccd04266897f8300b3a97df95ceeee.jpg)
328
+ Figure 7: Video UNet layer architecture details including normalization & activation, 2D temporal attention, followed by temporal shift and 1D spatial convolution.
329
+
330
+ Diffusion Model Training. We train diffusion model with training objectives and hyperparameters detailed in Table 1 and Table 12. For video LDM, we adopt a more specific training curriculum. We adopt curriculum learning on frame resolution and frames-per-second (FPS). First, the diffuser is trained on the WebVid dataset of a 256-frame resolution, with the training objective being textconditioned video generation. The training clips are sampled from 2-second video chunks with 4 FPS. Second, the model is further trained on HDVILLA and ACAV datasets, with a 512-frame resolution and 8 FPS, and the training objective is image-conditioned video generation (the image is a randomly sampled frame of the clip). Each training clip contains 16 frames sampled from a 2-second video chunk with 8 FPS.
331
+
332
+ Joint Generation Training. As discussed in Section 3.2, we train joint generation by aligning environment encoders and optimize cross-attention layers only in the diffusion models. We use Adam optimizer with learning rate 1e-5 and weight decay 1e-4.
333
+
334
+ # C Training Datasets
335
+
336
+ In this section, we introduce more details about the video and audiovisual training datasets.
337
+
338
+ Video. WebVid [4] is a large-scale dataset of web videos with diverse content, spanning over 40 categories such as sports, cooking, and travel. It contains over 1.2 million video clips (all without sound) that are all at least 30 seconds in duration with video descriptions. We perform text video and video-text contrastive learning task with this dataset. HD-Villa-100M [54] is a large-scale video dataset with over 100 million video clips sourced from YouTube. The dataset covers a wide range of video categories and includes high-quality videos with a resolution of at least 720P. Since it lacks curated video description and we use the middle frame as image input to perform image video generation.
339
+
340
+ Audiovisual. SoundNet originally contains over two million sounds and spans a wide range of categories including music, animal sounds, natural sounds, and environmental sounds. We collected all currently accessible 1M videos.
341
+
342
+ # D Limitations & Broader Impacts
343
+
344
+ While the paper primarily focuses on the technical advancements and potential applications of CoDi, we also consider potential negative social impacts that could arise from the development and deployment of such technology. These impacts can include:
345
+
346
+ Deepfakes and Misinformation. As part of a common issue for generative AI models, the ability of CoDi to generate realistic and synchronized multimodal outputs also raises concerns about the creation and dissemination of deepfakes. Malicious actors could exploit this technology to create highly convincing fake content, such as fabricated videos or audio clips, which can be used for misinformation, fraud, or other harmful purposes.
347
+
348
+ Bias and Stereotyping. If the training data used for CoDi is biased or contains stereotypes, the generated multimodal outputs may also reflect these.
349
+
350
+ # E License
351
+
352
+ We will publicly release our code and checkpoints. We cite licenses from the individual dataset or package we use from the community and provide the following links for references.
353
+
354
+ LAION-400M: Creative Common CC-BY 4.0
355
+
356
+ AudioSet: Creative Common CC-BY 4.0
357
+
358
+ AudioCaps: MIT
359
+
360
+ Freesound: Creative Commons
361
+
362
+ BBC Sound Effect: The BBC’s Content Licence
363
+
364
+ SoundNet: MIT
365
+
366
+ Webvid10M: Webvid
367
+
368
+ HD-Villa-100M: Research Use of Data Agreement v1.0
369
+
370
+ PyTorch: BSD-style
371
+
372
+ Huggingface Transformers: Apache
373
+
374
+ Torchvision: BSD 3-Clause
375
+
376
+ Torchaudio: BSD 2-Clause
md/dev/2EufPS5ABlJ/2EufPS5ABlJ.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/2PSrjVtj6gU/2PSrjVtj6gU.md ADDED
@@ -0,0 +1,404 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GRAPH ATTENTION MULTI-LAYER PERCEPTRON
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Recently, graph neural networks (GNNs) have achieved a stride of success in many graph-based applications. However, most GNNs suffer from a critical issue: representation learned is constructed based on a fixed $k$ -hop neighborhood and insensitive to individual needs for each node, which greatly hampers the performance of GNNs. To satisfy the unique needs of each node, we propose a new architecture – Graph Attention Multi-Layer Perceptron (GAMLP). This architecture combines multi-scale knowledge and learns to capture the underlying correlations between different scales of knowledge with two novel attention mechanisms: Recursive attention and Jumping Knowledge (JK) attention. Instead of using node feature only, the knowledge within node labels is also exploited to reinforce the performance of GAMLP. Extensive experiments on 12 real-world datasets demonstrate that GAMLP achieves state-of-the-art performance while enjoying high scalability and efficiency.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Graph Neural Networks (GNNs) generalize convolutional neural networks to graph-structured data and have achieved great success in a wide range of tasks, including node classification, link prediction, and recommendation. (Kipf & Welling, 2016; Hamilton et al., 2017; Bo et al., 2020; Cui et al., 2020; Fan et al., 2019). Through stacking $K$ graph convolution layers, GNNs learn node representations by utilizing information from the $K$ -hop neighborhood and thus enhance the performance by getting more unlabeled nodes involved in the training process. In such a GNN model, the nodes within the $K$ -hop neighborhood of a specific node are called this node’s Receptive Field (RF). As the size of RF grows exponentially to the number of GNN layers, the rapidly expanding RF incurs high computation and memory costs in a single machine. Besides, even in a distributed environment, GNN has to pull a great number of neighboring node features to compute the representation of each node, leading to high communication cost (Zheng et al., 2020).
12
+
13
+ Many recent advancements towards scalable GNNs are based on model simplification. For example, Simplified GCN (SGC) (Wu et al., 2019) decouples the feature propagation and the non-linear transformation process, and the former is executed during pre-processing. Unlike the sampling-based methods (Hamilton et al., 2017), which still need feature propagation during each training epoch, this time-consuming process in SGC is only executed once, and only the nodes of the training set are involved in the training process. As a result, SGC is computation and memory-efficient in a single machine and scalable in distributed settings since it does not require each machine to fetch neighboring node features during the model training process. Despite the high efficiency and scalability, SGC simply preserves a fixed RF for all the nodes by assigning them the same feature propagation depth. Such a fixed propagation mechanism in SGC disables its ability to exploit knowledge within neighborhoods of different sizes.
14
+
15
+ Lines of other simplified models have been proposed to learn better node representations exploiting multi-scale knowledge. SIGN (Frasca et al., 2020) proposes to concatenate all the propagated features without information loss, while $\mathrm { S ^ { 2 } G C }$ (Zhu & Koniusz, 2021) averages all these propagated features to generate the combined feature. Although multi-scale knowledge is considered, the importance and correlations between multiple scales are ignored. Being the first attempt to explore the correlations between different scales of knowledge, GBP (Chen et al., 2020b) adopts a heuristic constant decay factor for the weighted average for propagated features at different propagation steps. Motivated by Personalized PageRank, the large-scale features has a higher risk of over-smoothing, and they will contribute less to the combination in GBP.
16
+
17
+ ![](images/ce549669ff8e14edce795001721a899c92d9b43fcffe2c7d9fc54aaf98ef9990.jpg)
18
+ Figure 1: (Left) Test accuracy of SGC on 20 randomly sampled nodes of Citeseer. The X-axis is the node id, and Y-axis is the propagation steps (layers). The color from white to blue represents the ratio of being predicted correctly in 50 different runs. (Right) The local graph structures for two nodes in different regions; the node in the dense region has larger RF within two iterations of propagation.
19
+
20
+ Unfortunately, the coarse-grained, layer-wise combination prevents these methods from unleashing their full potential. As shown in Figure 1(a), different nodes require different propagation steps to achieve optimal predictive accuracy. Besides, assigning the same weight distribution to propagated features along with propagation depth to all the nodes may be unsuitable due to the inconsistent RF expansion speed shown in Figure 1(b). However, nodes in most existing GNNs are restricted to a fixed-hop neighborhood and insensitive to the actual demands of different nodes. This imperfection either makes that long-range dependencies cannot be fully leveraged due to limited hops/layers or loses local information by introducing many irrelevant nodes into the receptive fields for many nodes when increasing the number of propagation depth (Chen et al., 2020a; Li et al., 2018; Xu et al., 2018).
21
+
22
+ The above observations motivate us to explicitly learn the importance and correlation of multiscale knowledge in a node-adaptive manner. To this end, we develop a new architecture – Graph Attention Multi-Layer Perceptron (GAMLP) – that could automatically exploit the knowledge over different neighborhoods at the granularity of nodes. GAMLP achieves this by introducing two novel attention mechanisms: Recursive attention and Jumping Knowledge (JK) attention. These two attention mechanisms can capture the complex correlations between propagated features at different propagation depths in a node-adaptive manner. Consequently, our architecture has the same benefits as the existing simplified and scalable GNN models while providing much better performance derived from its ability to utilizes a node-adaptive receptive field. Moreover, the proposed attention mechanisms can be applied to both node features and labels over neighborhoods with different sizes. By combining these two categories of information together, GAMLP could achieve the best of both worlds in terms of accuracy.
23
+
24
+ Our contributions are as follows: (1) New perspective. To the best of our knowledge, we are the first to explore both node-adaptive feature and label propagation schemes for scalable GNNs. (2) Novel method. We propose GAMLP, a scalable, efficient, and deep graph model. (3) State-of-the-art performance. Experimental results demonstrate that GAMLP achieves state-of-theart performance on 12 benchmark datasets while maintains high scalability and efficiency. In particular, GAMLP outperforms the competitive baseline GraphSAINT (Zeng et al., 2020) in terms of accuracy by a margin of $0 . 4 2 \%$ , $3 . 0 2 \%$ and $0 . 4 4 \%$ on PPI, Flickr, and Reddit datasets under the inductive setting, while achieving up to $4 5 \times$ training speedups in the large ogbn-products dataset. Remarkably, under the transductive setting in large OGB datasets, the accuracy of GAMLP exceeds the current state-of-the-art method by $1 . 0 { \bar { 3 } } \%$ and $\mathbf { \bar { 1 . 3 2 \% } }$ on the ogbn-products and ogbn-papers100M datasets, respectively.
25
+
26
+ # 2 PRELIMINARIES
27
+
28
+ # 2.1 PROBLEM FORMULATION
29
+
30
+ We consider an undirected graph $\mathcal { G } = ( \nu , \mathcal { E } )$ with $| \nu | = n$ nodes, $| { \mathcal { E } } | = m$ edges, and $c$ different node classes. We denote by $\mathbf { A }$ the adjacency matrix of $\mathcal { G }$ , weighted or not. Nodes can possibly have features vector of size $f$ , stacked up in an $n \times f$ matrix $\mathbf { X }$ $\mathbf { \bar { \Phi } } _ { \cdot } \mathbf { \bar { D } } = \operatorname { d i a g } \left( d _ { 1 } , d _ { 2 } , \cdot \cdot \cdot , \mathbf { \bar { \Phi } } _ { \cdot } d _ { N } \right) \in \mathbf { \bar { \Phi } } _ { \mathbb { R } ^ { n \times n } }$ denotes the degree matrix of $\mathbf { A }$ , where $\begin{array} { r } { d _ { i } = \sum _ { v _ { j } \in \mathcal { V } } \mathbf { A } _ { i j } } \end{array}$ is the degree of node $v _ { i }$ . Suppose $\mathcal { V } _ { l }$ is the labeled set, and our goal is to predict the labels for nodes in the unlabeled set $\nu _ { u }$ with the supervision of $\nu _ { l }$ .
31
+
32
+ # 2.2 SCALABLE GNNS
33
+
34
+ Sampling. A commonly used method to tackle the scalability issue (i.e., the recursive neighborhood expansion) in GNN is sampling. As a node-wise sampling method, GraphSAGE (Hamilton et al., 2017) randomly samples a fixed-size set of neighbors for computation in each mini-batch. VRGCN (Chen et al., 2018a) analyzes the variance reduction, and it reduces the size of samples with additional memory cost. For the layer-wise sampling, Fast-GCN (Chen et al., 2018b) samples a fixed number of nodes at each layer, and ASGCN (Huang et al., 2018) proposes the adaptive layer-wise sampling with better variance control. In the graph level, Cluster-GCN (Chiang et al., 2019) firstly clusters the nodes and then samples the nodes in the clusters, and GraphSAINT (Zeng et al., 2020) directly samples a subgraph for mini-batch training. Orthogonal to model simplification, sampling has already been widely used in many GNNs and GNN systems (Zheng et al., 2020; Zhu et al., 2019; Fey & Lenssen, 2019). However, these sampling-based GNNs are imperfect because they still face high communication costs, and the sampling quality highly influences the model performance.
35
+
36
+ Graph-wise Propagation. Recently studies have observed that non-linear feature transformation contributes little to the performance of the GNNs as compared to feature propagation. Thus, a new direction recently emerging for scalable GNN is based on the simplified GCN (SGC) (Wu et al., 2019), which successively removes nonlinearities and collapsing weight matrices between consecutive layers. This reduces GNNs into a linear model operating on $K$ -layers propagated features:
37
+
38
+ $$
39
+ \mathbf { X } ^ { ( K ) } = \hat { \mathbf { A } } ^ { K } \mathbf { X } ^ { ( 0 ) } , \qquad \mathbf { Y } = \mathrm { s o f t m a x } ( \Theta \mathbf { X } ^ { ( K ) } ) ,
40
+ $$
41
+
42
+ where $\mathbf { X } ^ { ( 0 ) } = \mathbf { X }$ , $\mathbf { X } ^ { ( K ) }$ is the $K$ -layers propagated feature, and $\hat { \mathbf { A } } = \widetilde { \mathbf { D } } ^ { r - 1 } \widetilde { \mathbf { A } } \widetilde { \mathbf { D } } ^ { - r }$ . By setting $r =$ 0.5, 1 and 0, $\hat { \bf A }$ represents the symmetric normalization adjacency matrix $\widetilde { \mathbf { D } } ^ { - 1 / 2 } \widetilde { \mathbf { A } } \widetilde { \mathbf { D } } ^ { - \mathrm { i } / 2 }$ (Klicpera et al., 2019), the transition probability matrix $\widetilde { \mathbf { A } } \widetilde { \mathbf { D } } ^ { - 1 }$ (Zeng et al., 2020), or the reverse transition probability matrix $\widetilde { \bf D } ^ { - 1 } \widetilde { \bf A }$ ( $\mathrm { X u }$ et al., 2018), respectively. As the propagated features $\mathbf { X } ^ { ( K ) }$ can be precomputed, SGC is more scalable and efficient for the large graph. However, such graph-wise propagation restricts the same propagation steps and a fixed RF for each node. Therefore, some nodes’ features may be over-smoothed or under-smoothed due to the inconsistent RF expansion speed, leading to non-optimal performance.
43
+
44
+ Layer-wise Propagation. Following SGC, some recent methods adopt layer-wise propagation to combine the features with different propagation layers. SIGN (Frasca et al., 2020) proposes to concatenate the propagated features at different propagation depth after simple linear transformation: $[ \mathbf { X } ^ { ( 0 ) } \mathbf { W } _ { 0 } , \mathbf { X } ^ { ( 1 ) } \mathbf { W } _ { 1 } , . . . , \mathbf { X } ^ { ( K ) } \mathbf { W } _ { K } ]$ . $\mathrm { { S ^ { 2 } G C } }$ (Zhu & Koniusz, 2021) proposes the simple spectral graph convolution to average the propagated features in different iterations as $\mathbf { X } ^ { ( K ) } = \sum _ { l = 0 } ^ { K } \hat { \mathbf { A } } ^ { l } \mathbf { X } ^ { ( 0 ) }$ . In addition, GBP (Chen et al., 2020b) further improves the combination process by weighted averaging $\mathbf { X } ^ { ( K ) } = \sum _ { l = 0 } ^ { K } w _ { l } \hat { \mathbf { A } } ^ { l } \mathbf { X } ^ { ( 0 ) }$ with the layer weight $w _ { l } = \beta { \left( 1 - \beta \right) } ^ { l }$ . Similar to these works, we also use a linear model for higher training scalability. The difference lies in that we consider the propagation process from a node-wise perspective and each node in GAMLP has a personalized combination of different steps of the propagated features.
45
+
46
+ # 2.3 LABEL UTILIZATION ON GNNS.
47
+
48
+ Labels of training nodes are conventionally only used as supervision signals in loss functions in most graph learning methods. However, there also exist some graph learning methods that directly exploit the labels of training nodes. Among them, the label propagation algorithm (Zhu & Ghahramani, 2002) is the most well-known one. It simply regards the partially observed label matrix $\mathbf { Y } \in \mathbb { R } ^ { N \times C }$ as input features for nodes in the graph and propagates the input features through the graph structure, where $C$ is the number of candidate classes. UniMP (Shi et al., 2020) proposes to map the partially observed label matrix $\mathbf { Y }$ to the dimension of the node feature matrix $\mathbf { X }$ and add these two matrices together as the new input feature. To fight against the label leakage problem, UniMP further randomly masks the training nodes during every training epoch.
49
+
50
+ Instead of using only the hard training labels, Correct & Smooth (Huang et al., 2020) first trains a simple model such as an MLP and gets this model’s predicted soft labels for unlabeled nodes. Then, it propagates the learning errors on the labeled nodes to connected nodes and smooths the output in a
51
+
52
+ ![](images/62d7673bc40aa87230cac6510d4d33f63d305d75d7fd4451adc76c0d3dd60a5d.jpg)
53
+ Figure 2: Overview of the proposed GAMLP, including (1) feature and label propagation, (2) combine the propagated features and labels with RF attention, and (3) MLP training. Note that both the feature and label propagation can be pre-processed.
54
+
55
+ Personalized PageRank manner like APPNP (Klicpera et al., 2019). Besides, SLE (Sun & Wu, 2021) decouples the label utilization procedure in UniMP, and executes the propagation in advance. Unlike UniMP, “label reuse” (Wang et al., 2021) concatenates the partially observed label matrix $\mathbf { Y }$ with the node feature matrix $\mathbf { X }$ to form the new input matrix. Concretely, it fills the missing elements in the partially observed label matrix $\mathbf { Y }$ with the soft label predicted by the model, and this newly generated $\mathbf { Y } ^ { \prime }$ is again concatenated with $\mathbf { X }$ and then fed into the model to generate new predictions.
56
+
57
+ # 3 GRAPH ATTENTION MULTI-LAYER PERCEPTRON
58
+
59
+ # 3.1 ARCHITECTURE OVERVIEW
60
+
61
+ As shown in Fig. 2, GAMLP decomposes the end-to-end GNN training into three parts: feature and label propagation, feature and label combination with RF attention, and the MLP training. As the feature and label propagation is pre-processed only once, and MLP training is efficient and salable, we can easily scale GAMLP to large graphs. Besides, with the RF attention, each node in GAMLP can adaptively get the suitable combination weights for propagated features and labels under different receptive fields, thus boosting model performance.
62
+
63
+ # 3.2 NODE-WISE FEATURE AND LABEL PROPAGATION
64
+
65
+ Node-wise Feature Propagation. We separate the essential operation of GNNs — feature propagation by removing the neural network $\Theta$ and nonlinear activation $\delta$ for feature transformation. Specifically, we construct a parameter-free $K$ -step feature propagation as:
66
+
67
+ $$
68
+ \mathbf { X } ^ { ( k ) } \hat { \mathbf { A } } \mathbf { X } ^ { ( k - 1 ) } , \forall k = 1 , \ldots , K ,
69
+ $$
70
+
71
+ where $\mathbf { X } ^ { ( k ) }$ contains the features of a fixed RF: the node itself and its $k$ -hop neighborhoods.
72
+
73
+ After $K$ -step feature propagation shown in E.q. 2, we correspondingly get a list of propagated features under different propagation steps: $[ \mathbf { X } ^ { ( 0 ) } , \mathbf { X } ^ { ( 1 ) } , \mathbf { X } ^ { ( k ) } , . . . , \mathbf { X } ^ { ( K ) } ]$ . For a node-wise propagation, we propose to average these propagated features in a weighted manner:
74
+
75
+ $$
76
+ \mathbf { H } _ { \mathbf { X } } = \sum _ { k = 0 } ^ { K } \mathbf { W } _ { k } \mathbf { X } ^ { ( k ) } ,
77
+ $$
78
+
79
+ where $\mathbf { W } _ { k } = D i a g ( \eta _ { k } ) \in \mathbb { R } ^ { n \times n }$ is the diagonal matrix derived from vector $\eta _ { k }$ , and $\eta _ { k } \in \mathbb { R } ^ { n }$ is a vector derived from vector $\eta _ { k } [ i ] = w _ { i } ( k ) , 1 \le i \le n$ , and $w _ { i } ( k )$ measures the importance of the $k$ -step propagated feature for node $v _ { i }$ .
80
+
81
+ Node-wise Label Propagation. We use a scalable and node-adaptive way to take advantage of the node labels of the training set. Concretely, the label embedding matrix $\mathbf { Y } \in \mathbb { R } ^ { n \times c } ( \mathbf { Y } ^ { ( \bar { 0 } ) } )$ is propagated with the normalized adjacency matrix $\hat { \bf A }$ :
82
+
83
+ $$
84
+ \mathbf { Y } ^ { ( l ) } \hat { \mathbf { A } } \mathbf { Y } ^ { ( l - 1 ) } , \forall l = 1 , \dots , L ,
85
+ $$
86
+
87
+ After $L$ -step label propagation, we get a list of propagated labels under different propagation steps: $[ \mathbf { Y } ^ { ( 0 ) } , \mathbf { Y } ^ { ( 1 ) } , \mathbf { Y } ^ { ( 2 ) } , . . . , \mathbf { Y } ^ { ( L ) } ]$ . Generally, the propagated label $\mathbf { Y } ^ { ( l ) }$ is closer to the original label matrix $\mathbf { Y } ^ { ( 0 ) }$ with smaller propagation step $l$ , and thus face a higher risk of data leakage problem if it is directly used as the model input. We propose last residual connection to solve this problem.
88
+
89
+ Definition 3.1 (Last Residual Connection). Given the propagation step $l$ , and a list of propagated labels: $[ \mathbf { Y } ^ { ( 0 ) } , \dot { \mathbf { Y } } ^ { ( 1 ) } , \mathbf { Y } ^ { ( 2 ) } , . . . , \mathbf { Y } ^ { ( L ) } ]$ , we smooth each label $\dot { \mathbf { Y } } ^ { ( \tilde { l } ) }$ with the smoothed label ${ \bf Y } ^ { ( L ) }$ :
90
+
91
+ $$
92
+ \hat { \mathbf { Y } } ^ { ( l ) } \gets ( 1 - \alpha _ { l } ) \mathbf { Y } ^ { ( l ) } + \alpha _ { l } \mathbf { Y } ^ { ( L ) } , l = 1 , \dots , L ,
93
+ $$
94
+
95
+ where $\begin{array} { r } { \alpha _ { l } = \cos \left( \frac { \pi l } { 2 L } \right) } \end{array}$ controls the proportion of $\mathbf { Y } ^ { ( L ) }$ in the $l$ -step propagated label.
96
+
97
+ Similar to the node-wise feature propagation introduced in Sec. 3.2, we propose to average these propagated labels in a weighted manner:
98
+
99
+ $$
100
+ \mathbf { H } _ { \mathbf { Y } } = \sum _ { l = 0 } ^ { L } \hat { \mathbf { W } } _ { l } \hat { \mathbf { Y } } ^ { ( l ) } .
101
+ $$
102
+
103
+ # 3.3 NODE-ADAPTIVE ATTENTION MECHANISMS
104
+
105
+ To satisfy different RF requirements for each node, we introduce two RF attention mechanisms to get $w _ { i } ( k )$ . Note that these attention mechanisms can be used in both the feature and label propagation, and we introduce them from a feature perspective here. To apply them for node-wise label propagation, we only need to replace the feature $\mathbf { X } _ { i }$ in Eq. 7 and Eq. 8 with the label $\mathbf { Y } _ { i }$ .
106
+
107
+ Definition 3.2 (Recursive Attention). At each propagation step $l$ , suppose $s \in \mathbb { R } ^ { d }$ is a learnable parameter vector, we recursively measure the feature information gain compared with the previous combined feature as:
108
+
109
+ $$
110
+ \widetilde { \mathbf { X } } _ { i } ^ { ( l ) } = \mathbf { X } _ { i } ^ { ( l ) } \parallel \sum _ { k = 0 } ^ { l - 1 } w _ { i } ( k ) \mathbf { X } _ { i } ^ { ( k ) } , \quad \widetilde { w } _ { i } ( l ) = \delta ( \widetilde { \mathbf { X } } _ { i } ^ { ( l ) } \cdot s ) , \quad w _ { i } ( l ) = e ^ { \widetilde { w } _ { i } ( l ) } / \sum _ { k = 0 } ^ { K } e ^ { \widetilde { w } _ { i } ( k ) } .
111
+ $$
112
+
113
+ As Xe (l−1)i ∈ combines the graph information under different propagation steps and RF, large proportion of the information in $\widetilde { \mathbf { X } } _ { i } ^ { ( l ) }$ may have already existed in $\begin{array} { r } { \sum _ { k = 0 } ^ { l - 1 } w _ { i } ( k ) \mathbf { X } _ { i } ^ { ( k ) } } \end{array}$ , leading to small information gain. A larger $w _ { i } ( l )$ indicates the feature $\mathbf { X } _ { i } ^ { ( l ) }$ is more important to the current state of node $v _ { i }$ since combining $\widetilde { \mathbf X } _ { i } ^ { ( l ) }$ will introduce higher information gain.
114
+
115
+ Jumping Knowledge Network (JK-Net) (Xu et al., 2018) adopts layer aggregation to combine the node embeddings of different GCN layers, and thus it can leverage the propagated nodes’ information with different RF. Motivated by JK-Net, we propose to guide the feature combination process with the model prediction trained on all the propagated features. Concretely, GAMLP with JK attention includes two branches: the concatenated JK branch and the attention-based combination branch.
116
+
117
+ Definition 3.3 (JK Attention). Given the MLP prediction of the JK branch as $\mathbf { E } _ { i } = M L P ( \mathbf { X } _ { i } ^ { ( 1 ) } \mid \mid$ $\mathbf { X } _ { i } ^ { ( 2 ) } \parallel . . . \parallel \mathbf { X } _ { i } ^ { ( K ) } ) \in \mathbb { R } ^ { K f }$ , the combination weight is defined as:
118
+
119
+ $$
120
+ \widetilde { \mathbf { X } } _ { i } ^ { ( l ) } = \mathbf { X } _ { i } ^ { ( l ) } \parallel \mathbf { E } _ { i } , \quad \widetilde { w } _ { i } ( l ) = \delta ( \widetilde { \mathbf { X } } _ { i } ^ { ( l ) } \cdot s ) , \quad w _ { i } ( l ) = e ^ { \widetilde { w } _ { i } ( l ) } / \sum _ { k = 0 } ^ { K } e ^ { \widetilde { w } _ { i } ( k ) } .
121
+ $$
122
+
123
+ The JK branch aims to create a multi-scale feature representation for each node, which helps the attention mechanism learn the weight $w _ { i } ( k )$ . The learned weights are then fed into the attentionbased combination branch to generate each node’s refined attention feature representation. As the training process continues, the attention-based combination branch will gradually emphasize those neighborhood regions that are more helpful to the target nodes. The JK attention can model a wider neighborhood while enhancing correlations, bringing a better feature representation for each node.
124
+
125
+ # 3.4 MODEL TRAINING
126
+
127
+ Both the combined feature $\mathbf { H } _ { \mathbf { X } }$ and combined label $\mathbf { H } _ { \mathbf { Y } }$ are transformed with MLP, and then be added to get the final output embedding:
128
+
129
+ $$
130
+ \widetilde { \mathbf { H } } = \mathbf { M } \mathbf { L } \mathbf { P } ( \mathbf { H } _ { \mathbf { X } } ) + \beta \mathbf { M } \mathbf { L } \mathbf { P } ( \mathbf { H } _ { \mathbf { Y } } ) ,
131
+ $$
132
+
133
+ where $\beta$ is a hyper-parameter that measures the importance of the combined label. For example, some graphs have good features but low-quality labels (e.g., label noise or low label rate), and we should decrease $\beta$ so that more attention is paid to the graph features.
134
+
135
+ We adopt the Cross-Entropy (CE) measurement between the predicted softmax outputs and the one-hot ground-truth label distributions as the objective function:
136
+
137
+ $$
138
+ \mathcal { L } _ { C E } = - \sum _ { i \in \mathcal { V } _ { l } } \sum _ { j } \mathbf { Y } _ { i j } \log ( \mathrm { s o f t m a x } ( \widetilde { \mathbf { H } } ) _ { i j } ) ,
139
+ $$
140
+
141
+ where $\mathbf { Y } _ { i }$ is the one-hot label indicator vector.
142
+
143
+ # 3.5 PROPERTIES OF GAMLP
144
+
145
+ High Efficiency and Scalability. Compared with the previous GNNs (e.g., GCN and GraphSAGE), our proposed GAMLP only need to do the feature and label propagation only once. Suppose $P$ and $Q$ are the number of layers in MLP trained with feature and labels, and $k$ is the sampled nodes, the time complexity of GAMLP is $\mathcal { O } ( P n f ^ { 2 } + Q n c ^ { 2 } )$ , which is smaller than the complexity of GraphSAGE (i.e., $\mathcal { O } ( k ^ { \bar { K } _ { n } } f ^ { 2 } ) )$ . Besides, it also cost less memory than the sampling-based GNNs, and thus can scale to a larger graph in a single machine. Notably, like other simplified GNNs (i.e., SGC and SIGN), GAMLP can pre-compute the propagated features and labels only once. It doesn’t need to pull the intermediate representation of other nodes during the MLP training. Therefore, it can also be well adapted to the distributed environment. Further details can be found in Appendix A.3.
146
+
147
+ Deep propagation. With our recursive and JK attention, GAMLP can support large propagation depth without the over-smoothing issue since each node can get the node personalized combination weights for different propagated features and labels according to its demand. Such characteristic is essential for sparse graph, i.e., sparse labels, edges, and features. For example, a graph with a low label rate or edge rate can increase the propagation depth to spread the label supervision over the full graph. Each node can utilize the high-order graph structure information with deep propagation and then boost the node classification performance. Further details is in Appendix B.2.
148
+
149
+ # 3.6 RELATION WITH CURRENT METHODS
150
+
151
+ GAMLP vs. GBP. Both GAMLP and GBP propose to combine the propagated features under different propagation steps. However, GBP adopts a layer-wise propagation scheme and ignores the inconsistent receptive field expansion speed for different nodes. As the optimal propagation steps and smoothing levels of different nodes are different, some nodes may face the over-smoothing issue, even propagating the same step. GAMLP considers the feature and label propagation in a more fine-grained node perspective.
152
+
153
+ GAMLP vs. GAT. Each node in a GAT layer learns to weighted combine the embedding (or feature) of its neighborhoods with an attention mechanism, and the attention weights are measured by the local information in a fixed RF – the node itself and its direct neighbors. Different from the attention mechanism in GAT, GAMLP considers more global information under different RF.
154
+
155
+ GAMLP vs. JK-Net. Motivated by JK-Net, GAMLP with JK attention concatenate the propagated features under different propagation steps. However, the model prediction based on the concatenated feature is just used as a reference vector for the attention-based combination branch in GAMLP rather than the final results. Compared with JK-Net, GAMLP with JK attention is more effective in alleviating the over-smoothing and scalability issue that deep architecture introduces.
156
+
157
+ GAMLP vs. SAGN. SAGN also proposes to do node-specific propagation in GNN. Concretely, SAGN learns the node-specific attention weights with the original node feature. Unlike SAGN, GAMLP adopts two attention mechanisms to learn the interactions between the propagated features over different sizes of receptive fields. Besides, node-wise label propagation is also employed in GAMLP for better utilization of node labels.
158
+
159
+ # 4 EXPERIMENTS
160
+
161
+ In this section, we verify the effectiveness of GAMLP on 12 real-world graph datasets under both the transductive and inductive settings. We aim to answer the following four questions. Q1: Can GAMLP outperform the state-of-the-art GNN methods? Q2: If so, where does the performance gain of GAMLP come from? Q3: How about the efficiency of GAMLP compared with current GNN methods? Q4: How does GAMLP perform when applied to highly sparse graphs (i.e., given few edges and low label rate)? More experimental results about the heterogeneous graph, propagation depth and interpretability can be found in Appendix B.
162
+
163
+ Table 1: Performance comparison on seven transductive datasets.
164
+
165
+ <table><tr><td>Methods</td><td>Cora</td><td>Citeseer</td><td>PubMed</td><td>Amazon Computer</td><td>Amazon Photo</td><td>Coauthor CS</td><td>Coauthor Physics</td></tr><tr><td>GCN</td><td>81.8±0.5</td><td>70.8±0.5</td><td>79.3±0.7</td><td>82.4±0.4</td><td>91.2±0.6</td><td>90.7±0.2</td><td>92.7±1.1</td></tr><tr><td>GAT</td><td>83.0±0.7</td><td>72.5±0.7</td><td>79.0±0.3</td><td>80.1±0.6</td><td>90.8±1.0</td><td>87.4±0.2</td><td>90.2±1.4</td></tr><tr><td>JK-Net</td><td>81.8±0.5</td><td>70.7±0.7</td><td>78.8±0.7</td><td>82.0±0.6</td><td>91.9±0.7</td><td>89.5±0.6</td><td>92.5±0.4</td></tr><tr><td>ResGCN</td><td>82.2±0.6</td><td>70.8±0.7</td><td>78.3±0.6</td><td>81.1±0.7</td><td>91.3±0.9</td><td>87.9±0.6</td><td>92.2±1.5</td></tr><tr><td>APPNP</td><td>83.3±0.5</td><td>71.8±0.5</td><td>80.1±0.2</td><td>81.7±0.3</td><td>91.4±0.3</td><td>92.1±0.4</td><td>92.8±0.9</td></tr><tr><td>AP-GCN</td><td>83.4±0.3</td><td>71.3±0.5</td><td>79.7±0.3</td><td>83.7±0.6</td><td>92.1±0.3</td><td>91.6±0.7</td><td>93.1±0.9</td></tr><tr><td>SGC</td><td>81.0±0.2</td><td>71.3±0.5</td><td>78.9±0.5</td><td>82.2±0.9</td><td>91.6±0.7</td><td>90.3±0.5</td><td>91.7±1.1</td></tr><tr><td>SIGN</td><td>82.1±0.3</td><td>72.4±0.8</td><td>79.5±0.5</td><td>83.1±0.8</td><td>91.7±0.7</td><td>91.9±0.3</td><td>92.8±0.8</td></tr><tr><td>S²GC</td><td>82.7±0.3</td><td>73.0±0.2</td><td>79.9±0.3</td><td>83.1±0.7</td><td>91.6±0.6</td><td>91.6±0.6</td><td>93.1±0.8</td></tr><tr><td>GBP</td><td>83.9±0.7</td><td>72.9±0.5</td><td>80.6±0.4</td><td>83.5±0.8</td><td>92.1±0.8</td><td>92.3±0.4</td><td>93.3±0.7</td></tr><tr><td>UNIMP</td><td>82.6±0.4</td><td>72.5±0.9</td><td>80.1±0.5</td><td>83.9±0.8</td><td>92.0±1.1</td><td>92.4±0.3</td><td>93.5±0.8</td></tr><tr><td>GAMLP(JK)</td><td>84.3±0.8</td><td>74.6±0.4</td><td>80.7±0.4</td><td>84.5±0.7</td><td>92.8±0.7</td><td>92.6±0.5</td><td>93.6±1.0</td></tr><tr><td>GAMLP(R)</td><td>83.9±0.6</td><td>73.9±0.6</td><td>80.8±0.5</td><td>84.2±0.5</td><td>92.6±0.8</td><td>92.8±0.7</td><td>93.2±1.0</td></tr></table>
166
+
167
+ # 4.1 EXPERIMENTAL SETUP
168
+
169
+ Datasets. We evaluate the predictive accuracy of GAMLP under both transductive and inductive settings. For transductive settings, we conduct experiments on nine transductive datasets: three citation network datasets (Cora, Citeseer, PubMed) (Sen et al., 2008), two user-item datasets (Amazon Computer, Amazon Photo), two co-author datasets (Coauthor CS, Coauthor Physics) (Shchur et al., 2018), and two OGB datasets (ogbn-products, ogbn-papers100M) (Hu et al., 2021). For inductive settings, we perform the comparison experiments on three inductive datasets: PPI, Flickr, and Reddit (Zeng et al., 2019). The statistics about these datasets can be found in Table 10 in Appendix C.1.
170
+
171
+ Baselines. Under the transductive setting, we compare GAMLP with the following representative baseline methods: GCN (Kipf & Welling, 2016), GAT (Velickovi ˇ c et al., 2017), JK-Net (Xu et al., ´ 2018), ResGCN (Li et al., 2019), APPNP (Klicpera et al., 2018), AP-GCN (Spinelli et al., 2020), SGC (Wu et al., 2019), SIGN (Frasca et al., 2020), $\mathrm { { S ^ { 2 } G C } }$ (Zhu & Koniusz, 2021), and GBP (Chen et al., 2020b). For the comparison in the OGB datasets, we choose the top-performing methods from the OGB leaderboard along with their accuracy results. Under the inductive setting, we choose following representative methods: SGC (Wu et al., 2019), GraphSAGE (Hamilton et al., 2017), Cluster-GCN (Chiang et al., 2019), and GraphSAINT (Zeng et al., 2019).
172
+
173
+ In addition, two variants of GAMLP are tested in the evaluation: GAMLP(JK) and GAMLP(R). “JK” and “R” stand for adopting “JK attention” and “Recursive attention” for the node-adaptive attention mechanism, respectively.
174
+
175
+ Table 2: Performance comparison on the ogbnproducts dataset.
176
+
177
+ <table><tr><td>Methods</td><td>Val Accuracy</td><td>Test Accuracy</td></tr><tr><td>GCN</td><td>92.00±0.03</td><td>75.64±0.21</td></tr><tr><td>SGC</td><td>92.13±0.02</td><td>75.87±0.14</td></tr><tr><td>GraphSAGE</td><td>92.24±0.07</td><td>78.50±0.14</td></tr><tr><td>GraphSAINT</td><td>92.52±0.13</td><td>80.27±0.26</td></tr><tr><td>GBP</td><td>92.82±0.10</td><td>80.48±0.05</td></tr><tr><td>SIGN</td><td>92.99±0.04</td><td>80.52±0.16</td></tr><tr><td>DeeperGCN</td><td>92.38±0.09</td><td>80.98±0.20</td></tr><tr><td>UniMP</td><td>93.08±0.17</td><td>82.56±0.31</td></tr><tr><td>SAGN</td><td>93.09±0.04</td><td>81.20±0.07</td></tr><tr><td>SAGN+0-SLE</td><td>93.27±0.04</td><td>83.29±0.18</td></tr><tr><td>GAMLP(JK)</td><td>93.19±0.03</td><td>83.54±0.25</td></tr><tr><td>GAMLP(R)</td><td>93.11±0.05</td><td>83.59±0.09</td></tr></table>
178
+
179
+ Table 3: Performance comparison on the ogbnpapers100M dataset.
180
+
181
+ <table><tr><td>Methods</td><td>Val Accuracy</td><td>Test Accuracy</td></tr><tr><td>SGC</td><td>66.48±0.20</td><td>63.29±0.19</td></tr><tr><td>SIGN</td><td>69.32±0.06</td><td>65.68±0.06</td></tr><tr><td>SIGN-XL</td><td>69.84±0.06</td><td>66.06±0.19</td></tr><tr><td>SAGN</td><td>70.34±0.99</td><td>66.75±0.84</td></tr><tr><td>SAGN+0-SLE</td><td>71.06±0.08</td><td>67.55±0.15</td></tr><tr><td>GAMLP(JK)</td><td>71.92±0.04</td><td>68.07±0.10</td></tr><tr><td>GAMLP(R)</td><td>71.21±0.03</td><td>67.46±0.02</td></tr></table>
182
+
183
+ Table 4: Performance comparison on three inductive datasets.
184
+
185
+ <table><tr><td>Methods</td><td>PPI</td><td>Flickr</td><td>Reddit</td></tr><tr><td>SGC</td><td>65.7±0.01</td><td>50.2±0.12</td><td>94.9±0.00</td></tr><tr><td>GraphSAGE</td><td>61.2±0.05</td><td>50.1±0.13</td><td>95.4±0.01</td></tr><tr><td>Cluster-GCN</td><td>99.2±0.04</td><td>48.1±0.05</td><td>95.7±0.00</td></tr><tr><td>GraphSAINT</td><td>99.4±0.03</td><td>51.1±0.10</td><td>96.6±0.01</td></tr><tr><td>GAMLP(JK)</td><td>99.82±0.01</td><td>54.12±0.01</td><td>97.04±0.01</td></tr><tr><td>GAMLP(R)</td><td>99.66±0.01</td><td>53.12±0.00</td><td>96.62±0.01</td></tr></table>
186
+
187
+ # 4.2 END-TO-END COMPARISON
188
+
189
+ Transductive Performance. To answer Q1, we report the transductive performance of GAMLP in Tables 1, 2, and 3. We observe that both variants of GAMLP outperform all the baseline methods on almost all the datasets. For example, on the small Citeseer dataset, GAMLP(JK) outperforms the state-of-the-art method $\mathrm { { S ^ { 2 } G C } }$ by a large margin of $1 . 6 \%$ ; on the medium-sized dataset Amazon Computers, the predictive accuracy of GAMLP (JK) exceeds the one of the state-of-the-art method GBP by $1 . 0 \%$ ; on the two large OGB datasets, GAMLP takes the lead by $1 . 0 3 \%$ and $1 . 3 2 \%$ on ogbn-products and ogbn-papers100M, respectively. Furthermore, the experimental results illustrate that the contest between the two variants of GAMLP is not a one-horse race, which suggests that these two different attention mechanisms both have their irreplaceable sense in some ways.
190
+
191
+ Inductive Performance. We also evaluate GAMLP under the inductive setting. The experiment results in Table 4 show that GAMLP consistently outperforms all the baseline methods. The leading advantage of GAMLP(JK) over SOTA inductive method – GraphSAINT is more than $3 . 0 \%$ on the widely-used dataset – Filckr. The impressive performance of GAMLP under the inductive setting illustrates that GAMLP is alpowerful in predicting the properties of unseen nodes.
192
+
193
+ Table 5: Ablation study on label utilization.
194
+
195
+ <table><tr><td>Methods</td><td>Val Accuracy</td><td>Test Accuracy</td></tr><tr><td>GAMLP(R)</td><td>93.11±0.05</td><td>83.59±0.05</td></tr><tr><td>-no_label</td><td>92.29±0.06</td><td>81.43±0.18</td></tr><tr><td>-plain_label</td><td>92.53±0.21</td><td>81.12±0.45</td></tr><tr><td>-uniform</td><td>92.72±0.15</td><td>81.28±0.93</td></tr></table>
196
+
197
+ Table 6: Ablation study on reference vector.
198
+
199
+ <table><tr><td>Methods</td><td>Val Accuracy</td><td>Test Accuracy</td></tr><tr><td>GAMLP(JK)</td><td>82.5±0.5</td><td>80.7±0.4</td></tr><tr><td>-origin_feature</td><td>82.2±0.4</td><td>80.5±0.4</td></tr><tr><td>-normal_noise</td><td>81.8±0.4</td><td>79.8±0.5</td></tr><tr><td>-no_reference</td><td>81.5±0.5</td><td>79.9±0.3</td></tr></table>
200
+
201
+ # 4.3 ABLATION STUDY
202
+
203
+ To answer Q2, we focus on two modules in GAMLP: (1) label utilization; (2) attention mechanism in the node-wise propagation. For the second one, we evaluate the effects of different choices for reference vectors in the JK attention.
204
+
205
+ Label Utilization. In this part, we evaluate whether adding last residual connection and making use of training labels really help or not. The predictive accuracy of GAMLP(R) is evaluated on the ogbn-products dataset along with its three variants: “-no_label”, “-plain_label”, and “-uniform”, which stands for not using labels, removing last residual connections, and replacing last residual connections with uniform distributions, respectively. The experimental results in Table 5 show that utilizing labels brings huge performance gain to GAMLP: from $8 1 . 4 3 \%$ to $8 3 . 5 9 \%$ . The performance drop from removing the last residual connections (“-plain_label” in Table 5) is significant since directly adopting the raw training labels leads to the overfitting issue. The fact that “-uniform” performs worse than “-no_label” illustrates that intuitively fusing the original label distribution with the uniform distribution would harm the predictive accuracy. It further demonstrates the effectiveness of our proposed last residual connections.
206
+
207
+ Reference Vector in Attention Mechanism. In this part, we study the role of the reference vector (originally set as the concatenated features from different propagation steps) in our proposed JK attention. We evaluate the three variants of GAMLP(JK): “-origin_feature”, “-normal_noise”, and “-no_reference”, which changes the reference vector to the original node feature, noise from the normal distribution, and nothing, respectively. The predictive accuracy of each variant on the PubMed dataset is reported in Table 6. The experimental results show that our original choice of the reference vector is the best among itself and its three variants. The superiority of the concatenated features from different propagation steps comes from the fact that it allows the model to capture the interactions between the propagated features over the receptive fields with different sizes.
208
+
209
+ Table 7: Efficiency comparison on the ogbn-products dataset.
210
+
211
+ <table><tr><td>Methods</td><td>SGC</td><td>SIGN</td><td>GAMLP(JK)</td><td>GAMLP(R)</td><td>GraphSAINT</td><td>Cluster-GCN</td></tr><tr><td>Training time</td><td>1.0</td><td>4.0</td><td>8.0</td><td>9.3</td><td>364</td><td>503</td></tr><tr><td>Test accuracy</td><td>75.87</td><td>80.52</td><td>83.54</td><td>83.59</td><td>79.08</td><td>78.97</td></tr></table>
212
+
213
+ ![](images/60b26cb2f146ebaf212df7df59a70cd9b9815012880c1e774b16d614e3160772.jpg)
214
+ Figure 3: Test accuracy on PubMed dataset under different levels of label and edge sparsity.
215
+
216
+ # 4.4 EFFICIENCY COMPARISON
217
+
218
+ To answer Q3, we evaluate the efficiency of each method on the ogbn-products dataset. We compare the efficiency of GAMLP with sampling-based GraphSAINT and Cluster-GCN, graph-wisepropagation-based SGC, and layer-wise-propagation-based SIGN. Table 7 illustrates the relative training time of each compared method along with its predictive accuracy. The training time of SGC is set to 1 as reference. We observe that (1) sampling-based methods (e.g., GraphSAINT) consume much more time than graph/layer-wise-propagation based methods (e.g., SGC, SIGN) due to the high computation cost introduced by the sampling process; (2) the two variants of GAMLP achieve the best predictive accuracy while requiring comparable training time with SGC.
219
+
220
+ # 4.5 EXPERIMENTS ON SPARSE GRAPHS
221
+
222
+ To answer Q4, we conduct experiments to evaluate the predictive accuracy of GAMLP when faced with edge and label sparsity problems, where the number of edges and training labels are highly scarce. We randomly remove a fixed percentage of edges from the original graph to simulate the edge sparsity problem. The removed edges are exactly the same for all the compared methods. Besides, we enumerate the number of training nodes per class from 1 to 20 to evaluate the performance of GAMLP given different levels of label sparsity. The experimental results in Figure 3 show that GAMLP consistently outperforms all the baselines when faced with different levels of edge and label sparsity. This experiment further demonstrates the effectiveness of our proposed node-wise propagation scheme. The node-wise propagation enables GAMLP to better capture long-range dependencies, which is crucial when applying GNN methods to highly sparse graphs.
223
+
224
+ # 5 CONCLUSION
225
+
226
+ We presented Graph Attention Multilayer Perceptron (GAMLP), a scalable, efficient, and deep graph model based on receptive field attention. GAMLP introduced two new attention mechanisms: recursive attention and JK attention, which enables to learn the representations over RF with different sizes in a node-adaptive manner. Extensive experiments on 12 graph datasets verified the effectiveness of the proposed method. GAMLP moves forward the performance boundary of scalable GNNs, especially on large-scale graphs. This initial attempt also motivates several interesting future directions: (1) exploring other attention mechanisms and (2) studying the mechanisms on heterogeneous graphs.
227
+
228
+ # 6 REPRODUCIBILITY STATEMENT
229
+
230
+ The source code of GAMLP can be found in Anonymous Github (https://anonymous.4open. science/r/ICLR-GAMLP). To ensure reproducibility, we have provided the overview of datasets and baselines in Section 4.1 and Table 10 in Appendix C.1. The detailed hyperparameter settings for our GAMLP can be found in Appendix C.2. Our experimental environment is presented in Appendix C.1, and please refer to “README.md” in the Github repository for more details.
231
+
232
+ # REFERENCES
233
+
234
+ Deyu Bo, Xiao Wang, Chuan Shi, Meiqi Zhu, Emiao Lu, and Peng Cui. Structural deep clustering network. In Proceedings of The Web Conference 2020, pp. 1400–1410, 2020.
235
+
236
+ Deli Chen, Yankai Lin, Wei Li, Peng Li, Jie Zhou, and Xu Sun. Measuring and relieving the oversmoothing problem for graph neural networks from the topological view. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 3438–3445, 2020a.
237
+
238
+ Jianfei Chen, Jun Zhu, and Le Song. Stochastic training of graph convolutional networks with variance reduction. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmässan, Stockholm, Sweden, July 10-15, 2018, pp. 941–949, 2018a.
239
+
240
+ Jie Chen, Tengfei Ma, and Cao Xiao. Fastgcn: Fast learning with graph convolutional networks via importance sampling. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings, 2018b.
241
+
242
+ Ming Chen, Zhewei Wei, Bolin Ding, Yaliang Li, Ye Yuan, Xiaoyong Du, and Ji-Rong Wen. Scalable graph neural networks via bidirectional propagation. arXiv preprint arXiv:2010.15421, 2020b.
243
+
244
+ Wei-Lin Chiang, Xuanqing Liu, Si Si, Yang Li, Samy Bengio, and Cho-Jui Hsieh. Cluster-gcn: An efficient algorithm for training deep and large graph convolutional networks. In SIGKDD, pp. 257–266, 2019.
245
+
246
+ Ganqu Cui, Jie Zhou, Cheng Yang, and Zhiyuan Liu. Adaptive graph encoder for attributed graph embedding. In SIGKDD, pp. 976–985, 2020.
247
+
248
+ Wenqi Fan, Yao Ma, Qing Li, Yuan He, Eric Zhao, Jiliang Tang, and Dawei Yin. Graph neural networks for social recommendation. In The World Wide Web Conference, pp. 417–426, 2019.
249
+
250
+ Matthias Fey and Jan E. Lenssen. Fast graph representation learning with PyTorch Geometric. In ICLR 2019 Workshop on Representation Learning on Graphs and Manifolds, 2019. URL https://arxiv.org/abs/1903.02428.
251
+
252
+ Fabrizio Frasca, Emanuele Rossi, Davide Eynard, Ben Chamberlain, Michael Bronstein, and Federico Monti. Sign: Scalable inception graph neural networks. arXiv preprint arXiv:2004.11198, 2020.
253
+
254
+ William L Hamilton, Rex Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NeurIPS, pp. 1025–1035, 2017.
255
+
256
+ Weihua Hu, Matthias Fey, Hongyu Ren, Maho Nakata, Yuxiao Dong, and Jure Leskovec. Ogb-lsc: A large-scale challenge for machine learning on graphs. arXiv preprint arXiv:2103.09430, 2021.
257
+
258
+ Ziniu Hu, Yuxiao Dong, Kuansan Wang, and Yizhou Sun. Heterogeneous graph transformer. In Proceedings of The Web Conference 2020, pp. 2704–2710, 2020.
259
+
260
+ Qian Huang, Horace He, Abhay Singh, Ser-Nam Lim, and Austin R Benson. Combining label propagation and simple models out-performs graph neural networks. arXiv preprint arXiv:2010.13993, 2020.
261
+
262
+ Wen-bing Huang, Tong Zhang, Yu Rong, and Junzhou Huang. Adaptive sampling towards fast graph representation learning. In Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montréal, Canada, pp. 4563–4572, 2018.
263
+
264
+ Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
265
+
266
+ Johannes Klicpera, Aleksandar Bojchevski, and Stephan Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank. arXiv preprint arXiv:1810.05997, 2018.
267
+
268
+ Johannes Klicpera, Aleksandar Bojchevski, and Stephan Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019, 2019.
269
+
270
+ Guohao Li, Matthias Muller, Ali Thabet, and Bernard Ghanem. Deepgcns: Can gcns go as deep as cnns? In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 9267–9276, 2019.
271
+
272
+ Qimai Li, Zhichao Han, and Xiao-Ming Wu. Deeper insights into graph convolutional networks for semi-supervised learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
273
+
274
+ Michael Schlichtkrull, Thomas N Kipf, Peter Bloem, Rianne Van Den Berg, Ivan Titov, and Max Welling. Modeling relational data with graph convolutional networks. In European semantic web conference, pp. 593–607. Springer, 2018.
275
+
276
+ Prithviraj Sen, Galileo Namata, Mustafa Bilgic, Lise Getoor, Brian Gallagher, and Tina Eliassi-Rad. Collective classification in network data. AI Mag., 29(3):93–106, 2008.
277
+
278
+ Oleksandr Shchur, Maximilian Mumme, Aleksandar Bojchevski, and Stephan Günnemann. Pitfalls of graph neural network evaluation. arXiv preprint arXiv:1811.05868, 2018.
279
+
280
+ Yunsheng Shi, Zhengjie Huang, Wenjin Wang, Hui Zhong, Shikun Feng, and Yu Sun. Masked label prediction: Unified message passing model for semi-supervised classification. arXiv preprint arXiv:2009.03509, 2020.
281
+
282
+ Indro Spinelli, Simone Scardapane, and Aurelio Uncini. Adaptive propagation graph convolutional network. IEEE Transactions on Neural Networks and Learning Systems, 2020.
283
+
284
+ Chuxiong Sun and Guoshi Wu. Scalable and adaptive graph neural networks with self-label-enhanced training. arXiv preprint arXiv:2104.09376, 2021.
285
+
286
+ Théo Trouillon, Christopher R Dance, Johannes Welbl, Sebastian Riedel, Éric Gaussier, and Guillaume Bouchard. Knowledge graph completion via complex tensor factorization. arXiv preprint arXiv:1702.06879, 2017.
287
+
288
+ Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. arXiv preprint arXiv:1710.10903, 2017.
289
+
290
+ Yangkun Wang, Jiarui Jin, Weinan Zhang, Yong Yu, Zheng Zhang, and David Wipf. Bag of tricks for node classification with graph neural networks. arXiv preprint arXiv:2103.13355, 2021.
291
+
292
+ Felix Wu, Tianyi Zhang, Amauri Holanda de Souza Jr, Christopher Fifty, Tao Yu, and Kilian Q Weinberger. Simplifying graph convolutional networks. arXiv preprint arXiv:1902.07153, 2019.
293
+
294
+ Xinliang Wu, Mengying Jiang, and Guizhong Liu. R-gsn: The relation-based graph similar network for heterogeneous graph. arXiv preprint arXiv:2103.07877, 2021.
295
+
296
+ Keyulu Xu, Chengtao Li, Yonglong Tian, Tomohiro Sonobe, Ken-ichi Kawarabayashi, and Stefanie Jegelka. Representation learning on graphs with jumping knowledge networks. In ICML, pp. 5453–5462. PMLR, 2018.
297
+
298
+ Le Yu, Leilei Sun, Bowen Du, Chuanren Liu, Weifeng Lv, and Hui Xiong. Hybrid micro/macro level convolution for heterogeneous graph learning. arXiv preprint arXiv:2012.14722, 2020a.
299
+
300
+ Le Yu, Leilei Sun, Bowen Du, Chuanren Liu, Weifeng Lv, and Hui Xiong. Heterogeneous graph representation learning with relation awareness. arXiv preprint arXiv:2105.11122, 2021.
301
+
302
+ Lingfan Yu, Jiajun Shen, Jinyang Li, and Adam Lerer. Scalable graph neural networks for heterogeneous graphs. arXiv preprint arXiv:2011.09679, 2020b.
303
+
304
+ Hanqing Zeng, Hongkuan Zhou, Ajitesh Srivastava, Rajgopal Kannan, and Viktor Prasanna. Graphsaint: Graph sampling based inductive learning method. In ICLR, 2019.
305
+
306
+ Hanqing Zeng, Hongkuan Zhou, Ajitesh Srivastava, Rajgopal Kannan, and Viktor K. Prasanna. Graphsaint: Graph sampling based inductive learning method. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020, 2020.
307
+
308
+ Da Zheng, Chao Ma, Minjie Wang, Jinjing Zhou, Qidong Su, Xiang Song, Quan Gan, Zheng Zhang, and George Karypis. Distdgl: Distributed graph neural network training for billion-scale graphs. In 10th IEEE/ACM Workshop on Irregular Applications: Architectures and Algorithms, IA3 2020, Atlanta, GA, USA, November 11, 2020, pp. 36–44. IEEE, 2020.
309
+
310
+ Hao Zhu and Piotr Koniusz. Simple spectral graph convolution. In International Conference on Learning Representations, 2021.
311
+
312
+ Rong Zhu, Kun Zhao, Hongxia Yang, Wei Lin, Chang Zhou, Baole Ai, Yong Li, and Jingren Zhou. Aligraph: A comprehensive graph neural network platform. Proc. VLDB Endow., 12(12): 2094–2105, August 2019. ISSN 2150-8097. doi: 10.14778/3352063.3352127. URL https: //doi.org/10.14778/3352063.3352127.
313
+
314
+ Xiaojin Zhu and Zoubin Ghahramani. Learning from labeled and unlabeled data with label propagation. 2002.
315
+
316
+ ![](images/d7ef11ec87782651e0ec931f33eee529b59ac4904f874fb1fb3649c11687c823.jpg)
317
+ Figure 4: The architecture of GAMLP with JK Attention.
318
+
319
+ # A MORE DETAILS ABOUT GAMLP
320
+
321
+ A.1 AN EXAMPLE OF JK ATTENTION
322
+
323
+ Fig. 4 provides a more zoomed-in look of JK attention, one of the two node-adaptive attention mechanisms we proposed. The propagated features are concatenated and then fed into an MLP to map the concatenated feature to the hidden dimension of the model. The mapped feature is then set as the reference vector of the following attention mechanism, where a linear layer is adopted to calculate the combination weight for propagated features at different propagation steps. The propagated features are then multiplied with the corresponding combination weight, and the summed results are fed into another MLP to generate final predictions.
324
+
325
+ # A.2 COMPARISON BETWEEN THE LABEL USAGE IN UNIMP AND GAMLP
326
+
327
+ (1) The label usage in UniMP is coupled with the training process, making it hard to scale to large graphs. While GAMLP decouples the label usage from the training process, the label propagation process can be executed as preprocessing.
328
+
329
+ (2) The label propagation steps in UniMP are restricted to the same number of model layers. And if the number of model layers becomes large, UniMP will encounter the efficiency and scalability issues even on relatively small graphs. While the label propagation steps in GAMLP can be quite large since the label propagation is performed as preprocessing.
330
+
331
+ (3) Both UniMP and GAMLP propose approaches to fight against the label leakage issue. However, the random masking in UniMP has to be executed in each training epoch, while the last residual connection (composed of simple matrix addition) in GAMLP just needs to be executed once during preprocessing. Thus, UniMP consumes more resources than GAMLP to fight the label leakage issue.
332
+
333
+ # A.3 COMPLEXITY ANALYSIS
334
+
335
+ Table 8 provides a detailed asymptotic complexity comparison between GAMLP and representative scalable GNN methods. During preprocessing, the time cost of clustering in Cluster-GCN is $\mathcal { O } ( m )$ and the time complexity of most linear models is $\mathcal { O } ( K m f )$ . Besides, GAMLP has an extra time cost $\mathcal { O } ( L m c )$ for the propagation of training labels. GBP takes advantage of Monte-Carlo method and conducts this process approximately with a bound of $\begin{array} { r } { \mathcal { O } ( K n f + K \frac { \sqrt { m \log n } } { \varepsilon } ) } \end{array}$ , where $\varepsilon$ is a error threshold. Compared with sampling-based GNNs, graph/layer/node-wise-propagation-based models usually have smaller training and inference time complexity. Memory complexity is a crucial factor in large-scale graph learning as it fundamentally determines whether it is possible to adopt the method. Compared with SIGN, both GBP and GAMLP do not need to store smoothed features at different propagation steps, and the memory complexity can be reduced from $\mathcal { O } ( b L f )$ to $\mathcal { O } ( b f )$ .
336
+
337
+ Table 8: Algorithm analysis for existing scalable GNNs. $n , m , c ,$ , and $f$ are the number of nodes, edges, classes, and feature dimensions, respectively. $b$ is the batch size, and $k$ refers to the number of sampled nodes. $K$ and $L$ corresponds to the number of times we aggregate features and labels respectively. Besides, $P$ and $Q$ are the number of layers in MLP classifiers trained with features and labels respectively.
338
+
339
+ <table><tr><td>Type</td><td>Method</td><td>Pre-processing</td><td>Training</td><td>Memory</td></tr><tr><td rowspan="3">Sampling</td><td>GraphSAGE</td><td>=</td><td>O(kKnf²)</td><td>O(bkK f+Kf²)</td></tr><tr><td>FastGCN</td><td></td><td>O(kKnf2)</td><td>O(bkKf+Kf²)</td></tr><tr><td>Cluster-GCN</td><td>0(m)</td><td>O(Pmf+Pnf²)</td><td>O(bKf+Kf²)</td></tr><tr><td>Graph-wise propagation</td><td>SGC</td><td>O(Kmf)</td><td>O(nf²)</td><td>O(bf+f²)</td></tr><tr><td rowspan="3">Layer-wise propagation</td><td>SIGN</td><td>O(Kmf)</td><td>O(Pnf2)</td><td>O(bLf+Pf²)</td></tr><tr><td>S²GC</td><td>O(Kmf)</td><td>O(nf2)</td><td>O(bf+f²)</td></tr><tr><td>GBP</td><td>O(Knf+KVmlgn)</td><td>O(Pnf²)</td><td>O(bf+Pf²)</td></tr><tr><td>Node-wise propagation</td><td>GAMLP</td><td>O(Kmf+Lmc)</td><td>O(Pnf² +Qnc²)</td><td>O(bf+Pf²+Qc²)</td></tr></table>
340
+
341
+ Table 9: Test accuracy on ogbn-mag dataset.
342
+
343
+ <table><tr><td>Methods</td><td>Validation Accuracy</td><td>Test Accuracy</td></tr><tr><td>R-GCN</td><td>40.84±0.41</td><td>39.77±0.46</td></tr><tr><td>SIGN</td><td>40.68±0.10</td><td>40.46±0.12</td></tr><tr><td>HGT</td><td>49.84±0.47</td><td>49.27±0.61</td></tr><tr><td>R-GSN</td><td>51.82±0.41</td><td>50.32±0.37</td></tr><tr><td>HGConv</td><td>53.00±0.18</td><td>50.45±0.17</td></tr><tr><td>R-HGNN</td><td>53.61±0.22</td><td>52.04±0.26</td></tr><tr><td>NARS</td><td>53.72±0.09</td><td>52.40±0.16</td></tr><tr><td>NARS-GAMLP</td><td>55.52±0.08</td><td>54.01±0.21</td></tr></table>
344
+
345
+ # B ADDITIONAL EXPERIMENTS
346
+
347
+ # B.1 EXPERIMENTS ON OGBN-MAG
348
+
349
+ Compared Baselines. Ogbn-mag dataset is a heterogeneous graph consists of 1,939,743 nodes and 21,111,007 edges of different types. For comparison, we choose eight baseline methods from the OGB ogbn-mag leaderboard: R-GCN (Schlichtkrull et al., 2018), SIGN (Frasca et al., 2020), HGT (Hu et al., 2020), R-GSN (Wu et al., 2021), HGConv (Yu et al., 2020a), R-HGNN (Yu et al., 2021), and NARS (Yu et al., 2020b).
350
+
351
+ Adapt GAMLP to Heterogeneous Graphs. In its original design, GAMLP does not support training on heterogeneous graphs. Here we imitate the model design of NARS to adapt GAMLP to heterogeneous graphs.
352
+
353
+ First, we sample subgraphs from the original heterogeneous graphs according to relation types and regard the subgraph as a homogeneous graph although it may have different kinds of nodes and edges. Then, on each subgraph, the propagated features of different steps are generated. The propagated features of the same propagation step across different subgraphs are aggregated using 1-d convolution. After that, aggregated features of different steps are fed into our GAMLP to get the final results. This variant of our GAMLP is called NARS-GAMLP as it mimics the design of NARS.
354
+
355
+ As ogbn-mag dataset only contains node features for “paper” nodes, we here adopt the ComplEx algorithm (Trouillon et al., 2017) to generate features for other nodes.
356
+
357
+ Experiment Results. We report the validation and test accuracy of our proposed GAMLP on the ogbn-mag dataset in Table 9. It can be seen from the results that NARS-GAMLP achieves great performance on the heterogeneous graph ogbn-mag, outperforming the performance of the strongest single model baseline NARS by a large margin of $1 . 6 1 \%$ .
358
+
359
+ ![](images/f1ba10bc33b33c83e75d03d73546e6bd2a8de4e08b977541c38bd2a6524f2523.jpg)
360
+ Figure 5: Test accuracy when the propagation depth increases from 10 to 100.
361
+
362
+ ![](images/d5b642a4acc2caa43e1d152800df9623c7cfe56b5240b4086743fe9f9048d868.jpg)
363
+ Figure 6: The average attention weights of propagated features of different steps on 60 randomly selected nodes from ogbn-products.
364
+
365
+ # B.2 DEEP PROPAGATION IS POSSIBLE
366
+
367
+ Equipped with the learnable node-wise propagation scheme, our GAMLP can still maintain high predictive accuracy even when the propagation depth is over 50. Here, we evaluate the predictive accuracy of our proposed GAMLP(JK) at propagation depth 10, 30, 50, 80, 100 on the PubMed dataset. The performance of JK-Net and SGC are also reported as baselines. The experimental results in Fig. 5 show that even at propagation depth equals 100, the predictive accuracy of our GAMLP(JK) still exceeds $8 0 . 0 \%$ , higher than the predictive accuracy of most baselines in Table 1. At the same time, the predictive accuracy of SGC and JK-Net both drops rapidly when propagation depth increases from 10 to 100.
368
+
369
+ # B.3 INTERPRETABILITY OF THE ATTENTION MECHANISM
370
+
371
+ GAMLP can adaptively and effectively combine multi-scale propagated features for each node. To demonstrate this, Fig. 6 shows the average attention weights of propagated features of GAMLP(JK) according to the number of steps and degrees of input nodes, where the maximum step is 6. In this experiment, we randomly select 20 nodes for each degree range (1-4, 5-8, 9-12) and plot the relative weight based on the maximum value. We get two observations from the heat map: 1) The 1-step and 2-step propagated features are always of great importance, which shows that GAMLP captures the local information as those widely 2-layer methods do; 2) The weights of propagated features with larger steps drop faster as the degree grows, indicating that our attention mechanism could prevent high-degree nodes from including excessive irrelevant nodes, leading to over-smoothing. From the two observations, we conclude that GAMLP can identify the different RF demands of nodes and explicitly weight each propagated feature.
372
+
373
+ Table 10: Overview of the Datasets
374
+
375
+ <table><tr><td>Dataset</td><td>#Nodes</td><td>#Features</td><td>#Edges</td><td>#Classes</td><td>#Train/Val/Test</td><td>Task type</td><td>Description</td></tr><tr><td>Cora</td><td>2,708</td><td>1,433</td><td>5,429</td><td>7</td><td>140/500/1000</td><td>Transductive</td><td>citation network</td></tr><tr><td>Citeseer</td><td>3,327</td><td>3,703</td><td>4,732</td><td>6</td><td>120/500/1000</td><td>Transductive</td><td>citation network</td></tr><tr><td>Pubmed</td><td>19,717</td><td>500</td><td>44,338</td><td>3</td><td>60/500/1000</td><td>Transductive</td><td>citation network</td></tr><tr><td>Amazon Computer</td><td>13,381</td><td>767</td><td>245,778</td><td>10</td><td>200/300/12881</td><td>Transductive</td><td>co-purchase graph</td></tr><tr><td>Amazon Photo</td><td>7,487</td><td>745</td><td>119,043</td><td>8</td><td>160/240/7,087</td><td>Transductive</td><td>co-purchase graph</td></tr><tr><td>Coauthor CS</td><td>18,333</td><td>6,805</td><td>81,894</td><td>15</td><td>300/450/17,583</td><td>Transductive</td><td>co-authorship graph</td></tr><tr><td>Coauthor Physics</td><td>34,493</td><td>8,415</td><td>247,962</td><td>5</td><td>100/150/34,243</td><td>Transductive</td><td>co-authorship graph</td></tr><tr><td>ogbn-products</td><td>2,449,029</td><td>100</td><td>61,859,140</td><td>47</td><td>196k/49k/2204k</td><td>Transductive</td><td>co-purchase graph</td></tr><tr><td>ogbn-papers100M</td><td>111,059,956</td><td>128</td><td>1,615,685,872</td><td>172</td><td>1207k/125k/214k</td><td>Transductive</td><td>citation network</td></tr><tr><td>ogbn-mag</td><td>1,939,743</td><td>128</td><td>21,111,007</td><td>349</td><td>626k/66k/37k</td><td>Transductive</td><td>citation network</td></tr><tr><td>PPI</td><td>56,944</td><td>50</td><td>818,716</td><td>121</td><td>45k/6k/6k</td><td>Inductive</td><td>protein interactions network</td></tr><tr><td>Flickr</td><td>89,250</td><td>500</td><td>899,756</td><td>7</td><td>44k/22k/22k</td><td>Inductive</td><td>image network</td></tr><tr><td>Reddit</td><td>232.965</td><td>602</td><td>11,606,919</td><td>41</td><td>155k/23k/54k</td><td>Inductive</td><td>social network</td></tr></table>
376
+
377
+ Table 11: Ablation study of choices for $\alpha _ { l }$ on the ogbn-products dataset.
378
+ B.4 CHOICES FOR $\alpha _ { l }$ IN THE LAST RESIDUAL CONNECTION
379
+
380
+ <table><tr><td>Choices</td><td>Test Accuracy</td></tr><tr><td>Fixed weight</td><td>82.56±0.43</td></tr><tr><td>Linear-decreasing weight</td><td>82.72±0.93</td></tr><tr><td>Cosine function</td><td>83.59±0.05</td></tr></table>
381
+
382
+ Our first choice for the that GAMLP still enco $\alpha _ { l }$ in the last residual connection module is ters the over-fitting issue on some datas $\begin{array} { r } { \alpha _ { l } = \frac { L - l } { L } } \end{array}$ . However, we find we instead choose $\begin{array} { r } { \alpha _ { l } = \cos ( \frac { \pi l } { 2 L } ) } \end{array}$ to give more penalties to labels at large propagation steps. We provide the performance comparison on the ogbn-products dataset in Table 11. Three weighting schemes for the last residual connection module are tested: "Cosine function" stands for $\begin{array} { r } { \alpha _ { l } = \cos ( \frac { \pi l } { 2 L } ) } \end{array}$ , the one in GAMLP; "Linear-decreasing weight" stands for $\begin{array} { r } { \alpha _ { l } = \frac { L - l } { L } } \end{array}$ ; and "Fixed weight" stands for $\alpha _ { l } = 0 . 7$ . Table 11 shows that the weighting scheme GAMLP adopts, $\begin{array} { r } { \alpha _ { l } = \cos ( \frac { \pi l } { 2 L } ) } \end{array}$ , outperforms the other two options.
383
+
384
+ # C DETAILED EXPERIMENT SETUP
385
+
386
+ # C.1 EXPERIMENT ENVIRONMENT
387
+
388
+ We provide detailed information about the datasets we adopted during the experiment in Table 10. To alleviate the influence of randomness, we repeat each method ten times and report the mean performance and the standard deviations. For the largest ogbn-papers100M dataset, we run each method five times instead. The experiments are conducted on a machine with Intel(R) Xeon(R) Platinum 8255C $\mathrm { P U } @ 2 . 5 0 \mathrm { G H z }$ , and a single Tesla V100 GPU with 32GB GPU memory. The operating system of the machine is Ubuntu 16.04. As for software versions, we use Python 3.6, Pytorch 1.7.1, and CUDA 10.1. The hyper-parameters in each baseline are set according to the original paper if available. Please refer to Appendix C.2 for the detailed hyperparameter settings for our GAMLP.
389
+
390
+ # C.2 DETAILED HYPERPARAMETERS
391
+
392
+ We provide the detailed hyperparameter setting on GAMLP in Table 12, 13 and 14 to help reproduce the results. To reproduce the experimental results of GAMLP, just follow the same hyperparameter setting yet only run the first stage.
393
+
394
+ Table 12: Detailed hyperparameter setting on OGB datasets.
395
+
396
+ <table><tr><td rowspan=1 colspan=1>Datasets</td><td rowspan=1 colspan=1>attention type</td><td rowspan=1 colspan=1>hidden size</td><td rowspan=1 colspan=1>num layer in JK</td><td rowspan=1 colspan=1>num layer</td><td rowspan=1 colspan=1>activation</td></tr><tr><td rowspan=1 colspan=1>ogb-products</td><td rowspan=1 colspan=1>Recursive</td><td rowspan=1 colspan=1>512</td><td rowspan=1 colspan=1>/</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>leakyrelu,a=0.2</td></tr><tr><td rowspan=1 colspan=1>ogb-papers100M</td><td rowspan=1 colspan=1>JK</td><td rowspan=1 colspan=1>1280</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>sigmoid</td></tr><tr><td rowspan=1 colspan=1>ogb-mag</td><td rowspan=1 colspan=1>JK</td><td rowspan=1 colspan=1>512</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>leaky relu,a=0.2</td></tr></table>
397
+
398
+ Table 13: Detailed hyperparameter setting on OGB datasets.
399
+
400
+ <table><tr><td rowspan=1 colspan=1>Datasets</td><td rowspan=1 colspan=1>hops</td><td rowspan=1 colspan=1>hops for label</td><td rowspan=1 colspan=1>input dropout</td><td rowspan=1 colspan=1> attention dropout</td><td rowspan=1 colspan=1>dropout</td></tr><tr><td rowspan=1 colspan=1>ogb-products</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>10</td><td rowspan=1 colspan=1>0.2</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0.5</td></tr><tr><td rowspan=1 colspan=1>ogb-papers100M</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>10</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0.5</td></tr><tr><td rowspan=1 colspan=1>ogb-mag</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>0.1</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>0.5</td></tr></table>
401
+
402
+ Table 14: Detailed hyperparameter setting on OGB datasets.
403
+
404
+ <table><tr><td rowspan=1 colspan=1>Datasets</td><td rowspan=1 colspan=1>beta</td><td rowspan=1 colspan=1>patience</td><td rowspan=1 colspan=1>lr</td><td rowspan=1 colspan=1>batch size</td><td rowspan=1 colspan=1>epochs</td></tr><tr><td rowspan=1 colspan=1>ogb-products</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>300</td><td rowspan=1 colspan=1>0.001</td><td rowspan=1 colspan=1>50000</td><td rowspan=1 colspan=1>400</td></tr><tr><td rowspan=1 colspan=1>ogb-papers100M</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>60</td><td rowspan=1 colspan=1>0.0001</td><td rowspan=1 colspan=1>5000</td><td rowspan=1 colspan=1>400</td></tr><tr><td rowspan=1 colspan=1>ogb-mag</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>0.001</td><td rowspan=1 colspan=1>10000</td><td rowspan=1 colspan=1>400</td></tr></table>
md/dev/2clwrA2tfik/2clwrA2tfik.md ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dataset Distillation using Neural Feature Regression
2
+
3
+ Yongchao Zhou Department of Computer Science University of Toronto yongchao.zhou@mail.utoronto.ca
4
+
5
+ Ehsan Nezhadarya Toronto AI Lab LG Electronics Canada ehsan.nezhadarya@lge.com
6
+
7
+ Jimmy Ba Department of Computer Science University of Toronto jba@cs.toronto.edu
8
+
9
+ # Abstract
10
+
11
+ Dataset distillation aims to learn a small synthetic dataset that preserves most of the information from the original dataset. Dataset distillation can be formulated as a bi-level meta-learning problem where the outer loop optimizes the metadataset and the inner loop trains a model on the distilled data. Meta-gradient computation is one of the key challenges in this formulation, as differentiating through the inner loop learning procedure introduces significant computation and memory costs. In this paper, we address these challenges using neural Feature Regression with Pooling (FRePo), achieving the state-of-the-art performance with an order of magnitude less memory requirement and two orders of magnitude faster training than previous methods. The proposed algorithm is analogous to truncated backpropagation through time with a pool of models to alleviate various types of overfitting in dataset distillation. FRePo significantly outperforms the previous methods on CIFAR100, Tiny ImageNet, and ImageNet-1K. Furthermore, we show that high-quality distilled data can greatly improve various downstream applications, such as continual learning and membership inference defense. Please check out our webpage at https://sites.google.com/view/frepo.
12
+
13
+ # 1 Introduction
14
+
15
+ Knowledge distillation [1] is a technique in deep learning to compress knowledge for easy deployment. Most previous works focus on model distillation [2, 3] where the knowledge acquired by a large teacher model is transferred to a small student model. In contrast, dataset distillation [4, 5] aims to learn a small set of synthetic examples preserving most of the information from a large dataset such that a model trained on it can achieve similar test performance as one trained on the original dataset. Distilled data can accelerate model training and reduce the cost of storing and sharing a dataset. Moreover, its highly condensed and synthetic nature can also benefit various applications, such as continual learning [5–8], neural architecture search [5, 7], and privacy-preserving tasks [9, 10].
16
+
17
+ Dataset distillation was first studied by Maclaurin et al. [11] in the context of gradient-based hyperparameter optimization and subsequently Wang et al. [4] formally proposed dataset distillation as a new task. Dataset distillation can be naturally formulated as a bi-level meta-learning problem. The inner loop optimizes the model parameters on the distilled data (meta-parameters), while the outer loop refines the distilled data with meta-gradient updates.
18
+
19
+ One key challenge in dataset distillation is computing the meta-gradient. Several methods [4, 11–13] compute it by back-propagating through the unrolled computation graph, but they often suffer from huge compute and memory requirement [14], training instability [15, 16], and truncation bias [17]. To avoid unrolled optimization, surrogate objectives are used to derive the meta-gradient, such as gradient matching [5, 7, 18], feature alignment [8, 19], and training trajectory matching [20]. Nevertheless, a surrogate objective may introduce its own bias [19], and thus, may not accurately reflect the true objective. An alternative is using kernel methods, such as Neural Tangent Kernel (NTK) [21], to approximate the inner optimization [22, 23]. However, computing analytical NTK for modern neural network can be extremely expensive [22, 23].
20
+
21
+ ![](images/99c51e47398cb446d8e74bd29e225e4ce9dc4051310f93f7693b478569789644.jpg)
22
+ Figure 1: Example distilled images from $3 2 \mathbf { x } 3 2$ CIFAR100, 64x64 Tiny ImageNet, and $1 2 8 \mathrm { x } 1 2 8$ ImageNet Subset. The images look real and transfer well to different architectures. They can be used for various downstream applications, such as continual learning and membership inference defense.
23
+
24
+ Even with an accurate meta-gradient, dataset distillation still suffers from various types of overfitting. For instance, the distilled data can easily overfit to a particular learning algorithm [4, 13, 20], a certain stage of optimization [13, 19], or a certain network architecture [5, 7, 20, 22, 23]. Meanwhile, the model can also overfit the distilled data during training, which is the most common cause of overfitting when we train on a small dataset. All these kinds of overfitting impose difficulties on the training and general-purpose use of the distilled data.
25
+
26
+ We propose an efficient meta-gradient computation method and a “model pool” to address the overfitting problems. The bottleneck in meta-gradient computation arises due to the complexity of inner optimization, as we need to know how the inner parameters vary with the outer parameters [24]. However, the inner optimization can be pretty simple if we only train the last layer of a neural network to convergence while keeping the feature extractor fixed. In this case, computing the prediction on the real data using the model trained on the distilled data can be expressed as a kernel ridge regression (KRR) with respect to the conjugate kernel [25]. Hence, computing the meta-gradient is simply back-propagating through the kernel and a fixed feature extractor. To alleviate overfitting, we propose to maintain a diverse pool of models instead of periodically training and resetting a single model as in prior work [7, 13, 18]. Intuitively, our algorithm targets the following question: what is the best data to train the linear classifier given the current feature extractor? Due to the diverse feature extractors we use, the distilled data generalize well to a wide range of model distributions.
27
+
28
+ # Summary of Contributions:
29
+
30
+ • We propose an effective method for dataset distillation. Our method, named neural Feature Regression with Pooling (FRePo), achieves state-of-the-art results on various benchmark datasets with a $1 0 0 \mathrm { x }$ reduction in training time and a $1 0 \mathrm { x }$ reduction in GPU memory requirement. Our distilled data looks real (Figure 1) and transfers well to different architectures. We show that FRePo scales well to datasets with high-resolution images or complex label space. We achieve $7 . 5 \%$ top1 accuracy on ImageNet-1K [26] using only one image per class. The same classifier obtains only $1 . 1 \%$ accuracy from a random subset of real images. The previous methods struggle in this task due to large memory and compute requirements. • We demonstrate that high-quality distilled data can significantly improve various downstream applications, such as continual learning and membership inference defense.
31
+
32
+ ![](images/bd356bac9e8a26f60ac46a3e8c2299fdbc56eeb9580bd6cdb628ffbec6e98257.jpg)
33
+ Figure 2: Comparison of FRePo and Unrolled Optimization. $S$ , $X _ { s }$ , $Y _ { s }$ are the distilled dataset, images and labels. $\mathcal { L }$ is the meta-training loss and $\dot { \theta } ^ { ( k ) }$ , $g ^ { ( k ) }$ are the model parameter and gradient at step $k$ . $f ( X )$ is the feature for input $X$ and $K _ { X _ { t } X _ { s } } ^ { \theta }$ is the Gram matrix of $X _ { t }$ and $X _ { s }$ . FRePo is analogous to 1-step TBPTT as it computes the meta-gradient at each step while performing the online model update. However, instead of backpropagating through the inner optimization, FRePo computes the meta-gradient through a kernel and feature extractor.
34
+
35
+ # 2 Method
36
+
37
+ # 2.1 Dataset Distillation as Bi-level Optimization
38
+
39
+ Suppose we have a large labeled dataset $\mathcal { T } = \left\{ \left( \mathbf { x } _ { 1 } , \mathbf { y } _ { 1 } \right) , \dotsc , \left( \mathbf { x } _ { | T | } , \mathbf { y } _ { | T | } \right) \right\}$ with $| \tau |$ image and label\` ˘( pairs. Dataset distillation aims to learn a small synthetic dataset $\mathcal { S } = \left\{ ( \mathbf { x } _ { 1 } , \mathbf { y } _ { 1 } ) , \dotsc , \left( \mathbf { x } _ { | S | } , \mathbf { y } _ { | S | } \right) \right\}$ that preserves most of the information in $\tau$ . We train several neural networks parameterized by $\theta$ on the dataset $s$ and then compute the validation loss $\mathcal { L } ( \mathcal { A } l g \left( \theta , \mathcal { S } \right) , \mathcal { T } )$ on the real dataset $\tau$ , where ${ \mathcal { A } } l g \left( \theta , S \right)$ is the neural network parameters optimized by a learning algorithm $\mathcal { A } g$ with the model initialization $\theta$ and distilled dataset $s$ as its inputs. The validation loss $\mathcal { L } ( \mathcal { A } l g \left( \theta , S \right) , \mathcal { T } )$ is a noisy objective with the stochasticity coming from random model initialization and inner learning algorithm. Thus, we are interested in minimizing the expected value of this loss, which we denote it as $F ( S )$ . We formulate the dataset distillation as the following bi-level optimization problem.
40
+
41
+ $$
42
+ \overbrace { \mathcal { S } ^ { * } : = \mathop { \mathrm { a r g m i n } } _ { \mathcal { S } } F ( \mathcal { S } ) } ^ { o u t e r - l e v e l } , \mathrm { w h e r e } F ( \mathcal { S } ) = \mathbb { E } _ { \theta \sim P _ { \theta } } \biggl [ \mathcal { L } \Bigl ( \overbrace { \mathcal { A } l g \left( \theta , \mathcal { S } \right) } ^ { i n n e r - l e v e l } , \ T \Bigr ) \biggr ] .
43
+ $$
44
+
45
+ In this bi-level setup, the outer loop optimizes the distilled data to minimize $F ( S )$ , while the inner loop trains a neural network using the learning algorithm, $\mathcal { A } g$ , to minimize the training loss on the distilled data $s$ . From the meta-learning perspective, the task is defined by the model initialization $\theta$ , and we want to learn a meta-parameter $s$ that generalizes well to different models sampled from the model distributions $P _ { \theta }$ . During learning, we optimize the meta-parameter $s$ by minimizing the meta-training loss $F ( S )$ . In contrast, at meta-test time, we train a new model from scratch on $s$ and evaluate the trained model on a held-out real dataset. This meta-test performance reflects the quality of the distilled data.
46
+
47
+ # 2.2 Dataset Distillation using Neural Feature Regression with Pooling $\mathbf { ( F R e P 0 ) }$
48
+
49
+ The outer-level problem can be solved using gradient-based methods of the form $\mathcal { S } \gets \mathcal { S } \ – \alpha \nabla _ { \mathcal { S } } F ( \mathcal { S } )$ , where $\alpha$ is the learning rate for the distilled data and $\nabla _ { S } F ( S )$ is the meta-gradient [27]. For a particular model $\theta$ , the meta-gradient can be expressed as $\nabla _ { \mathcal { S } } \hat { \mathcal { L } } \left( \mathcal { A } l g \left( \theta , \mathcal { S } \right) , \mathcal { T } \right)$ . Computing this meta-gradient requires differentiating through inner optimization. If $\mathcal { A } \boldsymbol { { l } } _ { g }$ is an iterative algorithm like gradient descent, then backpropagating through the unrolled computation graph [14] can be a solution. However, this type of unrolled optimization introduces significant computation and memory overhead, as the whole training trajectory needs to be stored in memory (Figure 2(b)).
50
+
51
+ Traditionally, these issues are alleviated with truncated backpropagation through time (TBPTT) [28–30]. Instead of backpropagating through an entire unrolled sequence, TBPTT performs backpropagation for each subsequence separately. It is efficient because its time and memory complexity scale linearly with respect to the truncation steps. However, truncation may yield highly biased gradients that severely impact training. To mitigate this truncation bias [14], we consider training only the top layer of a network to convergence. The key insight is that the data helpful for training the output layer can also help train the whole network. Thus, we decompose the neural network into a feature
52
+
53
+ Require: $\tau$ : a labeled dataset; $\alpha$ : the learning rate for the distilled data nitialization: Initialize a labeled distilled dataset $\boldsymbol { \mathcal { S } } = \left( \boldsymbol { X _ { s } } , \boldsymbol { Y _ { s } } \right)$ .
54
+
55
+ Initialization: Initialize a model pool $\mathcal { M }$ with $m$ models $\left\{ \boldsymbol { \theta } _ { i } \right\} _ { i = 1 } ^ { m }$ randomly initialized from $P _ { \theta }$
56
+
57
+ 1: while not converged do
58
+ 2: Ż Sample a model uniformly from the model pool: $\theta _ { i } \sim \mathcal { M }$ .
59
+ 3: Ż Sample a target batch uniformly from the labeled dataset: $( X _ { t } , Y _ { t } ) \sim \tau$ .
60
+ 4: $\triangleright$ Compute the meta-training loss $\mathcal { L }$ using Eq. 2
61
+ 5: Ż Update the distilled data $s$ $\mathrm { : } ~ X _ { s } \gets X _ { s } - \alpha \nabla _ { X _ { s } } \mathcal { L }$ , and $Y _ { s } \gets Y _ { s } - \alpha \nabla _ { Y _ { s } } \mathcal { L }$
62
+ 6: $\triangleright$ Train the model $\theta _ { i }$ on the current distilled data $s$ for one step.
63
+ 7: $\triangleright$ Reinitialize the model $\theta _ { i } \sim P _ { \theta }$ if $\theta _ { i }$ has been updated more than $K$ steps.
64
+
65
+ 8: end while
66
+
67
+ Output: Learned distilled dataset $\boldsymbol { \mathcal { S } } = \left( \boldsymbol { X _ { s } } , \boldsymbol { Y _ { s } } \right)$
68
+
69
+ extractor and a linear classifier. We fix the feature extractor at each meta-gradient computation and train the linear classifier to convergence before updating $s$ . After that, we adjust the feature extractor by training the whole network on the updated distilled data. We note that similar two-phase procedure has been studied in the context of representation learning [31].
70
+
71
+ Meta-Gradient Computation: If we consider the mean square error loss, then the optimal weights for the linear classifier have a closed-form solution. Moreover, since the feature dimension is typically larger than the number of distilled data, we can use kernel ridge regression (KRR) with a conjugate kernel [25] rather than solving the weights explicitly [12]. The resulting meta-training loss (Eq. 2) is similar to that used in KIP [22, 23], but we use a more flexible kernel rather than NTK.
72
+
73
+ $$
74
+ \mathcal { L } \left( \mathcal { A } l g \left( \theta , \mathcal { S } \right) , \mathcal { T } \right) = \frac { 1 } { 2 } | | Y _ { t } - K _ { X _ { t } X _ { s } } ^ { \theta } ( K _ { X _ { s } X _ { s } } ^ { \theta } + \lambda I ) ^ { - 1 } Y _ { s } | | _ { 2 } ^ { 2 } ,
75
+ $$
76
+
77
+ where $( X _ { t } , Y _ { t } )$ and $( X _ { s } , Y _ { s } )$ are the inputs and labels of the real data $\tau$ and distilled data $s$ respectively. The Gram matrix between real inputs and distilled inputs is denoted as $K _ { X _ { t } X _ { s } } ^ { \theta } \in \mathbb { R } ^ { | T | \times | S | }$ while the Gram matrix between distilled inputs is denoted as $K _ { X _ { s } X _ { s } } ^ { \theta } \in \mathbb { R } ^ { | S | \times | S | }$ . $\lambda$ t scontrols the regularization strength for KRR. Let us denote the neural network feature for a given input $X$ and model parameter $\theta$ as $\mathbf { \bar { \chi } } _ { f ( X , \theta ) } \in \mathbb { R } ^ { N \times d }$ , where $N$ is the number of input and $d$ is the feature dimension 1. The conjugate kernel is defined by the inner product of the neural network features. Thus, the two Gram matrices are computed as follows:
78
+
79
+ $$
80
+ K _ { X _ { t } X _ { s } } ^ { \theta } = f ( X _ { t } , \theta ) f ( X _ { s } , \theta ) ^ { \top } , \quad K _ { X _ { s } X _ { s } } ^ { \theta } = f ( X _ { s } , \theta ) f ( X _ { s } , \theta ) ^ { \top } ,
81
+ $$
82
+
83
+ Now, computing the meta-gradient $\nabla _ { \mathcal { S } } \mathcal { L } \left( \mathcal { A } l g \left( \theta , \mathcal { S } \right) , \mathcal { T } \right)$ is just back-propagating through the conjugate kernel and a fixed feature extractor, which is very efficient and takes even fewer operations than computing the gradient for the network’s weights. Moreover, we decouple the meta-gradient computation from the model online update. Hence, we can train the online model using any optimizer, and the distilled data will be agnostic to the specific learning algorithm choice. Our proposed method is similar to 1-step TBPTT in that we compute the meta-gradient at each step while performing the online model update. Unlike the conventional 1-step TBPTT, we compute the meta-gradient using a KRR output layer to mitigate truncation bias, illustrated in Figure 2(a).
84
+
85
+ Model Pool: As discussed in Section 1, there are various types of overfitting in dataset distillation. Several techniques have been proposed to alleviate such problem, such as random initialization [4], periodic reset [13, 5, 7], and dynamic bi-level optimization [19]. These techniques share the same underlying principle: the model diversity matters. Thus, we propose to maintain a “model pool” filled with diverse set of parameters obtained from different number of training steps and different random initializations. Unlike the previous methods that periodically training and resetting a single model, FRePo randomly sample a model from the pool at each meta-gradient computation and update it using the current distilled data. However, if a model has been updated more than $K$ steps, we reinitialize it with a new random seed. From the meta-learning perspective, we maintain a diverse set of meta-tasks to sample from and avoid sampling very similar tasks at each consecutive gradient computation to avoid overfitting to a particular setup.
86
+
87
+ Pool Diversity: We can increase the regularization strength by increasing the diversity of the model pool by setting a larger $K$ , using data augmentation when training the model on the distilled data, or using models with different architectures. To keep our method simple, we use the same architecture for all models in the pool and do not use any data augmentation when training the model on the distilled data. Thus, our model pool only contains models with different initialization, at different optimization stages, and trained at different time-step of the distilled data.
88
+
89
+ # 3 Related Work
90
+
91
+ Unrolling in Bi-Level Optimization: One way to compute the meta-gradient is to differentiate through the unrolled inner optimization [4, 11–13]. However, this approach inherits several difficulties of the unrolled optimization, such as: 1) large computation and memory cost [14]; 2) truncation bias with short unrolls [17]; 3) exploding or vanishing gradients with long unrolls [15]; 4) chaotic and poorly conditioned loss landscapes with long unrolls [16]. In contrast, our method considers approximating the inner optimization with kernel ridge regression instead of unrolled optimization.
92
+
93
+ Surrogate Objective: To avoid unrolled optimization, several works turn to surrogate objectives. DC [5], DSA [7], and DCC [18] formulate the dataset distillation as a gradient matching problem between the gradients of neural network weights computed on the real and distilled data. In contrast, DM [8] and CAFE [19] consider the feature distribution alignment between the real and distilled data. Moreover, MTT [20] shows that knowledge from many expert training trajectories can be distilled to a dataset by using a training trajectory matching objective. Nevertheless, surrogate objectives may introduce new biases and thus, may not accurately reflect the true objective. For example, gradient matching approaches [5, 7, 18] only focus on short-range behavior and may easily overfit to a biased set of samples that produce dominant gradients [19, 20].
94
+
95
+ Closed-form Approximation: An alternative way to circumvent unrolled optimization is to find a closed-form approximation to the inner optimization. Based on the correspondence between infinitelywide neural networks and kernel methods, KIP [22, 23] approximates the inner optimization with NTK [21]. In this case, the meta-gradient can be computed by back-propagating through the NTK. However, computing NTK for modern neural networks is extremely expensive. Thus, using NTK for dataset distillation requires thousands of GPU hours and sophisticated implementation of the distributed kernel computation framework [23]. Similar to ours, Bohdal et al. [12] also decomposes the neural network as a feature extractor and a linear classifier. However, they only learn the label and explicitly solve for the optimal classifier weights rather than perform KRR.
96
+
97
+ # 4 Dataset Distillation
98
+
99
+ # 4.1 Implementation Details
100
+
101
+ We compare our method to four state-of-the-art dataset distillation methods [7, 8, 20, 23] on various benchmark datasets [26, 32–37]. We train the distilled data using Algorithm 1 with the same set of hyperparameters for all experiments except stated otherwise. Unlike prior work [7, 8, 20], we do not apply data augmentation during training. However, we apply the same data augmentation [7, 20] during evaluation for a fair comparison. We preprocess the data in a similar way as in previous works [20, 23] but use a wider architecture than previous works [7, 8, 20] because the KRR component does not behave well when the feature dimension is low, resulting in a significant performance drop for our method. Results on the original architecture are included in Appendix ??. We evaluate each distilled data using five random neural networks and report the mean and standard deviation. For the baseline method, we report the best of the reported value in the original paper and our reproducing results.
102
+
103
+ For the sake of brevity, we provide implementation details about data preprocessing, distilled data initialization, and hyperparameters in Appendix ?? and various ablation studies regarding the model pool, batch size, distilled data initialization, label learning, and model architectures in Appendix ??. More distilled image visualizations can be found in Appendix ??. Our code is available at https://github.com/yongchao97/FRePo.
104
+
105
+ Table 1: Test accuracies of models trained on the distilled data from scratch. : denotes performance better than the original reported performance. KRR preformance is shown in bracket. FRePo performs extremely well for one image per class setting on CIFAR100, Tiny ImageNet and CUB-200.
106
+
107
+ <table><tr><td></td><td>Img/Cls</td><td>DSA [7]</td><td>DM[8]</td><td>KIP [23]</td><td>MTT [20]</td><td>FRePo</td></tr><tr><td rowspan="3">MNIST</td><td>1</td><td>88.7±0.6</td><td>89.9 ± 0.8†</td><td>90.1± 0.1</td><td>91.4 ± 0.9†</td><td>93.0 ± 0.4 (92.6 ± 0.4)</td></tr><tr><td>10</td><td>97.9 ±0.1†</td><td>97.6 ± 0.1†</td><td>97.5 ± 0.0</td><td>97.3 ± 0.1+</td><td>98.6 ± 0.1 (98.6 ± 0.1)</td></tr><tr><td>50</td><td>99.2 ± 0.1</td><td>98.6 ± 0.1</td><td>98.3 ± 0.1</td><td>98.5±0.1+</td><td>99.2 ± 0.0 (99.2± 0.1)</td></tr><tr><td rowspan="3">F-MNIST</td><td>1</td><td>70.6 ± 0.6</td><td>71.5 ± 0.5†</td><td>73.5± 0.5</td><td>75.1 ± 0.9†</td><td>75.6 ± 0.3 (77.1 ± 0.2)</td></tr><tr><td>10</td><td>84.8±0.3t</td><td>83.6±0.2t</td><td>86.8±0.1</td><td>87.2± 0.3+</td><td>86.2 ± 0.2 (86.8 ± 0.1)</td></tr><tr><td>50</td><td>88.8±0.2t</td><td>88.2±0.1†</td><td>88.0±0.1</td><td>88.3± 0.1+</td><td>89.6 ± 0.1 (89.9 ± 0.1)</td></tr><tr><td rowspan="3">CIFAR10</td><td>1</td><td>36.7± 0.8†</td><td>31.0 ± 0.6†</td><td>49.9 ± 0.2</td><td>46.3 ± 0.8</td><td>46.8 ± 0.7 (47.9 ± 0.6)</td></tr><tr><td>10</td><td>53.2 ± 0.8†</td><td>49.2 ± 0.8†</td><td>62.7± 0.3</td><td>65.3 ± 0.7</td><td>65.5 ± 0.4 (68.0 ± 0.2)</td></tr><tr><td>50</td><td>66.8± 0.4†</td><td>63.7±0.5t</td><td>68.6± 0.2</td><td>71.6 ± 0.2</td><td>71.7 ± 0.2 (74.4 ± 0.1)</td></tr><tr><td rowspan="3">CIFAR100</td><td>1</td><td>16.8± 0.2†</td><td>12.2 ± 0.4†</td><td>15.7 ± 0.2</td><td>24.3 ± 0.3</td><td>28.7 ± 0.1 (32.3 ± 0.1)</td></tr><tr><td>10</td><td>32.3 ±0.3</td><td>29.7 ±0.3</td><td>28.3 ± 0.1</td><td>40.1 ± 0.4</td><td>42.5 ± 0.2 (44.9 ± 0.2)</td></tr><tr><td>50</td><td>42.8± 0.4</td><td>43.6 ± 0.4</td><td>1</td><td>47.7 ± 0.2</td><td>44.3 ± 0.2 (43.0 ± 0.3)</td></tr><tr><td rowspan="2">T-ImageNet</td><td>1</td><td>6.6± 0.2t</td><td>3.9± 0.2</td><td></td><td>8.8 ±0.3</td><td>15.4 ± 0.3 (19.1 ± 0.3)</td></tr><tr><td>10</td><td>一</td><td>12.9 ± 0.4</td><td></td><td>23.2 ± 0.2</td><td>25.4 ± 0.2 (26.5± 0.1)</td></tr><tr><td rowspan="2">CUB-200</td><td>1</td><td>1.3 ± 0.1†</td><td>1.6 ± 0.1†</td><td></td><td>2.2± 0.1†</td><td>12.4 ± 0.2 (13.7 ± 0.2)</td></tr><tr><td>10</td><td>4.5 ± 0.3†</td><td>4.4 ± 0.2†</td><td></td><td>1</td><td>16.8 ± 0.1 (16.1 ± 0.3)</td></tr></table>
108
+
109
+ ![](images/f1494e6fda90eb5674ceeec703ad75133081347b4f6471179e08a6c207b5ecd8.jpg)
110
+ Figure 3: (a,b) Training efficiency comparison when learning $1 \mathrm { I m g / C l s }$ on CIFAR100. (c,d) Time per iteration and peak memory usage as we increase the model size. FRePo is significantly more efficient than the previous methods, almost two orders of magnitude faster than the second-best method (i.e., MTT), with only 1/10 of the GPU memory requirement.
111
+
112
+ # 4.2 Standard Benchmarks
113
+
114
+ Distillation Performance: We first evaluate our method on six standard benchmark datasets. We learn 1, 10, and 50 images per class for datasets with only ten classes, while we learn 1 and 10 images per class for CIFAR100 [34] with 100 classes, Tiny ImageNet [35] with 200 classes, and CUB-200 [37] with 200 fine-grained classes. As shown in Table in 1, we achieve the state-of-the-art performance in most settings despite the hyperparameter may be suboptimal. Our method performs exceptionally well on datasets with a complex label space when learning few images per class. For example, we improve the CIFAR100, Tiny ImageNet, and CUB-200 in one image per class setting from $2 4 . 3 \%$ , $8 . 8 \%$ , and $2 . 2 \%$ to $2 8 . 7 \%$ , $1 5 . 4 \%$ , and $1 2 . 4 \%$ , respectively. Figure 4 shows that our distilled images look real and natural though we do not directly optimize for this objective. We observe a strong correlation between the test accuracy and image quality: the better the image quality, the higher the test accuracy. Our results suggest that a highly condensed dataset does not need to be very different from the real dataset as it may just reflect the most common pattern in a dataset. We also report the KRR predictor’s test accuracy using the feature extractor trained on the distilled data. When the dataset is as simple as MNIST [32], the KRR predictor achieves similar performance as the neural network predictor. In contrast, for more complex datasets, the KRR predictor consistently outperforms the neural network predictor, with the most significant gap being $3 . 7 \%$ for Tiny ImageNet in the one image per class setting.
115
+
116
+ Table 2: Cross-architecture transfer performance on CIFAR10 with $1 0 \mathrm { I m g / C l s }$ . Despite being trained for a specific architecture, our distilled data transfer well to various architectures unseen during training. Conv is the default evaluation model used for each method. NN, DN, IN, and BN stand for no normalization, default normalization, Instance Normalization, Batch Normalization respectively.
117
+
118
+ <table><tr><td rowspan="2"></td><td rowspan="2">Train Arch</td><td colspan="6">Evaluation Architecture</td></tr><tr><td>Conv</td><td>Conv-NN</td><td>ResNet-DN</td><td>ResNet-BN</td><td>VGG-BN</td><td>AlexNet</td></tr><tr><td>DSA [7]</td><td>Conv-IN</td><td>53.2 ± 0.8</td><td>36.4 ± 1.5</td><td>42.1 ± 0.7</td><td>34.1 ± 1.4</td><td>46.3 ± 1.3</td><td>34.0 ± 2.3</td></tr><tr><td>DM[8]</td><td>Conv-IN</td><td>49.2 ± 0.8</td><td>35.2 ± 0.5</td><td>36.8 ± 1.2</td><td>35.5 ± 1.3</td><td>41.2 ± 1.8</td><td>34.9 ± 1.1</td></tr><tr><td>MTT[20]</td><td>Conv-IN</td><td>64.4 ± 0.9</td><td>41.6 ± 1.3</td><td>49.2 ± 1.1</td><td>42.9 ± 1.5</td><td>46.6 ± 2.0</td><td>34.2 ± 2.6</td></tr><tr><td>KIP [23]</td><td>Conv-NTK</td><td>62.7 ± 0.3</td><td>58.2 ±0.4</td><td>49.0 ± 1.2</td><td>45.8 ± 1.4</td><td>30.1 ± 1.5</td><td>57.2 ± 0.4</td></tr><tr><td>FRePo</td><td>Conv-BN</td><td>65.5 ± 0.4</td><td>65.5 ± 0.4</td><td>58.1 ± 0.6</td><td>57.7 ± 0.7</td><td>59.4 ± 0.7</td><td>61.9 ± 0.7</td></tr></table>
119
+
120
+ ![](images/06d156480cb24f7de4d97dc51031b5fb9e76281f33da496484aeb238e841000d.jpg)
121
+ Figure 4: (a,b,c) Distilled 1 img/cls from CIFAR100 using FRePo, MTT, and DSA. High quality images also produce high test accuracy. (d) Three categories of learned labels. (Top) High confidence, large margin; (Middle) High confidence, small margin; (Bottom) Low confidence, small margin.
122
+
123
+ Label Learning: A similar trend can also be observed for label learning. When the dataset is simple and has only a few classes, label learning may not be necessary. However, it becomes crucial for complex datasets with many labels, such as CIFAR100 and Tiny-ImageNet (See more details in Appendix ??). Similar to the teacher label in the knowledge distillation [1], we observe that the distilled label also encodes the class similarity. We identify three typical cases in Figure 4d. The first group consists of highly confident labels with a much higher value for one class than other classes (large margin), such as sunflower, bicycle, and chair. In contrast, the distilled labels in the second group are confident but may get confused with some closely-related classes (small margin). For instance, the learned label for "girl" has almost equally high values for the girl, woman, man, boy, and baby, suggesting that these classes are very similar and may be difficult for the model to distinguish them apart. The last group contains distilled labels with low values for all classes, such as bear, beaver, and squirrel. It is often hard for humans to recognize the distilled images in such a group, suggesting that they may be the challenging classes in a dataset.
124
+
125
+ Training Cost Analysis: Figure 3a, 3b shows that our method is significantly more time-efficient than the previous methods. When learning one image per class on CIFAR100, FRePo reaches a similar test accuracy $( 2 3 . 4 \% )$ to the second-best method $( 2 4 . 0 \% )$ in 38 seconds, compared to 3805 seconds for MTT, which is roughly two orders of magnitude faster. Moreover, FRePo achieves $92 \%$ of its final test accuracy ( $2 6 . 4 \%$ out of $2 8 . 7 \%$ ) in only 385 seconds. As shown in Figure 3c, our algorithm takes much less time to perform one gradient step on the distilled data. Thus, we can perform more gradient steps in a fixed time. Furthermore, Figure 3d suggests that our algorithm has much less GPU memory requirement. Therefore, we can potentially use a much larger and more complex model to take advantage of the advancement in neural network architecture.
126
+
127
+ Cross-Architecture Generalization: One desired property of our distilled data is that it generalizes well to architecture it has not seen during the training. Similar to previous works [5, 20], we evaluate the distilled data from CIFAR10 on a wide range of architectures which it has not seen during training, including AlexNet [38], VGG [39], and ResNet [40]. Table 2 shows that our method outperforms previous methods on all unseen architectures. Instance Normalization (IN) [41], as the vital ingredient in several methods (DSA, DM, MTT), seems to hurt the cross-architecture transfer. The performance degrades a lot when no normalization (NN) is applied (Conv-NN, AlexNet) or using a different normalization, like Batch Normalization (BN) [42]. It suggests that the distilled data generated by those methods encode the inductive bias of a particular training architecture. In contrast, our distilled data generalize well to various architectures, including those without normalization (Conv-NN, AlexNet). Note that Figure 1, 4 also indicate that our distilled data encode less architectural bias as the distilled images look natural and authentic. A simple idea to further alleviate the overfitting of a particular architecture is to include more architectures in the model pool. However, the training may not be stable as the meta-gradient computed by different architectures can be very different.
128
+
129
+ Table 3: Distillation performance on higher resolution (128x128) dataset (i.e. ImageNette, ImageWoof) and medium resolution (64x64) dataset with a complex label space (i.e. ImageNet-1K). FRePo scales to high-resolution images and learns the discriminate feature of complex datasets.
130
+
131
+ <table><tr><td></td><td colspan="2">ImageNette (128x128)</td><td colspan="2">ImageWoof (128x128)</td><td colspan="2">ImageNet (64x64)</td></tr><tr><td>Img/Cls</td><td>1</td><td>10</td><td>1</td><td>10</td><td>1</td><td>2</td></tr><tr><td>Random Subset</td><td>23.5± 4.8</td><td>47.7 ± 2.4</td><td>14.2 ± 0.9</td><td>27.0± 1.9</td><td>1.1 ± 0.1</td><td>1.4 ± 0.1</td></tr><tr><td>MTT[20]</td><td>47.7± 0.9</td><td>63.0 ± 1.3</td><td>28.6 ± 0.8</td><td>35.8 ± 1.8</td><td>1</td><td>1</td></tr><tr><td>FRePo</td><td>48.1 ± 0.7</td><td>66.5 ± 0.8</td><td>29.7 ± 0.6</td><td>42.2 ± 0.9</td><td>7.5 ± 0.3</td><td>9.7 ± 0.2</td></tr></table>
132
+
133
+ # 4.3 ImageNet
134
+
135
+ High Resolution ImageNet Subset To understand how well our method performs on high-resolution images, we evaluate it on ImageNette and ImageWoof datasets [36] with a resolution of 128x128. We learn 1 and 10 images per class on both datasets and report the performance in Table 3 and visualize some distilled images in Figure 1. As shown in Table 3, we outperform MTT on all settings and achieve much better performance when we distill ten images per class on a more difficult dataset ImageWoof. It suggests that our distilled data is better at capturing the discriminative features for each class. Figure 1 shows that our distilled images look real and capture the distinguishable feature of different classes. For the easy dataset (i.e., ImageNette), all images have clear different structures, while for ImageWoof, the texture of each dog seems to be crucial.
136
+
137
+ Resized ImageNet-1K: We also evaluate our method on a resized version of ILSVRC2012 [26] with a resolution of 64x64 to see how it performs on a complex label space. Surprisingly, we can achieve $7 . 5 \%$ and $9 . 7 \%$ Top1 accuracy using only 1k and $2 \mathrm { k }$ training examples, compared to $1 . 1 \%$ and $1 . 4 \%$ using an equally-sized real subset.
138
+
139
+ # 5 Application
140
+
141
+ # 5.1 Continual Learning
142
+
143
+ Continual learning (CL) [43] aims to address the catastrophic forgetting problem [43–45] when a model learns sequentially from a stream of tasks. A commonly used strategy to recall past knowledge is based on a replay buffer, which stores representative samples from previous tasks [46–49]. Since sample selection is an important component of constructing an effective buffer [48–51], we believe distilled data can be a key ingredient for a continual learning algorithm due to its highly condensed nature. Several works [6–8, 52] have successfully applied the dataset distillation to the continual learning scenario. Our work shows that we can achieve much better results by using a better dataset distillation technique.
144
+
145
+ We follow Zhao and Bilen [8] that sets up the baseline based on GDumb [49] which greedily stores class-balanced training examples in memory and train model from scratch on the latest memory only. In that case, the continual learning performance only depends on the quality of the replay buffer. We perform 5 and 10 step class-incremental learning [53] on CIFAR100 with an increasing buffer size of 20 images per class. Specifically, we distill 400 and 200 images at each step and put them into the replay buffer. We follow the same class split as Zhao and Bilen [8] and compare our method to random [49], herding [54, 55], DSA [7], and DM [8]. We use the default data preprocessing and default model for each method in this experiment as we find it gives the best performance for each method. We use the test accuracy on all observed classes as the performance measure [8, 48].
146
+
147
+ Table 4: AUC of five attackers on models trained on the real and distilled MNIST data. The model trained on the real data is vulnerable to MIAs, while the model trained on the distilled data is robust to MIAs. Training on distilled data allows privacy preservation while retaining model performance.
148
+
149
+ <table><tr><td rowspan="2"></td><td rowspan="2">Test Acc (%)</td><td colspan="5">Attack AUC</td></tr><tr><td>Threshold</td><td>LR</td><td>MLP</td><td>RF</td><td>KNN</td></tr><tr><td>Real</td><td>99.2 ± 0.1</td><td>0.99 ± 0.01</td><td>0.99 ± 0.00</td><td>1.00 ±0.00</td><td>1.00 ± 0.00</td><td>0.97 ±0.00</td></tr><tr><td>Subset</td><td>96.8± 0.2</td><td>0.52 ±0.00</td><td>0.50 ± 0.01</td><td>0.53 ± 0.01</td><td>0.55 ± 0.00</td><td>0.54 ±0.00</td></tr><tr><td>DSA</td><td>98.5 ± 0.1</td><td>0.50 ± 0.00</td><td>0.51 ± 0.00</td><td>0.54 ± 0.00</td><td>0.54 ± 0.01</td><td>0.54 ± 0.01</td></tr><tr><td>DM</td><td>98.3 ± 0.0</td><td>0.50 ± 0.00</td><td>0.51 ± 0.01</td><td>0.54 ± 0.01</td><td>0.54 ± 0.01</td><td>0.53 ± 0.01</td></tr><tr><td>FRePo</td><td>98.5± 0.1</td><td>0.52 ±0.00</td><td>0.51 ± 0.00</td><td>0.53 ± 0.01</td><td>0.52 ± 0.01</td><td>0.51 ± 0.01</td></tr></table>
150
+
151
+ ![](images/3425d57f4bfa2229b9a55a067323e25dd62e8fcc52fb803fdd882c3fcc7566d9.jpg)
152
+ Figure 5: (a,b) Multi-class accuracies across all classes observed up to a certain time point. We perform significantly better than other methods in both 5 and 10 step class-incremental continual learning. (c,d) Test accuracy and attack AUC as we increase the number of training steps. AUC keeps increasing when training a model on the real data for more steps. In contrast, AUC keeps low when training on distilled data.
153
+
154
+ Figure 5 shows that our method performs significantly better than all previous methods. The final test accuracy for all classes for our method (FRePo) and the second-best method (DM) are $4 1 . 6 \%$ , $3 3 . 9 \%$ in 5-step learning, and $3 8 . 0 \%$ , $3 4 . 0 \%$ in 10-step learning. However, we notice that for FRePo, distilling 2000 images in a continual learning setup achieves a similar test accuracy $( 4 1 . 6 \% )$ as distilling only 1000 images from the whole dataset $( 4 1 . 3 \%$ from Table 1). In addition, performance drops as we perform more steps. It suggests that FRePo considers all available classes to derive the most condensed dataset. Splitting the data into multiple groups and performing independent distillation may generate redundant information or fail to capture the distinguishable features.
155
+
156
+ # 5.2 Membership Inference Defense
157
+
158
+ Membership inference attacks (MIA) aim to infer whether a given data point has been used to train the model or not [56–58]. Ideally, we want a model to learn from the data but not memorize it to preserve privacy. However, deep neural networks are well-known for their ability to memorize all the training examples, even on large and randomly labeled datasets [59]. Several methods have been proposed to defend against such attacks by either modifying the training procedure [60] or changing the inference workflow [61]. This section shows that the distilled data contain little information regarding sample presence in the original dataset. Thus, instead of training on the original datasets, training on distilled data allows privacy preservation while retaining model performance.
159
+
160
+ We consider three distilled data generated by DSA [7], DM [8] and FRePo. We perform five popular "black box" MIA provided by Tensorflow Privacy [62] on models trained on the real data or the data distilled from it. The attack methods include a threshold attack and four model-based attacks using logistic regression (LR), multi-layer perceptron (MLP), random forest (RF) and K-nearest neighbor (KNN). The inputs to those attack methods are ground-truth labels, model predictions, and losses. To measure the privacy vulnerability of the trained model, we compute the area under the ROC curve (AUC) of an attack classifier. Following prior work, [56, 63], we keep a balanced set of training examples (member) and test examples (non-member) with 10K each to maximize the uncertainty of MIA. Thus, the random guessing strategy results in a $50 \%$ MIA accuracy. We conduct experiments on MNIST and FashionMNIST with a distillation size of 500. For space reasons, we provide more implementation details and results in appendix.
161
+
162
+ As shown in Table 4, all models trained on the distilled data preserve privacy as their attack AUCs are closed to random guessing. However, we observe a small drop in test accuracy compared to the model trained on the full dataset, which is expected as we only distill 500 examples instead of 10,000 examples. Compared to the model trained on an equally sized subset of the original data, the model trained on distilled data results in much better test performance. Figure 5c, 5d demonstrate the trade-off between test accuracy and attack effectiveness as measured by ROC AUC. It shows that early stopping can be an effective technique to preserve privacy. However, we will still be under high MIA risk if we perform early stopping by monitoring the validation loss. In contrast, training a model on the distilled data does not have this problem as the attack AUCs keep at a very low level regardless of training steps.
163
+
164
+ # 6 Conclusion
165
+
166
+ We propose neural Feature Regression with Pooling (FRePo) to overcome two challenges in dataset distillation: meta-gradient computation and various types of overfitting in dataset distillation. We obtain state-of-the-art performance on various datasets with a $1 0 0 \mathrm { x }$ reduction in training time and a 10x reduction in GPU memory requirement. The distilled data generated by FRePo looks real and natural and generalizes well to a wide range of architectures. Furthermore, we demonstrate two applications that take advantage of the high-quality distilled data, namely, continual learning and membership inference defense.
167
+
168
+ Broader Impact “Synthetic data”, in the broader sense of artificial data created by generative models, can help researchers understand how an otherwise opaque learning machine “sees” the world. There have been concerns regarding the risk of fake data. This paper explores a new research direction in generating synthetic data only for downstream classification tasks. We believe this work can provide additional interpretability and potentially address the common concerns in machine learning regarding training data privacy.
169
+
170
+ # Acknowledgments and Disclosure of Funding
171
+
172
+ We would like to thank Harris Chan, Andrew Jung, Michael Zhang, Philip Fradkin, Denny Wu, Chong Shao, Leo Lee, Alice Gao, Keiran Paster, and Lazar Atanackovic for their valuable feedback. Jimmy Ba was supported by NSERC Grant [2020-06904], CIFAR AI Chairs program, Google Research Scholar Program and Amazon Research Award. This project was supported by LG Electronics Canada. Resources used in preparing this research were provided, in part, by the Province of Ontario, the Government of Canada through CIFAR, and companies sponsoring the Vector Institute for Artificial Intelligence.
173
+
174
+ # References
175
+
176
+ [1] Geoffrey E. Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. CoRR, abs/1503.02531, 2015. URL http://arxiv.org/abs/1503.02531.
177
+ [2] Takashi Fukuda, Masayuki Suzuki, Gakuto Kurata, Samuel Thomas, Jia Cui, and Bhuvana Ramabhadran. Efficient knowledge distillation from an ensemble of teachers. In Francisco Lacerda, editor, Interspeech 2017, 18th Annual Conference of the International Speech Communication Association, Stockholm, Sweden, August 20-24, 2017, pages 3697–3701. ISCA, 2017. URL http://www.isca-speech.org/archive/Interspeech_2017/abstracts/0614.html.
178
+ [3] Antonio Polino, Razvan Pascanu, and Dan Alistarh. Model compression via distillation and quantization. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018. URL https://openreview.net/forum?id $\cdot ^ { = }$ S1XolQbRW.
179
+ [4] Tongzhou Wang, Jun-Yan Zhu, Antonio Torralba, and Alexei A. Efros. Dataset distillation. CoRR, abs/1811.10959, 2018. URL http://arxiv.org/abs/1811.10959.
180
+ [5] Bo Zhao, Konda Reddy Mopuri, and Hakan Bilen. Dataset condensation with gradient matching. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event,
181
+
182
+ Austria, May 3-7, 2021. OpenReview.net, 2021. URL https://openreview.net/forum? id=mSAKhLYLSsl.
183
+
184
+ [6] Andrea Rosasco, Antonio Carta, Andrea Cossu, Vincenzo Lomonaco, and Davide Bacciu. Distilled replay: Overcoming forgetting through synthetic samples. CoRR, abs/2103.15851, 2021. URL https://arxiv.org/abs/2103.15851.
185
+
186
+ [7] Bo Zhao and Hakan Bilen. Dataset condensation with differentiable siamese augmentation. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, volume 139 of Proceedings of Machine Learning Research, pages 12674–12685. PMLR, 2021. URL http://proceedings. mlr.press/v139/zhao21a.html.
187
+
188
+ [8] Bo Zhao and Hakan Bilen. Dataset condensation with distribution matching. CoRR, abs/2110.04181, 2021. URL https://arxiv.org/abs/2110.04181.
189
+
190
+ [9] Guang Li, Ren Togo, Takahiro Ogawa, and Miki Haseyama. Soft-label anonymous gastric x-ray image distillation. CoRR, abs/2104.02857, 2021. URL https://arxiv.org/abs/2104. 02857.
191
+
192
+ [10] Jack Goetz and Ambuj Tewari. Federated learning via synthetic data. CoRR, abs/2008.04489, 2020. URL https://arxiv.org/abs/2008.04489.
193
+
194
+ [11] Dougal Maclaurin, David Duvenaud, and Ryan P. Adams. Gradient-based hyperparameter optimization through reversible learning. In Francis R. Bach and David M. Blei, editors, Proceedings of the 32nd International Conference on Machine Learning, ICML 2015, Lille, France, 6-11 July 2015, volume 37 of JMLR Workshop and Conference Proceedings, pages 2113– 2122. JMLR.org, 2015. URL http://proceedings.mlr.press/v37/maclaurin15.html.
195
+
196
+ [12] Ondrej Bohdal, Yongxin Yang, and Timothy M. Hospedales. Flexible dataset distillation: Learn labels instead of images. CoRR, abs/2006.08572, 2020. URL https://arxiv.org/abs/ 2006.08572.
197
+
198
+ [13] Ilia Sucholutsky and Matthias Schonlau. Improving dataset distillation. CoRR, abs/1910.02551, 2019. URL http://arxiv.org/abs/1910.02551.
199
+
200
+ [14] Paul Vicol, Luke Metz, and Jascha Sohl-Dickstein. Unbiased gradient estimation in unrolled computation graphs with persistent evolution strategies. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, volume 139 of Proceedings of Machine Learning Research, pages 10553–10563. PMLR, 2021. URL http://proceedings.mlr.press/v139/ vicol21a.html.
201
+
202
+ [15] Razvan Pascanu, Tomás Mikolov, and Yoshua Bengio. On the difficulty of training recurrent neural networks. In Proceedings of the 30th International Conference on Machine Learning, ICML 2013, Atlanta, GA, USA, 16-21 June 2013, volume 28 of JMLR Workshop and Conference Proceedings, pages 1310–1318. JMLR.org, 2013. URL http://proceedings.mlr.press/ v28/pascanu13.html.
203
+
204
+ [16] Luke Metz, Niru Maheswaranathan, Jeremy Nixon, C. Daniel Freeman, and Jascha SohlDickstein. Understanding and correcting pathologies in the training of learned optimizers. In Kamalika Chaudhuri and Ruslan Salakhutdinov, editors, Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pages 4556–4565. PMLR, 2019. URL http://proceedings.mlr.press/v97/metz19a.html.
205
+
206
+ [17] Yuhuai Wu, Mengye Ren, Renjie Liao, and Roger B. Grosse. Understanding short-horizon bias in stochastic meta-optimization. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018. URL https://openreview.net/forum?id=H1MczcgR-.
207
+
208
+ [18] Saehyung Lee, Sanghyuk Chun, Sangwon Jung, Sangdoo Yun, and Sungroh Yoon. Dataset condensation with contrastive signals. CoRR, abs/2202.02916, 2022. URL https://arxiv. org/abs/2202.02916.
209
+
210
+ [19] Kai Wang, Bo Zhao, Xiangyu Peng, Zheng Zhu, Shuo Yang, Shuo Wang, Guan Huang, Hakan Bilen, Xinchao Wang, and Yang You. CAFE: learning to condense dataset by aligning features. CoRR, abs/2203.01531, 2022. doi: 10.48550/arXiv.2203.01531. URL https: //doi.org/10.48550/arXiv.2203.01531.
211
+
212
+ [20] George Cazenavette, Tongzhou Wang, Antonio Torralba, Alexei A. Efros, and Jun-Yan Zhu. Dataset distillation by matching training trajectories. CoRR, abs/2203.11932, 2022. doi: 10.48550/arXiv.2203.11932. URL https://doi.org/10.48550/arXiv.2203.11932.
213
+
214
+ [21] Jaehoon Lee, Lechao Xiao, Samuel S. Schoenholz, Yasaman Bahri, Roman Novak, Jascha Sohl-Dickstein, and Jeffrey Pennington. Wide neural networks of any depth evolve as linear models under gradient descent. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alché-Buc, Emily B. Fox, and Roman Garnett, editors, Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 8570–8581, 2019. URL https://proceedings.neurips.cc/paper/2019/hash/ 0d1a9651497a38d8b1c3871c84528bd4-Abstract.html.
215
+
216
+ [22] Timothy Nguyen, Zhourong Chen, and Jaehoon Lee. Dataset meta-learning from kernel ridgeregression. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. URL https://openreview.net/ forum?id $= 1$ -PrrQrK0QR.
217
+
218
+ [23] Timothy Nguyen, Roman Novak, Lechao Xiao, and Jaehoon Lee. Dataset distillation with infinitely wide convolutional networks. In Marc’Aurelio Ranzato, Alina Beygelzimer, Yann N. Dauphin, Percy Liang, and Jennifer Wortman Vaughan, editors, Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, pages 5186–5198, 2021. URL https://proceedings.neurips.cc/paper/2021/hash/ 299a23a2291e2126b91d54f3601ec162-Abstract.html.
219
+
220
+ [24] Jonathan Lorraine, Paul Vicol, and David Duvenaud. Optimizing millions of hyperparameters by implicit differentiation. In Silvia Chiappa and Roberto Calandra, editors, The 23rd International Conference on Artificial Intelligence and Statistics, AISTATS 2020, 26-28 August 2020, Online [Palermo, Sicily, Italy], volume 108 of Proceedings of Machine Learning Research, pages 1540– 1552. PMLR, 2020. URL http://proceedings.mlr.press/v108/lorraine20a.html.
221
+
222
+ [25] Radford M. Neal. Bayesian learning for neural networks. 1995.
223
+
224
+ [26] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115(3):211–252, 2015. doi: 10.1007/s11263-015-0816-y.
225
+
226
+ [27] Aravind Rajeswaran, Chelsea Finn, Sham M. Kakade, and Sergey Levine. Meta-learning with implicit gradients. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alché-Buc, Emily B. Fox, and Roman Garnett, editors, Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 113–124, 2019. URL https://proceedings.neurips.cc/paper/2019/hash/ 072b030ba126b2f4b2374f342be9ed44-Abstract.html.
227
+
228
+ [28] P.J. Werbos. Backpropagation through time: what it does and how to do it. Proceedings of the IEEE, 78(10):1550–1560, 1990. doi: 10.1109/5.58337.
229
+
230
+ [29] Ilya Sutskever. Training recurrent neural networks. University of Toronto Toronto, ON, Canada, 2013.
231
+
232
+ [30] Corentin Tallec and Yann Ollivier. Unbiasing truncated backpropagation through time. CoRR, abs/1705.08209, 2017. URL http://arxiv.org/abs/1705.08209.
233
+
234
+ [31] Jimmy Ba, Murat A Erdogdu, Taiji Suzuki, Zhichao Wang, Denny Wu, and Greg Yang. Highdimensional asymptotics of feature learning: How one gradient step improves the representation. arXiv preprint arXiv:2205.01445, 2022.
235
+
236
+ [32] Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proc. IEEE, 86(11):2278–2324, 1998. doi: 10.1109/5.726791. URL https://doi.org/10.1109/5.726791.
237
+
238
+ [33] Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms. CoRR, abs/1708.07747, 2017. URL http:// arxiv.org/abs/1708.07747.
239
+
240
+ [34] Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, 2009.
241
+
242
+ [35] Ya Le and Xuan S. Yang. Tiny imagenet visual recognition challenge. 2015.
243
+
244
+ [36] Jeremy Howard. A smaller subset of 10 easily classified classes from imagenet, and a little more french. URL https://github.com/fastai/imagenette/.
245
+
246
+ [37] Technical report.
247
+
248
+ [38] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton. Imagenet classification with deep convolutional neural networks. In Peter L. Bartlett, Fernando C. N. Pereira, Christopher J. C. Burges, Léon Bottou, and Kilian Q. Weinberger, editors, Advances in Neural Information Processing Systems 25: 26th Annual Conference on Neural Information Processing Systems 2012. Proceedings of a meeting held December 3-6, 2012, Lake Tahoe, Nevada, United States, pages 1106–1114, 2012. URL https://proceedings.neurips.cc/paper/2012/hash/ c399862d3b9d6b76c8436e924a68c45b-Abstract.html.
249
+
250
+ [39] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In Yoshua Bengio and Yann LeCun, editors, 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http://arxiv.org/abs/1409.1556.
251
+
252
+ [40] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pages 770–778. IEEE Computer Society, 2016. doi: 10.1109/CVPR.2016.90. URL https://doi.org/10.1109/CVPR.2016.90.
253
+
254
+ [41] Dmitry Ulyanov, Andrea Vedaldi, and Victor S. Lempitsky. Instance normalization: The missing ingredient for fast stylization. CoRR, abs/1607.08022, 2016. URL http://arxiv.org/abs/ 1607.08022.
255
+
256
+ [42] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In Francis R. Bach and David M. Blei, editors, Proceedings of the 32nd International Conference on Machine Learning, ICML 2015, Lille, France, 6-11 July 2015, volume 37 of JMLR Workshop and Conference Proceedings, pages 448–456. JMLR.org, 2015. URL http://proceedings.mlr.press/v37/ioffe15.html.
257
+
258
+ [43] James Kirkpatrick, Razvan Pascanu, Neil C. Rabinowitz, Joel Veness, Guillaume Desjardins, Andrei A. Rusu, Kieran Milan, John Quan, Tiago Ramalho, Agnieszka GrabskaBarwinska, Demis Hassabis, Claudia Clopath, Dharshan Kumaran, and Raia Hadsell. Overcoming catastrophic forgetting in neural networks. CoRR, abs/1612.00796, 2016. URL http://arxiv.org/abs/1612.00796.
259
+
260
+ [44] Robert French. Catastrophic forgetting in connectionist networks. Trends in cognitive sciences, 3:128–135, 05 1999. doi: 10.1016/S1364-6613(99)01294-2.
261
+
262
+ [45] Anthony V. Robins. Catastrophic forgetting, rehearsal and pseudorehearsal. Connect. Sci., 7 (2):123–146, 1995. doi: 10.1080/09540099550039318. URL https://doi.org/10.1080/ 09540099550039318.
263
+
264
+ [46] Pietro Buzzega, Matteo Boschini, Angelo Porrello, and Simone Calderara. Rethinking experience replay: a bag of tricks for continual learning. In 25th International Conference on Pattern Recognition, ICPR 2020, Virtual Event / Milan, Italy, January 10-15, 2021, pages 2180–2187. IEEE, 2020. doi: 10.1109/ICPR48806.2021.9412614. URL https: //doi.org/10.1109/ICPR48806.2021.9412614.
265
+
266
+ [47] Yaoyao Liu, Bernt Schiele, and Qianru Sun. Adaptive aggregation networks for classincremental learning. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2021, virtual, June 19-25, 2021, pages 2544–2553. Computer Vision Foundation / IEEE, 2021. URL https://openaccess.thecvf.com/content/CVPR2021/html/Liu_ Adaptive_Aggregation_Networks_for_Class-Incremental_Learning_CVPR_2021_ paper.html.
267
+
268
+ [48] Sylvestre-Alvise Rebuffi, Alexander Kolesnikov, and Christoph H. Lampert. icarl: Incremental classifier and representation learning. CoRR, abs/1611.07725, 2016. URL http://arxiv. org/abs/1611.07725.
269
+
270
+ [49] Ameya Prabhu, Philip H. S. Torr, and Puneet K. Dokania. Gdumb: A simple approach that questions our progress in continual learning. In Andrea Vedaldi, Horst Bischof, Thomas Brox, and Jan-Michael Frahm, editors, Computer Vision - ECCV 2020 - 16th European Conference, Glasgow, UK, August 23-28, 2020, Proceedings, Part II, volume 12347 of Lecture Notes in Computer Science, pages 524–540. Springer, 2020. doi: 10.1007/978-3-030-58536-5\_31. URL https://doi.org/10.1007/978-3-030-58536-5_31.
271
+
272
+ [50] Rahaf Aljundi, Min Lin, Baptiste Goujaud, and Yoshua Bengio. Gradient based sample selection for online continual learning. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alché-Buc, Emily B. Fox, and Roman Garnett, editors, Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 11816–11825, 2019. URL https://proceedings.neurips.cc/paper/2019/hash/ e562cd9c0768d5464b64cf61da7fc6bb-Abstract.html.
273
+
274
+ [51] Rahaf Aljundi, Eugene Belilovsky, Tinne Tuytelaars, Laurent Charlin, Massimo Caccia, Min Lin, and Lucas Page-Caccia. Online continual learning with maximal interfered retrieval. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alché-Buc, Emily B. Fox, and Roman Garnett, editors, Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 11849–11860, 2019. URL https://proceedings.neurips.cc/paper/ 2019/hash/15825aee15eb335cc13f9b559f166ee8-Abstract.html.
275
+
276
+ [52] Yaoyao Liu, Yuting Su, An-An Liu, Bernt Schiele, and Qianru Sun. Mnemonics training: Multiclass incremental learning without forgetting. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2020, Seattle, WA, USA, June 13-19, 2020, pages 12242– 12251. Computer Vision Foundation / IEEE, 2020. doi: 10.1109/CVPR42600.2020.01226. URL https://openaccess.thecvf.com/content_CVPR_2020/html/Liu_Mnemonics_ Training_Multi-Class_Incremental_Learning_Without_Forgetting_CVPR_2020_ paper.html.
277
+
278
+ [53] Gido M. van de Ven and Andreas S. Tolias. Three scenarios for continual learning. CoRR, abs/1904.07734, 2019. URL http://arxiv.org/abs/1904.07734.
279
+
280
+ [54] Francisco M. Castro, Manuel J. Marín-Jiménez, Nicolás Guil, Cordelia Schmid, and Karteek Alahari. End-to-end incremental learning. In Vittorio Ferrari, Martial Hebert, Cristian Sminchisescu, and Yair Weiss, editors, Computer Vision - ECCV 2018 - 15th European Conference, Munich, Germany, September 8-14, 2018, Proceedings, Part XII, volume 11216 of Lecture Notes in Computer Science, pages 241–257. Springer, 2018. doi: 10.1007/978-3-030-01258-8\_15. URL https://doi.org/10.1007/978-3-030-01258-8_15.
281
+
282
+ [55] Yutian Chen, Max Welling, and Alexander J. Smola. Super-samples from kernel herding. In Peter Grünwald and Peter Spirtes, editors, UAI 2010, Proceedings of the Twenty-Sixth Conference on Uncertainty in Artificial Intelligence, Catalina Island, CA, USA, July 8-11, 2010, pages 109–116. AUAI Press, 2010. URL https://dslpitt.org/uai/displayArticleDetails. jsp?mmnu $\equiv$ 1&smnu $\underset { . } { = }$ 2&article_id $\equiv$ 2148&proceeding_id=26.
283
+
284
+ [56] Reza Shokri, Marco Stronati, Congzheng Song, and Vitaly Shmatikov. Membership inference attacks against machine learning models. In 2017 IEEE Symposium on Security and Privacy, SP 2017, San Jose, CA, USA, May 22-26, 2017, pages 3–18. IEEE Computer Society, 2017. doi: 10.1109/SP.2017.41. URL https://doi.org/10.1109/SP.2017.41.
285
+
286
+ [57] Yunhui Long, Vincent Bindschaedler, Lei Wang, Diyue Bu, Xiaofeng Wang, Haixu Tang, Carl A. Gunter, and Kai Chen. Understanding membership inferences on well-generalized learning models. CoRR, abs/1802.04889, 2018. URL http://arxiv.org/abs/1802.04889.
287
+
288
+ [58] Ahmed Salem, Yang Zhang, Mathias Humbert, Pascal Berrang, Mario Fritz, and Michael Backes. Ml-leaks: Model and data independent membership inference attacks and defenses on machine learning models. In 26th Annual Network and Distributed System Security Symposium, NDSS 2019, San Diego, California, USA, February 24-27, 2019. The Internet Society, 2019.
289
+
290
+ [59] Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. URL https://openreview.net/forum?id $=$ Sy8gdB9xx.
291
+
292
+ [60] Milad Nasr, Reza Shokri, and Amir Houmansadr. Machine learning with membership privacy using adversarial regularization. In David Lie, Mohammad Mannan, Michael Backes, and XiaoFeng Wang, editors, Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security, CCS 2018, Toronto, ON, Canada, October 15-19, 2018, pages 634–646. ACM, 2018. doi: 10.1145/3243734.3243855. URL https://doi.org/10.1145/ 3243734.3243855.
293
+
294
+ [61] Jinyuan Jia, Ahmed Salem, Michael Backes, Yang Zhang, and Neil Zhenqiang Gong. Memguard: Defending against black-box membership inference attacks via adversarial examples. In Lorenzo Cavallaro, Johannes Kinder, XiaoFeng Wang, and Jonathan Katz, editors, Proceedings of the 2019 ACM SIGSAC Conference on Computer and Communications Security, CCS 2019, London, UK, November 11-15, 2019, pages 259–274. ACM, 2019. doi: 10.1145/3319535.3363201. URL https://doi.org/10.1145/3319535.3363201.
295
+
296
+ [62] tensorflow/privacy: library for training machine learning models with privacy for training data, 2022. URL https://github.com/tensorflow/privacy.
297
+
298
+ [63] Samuel Yeom, Irene Giacomelli, Matt Fredrikson, and Somesh Jha. Privacy risk in machine learning: Analyzing the connection to overfitting. In 31st IEEE Computer Security Foundations Symposium, CSF 2018, Oxford, United Kingdom, July 9-12, 2018, pages 268–282. IEEE Computer Society, 2018. doi: 10.1109/CSF.2018.00027. URL https://doi.org/10.1109/ CSF.2018.00027.
md/dev/2hMEdc35xZ6/2hMEdc35xZ6.md ADDED
@@ -0,0 +1,452 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DEFECT TRANSFER GAN: DIVERSE DEFECT SYNTHESIS FOR DATA AUGMENTATION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Large amounts of data are a common requirement for many deep learning approaches. However, data is not always equally available at large scale for all classes. For example, on highly optimized production lines, defective samples are hardly acquired while non-defective samples come almost for free. The defects however often seem to resemble each other, e.g., scratches on different products may only differ in few characteristics. In this work, we propose to make use of the shared characteristics by transferring a stylized defect-specific content from one type of background product to another. Moreover, the stochastic variations of the shared characteristics are captured, which also allows generating novel defects from random noise. These synthetic defective samples enlarge the dataset and increase the diversity of defects on the target product. Experiments demonstrate that our model is able to disentangle the defect-specific content from the background of an image without pixel-level labels. We present convincing results on images from real industrial production lines. Also, we show consistent gains of using our method to enlarge training sets in classification tasks.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Automated Visual Inspection (AVI) is vital for quality control in modern production lines. Despite the fact that AVI has been studied for decades, it remains a challenging task with many open research questions await to be answered. One of the main challenges in data-driven AVI is the acquisition of suitable training data. This is for two reasons: First, collecting a vast amount of labelled data is usually labor-intensive and time-consuming. In many cases, even experts are required to identify where and what to look for. However, the acquired label information is task-specific and cannot be reused or transferred to a new task in most cases. Thus, the tedious labelling process must be repeated for each new product, even if its defect is similar to other products in people’s eyes. Second, in real-world scenarios such as highly optimized production lines, a more severe problem emerges: data imbalance. Only very few defective parts are produced by design. Moreover, the acquired anomaly images from a single product are lacking diversity and may not capture the full defect distribution. Training a robust deep neural network model in such conditions is very challenging.
12
+
13
+ Since collecting sufficient real-world defective samples is impractical, algorithms to synthesize required images became a focus in research. Image synthesis through Generative Adversarial Networks (GANs) (Goodfellow et al., 2014) has shown promising performance in recent years. But it also requires large amounts of balanced data which are not available in most industrial use cases, in particular for irregular defect patterns and large variation. Therefore, GANs tend to overfit to the training examples when trained with little data (Karras et al., 2020a).
14
+
15
+ In this work, we tackle these issues by exploiting cross-domain information: we first define two sets of domains—foreground domains and background domains. The foreground domain describes a set of images that contains a specific foreground content to be grouped into a distinctive category, and each content has a different style. The background domain instead is considered as a group of images that shares similar structural appearance over the whole image. For example, we can set foreground domains as defect types and background domains as product types while the styles of defects indicate their artistic looks such as light or heavy strokes. Building upon StarGAN v2 (Choi et al., 2020), the concept underlying this work is to transfer and generate foreground contents with a variety of styles across different background domains, as illustrated in Figure 1.
16
+
17
+ ![](images/7375134a93e4d6c487812a69c420b54b7f33ccdc499b7470357d6f8e1d3d2531.jpg)
18
+ Figure 1: The underlying concept of DT-GAN is to transfer and generate foreground contents with a variety of artistic styles (e.g., light / heavy strokes) across different background domains.
19
+
20
+ The contributions of this work are three-fold: First, we introduce Defect Transfer GAN (DT-GAN), a model that learns transferring existing foreground content and generating novel contents onto different backgrounds at the same time. In the real-world scenario, it allows defect inspection networks to learn from a variety of synthetic defective images by composing the foreground defects together with various non-defective images from different products. Second, DT-GAN is able to disentangle the foreground defect-specific content and the defect-irrelevant background in a weakly-supervised manner. Third, extensive experiments show that our method can generate diverse and real-looking defective samples even for products with only 20 real defective images. These defective images generated by DT-GAN boost the performance in defect inspection networks significantly.
21
+
22
+ # 2 RELATED WORK
23
+
24
+ GANs have shown their power in many computer vision tasks such as image synthesis (Luciˇ c et al., ´ 2019), style translation (Johnson et al., 2016), super-resolution (Ledig et al., 2017), image impainting (Pathak et al., 2016) and many other applications. To quantify the performance of GANs, visual quality and the diversity of generated images are considered as two of the most important criteria. Recent models address these requirements either by dedicated loss functions (Mao et al., 2019b; Yang et al., 2019) or architectural design (Brock et al., 2019). StyleGAN v2 (Karras et al., 2020b), the latest state-of-the-art model in image synthesis, introduces stochastic variation in image generating process by adding per-pixel noise after each convolution. However, it is non-trivial to adapt the model to transform given input images due to the design of the generator.
25
+
26
+ In contrast, image-to-image translation methods (Isola et al., 2017) provide a way to recover the connection between inputs and the generated images while encouraging diversity. For example, Zhu et al. (2017b) and Huang et al. (2018) impose consistent mappings in latent space to achieve the goal. Some approaches (Ma et al., 2019; Park et al., 2019) use reference images as guidance to generate diverse outputs. Mokady et al. (2020) further extends the translation task from styles to contents. It learns to identify a specific content in a given input (e.g., a specific pair of glasses) and transfer it to the target image. However, aforementioned methods only consider the translation between two domains and their extension to multiple domains is non-trivial.
27
+
28
+ Surface defect detection is one of the important tasks in real-world industrial manufacturing. It aims at identifying and classifying defects with the help of machine vision. Traditional methods (Ngan et al., 2011) build models upon hand-crafted feature extractors, which are unstable and outperformed by deep learning based models. However, the performance and generalization ability of deep learning approaches are restricted due to limited number of defective samples in real-world scenarios. Data augmentation aims to enrich the training dataset by introducing different kinds of invariance for the model to capture. Several recent works (Niu et al., 2020; Zhang et al., 2021) have proposed to adopt GANs as a data augmentation method to generate realistic defective samples. Among them, Defect-GAN (Zhang et al., 2021) tries to capture the stochastic variation within defects by mimicking the defacement and restoration processes. However, it still learns a deterministic mapping between inputs and outputs while DT-GAN achieves multi-modality by varying styles. Moreover, our method can generate realistic defects with sophisticated patterns copied from real-world defective samples.
29
+
30
+ ![](images/83af523dcfeb8e486bbe482fe2fcb6e531192ec8f0ab542aeb5d211eff025025.jpg)
31
+ Figure 2: Overview of all modules in DT-GAN.
32
+
33
+ # 3 METHODOLOGY
34
+
35
+ Our primary aim is to perform unpaired image-to-image translation across multiple foreground domains within a single model. In our use case, the foreground domains refer to the defect types, which means we want to achieve translations between different types of defects while the background remains unaffected. We assume that there is always an adequate amount of normal samples (e.g., non-defective) available, while anomaly samples are rare and hard to acquire.
36
+
37
+ # 3.1 PROPOSED FRAMEWORK
38
+
39
+ Our framework builds on StarGAN v2, a multimodal image-to-image translation model. Given an input image $\textbf { x } \in { \mathcal { X } }$ and an arbitrary domain $y \in \mathcal { V }$ , StarGAN v2 generates a domain specific style code in a learned style space and outputs an image that is stylized to fit the domain of $y$ . Its network architecture consists of four modules: a generator, a mapping network, a style encoder and a discriminator. We modify and extend all four modules (see Figure 2) and describe the key differences in details as below.
40
+
41
+ Style-Content Separation. Given a latent code $\mathbf { z }$ and a domain $y$ , the mapping network $M$ (Figure 2(b)) generates a style code $\mathbf { s } = M _ { y } ( \mathbf { z } )$ and a domain specific content $\mathbf { c } = M _ { y } ( \mathbf { z } )$ in different branches. It is worth mentioning that $M _ { y }$ here denotes an output of $M$ corresponding to the domain $y$ . This feature allows our method to separately model the structural appearance (i.e. content) and its artistic looks (i.e. style), which is essential because applying different styles to the same content enriches the diversity of outputs. By randomly sampling $\mathbf { z }$ from a standard normal distribution and $y$ from all available foreground domains, $M$ is able to produce diverse style codes and domain specific contents.
42
+
43
+ The encoder $E$ (Figure 2(c)) extracts the style code $\mathbf { s } = E _ { y } ( \mathbf { x } )$ and the domain specific content $\mathbf { c } = E _ { y } ( \mathbf { x } )$ from an given image $\mathbf { x }$ , which reflect the characteristics of reference images instead of randomly sampled noise.
44
+
45
+ Foreground/Background (FG/BG) Disentanglement. The generator $G$ (Figure 2(a)) translates an input image x into an output image $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ according to given domain specific style code es and content ec, which are provided either by the mapping network $M$ when generating from random noise or by the style-content encoder $E$ when transferring an existing content from a reference image. To achieve a FG/BG disentanglement, we split the channels of the three-dimensional feature map (i.e., $H \times W \times C$ ) at the bottle neck of $G$ into two parts. The model is then forced to encode the background into the first channels and the domain specific content cˆ into the latter channels by classification losses as discussed in Section 3.2. cˆ can then be replaced with content ec from the target domain. The adaptive instance normalization (AdaIN) (Huang & Belongie, 2017) is then used to inject es into ec during the decoding process while the background $B G _ { G } ( \mathbf { x } )$ is decoded separately. StarGAN v2 learns $\mathbf { F G }$ and BG together which leads to a conditional relationship between both. Our disentanglement and separate encoding break this conditioning and therefore enable our method to freely combine FG and BG as well as learn the full variation of FG content. Finally, $B G _ { G } ( \mathbf { x } )$ and ec are concatenated together and then fused before output.
46
+
47
+ Multi-task discriminator with auxiliary classifiers. The discriminator $D$ (Figure 2(d)) is a multitask discriminator with two auxiliary classifiers: a foreground domain classifier and a background domain classifier. This feature strengthens the disentanglement of FG and BG by first ensuring the input image $\mathbf { x }$ contains a domain specific content that can be recognized by the foreground domain classifier independent of the background. Later, each branch $D _ { y }$ in the multi-task discriminator $D$ is trained to determine if an image $\mathbf { x }$ is a real image of its foreground domain or a fake image $G ( \mathbf { x } , \mathbf { s } , \mathbf { c } )$ generated by $G$ . Apart from that, one extra branch $B G _ { \mathrm { c l s } }$ is attached to decide whether the background information of the input images is well preserved.
48
+
49
+ Content Transfer. Mokady et al. (2020) introduced a concept that a model should be able to identity the difference between two domains when one of the domains contains a feature that the other does not have. We refer to this concept as ‘anchor’ and extend to multiple domains $( > 2 )$ by the FG/BG disentanglement, the multi-task discriminator and the foreground content classifier in $D$ . We treat domain Normal as the anchor domain i.e. set the domain specific content to zero, because a normal image has no domain specific content in our definition. As a result, we can now transfer contents between all combination of FG and BG domains (see Figure 10).
50
+
51
+ Compared to StarGAN v2, our method not only models style codes and contents separately but also disentangles the foreground and background of an image in a weakly-supervised manner. These features allow explicit control over output images by combining desired style codes and contents from one of the subnetworks with the input images. Therefore, it leads to higher variance regarding the location, structural pattern and artistic style of defects in the synthetic images of DT-GAN.
52
+
53
+ # 3.2 TRAINING OBJECTIVES
54
+
55
+ Given an image $\mathbf { x } \in \mathcal { X }$ , its original foreground domain $y \in \mathcal { V }$ and its background domain $p \in \mathcal { P }$ , the following objectives are used to train our framework.
56
+
57
+ Adversarial loss. In the training phase, a noise vector $\mathbf { z } \in { \mathcal { Z } }$ and a target foreground domain $\widetilde y \in \mathcal { V }$ are sampled randomly. Both of them are fed to $M$ , producing a target style code $\widetilde { \mathbf { s } }$ and a target content ec as follows: $\widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } = M _ { \widetilde { y } } ( \mathbf { z } )$ . Goal of the training is to ensure that $\widetilde { \mathbf { s } }$ and ec are sampled from the distribution over styles and contents of the target domain $\widetilde { y }$ . The generator $G$ then combines an image $\mathbf { x }$ with $\widetilde { \mathbf { s } }$ and $\widetilde { \mathbf c }$ and learns to generate an output image $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ that is indistinguishable from real images in the target domain $\widetilde { y }$ . We encourage this behavior by using an adversarial loss same as in Choi et al. (2020)
58
+
59
+ $$
60
+ \mathcal { L } _ { \mathrm { a d v } } = \mathbb { E } _ { { \mathbf { x } } , y } \big [ \log D _ { y } ( { \mathbf { x } } ) \big ] + \mathbb { E } _ { { \mathbf { x } } , \widetilde { y } , { \mathbf { z } } } [ \log \left( 1 - D _ { \widetilde { y } } ( G ( { \mathbf { x } } , \widetilde { { \mathbf { s } } } , \widetilde { { \mathbf { c } } } ) ) \right) ] ,
61
+ $$
62
+
63
+ where $D _ { y }$ and $D _ { \widetilde { y } }$ are the output branches of $D$ that correspond to the source domain $y$ and the target domain $\widetilde { y }$ , respectively.
64
+
65
+ Style-content reconstruction loss. Similar to StarGAN v2, to enforce the generator $G$ takes the style code $\widetilde { \mathbf { s } }$ and the domain specific content ec into consideration during the generation process, we employ a style-content reconstruction loss
66
+
67
+ $$
68
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { s t y . c o n } } = \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } } \big [ \| \widetilde { \mathbf { s } } - S _ { E } ( G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } ) ) \| _ { 1 } \big ] + \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } } \big [ \| \widetilde { \mathbf { c } } - C _ { E } ( G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } ) ) \| _ { 1 } \big ] . } \end{array}
69
+ $$
70
+
71
+ This objective urges the style-content encoder $E$ to recover $\widetilde { \mathbf { s } }$ and c from $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ . Here, the stylecontent encoder $E$ learns a mapping from an image to its style and content domains, which allows $G$ to synthesize an image with given s and c from reference images at test time.
72
+
73
+ Diversity loss. In order to further boost the diversity of output images from $G$ , we introduce a loss that encourages diversity as follows: for a pair of random latent codes $\mathbf { z } _ { 1 }$ and $\mathbf { z } _ { 2 }$ we compute $\widetilde { \mathbf { s } } _ { i } , \widetilde { \mathbf { c } } _ { i } = M _ { \widetilde { y } } ( \mathbf { z } _ { i } )$ for $i \in \{ 1 , 2 \}$ and enforce a different outcome of the generator $G$ for differently mixed style and content input pairs:
74
+
75
+ $$
76
+ \begin{array} { r l } & { \mathcal { L } _ { \mathrm { d s } } = \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } _ { 1 } , \mathbf { z } _ { 2 } } \left[ \| G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { 1 } , \widetilde { \mathbf { c } } _ { 2 } ) - G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { 2 } , \widetilde { \mathbf { c } } _ { 1 } ) \| _ { 1 } \right] } \\ & { \quad \quad + \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } _ { 1 } , \mathbf { z } _ { 2 } } \left[ \| G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { 1 } , \widetilde { \mathbf { c } } _ { 1 } ) - G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { 2 } , \widetilde { \mathbf { c } } _ { 2 } ) \| _ { 1 } \right] } \\ & { \quad \quad + \sum _ { m , n , o } \left[ \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } _ { 1 } , \mathbf { z } _ { 2 } } \left[ \| G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { m } , \widetilde { \mathbf { c } } _ { n } ) - G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { o } , \widetilde { \mathbf { c } } _ { o } ) \| _ { 1 } \right] \right] , } \end{array}
77
+ $$
78
+
79
+ where $m , n \in \{ 1 , 2 | m \neq n \}$ and $o \in \{ 1 , 2 \}$ . Driven by this term, the generator $G$ is forced to discover meaningful style features and contents that eventually lead to diversity in generated images.
80
+
81
+ We ignore the denominator ${ \left\| { \bf z } _ { 1 } - { \bf z } _ { 2 } \right\| } _ { 1 }$ of the original diversity loss (Mao et al., 2019a) for stable training as in StarGAN v2.
82
+
83
+ Cycle consistency loss. To ensure that the generated image $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ preserves the domaininvariant properties of its input image $\mathbf { x }$ , we impose the cycle consistency loss (Zhu et al., 2017a)
84
+
85
+ $$
86
+ \mathcal { L } _ { \mathrm { c y c } } = \mathbb { E } _ { { \mathbf { x } } , y , \widetilde { y } , { \mathbf { z } } } \big [ | | { \mathbf { x } } - G ( G ( { \mathbf { x } } , \widetilde { { \mathbf { s } } } , \widetilde { { \mathbf { c } } } ) , \widehat { { \mathbf { s } } } , \widehat { { \mathbf { c } } } ) | | _ { 1 } \big ] ,
87
+ $$
88
+
89
+ where $\hat { \bf s } , \hat { \bf c } = E _ { y } ( { \bf x } )$ is the extracted style code and domain specific content of the input image $\mathbf { x }$ , and $y$ is the original domain of $\mathbf { x }$ . By learning to reconstruct the input image $\mathbf { x }$ with given style code ˆs and content cˆ, the generator $G$ is then further encouraged to disentangle the background, the domain specific content and the style code.
90
+
91
+ Content consistency loss. Besides the cycle consistency loss, we apply another constraint to enforce that the detached domain specific content from $G$ is consistent with the one retrieved from $E$ according to
92
+
93
+ $$
94
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { c o n . c y c } } = \mathbb { E } _ { \mathbf { x } , y , \widetilde { y } , \mathbf { z } } \left[ \left\| F G _ { G } ( \mathbf { x } ) - \widehat { \mathbf { c } } \right\| _ { 1 } \right] + \mathbb { E } _ { \mathbf { x } , y , \widetilde { y } , \mathbf { z } } \left[ \left\| F G _ { G } ( G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } ) ) - \widetilde { \mathbf { c } } \right\| _ { 1 } \right] , } \end{array}
95
+ $$
96
+
97
+ where $\hat { \mathbf { c } } = E _ { y } ( \mathbf { x } ) , \widetilde { \mathbf { c } } = E _ { \widetilde { y } } ( \mathbf { x } ) , F G _ { G } ( \mathbf { x } )$ and $F G _ { G } ( G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } ) )$ are the pop-out domain specific content from input image $\mathbf { x }$ and generated image $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ , respectively.
98
+
99
+ Classification losses. We employ two classification losses: the first one is the foreground content classification loss
100
+
101
+ $$
102
+ \mathcal { L } _ { \mathrm { F G . c l s } } = \mathbb { E } _ { \mathbf { x } _ { \mathrm { r e a l } } , y } \Big [ - \log D _ { \mathrm { F G . c l s } } \big ( y | \mathbf { x } _ { \mathrm { r e a l } } \big ) \Big ] + \mathbb { E } _ { \mathbf { x } _ { \mathrm { f a k e } } , \widetilde { y } } \Big [ - \log D _ { \mathrm { F G . c l s } } \big ( \widetilde { y } | \mathbf { x } _ { \mathrm { f a k e } } \big ) \Big ] \ ,
103
+ $$
104
+
105
+ which aims to ensure that the domain specific content is properly encoded and carries enough information from the target domain. The second one is the background classification loss
106
+
107
+ $$
108
+ \mathcal { L } _ { \mathrm { B G } . \mathrm { c l s } } = \mathbb { E } _ { \mathbf { x } _ { \mathrm { r e a l } } , p } \big [ - \log D _ { \mathrm { B G } . \mathrm { c l s } } ( p | \mathbf { x } _ { \mathrm { r e a l } } ) \big ] + \mathbb { E } _ { \mathbf { x } _ { \mathrm { f a k e } } , p } \big [ - \log D _ { \mathrm { B G } . \mathrm { c l s } } ( p | \mathbf { x } _ { \mathrm { f a k e } } ) \big ] \ ,
109
+ $$
110
+
111
+ where $p$ is the corresponding background type of $\mathbf { x } _ { \mathrm { r e a l } }$ and $\mathbf { x } _ { \mathrm { f a k e } }$ . With the help of this objective, the generator $G$ learns to preserve the domain-invariant characteristics of its input image $\mathbf { x }$ while dissociating the foreground domain specific part.
112
+
113
+ Full objective. Our full objective functions can be summarized as
114
+
115
+ $$
116
+ \begin{array} { r l } { \underset { G , F , E } { \operatorname* { m i n } } \underset { D } { \operatorname* { m a x } } } & { \mathcal { L } _ { \mathrm { a d v } } + \lambda _ { \mathrm { s t y } . \mathrm { c o n } } \mathcal { L } _ { \mathrm { s t y } . \mathrm { c o n } } - \lambda _ { \mathrm { d s } } \mathcal { L } _ { \mathrm { d s } } + \lambda _ { \mathrm { c y c } } \mathcal { L } _ { \mathrm { c y c } } + } \\ & { \lambda _ { \mathrm { c o n . c y c } } \mathcal { L } _ { \mathrm { c o n . c y c } } + \lambda _ { \mathrm { F G . c l s } } \mathcal { L } _ { \mathrm { F G . c l s } } + \lambda _ { \mathrm { B G . c l s } } \mathcal { L } _ { \mathrm { B G . c l s } } \ , } \end{array}
117
+ $$
118
+
119
+ where $\lambda _ { \mathrm { s t y } }$ , $\lambda _ { \mathrm { d s } }$ , $\lambda _ { \mathrm { c y c } }$ , $\lambda _ { \mathrm { c o n \mathrm { { - } c y c } } }$ , $\lambda _ { \mathrm { F G \mathrm { - } c l s } }$ and $\lambda _ { \mathrm { B G \mathrm { { - } c l s } } }$ are the hyperparameters for each term.
120
+
121
+ # 4 EXPERIMENTS
122
+
123
+ We evaluated the images generated by DT-GAN through a series of experiments both quantitatively and qualitatively. Finally, we demonstrate the benefits of our generated images when being used as data augmentation for a defect classification task on limited data.
124
+
125
+ Dataset. All experiments were performed on a real industrial dataset: a Surface Defect Inspection (SDI) dataset that contains three different kinds of products from production lines and samples from each product are classified into three mutually exclusive classes: Normal, Scratch and Spot. All of the images are grayscale. Detailed statistics of the dataset are summarized in Appendix A. Note that only the training set was used in GAN training, the test set was left untouched for final evaluation in classifier training. For a fair comparison, all images were resized to $1 2 8 \times 1 2 8$ resolution for both GAN training and classifier training, which was also the highest resolution used in the baselines for image generation. For comparison, we also conducted experiments on the widely used MVTec Anomaly Detection dataset (Bergmann et al., 2019) in Appendix E.4.
126
+
127
+ # 4.1 DEFECT GENERATION
128
+
129
+ Baselines. As discussed in Section 3, DT-GAN can either use the mapping network to randomly generate styles and defects, or it can use the style-content encoder to extract both from reference images. We refer to these cases as ‘latent-guided’ and ‘reference-guided’, respectively.
130
+
131
+ Since the two ways of guidance are fundamentally different, we evaluated them against two sets of baselines: Our reference-guided image generation was compared to Mokady et al. (2020) and StarGAN v2, because both of them can perform a reference-guided translation. Note that Mokady et al. (2020) can only translate between two domains while StarGAN v2 and DT-GAN can achieve multi-domain translation within a single model. Images generated through the latent-guided part of DT-GAN were compared to state-of-the-art GANs in image synthesis: BigGAN (Brock et al., 2019) and StyleGAN v2 (Karras et al., 2020b). We set BigGAN to condition on defect types during training while StyleGAN v2 was trained unconditionally. All baselines were trained from scratch with the public implementations provided by the authors1.
132
+
133
+ # 4.1.1 QUANTITATIVE EVALUATION
134
+
135
+ Metrics. We employed the commonly used frechet inception distance (FID) (Heusel et al., 2017) to evaluate both the visual quality and the diversity of the generated images. We also report the kernel inception distance (KID) (Binkowski et al., 2018) which is a more stable metric for small sets of images like our SDI dataset. Lower FID and KID scores indicate better performance.
136
+
137
+ Both scores are shown in Table 1. We observe that methods like BigGAN and StyleGAN v2, which perform defect synthesis purely based on latent codes, generally provide unsatisfactory results on the SDI dataset, presumably due to the small number of defective samples that were available. These methods then struggle to capture the complex and irregular patterns of defects. We also experimented with augmentation methods for GAN training (Karras et al., 2020a; Zhao et al., 2020) but did not find a consistent improvement (see Appendix E.2). We thus only report the best scores.
138
+
139
+ Reference-guided synthesis methods like Mokady et al. (2020) and StarGAN v2 seem to generate more realistic images. The scores of StarGAN v2 on a single product are omitted here because generating images with specified background is not possible due to its network design—the product type changes in output images, which we refer to as ‘identity-shift’. As seen in Table 1, our method achieves better scores in all cases. We believe this is due to the fact that our method allows free combination of foreground defects and backgrounds, making the generated images more diverse even with a small number of training samples.
140
+
141
+ Table 1: Quantitative comparison of DT-GAN with baseline image synthesis methods using FID and KID. Note that the reported values are not comparable between columns, because they were calculated on different training sets.
142
+
143
+ <table><tr><td rowspan="2">Method</td><td colspan="4">FID↓</td><td colspan="4">KID↓</td></tr><tr><td>A</td><td>B</td><td>C</td><td>All</td><td>A</td><td>B</td><td>C</td><td>All</td></tr><tr><td>Mokady (2020)</td><td>68.69</td><td>66.90</td><td>36.21</td><td>58.63</td><td>0.050</td><td>0.036</td><td>0.030</td><td>0.036</td></tr><tr><td>StarGAN v2</td><td>1</td><td></td><td>1</td><td>37.70</td><td>-</td><td>1</td><td>1</td><td>0.013</td></tr><tr><td>StyleGAN v2</td><td>90.10</td><td>52.95</td><td>138.09</td><td>35.34</td><td>0.072</td><td>0.027</td><td>0.186</td><td>0.013</td></tr><tr><td>BigGAN + DiffAug</td><td>218.74</td><td>134.41</td><td>270.89</td><td>155.88</td><td>0.220</td><td>0.121</td><td>0.378</td><td>0.099</td></tr><tr><td>Ours</td><td>58.43</td><td>36.44</td><td>22.68</td><td>29.73</td><td>0.025</td><td>0.013</td><td>0.012</td><td>0.009</td></tr></table>
144
+
145
+ # 4.1.2 QUALITATIVE EVALUATION
146
+
147
+ We present a qualitative comparison with the baseline methods in latent-guided image synthesis in Figure 3. To make a fair comparison, we trained StyleGAN v2 and BigGAN on each product separately to have control on background products. Note however, that images from DT-GAN were always obtained from a single model. We can see that some generated samples from StyleGAN v2 do not contain clear defects, and samples from BigGAN present abnormal grid patterns. Both methods do not take images as inputs but generate synthetic images according to a given latent code which contains information for both FG and BG. This conditioning leads to limited diversity in the output images. On the other hand, StarGAN v2 performs translation based on input images but suffers from the same entanglement issue. Thus, it fails to preserve the background, which results in artifacts or identity-shift in its outputs. Our network architecture that disentangles foreground and background seems to mitigate these issues. See Appendix E.4 for more images.
148
+
149
+ ![](images/e8844ad801507fcb58625110b5ddd1e08b278ccc393d4b6551f6e75e4f93f6ca.jpg)
150
+ Figure 3: Qualitative comparison of latent-guided image synthesis results. In each subfigure: on the left, defective images are fully generated from random noise. On the right, random defects are synthesized onto given normal samples. Note that BigGAN\* denotes it was trained with DiffAug.
151
+
152
+ ![](images/c8d4f138dd7a663cb4fbcdd6d95ca7b5d88bc4505014c289d8d78e678a6ef857.jpg)
153
+ Figure 4: Qualitative comparison of reference-guided image synthesis results on the SDI dataset. Each method transforms the given source images into target foreground domains (e.g., Scratches) with the styles and contents extracted from the reference images.
154
+
155
+ Also for reference-guided image synthesis, where we used different background and foreground reference images as illustrated in Figure 4, only our method produces high quality images with preserved background from the source and transferred foreground defect from the reference.
156
+
157
+ Ablation study. We visually demonstrate the effect of each component we added to DT-GAN compared to StarGAN v2 in Figure 5, using the examples of both latent- and reference-guided image synthesis from Normal to Scratches. The quantitative evaluation can be found in Appendix E.3.
158
+
159
+ Column (a) corresponds to StarGAN v2 and highlights the drawback of entangled FG/BG again (i.e. the identity-shift in the background). We first tackle this problem by modeling the style code and foreground content explicitly and feeding them separately to the generator. This leads to a better preservation of the background structure in column (b) for the reference-guided subnetwork, but not for the latent-guided synthesis on the bottom of Figure 5. Thus, we add a foreground classifier in the discriminator in (c) to ensure the output image contains the desired foreground content (scratch). Similarly, we introduce a background classifier to the discriminator in column (d). Note that the additional product type labels can be acquired automatically from production lines.
160
+
161
+ For column (e), we add the separate decoders for foreground and background in the generator which are fused only in the end. This enhances the preservation of background characteristics like lighting even more. Imposing an additional penalty for foreground content extracted from a normal sample as described in Section 3.1 leads to another visual improvement of the foreground edges for reference-guided synthesis in column (f). Finally, inspired by StyleGAN, we incorporate adaptive noise injection to the mapping network, which significantly boosts the performance of our latentguided image synthesis as shown in column (g).
162
+
163
+ Styling. We visually demonstrate the effect of style codes in our method by randomly sampling those and combining them with fixed reference background and foreground images in Figure 6, where a variety of artistic styles can be seen on the output columns.
164
+
165
+ ![](images/91696fc85e55662030167a35ef4aae436fa0857c2b3a62e62f0e14e5967749b8.jpg)
166
+ Figure 5: Ablation study. (a) The baseline StarGAN v2. (b) $^ +$ Style-Content branches. (c) $^ +$ Foreground classifier. (d) $^ +$ Background classifier. (e) $^ +$ Separately decoding foreground and background in $G$ . (f) $^ +$ Anchor foreground domain (e.g. Normal). (g) $^ +$ Noise injection in Mapping Network.
167
+
168
+ ![](images/10b4554eb02cdbab48f0a3b29e5fed2318aee10f044aacf5703500d8bb21eef0.jpg)
169
+ Figure 6: Visual effect of randomly sampled style codes on fixed pairs of reference background (Source) and foreground (Content) images.
170
+
171
+ # 4.2 DT-GAN FOR DATA AUGMENTATION
172
+
173
+ We also evaluated our method as a data augmentation method for defect classification on the SDI dataset. We defined one task ‘general’, where the classifier was trained on images from all products at once, while task ‘single product’ only used the subset of images for one product.
174
+
175
+ Besides, we incrementally varied the amount of real Normal data available for classifier training: 4500, 6600, 12000 and 18600. In the case of defective images, all of them were always used due to the small amount unless otherwise specified. As backbone we used a ResNet-50 (He et al., 2016a) with ImageNet pretrained weights. For experiments with synthetic data, we attached an auxiliary domain classifier to the network through a Gradient Reversal Layer (Ganin & Lempitsky, 2015).
176
+
177
+ Table 2: Quantitative comparison of the baseline methods on defect classification task at the scale of 12000 images/class. The reported values are the achieved error rates $( \% )$ over five runs.
178
+
179
+ <table><tr><td>Method</td><td>ResNet-50</td><td>EfficientNet-b4</td></tr><tr><td>No-Aug</td><td>21.64±1.24</td><td>12.06±0.64</td></tr><tr><td>Trad-Aug</td><td>12.58±0.81</td><td>9.33±0.73</td></tr><tr><td>Mokady (2020)</td><td>11.11±1.19</td><td>13.26±1.13</td></tr><tr><td>StarGAN v2</td><td>13.07±1.30</td><td>12.25±0.79</td></tr><tr><td>StyleGAN v2</td><td>11.55±1.79</td><td>11.68±0.76</td></tr><tr><td>BigGAN+DiffAug</td><td>11.45±0.61</td><td>12.06±0.50</td></tr><tr><td>Ours</td><td>9.9±0.69</td><td>9.14±1.02</td></tr></table>
180
+
181
+ Since the SDI dataset is highly imbalanced, we oversampled the minority classes (Ling et al., 1998) unless the data was balanced through synthetic images. Additionally, we always applied traditional data augmentation techniques like random horizontal flips, jittering and lighting (Shorten & Khoshgoftaar, 2019) except where noted. All following results were evaluated by the achieved error rates over five runs with different random seeds.
182
+
183
+ Effectiveness of synthetic data. We first compare classifier performance for no augmentation (NoAug), traditional data augmentation (Trad-Aug), and a combination of traditional augmentation with synthetic images for GAN methods including DT-GAN. We also introduce a stronger backbone, EfficientNet-b4 (Tan & Le, 2019), to demonstrate that our results are not confined to a specific network. Table 2 shows that our method is the only one that improves performance for both backbones, presumably due to the combination of high visual image quality and diversity in our samples.
184
+
185
+ Table 3: Experimental results on using different amount of synthetic images generated by DT-GAN to train classifiers. The left-most column stands for number of samples per class to be classified. The training set of the baselines is balanced by oversampling while ours is by synthetic images.
186
+
187
+ <table><tr><td rowspan="2">Dataset Size</td><td colspan="2">20A</td><td colspan="2">All</td></tr><tr><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td></tr><tr><td>4500</td><td>15.55±0.63</td><td>14.28±1.25</td><td>12.75±0.61</td><td>11.04±0.76</td></tr><tr><td>6600</td><td>16.69±0.76</td><td>14.41±3.12</td><td>13.07±1.57</td><td>10.60±0.48</td></tr><tr><td>12000</td><td>16.95±1.02</td><td>14.22±1.53</td><td>12.05±0.81</td><td>9.90±0.69</td></tr><tr><td>18600</td><td>16.12±2.19</td><td>15.36±0.86</td><td>12.37±0.32</td><td>10.21±0.96</td></tr></table>
188
+
189
+ Impact of dataset size. Motivated by the limited availability of data in real-world production scenarios, we therefore evaluated DT-GAN for data augmentation on a subset of the full SDI dataset (All), which only contains 20 defective samples in product A for each defect type (20A). In this case, DT-GAN was also trained on the reduced subset. As shown in Table 3, there is a clear improvement when synthetic images from DT-GAN are used as data augmentation, even for the extremely limited data subset. Further results on single product classifiers can be found in Appendix E.1.
190
+
191
+ Table 4: Cross-domain effect on single product classifiers trained with reference-guided synthetic images at the scale of 12000 images/class.
192
+
193
+ <table><tr><td></td><td>Trad-Aug</td><td>vA</td><td>VB</td><td>vC</td><td>vABC</td></tr><tr><td>A</td><td>13.81±2.36</td><td>11.81±2.65</td><td>12.72±2.87</td><td>11.99±1.63</td><td>11.09±3.49</td></tr><tr><td>B</td><td>6.80±1.64</td><td>6.40±1.34</td><td>6.60±1.52</td><td>6.59±1.34</td><td>5.60±1.34</td></tr><tr><td>C</td><td>16.57±3.20</td><td>13.14±2.81</td><td>11.23±0.80</td><td>14.85±1.73</td><td>11.42±0.96</td></tr></table>
194
+
195
+ Cross-domain effect. We hypothesized that limited data can be counteracted by transferring defects across multiple background products, if there are at least some defects that occur on multiple products (See Appendix E.1 for further discussion). We tested this approach by comparing the performance of classifiers trained on synthetic images with defects from a specific source (vA, vB, vC) to classifiers trained on images with defects from all products (vABC). As we can see in Table 4, the best performances are reached by the models that take over defects from other products. We interpret this as support for our hypothesis and its practical usefulness.
196
+
197
+ # 5 CONCLUSION
198
+
199
+ We propose a novel method, DT-GAN, which allows diverse defect synthesis both by generating from randomly sampled noise and by following the guidance of given reference images. Due to explicit style-content separation and FG/BG disentanglement, DT-GAN achieves higher image fidelity, better variance in defects and full control over background and foreground while being sample-efficient. We demonstrated the feasibility and benefits of DT-GAN on a real industrial defect classification task and the results show our method provides consistent gains even with limited data and boosts the performance of classifiers compared to state-of-the-art image synthesis methods. For future investigation, we aim to represent defects more explicitly (e.g., localization) to improve the explainability of the model and also enhance the model transferability to unseen products.
200
+
201
+ # REPRODUCIBILITY STATEMENT
202
+
203
+ We aim for full reproducibility by publishing the source code and dataset with the final version of the paper. Besides, we provide descriptions of the training details in Appendix B, the evaluation setup in Appendix C and the network architecture in Appendix D.
204
+
205
+ REFERENCES
206
+ Paul Bergmann, Michael Fauser, David Sattlegger, and Carsten Steger. Mvtec ad — a comprehensive real-world dataset for unsupervised anomaly detection. In 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 9584–9592, 2019. doi: 10.1109/CVPR.2019.00982.
207
+ Mikolaj Binkowski, Danica J. Sutherland, Michael Arbel, and A. Gretton. Demystifying MMD GANs. ArXiv, abs/1801.01401, 2018.
208
+ Andrew Brock, Jeff Donahue, and K. Simonyan. Large scale gan training for high fidelity natural image synthesis. ArXiv, abs/1809.11096, 2019.
209
+ Yuhua Chen, Wen Li, Christos Sakaridis, Dengxin Dai, and Luc Van Gool. Domain adaptive faster rcnn for object detection in the wild. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3339–3348, 2018.
210
+ Yunjey Choi, Youngjung Uh, Jaejun Yoo, and Jung-Woo Ha. Stargan v2: Diverse image synthesis for multiple domains. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
211
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
212
+ Yaroslav Ganin and Victor Lempitsky. Unsupervised domain adaptation by backpropagation. In Francis Bach and David Blei (eds.), Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, pp. 1180–1189, Lille, France, 07–09 Jul 2015. PMLR. URL https://proceedings.mlr.press/v37/ ganin15.html.
213
+ Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial networks. In NeurIPS, 2014.
214
+ Kaiming He, X. Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770–778, 2016a.
215
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks, 2016b. URL http://arxiv.org/abs/1603.05027. cite arxiv:1603.05027Comment: ECCV 2016 camera-ready.
216
+ Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and S. Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In NIPS, 2017.
217
+ Xun Huang and Serge Belongie. Arbitrary style transfer in real-time with adaptive instance normalization. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), Oct 2017.
218
+ Xun Huang, Ming-Yu Liu, Serge J. Belongie, and J. Kautz. Multimodal unsupervised image-toimage translation. ArXiv, abs/1804.04732, 2018.
219
+ Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A. Efros. Image-to-image translation with conditional adversarial networks. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 5967–5976, 2017.
220
+ Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution, 2016.
221
+
222
+ Tero Karras, Miika Aittala, Janne Hellsten, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Training generative adversarial networks with limited data, 2020a.
223
+
224
+ Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Analyzing and improving the image quality of stylegan. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020b.
225
+
226
+ Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical Report 0, University of Toronto, Toronto, Ontario, 2009.
227
+
228
+ Christian Ledig, Lucas Theis, Ferenc Huszar, Jose Caballero, Andrew Cunningham, Alejandro ´ Acosta, Andrew Aitken, Alykhan Tejani, Johannes Totz, Zehan Wang, et al. Photo-realistic single image super-resolution using a generative adversarial network. In CVPR, 2017.
229
+
230
+ Charles Ling, , Charles X. Ling, and Chenghui Li. Data mining for direct marketing: Problems and solutions. In In Proceedings of the Fourth International Conference on Knowledge Discovery and Data Mining (KDD-98, pp. 73–79. AAAI Press, 1998.
231
+
232
+ Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In Proceedings of International Conference on Computer Vision (ICCV), December 2015.
233
+
234
+ Mario Luciˇ c, Michael Tschannen, Marvin Ritter, Xiaohua Zhai, Olivier Bachem, and Sylvain Gelly. ´ High-fidelity image generation with fewer labels. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 4183–4192. PMLR, 09–15 Jun 2019. URL https://proceedings.mlr.press/v97/lucic19a.html.
235
+
236
+ Liqian Ma, Xu Jia, Stamatios Georgoulis, Tinne Tuytelaars, and Luc Van Gool. Exemplar guided unsupervised image-to-image translation with semantic consistency. In ICLR, 2019.
237
+
238
+ Qi Mao, Hsin-Ying Lee, Hung-Yu Tseng, Siwei Ma, and Ming-Hsuan Yang. Mode seeking generative adversarial networks for diverse image synthesis. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 1429–1437, 2019a.
239
+
240
+ Qi Mao, Hsin-Ying Lee, Hung-Yu Tseng, Siwei Ma, and Ming-Hsuan Yang. Mode seeking generative adversarial networks for diverse image synthesis. In CVPR, 2019b.
241
+
242
+ Ron Mokady, Sagie Benaim, Lior Wolf, and Amit Bermano. Masked based unsupervised content transfer. In International Conference on Learning Representations, 2020. URL https:// openreview.net/forum?id $=$ BJe-91BtvH.
243
+
244
+ Henry Y. T. Ngan, Grantham K. H. Pang, and Nelson H. C. Yung. Review article: Automated fabric defect detection-a review. Image Vision Comput., 29(7):442–458, June 2011. ISSN 0262- 8856. doi: 10.1016/j.imavis.2011.02.002. URL https://doi.org/10.1016/j.imavis. 2011.02.002.
245
+
246
+ Shuanlong Niu, Bin Li, Xinggang Wang, and Hui Lin. Defect image sample generation with gan for improving defect recognition. IEEE Transactions on Automation Science and Engineering, 17(3):1611–1622, 2020. doi: 10.1109/TASE.2020.2967415.
247
+
248
+ Taesung Park, Ming-Yu Liu, Ting-Chun Wang, and Jun-Yan Zhu. Semantic image synthesis with spatially-adaptive normalization. In CVPR, 2019.
249
+
250
+ Adam Paszke, Sam Gross, Soumith Chintala, Gregory Chanan, Edward Yang, Zach DeVito, Zeming Lin, Alban Desmaison, Luca Antiga, and Adam Lerer. Automatic differentiation in pytorch. 2017.
251
+
252
+ Deepak Pathak, Philipp Krahenb ¨ uhl, Jeff Donahue, Trevor Darrell, and Alexei A. Efros. Context ¨ encoders: Feature learning by inpainting. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2536–2544, 2016.
253
+
254
+ Sebastian Ruder. An overview of gradient descent optimization algorithms. arXiv preprint arXiv:1609.04747, 2016.
255
+
256
+ Connor Shorten and T. Khoshgoftaar. A survey on image data augmentation for deep learning. Journal of Big Data, 6:1–48, 2019.
257
+
258
+ Mingxing Tan and Quoc Le. EfficientNet: Rethinking model scaling for convolutional neural networks. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 6105–6114. PMLR, 09–15 Jun 2019. URL https://proceedings.mlr. press/v97/tan19a.html.
259
+
260
+ Dingdong Yang, Seunghoon Hong, Yunseok Jang, Tiangchen Zhao, and Honglak Lee. Diversitysensitive conditional generative adversarial networks. In ICLR, 2019.
261
+
262
+ Gongjie Zhang, Kaiwen Cui, Tzu-Yi Hung, and Shijian Lu. Defect-gan: High-fidelity defect synthesis for automated defect inspection. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), pp. 2524–2534, January 2021.
263
+
264
+ Shengyu Zhao, Zhijian Liu, Ji Lin, Jun-Yan Zhu, and Song Han. Differentiable augmentation for data-efficient gan training, 2020.
265
+
266
+ Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A. Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), Oct 2017a.
267
+
268
+ Jun-Yan Zhu, Richard Zhang, Deepak Pathak, Trevor Darrell, Alexei A. Efros, O. Wang, and E. Shechtman. Toward multimodal image-to-image translation. In NIPS, 2017b.
269
+
270
+ # A THE SURFACE DEFECT INSPECTION DATASET
271
+
272
+ The Surface Defect Inspection (SDI) dataset consists of 20,414 images at $1 2 8 \times 1 2 8$ resolution. It contains three background domains—product A, product $\mathbf { B }$ and product C, each can be further classified into three foreground domains—Normal, Scratches and Spots. Figure 7 shows example images of the SDI dataset. To be noticed that the dataset is highly imbalanced not only between normal and defective samples but also between different products as shown in Table 5. This sets a more challenging task when training deep neural networks like GANs and downstream classifiers.
273
+
274
+ For each foreground and background domains, we randomly select 50 images for a joint validation/test set, which is then further split into separate sets in the ratio of 3:7, and use all remaining images as training sets for GAN and classifier training. We present the distribution of the training set when training DT-GAN in Table 6. Note that the normal samples used in GAN training are only a subset of all available samples in Normal and we keep the rest of them for generating defective samples at test time. For classifier training, we show the statistics in Table 7, where the number of normal samples involved in classifier training increase incrementally. The validation set is used to select the best model during classifier training while the test set is left untouched until the final evaluation. Both of the validation and test set are inaccessible by DT-GAN.
275
+
276
+ Table 5: Distribution of the full SDI dataset.
277
+
278
+ <table><tr><td></td><td colspan="3">Overview</td></tr><tr><td></td><td>A</td><td>B</td><td>C</td></tr><tr><td>Normal</td><td>6250</td><td>6250</td><td>6250</td></tr><tr><td>Scratches</td><td>340</td><td>167</td><td>121</td></tr><tr><td>Spots</td><td>108</td><td>670</td><td>258</td></tr></table>
279
+
280
+ Table 6: The training set for DT-GAN and the baseline image synthesis methods.
281
+
282
+ <table><tr><td></td><td colspan="3">Overview</td></tr><tr><td></td><td>A</td><td>B</td><td>C</td></tr><tr><td>Normal</td><td>700</td><td>700</td><td>700</td></tr><tr><td>Scratches</td><td>290</td><td>117</td><td>71</td></tr><tr><td>Spots</td><td>58</td><td>620</td><td>208</td></tr></table>
283
+
284
+ Table 7: The training, validation and test set for classifier training, where $N$ increases incrementally—1500, 2200, 4000 and 6200.
285
+
286
+ <table><tr><td></td><td colspan="3">Train</td><td colspan="3">Validation</td><td colspan="3">Test</td></tr><tr><td></td><td>A</td><td>B</td><td>C</td><td>A</td><td>B</td><td>C</td><td>A</td><td>B</td><td>C</td></tr><tr><td>Normal</td><td>N</td><td>N</td><td>N</td><td>12</td><td>18</td><td>15</td><td>38</td><td>32</td><td>35</td></tr><tr><td>Scratches</td><td>290</td><td>117</td><td>71</td><td>14</td><td>16</td><td>15</td><td>36</td><td>34</td><td>35</td></tr><tr><td>Spots</td><td>58</td><td>620</td><td>208</td><td>14</td><td>16</td><td>15</td><td>36</td><td>34</td><td>35</td></tr></table>
287
+
288
+ # B TRAINING DETAILS
289
+
290
+ DT-GAN. We follow the training scheme as described in StarGAN v2 with minor modifications. To fit the model on a single Nvidia GTX TITAN X, the batch size is reduced to four while the model is still trained for 100,000 iterations. The training time is about three and a half days on the dedicated GPU with the modified network architecture2 and loss functions mentioned in Section 3 in PyTorch (Paszke et al., 2017). We set $\lambda _ { \mathrm { s t y } } = 1$ , $\lambda _ { \mathrm { d s } } = 1$ , $\lambda _ { \mathrm { c y c } } = 1$ , $\lambda _ { \mathrm { c o n . c y c } } = 1$ , $\lambda _ { \mathrm { c l s } } = 1$ and $\lambda _ { \mathrm { B G . c l s } } = 1$ for the SDI dataset. All other design choices remain the same as in StarGAN v2.
291
+
292
+ Classifiers. We train all the classifiers that use ResNet-50 as backbone for 100 epochs with the SGD optimizer (Ruder, 2016) and batch size 256. The initial learning rate is 0.001, momentum is 0.9 and weight decay is 1e-4. A learning rate scheduler is set to reduce the learning rate by factor of 0.1 when the validation loss stops decreasing for 5 epochs. The same setting also applies to EfficientNet-b4, except the batch size is reduced to 128. Although DT-GAN can synthesize realistic defective samples, we notice that there still exists a domain gap between the generated samples and the real samples. To explore the full potential of the generated samples, we attach an auxiliary source classifier to distinguish between synthetic and real samples. Then, this classifier is connected to the backbone (e.g. ResNet-50) through a Gradient Reversal Layer. With the help of the Gradient Reversal Layer, the backbone is forced to extract the shared features between synthetic and real samples, which ensures all training samples are effectively learned.
293
+
294
+ ![](images/2b5df2b8d264369f1ee04ca1e3d7919ee1d3d69e7370aa9deec145bb6941e15e.jpg)
295
+ Figure 7: Overview of the SDI dataset.
296
+
297
+ We design a two-layer perceptron that connects to the average pooling layer in ResNet-50 as shown in Figure 8. Note that the usual fully connected layer after the average pooling in ResNet-50 remains the same and is not affected by the extra branch we added. Inspired by Chen et al. (2018), a threelayer perceptron is used for EfficientNet-b4 instead as shown in Figure 9. Its layers are initialized with a random normal distribution, where the standard deviation is set to 0.01 for the first two layers and 0.05 for the output layer. The biases for all layers are set to 0.
298
+
299
+ ![](images/5876fcb93af3f0aad7fc6536e733bff52799290b671bdeef4fd81bf21ab172fb.jpg)
300
+ Figure 8: ResNet-50 with GRL.
301
+
302
+ ![](images/79d423c36937100d387ec0e803940f1adbc96236a1a0b915320ec3741d5f7095.jpg)
303
+ Figure 9: EfficientNet-b4 with GRL.
304
+
305
+ # C EVALUATION SETUP
306
+
307
+ Generated samples from DT-GAN. DT-GAN requires images as input for generating synthetic data. At test time, we translated each Normal image in the SDI dataset into four defective images: two with Scratches and two with Spots. The translations were performed by two subnetworks: by the mapping network $M$ using random noise (‘latent-guided’) and by the style-content encoder $E$ using a reference image (‘reference-guided’). We first randomly sampled one latent code for each defective foreground domain. Similarly, we also randomly sampled one reference image from the training set for each defective foreground domain. The corresponding style codes and defect contents were then produced by the two subnetworks respectively and fed to the generator for target image generation.
308
+
309
+ We conducted classification experiments separately on images generated from the two subnetworks and a mixture set of both (i.e. $50 \%$ from each subnetwork). Experiments show consistent gains of using synthetic images generated from DT-GAN (Table 8). We observe that the latent-guided synthetic images in general perform better than the reference-guided one, while the mixture set provides more stable results with regard to the standard deviation. Presumably the mixture set benefits from the combination of samples from reference-guided synthesis, which are well aligned with the original defect distribution, and the samples from latent-guided synthesis, i.e. from random noise, which adds novel but plausible defects to the dataset. In the main text, we report the results of the mixture set for all experiments, including the quantitative evaluation of DT-GAN.
310
+
311
+ Table 8: Classification results with regard to the synthetic images generated from the two subnetworks and the mixture set.
312
+
313
+ <table><tr><td rowspan="2">Dataset Size</td><td colspan="4">All</td></tr><tr><td>Trad-Aug</td><td>Latent</td><td>Reference</td><td>Mix</td></tr><tr><td>4500</td><td>12.75±0.61</td><td>10.72±0.96</td><td>11.48±0.88</td><td>11.04±0.76</td></tr><tr><td>6600</td><td>13.07±1.57</td><td>10.34±1.86</td><td>11.55±1.64</td><td>10.60±0.48</td></tr><tr><td>12000</td><td>12.05±0.81</td><td>9.90±1.26</td><td>10.40±0.99</td><td>9.90±0.69</td></tr><tr><td>18600</td><td>12.37±0.32</td><td>11.04±1.26</td><td>12.12±0.75</td><td>10.21±0.96</td></tr></table>
314
+
315
+ Frechet inception distance (FID) and Kernel inception distance (KID). ´ We used the feature vectors from the last average pooling layer of the ImageNet pretrained Inception-V3 to calculate both scores. For each test image from the Normal domain, we translated it into a synthetic defective image of each defect domain. The style codes and contents for the translation were acquired in two ways: by randomly sampling from the standard normal distribution and by randomly sampling a reference image from the train set of a defect domain. To calculate the FID and KID score, we generated 4000 defective samples per product per defect domain for each way of guidance, and formed the mixture set by randomly sampling 2000 images per product per defect domain from each way. The reported FID and KID scores were then computed between the defective images in the training set and the mixture set of synthetic defective images. The same procedure was applied when computing scores on single product subsets of the SDI dataset. For example, for product A, we calculated the scores between the defective image of product A in the training set and the mixture set of synthetic defective images of product A.
316
+
317
+ # D NETWORK ARCHITECTURE
318
+
319
+ In this section, we provide the architectural details of all four modules in DT-GAN.
320
+
321
+ Table 9: Generator architecture.
322
+
323
+ <table><tr><td colspan="7">(a)Encoder</td></tr><tr><td>Layer</td><td colspan="2">Resample</td><td>Norm</td><td colspan="3">Output Shape</td></tr><tr><td>Image x</td><td colspan="2"></td><td>-</td><td colspan="3">128 × 128×3</td></tr><tr><td>Conv 1×1</td><td colspan="2"></td><td>-</td><td colspan="3">128 ×128 ×128</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td>IN</td><td colspan="3">64× 64×256</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td>IN</td><td colspan="3">32 × 32 × 512</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td>IN</td><td colspan="3">16 × 16 × 512</td></tr><tr><td>ResBlk</td><td colspan="2"></td><td>IN</td><td colspan="3">16 ×16× 512</td></tr><tr><td>ResBlk</td><td colspan="2"></td><td>IN</td><td colspan="3">16 ×16 × 512</td></tr><tr><td colspan="3">(b) Background Decoder</td><td colspan="5">(c) Foreground Decoder</td></tr><tr><td>Layer</td><td>Resample</td><td>Norm</td><td> Output Shape</td><td>Layer</td><td>Resample Norm</td><td>Output Shape</td></tr><tr><td>Input</td><td></td><td>-</td><td>16 × 16 × 448</td><td>Input ResBlk</td><td></td><td>16 × 16 × 64</td></tr><tr><td>ResBlk</td><td></td><td>IN 16 ×16× 448 16 ×16× 512</td><td>ResBlk</td><td></td><td>AdaIN</td><td>16 ×16× 64</td></tr><tr><td>ResBlk</td><td></td><td>IN</td><td></td><td>=</td><td>AdaIN</td><td>16 × 16 × 256</td></tr><tr><td>ResBlk</td><td>=</td><td>IN</td><td>16 ×16 × 512</td><td>ResBlk</td><td>AdaIN</td><td>16 ×16× 256</td></tr><tr><td>ResBlk</td><td>Upsample</td><td>IN</td><td>32 × 32×512</td><td>ResBlk Upsample ResBlk</td><td>AdaIN</td><td>32 × 32 × 256</td></tr><tr><td>ResBlk ResBlk</td><td>Upsample Upsample</td><td>IN IN</td><td>64 × 64× 256 128 × 128× 448</td><td>Upsample</td><td>AdaIN</td><td>64×64×128</td></tr><tr><td></td><td></td><td></td><td>ResBlk</td><td>Upsample</td><td>AdaIN</td><td>128 ×128 × 64</td></tr><tr><td colspan="7">(d) Fusion</td></tr><tr><td>Layer</td><td colspan="2">Resample</td><td colspan="2">Norm</td><td colspan="2">Output Shape</td></tr><tr><td>Input</td><td colspan="2"></td><td colspan="2"></td><td colspan="2">128 × 128 × (448 + 64)</td></tr><tr><td>Conv 1×1</td><td colspan="2"></td><td colspan="2"></td><td colspan="2">128 × 128× 3</td></tr></table>
324
+
325
+ Table 10: Mapping network architecture.
326
+
327
+ <table><tr><td>Layer</td><td></td><td>Activation</td><td></td><td></td><td></td><td>Output Shape</td></tr><tr><td>Latent z</td><td></td><td>=</td><td></td><td></td><td></td><td>16</td></tr><tr><td>Linear</td><td></td><td>ReLU</td><td></td><td></td><td></td><td>512</td></tr><tr><td>Linear</td><td></td><td>ReLU</td><td></td><td></td><td></td><td>512</td></tr><tr><td>Linear</td><td></td><td>ReLU</td><td></td><td></td><td></td><td>512</td></tr><tr><td>Linear</td><td></td><td>ReLU</td><td></td><td></td><td></td><td>512</td></tr><tr><td colspan="3">(b) Style Code</td><td colspan="5">(c) Content</td></tr><tr><td>Layer</td><td>Activation</td><td> Output Shape</td><td>Layer</td><td>Resample Activation</td><td></td><td>Noise</td><td> Output Shape</td></tr><tr><td>Input</td><td>=</td><td>512</td><td>Input</td><td></td><td></td><td>=</td><td>512</td></tr><tr><td>Linear</td><td>ReLU</td><td>512</td><td>Reshape</td><td></td><td>-</td><td>-</td><td>1×1×512</td></tr><tr><td>Linear</td><td>ReLU</td><td>512</td><td>ResBlk</td><td>Upsample</td><td>IN</td><td>True</td><td>2×2×512</td></tr><tr><td>Linear</td><td>ReLU</td><td>512</td><td>ResBlk</td><td>Upsample</td><td>IN</td><td>True</td><td>4×4×512</td></tr><tr><td>Linear</td><td>1</td><td>64</td><td>ResBlk</td><td>Upsample</td><td>IN</td><td>True</td><td>8×8×256</td></tr><tr><td></td><td></td><td></td><td>ResBlk</td><td>Upsample</td><td>IN</td><td>True</td><td>16 ×16×128</td></tr><tr><td></td><td></td><td></td><td>Conv 1×1</td><td>=</td><td>IN</td><td>True</td><td>16 × 16× 64</td></tr></table>
328
+
329
+ Generator (Table 9). For the SDI dataset, the encoder part of the generator consists of three downsampling blocks and two intermediate blocks (Table 9 (a)), all of them are pre-activation residual units (He et al., 2016b). Then the encoded feature map is split channel-wise into background (Table 9 (b)) and foreground (Table 9 (c)). Both of them are then carried through separate decoders. We use the instance normalization (IN) and the adaptive instance normalization (AdaIN) as indicated. The style code is injected into all AdaIN layers to modulate the affine transformations. Note that
330
+
331
+ Table 11: Style-content encoder and discriminator architectures.
332
+
333
+ <table><tr><td colspan="6">(a)SharedLayers</td></tr><tr><td>Layer</td><td colspan="2">Resample</td><td colspan="2">Norm</td><td>Output Shape</td></tr><tr><td>Input x</td><td colspan="2"></td><td colspan="2"></td><td>128 × 128 ×3</td></tr><tr><td>Conv 1×1</td><td colspan="2">1</td><td colspan="2"></td><td>128 × 128 × 64</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td colspan="2"></td><td>64 × 64× 256</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td colspan="2"></td><td>32 × 32×512</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td colspan="2"></td><td>16 ×16 × 512</td></tr><tr><td>(b) Style Code /Discriminator and BG Classifier</td><td></td><td></td><td colspan="3">(c) Content /FG Classifier</td></tr><tr><td>Layer</td><td>Resample Norm</td><td>Output Shape</td><td>Layer</td><td>Resample Norm</td><td>Output Shape</td></tr><tr><td>Input</td><td>-</td><td>16 ×16× 512</td><td>Input</td><td></td><td>16 ×16× 512</td></tr><tr><td>ResBlk</td><td>AvgPool</td><td>8×8×512</td><td colspan="2">LReLU</td><td>16 ×16 × 512</td></tr><tr><td>ResBlk</td><td>AvgPool</td><td>4×4×512</td><td colspan="2">Conv 1×1*K</td><td>16×16×64*K</td></tr><tr><td>LReLU</td><td></td><td>4×4×512</td><td colspan="2"></td><td></td></tr><tr><td>Conv 4×4</td><td></td><td>1×1×512</td><td colspan="2"></td><td></td></tr><tr><td>LReLU</td><td></td><td>1×1×512</td><td colspan="4"></td></tr><tr><td>Reshape</td><td></td><td>512</td><td colspan="4"></td></tr><tr><td>Linear *K</td><td></td><td>D*K</td><td colspan="4"></td></tr></table>
334
+
335
+ AdaIN is only used in the foreground decoder. The outputs of both decoders are only fused in the end (Table 9 (d)).
336
+
337
+ Mapping Network (Table 10). The mapping network consists of four shared linear layers (Table 10 (a)) and two separate branches: one for generating style codes (Table 10(b)) and one for contents (Table 10(c)). Each of them is further divided into $K$ output branches, where $K$ denotes the number of domains. The dimension of the input, the output style code and the output content is set to 16, 64, and $1 6 \times 1 6 \times 6 4$ , respectively. The latent code is sampled from the standard normal distribution. Note that we apply per-pixel noise after each convolution in the content branch, which we have observed to increase the diversity of generated defects significantly (cf. Figure 5 (g)).
338
+
339
+ Style-Content Encoder (Table 11). The style-content encoder consists of a CNN (Table 11 (a)) with two branches (Table 11 (b) and (c)) as in the mapping network. Each branch has $K$ outputs, where $K$ is the number of domains. Three pre-activation residual blocks are shared among two branches, followed by a specific structure for each branch. The output dimension $D$ in Table 11 is set to 64, which denotes the dimension of the style code.
340
+
341
+ Discriminator (Table 11). The discriminator is a multi-task discriminator with two auxiliary classifiers for the foreground content and the background. The structure is almost identical to the stylecontent encoder, except $D$ is set to 1 for real/fake classification. The background classifier acts in parallel to final linear layer in Table 11 (b) and provides the logits for background classification. The foreground classifier instead acts on top of the output in Table 11 (c) and four more pre-activation residual layers are applied to encode the content into logits for foreground content classification.
342
+
343
+ # E ADDITIONAL RESULTS
344
+
345
+ # E.1 ADDITIONAL RESULTS ON THE SDI DATASET
346
+
347
+ We provide additional reference-guided image synthesis results on the SDI dataset in Figure 10. We demonstrate all the possible transfers among all foreground domains. Both style codes and contents are extracted from the reference images. To be noted that DT-GAN can append and remove foreground defects not only onto Normal samples but also to defective samples. For example, in the fifth column of Figure 10, the original scratch in the source image is removed and only the defects from the reference images are presented in the output images.
348
+
349
+ Besides, we present additional evaluations showing the effectiveness of our synthetic data according to Table 3. As seen in Table 12, the synthetic images from DT-GAN also boost the performance in single product classifiers, where the classifiers were trained on the subset of images for one product (A, B, C) instead of the full dataset (ABC).
350
+
351
+ ![](images/ba0e2234e87b25b63cc95ac4e5644f8da2a00a1e319667a7cf9fa0a32eed56c7.jpg)
352
+ Figure 10: Reference-guided image synthesis results on the SDI dataset. The first row and the first column are the real images sampled from the dataset, while the rest are synthetic images generated by the proposed DT-GAN. Our model provides translations between different foreground domains (Normal, Scratches and Spots) with styles and contents extracted from reference images while the backgrounds from source images are well preserved.
353
+
354
+ As discussed in Section 4.2, we assumed that the data-insufficiency problem can be mitigated by transferring defects across multiple background products. To examine if this assumption holds, we compared the performance of classifiers trained on synthetic images with defects from a specific source (vA, vB, vC) to classifiers trained on images with defects from all products (vABC). The results on the cross-domain effect with regard to different sizes of the training set are shown in Table 13. We again notice that using our synthetic data is beneficial. Moreover, in most cases the performance is further improved by exploiting cross-domain information (i.e. by transferring defects from other products). We interpret this as support for our assumption and the practical usefulness of our method in the real-world scenario. The case of cross-domain image synthesis when the desired combination is not presented in the training set is covered in the study on the MVTec Anomaly Detection dataset (Bergmann et al., 2019) (see Appendix E.4).
355
+
356
+ Table 12: Quantitative results for DT-GAN as a data augmentation method to train general and single product classifiers. The left-most column indicates the number of samples per class, including all images from the training set plus increasing amounts of synthetic images. In the first row, 20A refers to the case of 20 real defective samples for product A, while All refers to the full training set.
357
+
358
+ <table><tr><td rowspan="3">Dataset Size</td><td colspan="8">20A</td></tr><tr><td colspan="2">A</td><td colspan="2">B</td><td colspan="2">C</td><td colspan="2">ABC</td></tr><tr><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td></tr><tr><td>4500</td><td>35.09±2.62 27.64±3.12</td><td></td><td>7.8±1.48</td><td>5.6±1.67</td><td></td><td></td><td>15.24±1.90 13.14±1.7015.55±0.63 14.28±1.25</td><td></td></tr><tr><td>6600</td><td>39.64±2.28 27.64±1.65</td><td></td><td>8.8±1.64</td><td>6.2±1.64</td><td>15.81±1.731</td><td></td><td></td><td>12.38±1.6516.69±0.76 14.41±3.12</td></tr><tr><td>12000</td><td>34.18±4.39 28.55±7.32</td><td></td><td>5.8±0.45</td><td>5.6±1.14</td><td></td><td></td><td>16.19±1.17 10.86±1.28 16.95±1.02 14.22±1.53</td><td></td></tr><tr><td>18600</td><td>39.45±7.06 32.55±5.04</td><td></td><td>7.2±0.84</td><td>5.2±1.10</td><td></td><td></td><td>14.86±0.85 13.14±2.06 16.12±2.19 15.36±0.86</td><td></td></tr><tr><td rowspan="3">Dataset Size</td><td colspan="8">All</td></tr><tr><td>A</td><td></td><td colspan="2">B</td><td colspan="2">C</td><td colspan="2">ABC</td></tr><tr><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td></td><td>Ours</td><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td></tr><tr><td>4500</td><td>16.00±1.041</td><td>10.18±1.75 8.79±0.45</td><td></td><td>5.60±1.51</td><td></td><td></td><td></td><td>17.13±6.62 14.09±2.2712.75±0.61 11.04±0.76</td></tr><tr><td>6600</td><td>14.90±1.38</td><td>10.54±1.22 7.60±1.51</td><td></td><td>6.80±3.11</td><td>15.23±2.33 11.42±0</td><td></td><td></td><td>13.07±1.57 10.60±0.48</td></tr><tr><td>12000</td><td>13.81±2.36</td><td>6.72±1.65 6.80±1.64</td><td></td><td>4.60±0</td><td>16.57±3.20 13.90±2.5712.05±0.81</td><td></td><td></td><td>9.90±0.69</td></tr><tr><td>18600</td><td>13.63±2.22 10.54±2.45 6.80±1.79</td><td></td><td></td><td></td><td></td><td></td><td></td><td>4.99±1.87 15.62±0.85 11.61±1.24 12.37±0.32 10.21±0.96</td></tr></table>
359
+
360
+ Table 13: Cross-domain effect on single product classifiers trained with reference-guided synthetic images at all scales. Note that here A, B and C stand for 3 products in the SDI dataset while vA, vB, vC and vABC indicate the defects are copied from which reference set.
361
+
362
+ <table><tr><td rowspan="2">Dataset Size</td><td colspan="5">A</td></tr><tr><td>Trad-Aug</td><td>vA</td><td>vB</td><td>vC</td><td>vABC</td></tr><tr><td>4500</td><td>16.00±1.04</td><td>12.90±2.61</td><td>13.08±1.65</td><td>14.90±2.46</td><td>15.27±3.49</td></tr><tr><td>6600</td><td>14.90±1.38</td><td>13.99±1.89</td><td>11.26±1.04</td><td>14.36±4.04</td><td>16.00±2.85</td></tr><tr><td>12000</td><td>13.81±2.36</td><td>11.81±2.65</td><td>12.72±2.87</td><td>11.99±1.63</td><td>11.09±3.49</td></tr><tr><td>18600</td><td>13.63±2.22</td><td>12.72±5.22</td><td>14.36±3.83</td><td>14.18±5.05</td><td>13.81±8.56</td></tr><tr><td>Dataset</td><td colspan="5">B</td></tr><tr><td>Size</td><td>Trad-Aug</td><td>vA</td><td>vB</td><td>vC</td><td>VABC</td></tr><tr><td>4500</td><td>8.79±0.45</td><td>7.80±2.15</td><td>5.60±1.14</td><td>10.19±0.84</td><td>6.79±1.30</td></tr><tr><td>6600</td><td>7.60±1.51</td><td>6.80±1.65</td><td>7.80±1.10</td><td>8.00±2.34</td><td>6.00±1.41</td></tr><tr><td>12000</td><td>6.80±1.64</td><td>6.40±1.34</td><td>6.60±1.52</td><td>6.59±1.34</td><td>5.60±1.34</td></tr><tr><td>18600</td><td>6.80±1.79</td><td>6.19±1.78</td><td>4.40±1.14</td><td>6.60±1.95</td><td>5.99±1.58</td></tr><tr><td>Dataset</td><td colspan="5">C</td></tr><tr><td>Size</td><td>Trad-Aug</td><td>vA</td><td>VB</td><td>vC</td><td>vABC</td></tr><tr><td>4500</td><td>17.14±4.62</td><td>14.85±0.52</td><td>16.76±2.58</td><td>13.90±1.98</td><td>12.00±1.59</td></tr><tr><td>6600</td><td>15.23±2.33</td><td>13.14±1.24</td><td>13.90±2.29</td><td>14.28±1.34</td><td>12.57±1.57</td></tr><tr><td>12000</td><td>16.57±3.20</td><td>13.14±2.81</td><td>11.23±0.80</td><td>14.85±1.73</td><td>11.42±0.96</td></tr><tr><td>18600</td><td>15.62±0.85</td><td>13.71±1.73</td><td>15.99±6.75</td><td>12.57±3.26</td><td>12.95±2.98</td></tr></table>
363
+
364
+ # E.2 ADDITIONAL FID AND KID RESULTS ON THE SDI DATASET
365
+
366
+ We provide additional results in the case of training GANs with augmentation methods in Table 14. Augmentation methods like ADA (Karras et al., 2020a) or DiffAug (Zhao et al., 2020) are proposed to adapt GAN training to limited data. We applied these augmentation methods to StyleGAN v2 and BigGAN, because these state-of-art image synthesis methods are not optimized for small dataset. However, incorporating the augmentation methods in training GANs on the SDI dataset is not always beneficial. The performance of StyleGAN v2 is largely degraded when using ADA, potentially due to the conflict between augmentation methods and the decentralized location of defects—in the SDI dataset, defects can occur anywhere on the surface. This is in contrast to datasets that were used to evaluate the aforementioned augmentation methods in GANs, where the objects are centralized (e.g., ImageNet (Deng et al., 2009), Cifar (Krizhevsky & Hinton, 2009)) and their attributes (e.g., beard, eye glasses in CelebA (Liu et al., 2015)) only occur in specific images parts.
367
+
368
+ Table 14: Quantitative comparison of DT-GAN with baseline image synthesis methods using FID and KID. Note that the reported values are not comparable between columns, because they are calculated on different training sets. The scores of StarGAN v2 on single products are omitted because generating images with specified background is not possible due to its network design.
369
+
370
+ <table><tr><td rowspan="2">Method</td><td colspan="4">FID↓</td><td colspan="4">KID↓</td></tr><tr><td>A</td><td>B</td><td>C</td><td>All</td><td>A</td><td>B</td><td>C</td><td>All</td></tr><tr><td>Mokady et al. (2020)</td><td>68.69</td><td>66.90</td><td>36.21</td><td>58.63</td><td>0.050</td><td>0.036</td><td>0.030</td><td>0.036</td></tr><tr><td>StarGAN v2</td><td>-</td><td>-</td><td>1</td><td>37.70</td><td>1</td><td>-</td><td>1</td><td>0.013</td></tr><tr><td>StyleGAN v2</td><td>90.10</td><td>52.95</td><td>138.09</td><td>35.34</td><td>0.072</td><td>0.027</td><td>0.186</td><td>0.013</td></tr><tr><td>StyleGAN v2 + ADA</td><td>149.66</td><td>42.75</td><td>135.69</td><td>76.16</td><td>0.138</td><td>0.019</td><td>0.191</td><td>0.055</td></tr><tr><td>BigGAN</td><td>235.66</td><td>192.89</td><td>193.61</td><td>151.43</td><td>0.248</td><td>0.199</td><td>0.276</td><td>0.115</td></tr><tr><td>BigGAN + DiffAug</td><td>218.74</td><td>134.41</td><td>270.89</td><td>155.88</td><td>0.220</td><td>0.121</td><td>0.378</td><td>0.099</td></tr><tr><td>Ours</td><td>58.43</td><td>36.44</td><td>22.68</td><td>29.73</td><td>0.025</td><td>0.013</td><td>0.012</td><td>0.009</td></tr></table>
371
+
372
+ # E.3 ABLATION STUDY WITH REGARD TO FID AND KID SCORES
373
+
374
+ We report the FID and KID scores of the ablation study in Table 15. We notice that both subnetworks show positive correlation to each modification except for structural change as in (a) and (e) . Among the two subnetworks, the reference-guided subnetwork outperforms the latent-guided one in the beginning, which is due to the fact that transferring existing contents is easier than generating them from random noise. This effect is also observed in Figure 5. However, the performance of the latentguided subnetwork improves significantly after applying per-pixel noise injection. The subnetwork can now output non-deterministic foreground contents even for a fixed input vector which results in better visual quality and higher diversity of generated defects. In the main text, the scores of the mixture set are reported.
375
+
376
+ Table 15: Ablation study with regard to FID and KID scores.
377
+
378
+ <table><tr><td rowspan="2"></td><td colspan="3">FID↓</td><td colspan="3">KID↓</td></tr><tr><td>Latent</td><td>Reference</td><td>Mix</td><td>Latent</td><td>Reference</td><td>Mix</td></tr><tr><td>(a) Baseline StarGAN v2</td><td>37.73</td><td>37.99</td><td>37.70</td><td>0.013</td><td>0.013</td><td>0.013</td></tr><tr><td>(b)+ Style-Content branches</td><td>43.90</td><td>32.61</td><td>33.36</td><td>0.017</td><td>0.011</td><td>0.011</td></tr><tr><td>(c)+Foreground classifier</td><td>37.14</td><td>32.34</td><td>27.69</td><td>0.014</td><td>0.011</td><td>0.008</td></tr><tr><td>(d) + Background classifier</td><td>34.12</td><td>32.50</td><td>30.23</td><td>0.011</td><td>0.011</td><td>0.010</td></tr><tr><td>(e)+ Separately decoding foreground and background in G</td><td>48.52</td><td>38.11</td><td>34.79</td><td>0.017</td><td>0.015</td><td>0.011</td></tr><tr><td>(f) + Anchor foreground domain (e.g. No rmal)</td><td>43.66</td><td>37.45</td><td>32.15</td><td>0.019</td><td>0.015</td><td>0.011</td></tr><tr><td></td><td>33.05</td><td></td><td></td><td>0.009</td><td>0.011</td><td></td></tr><tr><td>(g)+ Noise injection in Mapping Network</td><td></td><td>34.42</td><td>29.73</td><td></td><td></td><td>0.009</td></tr></table>
379
+
380
+ # E.4 ADDITIONAL RESULTS ON THE MVTEC ANOMALY DETECTION DATASET
381
+
382
+ The MVTec Anomaly Detection dataset (Bergmann et al., 2019) contains 15 different object and texture categories for anomaly detection. The dataset is formed of non-defective image for training and both non-defective and defective images with various kinds of defects for testing. The pixel-level annotations of all defective images are also provided. It is worth noting that the MVTec Anomaly Detection dataset is relatively small scale in number of images, where the number of training images is ranging from 60 to 391. Moreover, the number of defective images for each defect category in the test set is varying only from 8 to 30, which is relatively limited considering the sophisticated pattern of defects.
383
+
384
+ We conducted image synthesis experiments on a subset of MVTec Anomaly Detection dataset, where we selected four texture categories: Carpet, Leather, Wood and Tile for our targeted scenario i.e. surface defects. Furthermore, we aggregated some of the original defect types defined in the MVTec Anomaly Detection dataset into scratches and spots according to their visual appearance. We then simply added the subset of the MVTec Anomaly Detection dataset to the training set together with the SDI dataset for training DT-GAN. Details of the resulting dataset are shown in Table 17. Note that the small scale of available data posts a major challenge for training generative models.
385
+
386
+ Quantitative Evaluation. We present additional quantitative results on the subset of the MVTec Anomaly Detection dataset in Table 16, following the same evaluation setup as described in Appendix C. As shown in Table 16, our method achieves the best scores in Carpet and Wood, which supports our claim that DT-GAN generates synthetic images with higher fidelity and more diverse defect. However, we also observe that StyleGAN v2 seems to outperform our method in Leather and Tile.
387
+
388
+ Please note that FID and KID are not optimized to evaluate such a small dataset, there the results should only be interpreted together with the qualitative results.
389
+
390
+ Note the we again omit the FID and KID of StarGAN v2 because it is not cable of generating images for a specified product due to the ‘identity-shift’, which is also explained in detail in the qualitative evaluation.
391
+
392
+ Table 16: Quantitative comparison of DT-GAN with baseline image synthesis methods using FID and KID. Note that the reported values are not comparable between columns, because they were calculated on different training sets.
393
+
394
+ <table><tr><td rowspan="2">Method</td><td colspan="4">FID↓</td><td colspan="4">KID↓</td></tr><tr><td>Carpet</td><td>Leather</td><td>Tile</td><td>Wood</td><td>Carpet</td><td>Leather</td><td>Tile</td><td>Wood</td></tr><tr><td>Mokady (2020)</td><td>41.87</td><td>60.26</td><td>275.12</td><td>81.71</td><td>0.04</td><td>0.03</td><td>0.29</td><td>0.04</td></tr><tr><td>StarGAN v2</td><td>1</td><td></td><td></td><td></td><td>1</td><td></td><td>=</td><td>1</td></tr><tr><td>StyleGAN v2</td><td>51.37</td><td>51.60</td><td>225.96</td><td>140.01</td><td>0.05</td><td>0.03</td><td>0.23</td><td>0.12</td></tr><tr><td>BigGAN + DiffAug</td><td>34.47</td><td>101.70</td><td>391.54</td><td>113.32</td><td>0.03</td><td>0.07</td><td>0.42</td><td>0.07</td></tr><tr><td>Ours</td><td>22.79</td><td>86.13</td><td>321.35</td><td>75.83</td><td>0.01</td><td>0.07</td><td>0.36</td><td>0.03</td></tr></table>
395
+
396
+ Qualitative Evaluation. For qualitative results, we again discuss the ‘latent-guided’ and ‘referenceguided’ synthesis separately.
397
+
398
+ We present the ‘latent-guided’ image synthesis results of StyleGAN v2 in Figure 11 and Figure 12 and BigGAN in Figure 13 and Figure 14. The results are acquired by training one model for each product and then generating 16 images from randomly sampled latent codes from each of them. As pointed out in Section 4.1.2, both methods can not adapt well on small dataset. They suffer from model collapsing and show signs of overfitting by generating images similar to the training data. For example, StyleGAN v2 generates images either with no clear defect or identical to the training set (e.g., Leather in Figure 11 and Product B in Figure 12). The overfitting we observe here also explains the better FID and KID scores in Table 16. For Tile, we can see clear signs of mode collapse in the generated Tile images of StyleGAN v2. Similarly, BigGAN produces images with single mode and abnormal patterns (e.g., grid structure and gray edges). Unlike StyleGAN v2 and BigGAN, StarGAN v2 and our method both require images as input (i.e. Source). Therefore, we randomly sampled two Normal images and applied eight defects which are generated from randomly sampled latent codes to each of them. As seen in Figure 15 and Figure 16, StarGAN v2 fails to preserve the background from the given input images due to the highly entangled FG and BG. Also it fails to generates legit and diverse defects without separately modeling the style and the content. In contrast to aforementioned methods, our DT-GAN produces images with higher fidelity and more diversity in defect patterns as shown in Figure 17 and Figure 18. We believe this again prove the importance of style-content separation and FG/BG disentanglement, which we introduce in Section 3.1.
399
+
400
+ For ‘reference-guided’ image synthesis, the results of Mokady et al. (2020) are shown in Figure 19 and Figure 20 while the results of StarGAN v2 are in Figure 21 and Figure 22. We can observe a clear shift in color in all the outputs from Mokady et al. (2020). Moreover, Mokady et al. (2020) can only transfer content between two domains. In order to perform translation from a non-defective sample to a defective one, we trained a model for each type of defect and for each product. This sums up to be 13 models (Scratches and Spots for 6 categories and Scratches only for Tile). The results from the intended use within one background domain can be found on the diagonal and are marked in red in both Figure 19 and Figure 20. We still show the images that we feed in images from other background domains. As expected, the model then fails to preserve the background of given source images and introduce artifacts to the outputs. Similarly, StarGAN v2 does not preserve the background from the input images. Without style-content separation and FG/BG disentanglement, we observe that StarGAN v2 encodes the background characteristics together with the foreground content of the reference images, which results in identity-shits in its output images. Moreover, the output images either show no clear defect or contain abnormal patterns which sabotage the fidelity. On the contrary, our method can faithfully transfer the foreground content of reference images across given background of different products as shown in Figure 23 and Figure 24, which demonstrate the effectiveness of the style-content separation and FG/BG disentanglement we introduced in Section 3.1.
401
+
402
+ It is also worth noting that our method can perform cross-domain image synthesis even the desired combination is not presented in the training set. We demonstrate this on product Tile, which only has images with Scratches but no Spots. As shown in Figure 18 and Figure 24, DT-GAN can generated spots one given Tile images. However, this kind of transformation is most useful when the desired combination is reasonable for the downstream applications.
403
+
404
+ Limitation and Future Work. We have demonstrated the feasibility of the proposed DT-GAN by incorporating more products from the MVTec Anomaly Detection dataset in our training procedure. Intensive experiments have shown that the generated images from DT-GAN yielded better results compared to the baseline image synthesis methods. However, we noticed that despite the diverse patterns of the generated defects, DT-GAN tends to apply the styles learned from the SDI dataset also to the samples from the MVTec Anomaly Detection dataset. For example, we can observe some ”halo” effects in Leather and Wood in Figure 18 and some of the generated scratches in Figure 17 and Figure 23 are rather weakly pronounced. We hypothesize this can be counteracted by explicitly localizing the defect and enforcing the model to learn conditional relationships between ‘styles’ and different backgrounds. We aim to address these issues in future work.
405
+
406
+ Table 17: Overview of our formation of the MVTec Anomaly Detection sub-dataset. The first column represents the original defect types in the MVTec Anomaly Detection dataset while the first row stands for the defect types in our targeted scenario. We list the ID of samples we took from the MVTec Anomaly Detection dataset and show the number of samples in row Sum.
407
+
408
+ <table><tr><td colspan="3">(a) Carpet</td></tr><tr><td></td><td>Scratches</td><td>Spots</td></tr><tr><td>Color</td><td>011,012,014,016, 017</td><td>000,003,004,007,015,018</td></tr><tr><td>Thread</td><td>000-018</td><td></td></tr><tr><td>Hole</td><td>-</td><td>000 - 016</td></tr><tr><td>Sum</td><td>24</td><td>23</td></tr><tr><td colspan="3">(b) Leather</td></tr><tr><td></td><td>Scratches</td><td>Spots</td></tr><tr><td>Color</td><td>001,003,005,007,009,011,013,015,018</td><td>000,002,006,008,010,012,014</td></tr><tr><td>Cut</td><td>000 -018 000 - 006,009 - 016</td><td>-</td></tr><tr><td>Fold Glue</td><td></td><td>000 - 002,005-009,011-015,018</td></tr><tr><td>Poke</td><td>003,009,010,016,017</td><td>000-017</td></tr><tr><td>Sum</td><td></td><td>39</td></tr><tr><td></td><td>48</td><td></td></tr><tr><td colspan="3">(c) Tile</td></tr><tr><td></td><td>Scratches</td><td>Spots</td></tr><tr><td>Crack</td><td>000 - 016</td><td>二</td></tr><tr><td>Sum</td><td>17</td><td>0</td></tr><tr><td colspan="3">(d) Wood</td></tr><tr><td></td><td>Scratches</td><td>Spots</td></tr><tr><td>Color</td><td>003,005</td><td></td></tr><tr><td>Scratch</td><td>001-006,008- 010,013 -016,018- 020</td><td>000 - 016</td></tr><tr><td>Hole</td><td>=</td><td>000 - 004,006-009</td></tr><tr><td>Combined</td><td>008</td><td>001,002,009</td></tr><tr><td>Sum</td><td>19</td><td>12</td></tr></table>
409
+
410
+ # Randomly Sampled Defects (Scratches)
411
+
412
+ ![](images/567f75bf12cbd5a5119634c75240da3d88366422eb7484cba51a63409149e476.jpg)
413
+ Figure 11: Latent-guided image synthesis results of StyleGAN v2 on the SDI dataset and the MVTec AD dataset. We train a model for each product and generate 16 Scratches images from randomly sampled latent codes.
414
+
415
+ ![](images/3f55519405e1df2af7deb5998aea2cd1baa9a5f4eca9816aac99ce93d6637aef.jpg)
416
+ Figure 12: Latent-guided image synthesis results of StyleGAN v2 on the SDI dataset and the MVTec AD dataset. We train a model for each product and generate 16 Spots images from randomly sampled latent codes.
417
+
418
+ ![](images/9af2881df4cd89bcd7f83e40ecac133c4486b383aca6a5f80167e218d4861e0f.jpg)
419
+ Figure 13: Latent-guided image synthesis results of BigGAN with DiffAug on the SDI dataset and the MVTec AD dataset. We train a model for each product and generate 16 Scratches images from randomly sampled latent codes.
420
+
421
+ ![](images/6502d31fa4830920177c7a1201405a5d38fd61293a22fa5cc40cc805b4888a23.jpg)
422
+ Figure 14: Latent-guided image synthesis results of BigGAN with DiffAug on the SDI dataset and the MVTec AD dataset. We train a model for each product and generate 16 Spots images from randomly sampled latent codes.
423
+
424
+ ![](images/753dedb2a88181dd1a02122d6d4012b9e01f9fd382ccd9580c8645207ed06d8d.jpg)
425
+ Figure 15: Latent-guided image synthesis results of StarGAN v2 on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Scratches. Note that without the style-content separation and the FG/BG disentanglement, StarGAN v2 not only fails to preserve the background from the given Source image but also fail to generates legit defects.
426
+
427
+ ![](images/49e2bc6b1e4d4de05a60e2ef2fb4992d1dc00bdd8bcc62cfa38819c364a1a72e.jpg)
428
+ Figure 16: Latent-guided image synthesis results of StarGAN v2 on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Spots. Note that without the style-content separation and the FG/BG disentanglement, StarGAN v2 not only fails to preserve the background from the given Source image but also fail to generates legit defects.
429
+
430
+ ![](images/d7665bc9189f97191cb363ff43243d45d9c0eed07ddb8d132a1899df30a87129.jpg)
431
+ Figure 17: Latent-guided image synthesis results of DT-GAN on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Scratches. Note the our model takes input Source images as background and only synthesizes the foreground defects from randomly sampled latent code compared to StyleGAN v2 and BigGAN.
432
+
433
+ ![](images/6dc33723b61a8a29ea99523303f759e2ec80cca613f5db714539c271f27d80a8.jpg)
434
+ Figure 18: Latent-guided image synthesis results of DT-GAN on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Spots. Note the our model takes input Source images as background and only synthesizes the foreground defects from randomly sampled latent code compared to StyleGAN v2 and BigGAN.
435
+
436
+ ![](images/6fbc28db81f825e8f35749ff8c9692af1a0d34358c15a1ea8e335765a76b1ab6.jpg)
437
+ Figure 19: Reference-guided image synthesis results of Mokady et al. (2020) on the SDI dataset and the MVTec AD dataset. We train a model for each product and each defect type. Then we translate Normal images to Scratches by taking the Source as background and applying the foreground defect from Reference to it.
438
+
439
+ ![](images/52103c7943c67c62f890f5864b5e34df9520df52349661b703bc363d3ec05466.jpg)
440
+ Figure 20: Reference-guided image synthesis results of Mokady et al. (2020) on the SDI dataset and the MVTec AD dataset. We train a model for each product and each defect type. Then we translate Normal images to Spots by taking the Source as background and applying the foreground defect from Reference to it.
441
+
442
+ ![](images/cb73ee815eca7466279848e34aba2a7625dd3b27655d8dcff88d57a806fdbab6.jpg)
443
+ Figure 21: Reference-guided image synthesis results StarGAN v2 on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Scratches by taking the Source as background and applying the foreground defect from Reference to it. Note that without the style-content separation and the FG/BG disentanglement, StarGAN v2 not only fails to preserve the background from the given Source image but also fail to generates legit defects.
444
+
445
+ ![](images/c0757dd5081906d67150a0b1e7071d90d4070ef9a33fedd3004d5d77e8301ddd.jpg)
446
+ Figure 22: Reference-guided image synthesis results of StarGAN v2 on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Spots by taking the Source as background and applying the foreground defect from Reference to it. Note that without the style-content separation and the FG/BG disentanglement, StarGAN v2 not only fails to preserve the background from the given Source image but also fail to generates legit defects.
447
+
448
+ ![](images/8f5416bea6a57fe53694b7b81ca32fab188b10b5307dd5743801f95cfe3dc61b.jpg)
449
+ Figure 23: Reference-guided image synthesis results DT-GAN on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Scratches by taking the Source as background and applying the foreground defect from Reference to it.
450
+
451
+ ![](images/038273ee81067405ed8edb30707628ce21e36f0f73845fa8004a02f19865a69d.jpg)
452
+ Figure 24: Reference-guided image synthesis results of DT-GAN on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Spots by taking the Source as background and applying the foreground defect from Reference to it.
md/dev/2jUKhUrBxP/2jUKhUrBxP.md ADDED
@@ -0,0 +1,377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Memory-Efficient Fine-Tuning of Compressed Large Language Models via sub-4-bit Integer Quantization
2
+
3
+ Jeonghoon Kim∗ NAVER Cloud jeonghoon.samuel@gmail.com
4
+
5
+ Jung Hyun Lee∗ NAVER Cloud onliwad101@gmail.com
6
+
7
+ Sungdong Kim NAVER Cloud, KAIST AI sungdong.kim@navercorp.com
8
+
9
+ Joonsuk Park NAVER Cloud, NAVER AI Lab, University of Richmond park@joonsuk.org
10
+
11
+ Kang Min Yoo NAVER Cloud, SNU AI Center kangmin.yoo@gmail.com
12
+
13
+ Se Jung Kwon NAVER Cloud sejung.kwon@navercorp.com
14
+
15
+ Dongsoo Lee NAVER Cloud dongsoo.lee@navercorp.com
16
+
17
+ # Abstract
18
+
19
+ Large language models (LLMs) face the challenges in fine-tuning and deployment due to their high memory demands and computational costs. While parameterefficient fine-tuning (PEFT) methods aim to reduce the memory usage of the optimizer state during fine-tuning, the inherent size of pre-trained LLM weights continues to be a pressing concern. Even though quantization techniques are widely proposed to ease memory demands and accelerate LLM inference, most of these techniques are geared towards the deployment phase. To bridge this gap, this paper presents Parameter-Efficient and Quantization-aware Adaptation (PEQA) – a simple yet effective method that combines the advantages of PEFT with quantized LLMs. By updating solely the quantization scales, PEQA can be directly applied to quantized LLMs, ensuring seamless task transitions. Parallel to existing PEFT methods, PEQA significantly reduces the memory overhead associated with the optimizer state. Furthermore, it leverages the advantages of quantization to substantially reduce model sizes. Even after fine-tuning, the quantization structure of a PEQA-tuned LLM remains intact, allowing for accelerated inference on the deployment stage. We employ PEQA-tuning for task-specific adaptation on LLMs with up to 65 billion parameters. To assess the logical reasoning and language comprehension of PEQA-tuned LLMs, we fine-tune low-bit quantized LLMs using a instruction dataset. Our results show that even when LLMs are quantized to below 4-bit precision, their capabilities in language modeling, few-shot in-context learning, and comprehension can be resiliently restored to (or even improved over) their full-precision original performances with PEQA.
20
+
21
+ ![](images/c6597cfef9015347c41f4440e445cb25da68bff3d2ba7355747c52bf6aebd785.jpg)
22
+ Figure 1: Illustration of our proposed PEQA scheme where $A \cdot B$ indicates the element-wise product of $A$ and $B$ . PEQA is memory-efficient fine-tuning method for quantized large language models that updates only the quantization scale while keeping the integer matrix frozen. Notice a significant reduction in memory footprint when full-precision weights are converted into sub-4-bit integers.
23
+
24
+ # 1 Introduction
25
+
26
+ Large language models (LLMs) such as PaLM, LLaMA, and the GPT-series [1–7] have demonstrated unprecedented levels of task-generalization ability in various applications, including dialogue systems, question answering, summarization, and translation [8, 9]. While they can follow instructions and learn to solve tasks via in-context task descriptions or few-shot examples [10], fine-tuning allows LLMs to align their behavior with desirable traits, such as following instructions more precisely [11] or adhering to certain principles [12]. Additionally, fine-tuning can improve the scaling curve by exposing the model to large collections of task-specific instruction datasets, leading to significant performance enhancements in various unseen downstream tasks [13–17]. However, the immense computational cost of fully fine-tuning large-scale models presents challenges for researchers and developers, especially given that LLMs have billions or even trillions of parameters [18].
27
+
28
+ In response, several parameter-efficient fine-tuning (PEFT) methods have been introduced [19–21], which only update a small number of parameters compared to the pre-trained weights of LLMs. PEFT notably reduces the number of learnable parameters, making the fine-tuning of pre-trained LLMs viable by ensuring that the optimizer states’ memory usage becomes negligible. These strategies lead to decreased memory usage during training and more efficient storage and seamless transitions of task-specifically fine-tuned parameters during deployment. Nonetheless, LLMs as a whole still demand significant memory, and further reductions are attainable through model compression. As outlined in Hu et al. [21], for instance, LoRA can cut the memory usage during the fine-tuning of GPT-3 175B from $1 . 2 \mathrm { T B }$ to 350GB. However, the model still requires approximately 350GB of memory for parameters in half-precision floating-point format.
29
+
30
+ Quantization is a favorable method for both compressing and accelerating neural networks by discretizing parameters into low-bit integers while maintaining a shared high-precision scale within each parameter group (e.g., channel or layer). However, during training phases, quantization-aware training (QAT) [22–25] mandates updates for all parameters, rendering it not parameter-efficient. Since post-training quantization (PTQ) [26–29] is executed after training, most existing quantization schemes primarily target the deployment phases. Although PTQ can be integrated with PEFT, when PTQ follows PEFT, the model remains intact during fine-tuning, not decreasing the memory usage. Conversely, if PTQ precedes PEFT, while there’s a reduction in memory usage during fine-tuning, no inference acceleration can be achieved due to the PEFT parameters during deployment.
31
+
32
+ To bridge the gap between PEFT and quantization, we introduce the Parameter-Efficient and Quantization-aware Adaptation (PEQA), a simple yet effective quantization-aware PEFT method. As illustrated in Figure 1, PEQA encompasses two steps: (a) Decomposition (Quantization) where the parameter matrix of each fully-connected layer is decomposed into a matrix of low-bit integers and quantization scales; and (b) Fine-tuning wherein, for each downstream task, the quantization scale is fine-tuned while the integer matrix remains unchanged. For the quantized LLMs, merely updating the quantization scale leverages the advantages of PEQA. As a result, PEQA maintains the merits of PEFT, such as fewer trainable parameters, along with efficient storage and swift switching of task-specific parameters. Concurrently, it provides the benefits of quantization, including reduced
33
+
34
+ DRAM usage during both training and deployment, and inference acceleration due to fewer memory accesses at deployment.
35
+
36
+ Through this, we highlight the following:
37
+
38
+ • We introduce PEQA, a method that fine-tunes only the quantization scales of quantized LLMs, keeping the integer matrix frozen. It bridges the gap between PEFT and quantization, offering advantages such as reduced memory consumption during both training and deployment phases, seamless task transitions, and faster inference. To empirically validate the approach of solely fine-tuning the quantization scale while freezing the integer matrix, we compare the perplexity of LLMs fine-tuned with QAT, PEFT $\left( + \mathrm { P T Q } \right)$ , and PEQA. The results indicate that PEQA delivers competitive performance in comparison to QAT and PEFT $+$ PTQ, even at sub-4-bit precision.
39
+ To assess the scalability and comprehension performance of PEQA, we apply PEQA to taskspecific adaptation and instruction-tuning. Despite the reduction in model size by a factor of 4 to 5, PEQA demonstrates competitive performance up to a 65B LLM when compared to full-precision baselines. The results suggest that even when LLMs are quantized into low-bit precision, the overall comprehension capability of quantized LLMs can be effectively restored to their original performance using PEQA.
40
+
41
+ # 2 Related Work
42
+
43
+ Large Language Models and Alignment Learning. Although LLMs have demonstrated great generalization capabilities through their sheer scales [2, 6, 30] and the emergent mechanism known as in-context learning [1], they still require significant alignment to follow natural language instructions [13], adhere to ethical guidelines or steer towards harmlessness [12], utilize external tools [31], and to be grounded in knowledge to generate truthful answers [16, 32]. In particular, instruction-tuning has been pivotal in enabling LLMs to generalize instruction-following abilities, enabling them to solve seemingly any NLP task with only the description of the task in natural text [13, 33, 34], allowing the models to be accessed in an interactive manner.
44
+
45
+ Parameter-Efficient Fine-Tuning. Fine-tuning leverages the generalization capabilities elicited from the general pretraining to specialize in specific domains and tasks [35, 36] or align the LLM with target behaviors [13]. However, updating parameters in LLMs comes with a high computation cost and minimal compute environment required for gradient computation. As the hyper-scale era makes fine-tuning for LLMs prohibitively expensive, both efficient and effective alternatives to fine-tuning have received considerable attention. Specifically, inspired by the sensitivity of LLMs to prompts [37], a line of works has proposed introducing trainable prompt embeddings prepended to the input text while freezing the original LLM parameters [19, 38, 39]. As another approach, adapter modules [20] introduce task-specific parameters, which are inserted between the pre-existing layers of the model Extending on this adapter-based approach, LoRA [21] employs the concept of low-rank bottleneck modules while demonstrating comparable performance to full fine-tuning. Subsequent works have unified the various versions and diverging approaches to PEFT [40, 41] by formulating them in a single mathematical framework. These parameter-efficient methods have shown comparable performance to full model fine-tuning, presenting a cost-effective and efficient avenue for tailoring LLMs to specific tasks.
46
+
47
+ However, even with the adoption of PEFT, the inherent model size of the LLM remains a challenge to handle. One immediate solution is to apply post-training quantization (PTQ), but its interaction with task-specific parameters is still an area of active research.There have been attempts to integrate PEFT and neural network quantization, including methods like Quadapter [42] and AlphaTuning [43]. Yet, these methods have primarily been explored in smaller models of 1.3B or fewer parameters. Appendix J delineates the distinctions between our method and AlphaTuning.
48
+
49
+ Neural Network Quantization. Neural network quantization consists largely of quantizationaware training (QAT) and PTQ. QAT methods [22–25] basically train not only quantization scales but all the parameters of a full-precision neural network to narrow the performance gap between the full-precision model and its quantized counterpart. Unfortunately, since QAT involves training all the weights of a full-precision network, it is not feasible to apply QAT to LLMs. To quantize LLMs, PTQ techniques tailored to LLMs [26–29, 44, 45] have been presented. Although such PTQ approaches do not require learning all the parameters of an LLM at all, as PTQ occurs after training/fine-tuning LLMs, PTQ cannot allow for compressing the model size during training/fine-tuning LLMs. To reduce the model size even during training/fine-tuning LLMs, researchers have recently focused on combining PEFT with quantization.
50
+
51
+ ![](images/7df181b8c63472039d556a92ba3c3dd756dcd6dd16c76308bb377290ea96fee0.jpg)
52
+ Figure 2: (a) DRAM usage comparison of LLaMA-65B on various tuning methods and (b) perplexity over model size when tuning LLaMA models with LoRA and PEQA on Wikitext2 dataset. The size of a circle indicates the number of trainable parameters. For instance, the LLaMA-65B model with LoRA has a size of 131GB and 10.49M trainable parameters. Otherwise, LLaMA-65B with 4-bit PEQA has a model size of 33GB and $6 . 8 \mathbf { M }$ trainable parameters.
53
+
54
+ # 3 Methodology
55
+
56
+ # 3.1 Problem Setup
57
+
58
+ Memory Demands in Fine-tuning. Given the significant computational demands associated with fully fine-tuning large language models, parameter-efficient fine-tuning (PEFT) methods have been introduced [19–21, 46]. One of the primary goals of PEFT methods is to reduce memory usage of the optimizer state during training, specifically by reducing the number of learnable parameters. While existing PEFT techniques do decrease memory consumption of the optimizer state and also narrow the accuracy gap between full fine-tuning and PEFT, the pre-trained weights of large language models still demand substantial memory space. When applying LoRA [21] to LLaMA-65B, for instance, even though storing optimizer states for trainable parameters consumes only 52MB (only query and value matrices are adapted with a LoRA rank of 4), the model size still occupies a huge portion of DRAM usage due to the frozen FP16 weights of a pre-trained model. To make PEFT more efficient, reducing the model size is an indispensable requisite. Given that LLMs mostly consist of fully-connected layers, compressing the weights of fully-connected layers is a key factor in compressing the model size and thus leading to more efficient PEFT.
59
+
60
+ Inference Latency of Large Language Models. During text generation inference, an autoregressive LLM generates tokens sequentially. A significant portion of the inference latency arises from matrix-vector multiplications, as opposed to matrix-matrix multiplications. Given that the batch size during inference is typically small [27, 28], matrix-vector multiplications tend to be memory-bound. Specifically, accessing global memory, such as DRAM, is expensive on contemporary high-end GPUs. Thus, the number of weights loaded into registers profoundly impacts the speed of multiplication between a matrix and a vector. To decrease the number of weights (subsequently increasing the weights loaded into registers), quantization is a widely researched method for both compressing and speeding up neural networks [29, 44, 47]. While quantization-aware training (QAT) imposes a significant load on both computation and memory, post-training quantization (PTQ) is often viewed as a fallback strategy among traditional quantization techniques to enhance the generation latency of LLMs. To both accelerate LLM inference and retain all advantages of PEFT, an innovative alternative approach should be pursued.
61
+
62
+ Table 1: Comparison of PEQA with other methods using LLaMA 65B on the DRAM usage and training time during fine-tuning, the DRAM storage for deployment, the inference acceleration, and task-switching efficiency. The DRAM usage estimation for PEFT is based on LoRA. PEFT $+$ PTQ denotes PTQ after PEFT and $\mathrm { P T Q + P E F T }$ denotes PTQ before PEFT.
63
+
64
+ <table><tr><td>Method</td><td>DRAM (Fine-Tuning)</td><td>DRAM (Deployment)</td><td>Inference Speed</td><td>Task- Switching</td></tr><tr><td>Full Fine-Tuning</td><td>457GB</td><td>131GB</td><td>Slow</td><td>Slow</td></tr><tr><td>PEFT</td><td>131GB</td><td>131GB</td><td>Slow</td><td>Fast</td></tr><tr><td>PEFT+PTQ</td><td>131GB</td><td>33GB</td><td>Fast</td><td>Slow</td></tr><tr><td>PTQ+PEFT</td><td>33GB</td><td>33GB</td><td>Slow</td><td>Fast</td></tr><tr><td>PEQA (Ours)</td><td>33GB</td><td>33GB</td><td>Fast</td><td>Fast</td></tr></table>
65
+
66
+ # 3.2 Parameter-Efficient and Quantization-aware Adaptation (PEQA)
67
+
68
+ Quantization reduces bit-precision for inference acceleration, less storage and increasing throughput. INT8 quantization, which lower the bit-precision for both activations and weights, utilize dedicated engine to effectively accelerate arithmetic computation [48]. This is effective for large batches where computing speed matters but less so for smaller batches constrained by memory. To tackle this memory issue, weight-only quantization keeps high precision for activations (e.g., FP16) but compresses weights to 4-bit or less, targeting memory I/O enhancement in modern GPUs [28, 47]. For simplicity, we mainly focus on low-bit weight-only quantization in a linear asymmetric per-channel context in this paper.
69
+
70
+ For pre-trained weights of a fully-connected layer $W _ { 0 } \in \mathbb { R } ^ { n \times m }$ , while PEQA can be applied to quantized LLMs, we first quantize $W _ { 0 }$ . In other words, for a given bit-width $b$ , quantized pre-trained weights $\widehat { W } _ { 0 }$ can be written as
71
+
72
+ $$
73
+ \widehat { W } _ { 0 } = s _ { 0 } \cdot \overline { { W } } _ { 0 } = s _ { 0 } \cdot \Big ( \mathrm { c l a m p } \Big ( \Big \lfloor \frac { W _ { 0 } } { s _ { 0 } } \Big \rceil + z _ { 0 } , 0 , 2 ^ { b } - 1 \Big ) - z _ { 0 } \Big ) ,
74
+ $$
75
+
76
+ where $A \cdot B , \lfloor \cdot \rceil$ , and $\mathrm { c l a m p } ( \cdot , a , b )$ indicate the element-wise product of $A$ and $B$ , the rounding function, and the clamping function into the range $[ a , b ]$ , respectively, while per-channel scales and zero-points (namely, $\pmb { s } _ { 0 } , \pmb { z } _ { 0 } \in \mathbb { R } ^ { n \times 1 } )$ are initialized to minimize $\| \boldsymbol { W } _ { 0 } - \widehat { \boldsymbol { W } } _ { 0 } \| _ { F } ^ { 2 }$ . Notice that $s _ { 0 }$ and $z _ { \mathrm { 0 } }$ are not related to any downstream task. Here, we freeze $\begin{array} { r } { \overline { { W } } _ { 0 } = \mathrm { c l a m p } ( \lfloor \frac { W _ { 0 } } { s _ { 0 } } \rceil + z _ { 0 } , 0 , 2 ^ { b } - 1 ) - z _ { 0 } ) } \end{array}$ , which is the integer quantization indices of $W _ { 0 }$ , for every full-connected layer in a pre-trained LLM. And then we fine-tune only $s _ { 0 }$ (residing outside the clamp function in Eq. 1) while sharing $\overline { { \boldsymbol { W } } } _ { 0 }$ across all downstream tasks. Consequently, quantized pre-trained weights $\widehat { W } _ { 0 }$ are adapted to a downstream task as follows:
77
+
78
+ $$
79
+ \widehat { W } = \left( s _ { 0 } + \Delta s \right) \cdot \overline { { W } } _ { 0 } = \left( s _ { 0 } + \Delta s \right) \cdot \Big ( \mathrm { c l a m p } \Big ( \Big \lfloor \frac { W _ { 0 } } { s _ { 0 } } \Big \rceil + z _ { 0 } , 0 , 2 ^ { b } - 1 \Big ) - z _ { 0 } \Big ) ,
80
+ $$
81
+
82
+ where $\Delta s \in \mathbb { R } ^ { n \times 1 }$ represents the gradient update of $s _ { 0 }$ obtained by adaptation to a downstream task. We dub Eq. 2 as Parameter-Efficient and Quantization-aware Adaptation (PEQA). PEQA is a memory-efficient fine-tuning method dedicated to quantized LLMs by solely updating quantization scales $\scriptstyle { \pmb { s } } _ { 0 }$ . With $\overline { { \boldsymbol { W } } } _ { 0 }$ being frozen and shared for all downstream tasks, $s _ { 0 } + \Delta s$ are task-specific parameters in PEQA, which can be quickly and easily swapped when it is needed to switch to a different downstream task. Note that, PEQA can be seamlessly applied not only to weight-only quantized LLMs but also to weight-activation quantized ones. The overall procedure of PEQA is described in Figure 1 in detail.
83
+
84
+ # 3.3 Benefits of PEQA Inherited from Bridging the Gap between PEFT and Quantization
85
+
86
+ PEQA is designed to have the advantages of both existing PEFT methods [19, 21, 46] and quantized LLM [28, 44, 47, 49]. We summarize the benefits of PEQA in this subsection.
87
+
88
+ Table 2: To empirically confirm the validity of PEQA’s approach, we compare the perplexity (PPL) of fine-tuned LLMs through QAT, PEFT $+$ PTQ, and PEQA on Wikitext2 [51] for GPT-Neo 2.7B, GPT-J 6B, LLaMA 7B, and LLaMA 13B. Weights are quantized into either 3-bit or 4-bit per channel, without a group size [28, 49]. LoRA configuration is set to QV4. The lower PPL, the better.
89
+
90
+ <table><tr><td>Method</td><td>W Bits</td><td>GPT-Neo 2.7B</td><td>GPT-J 6B</td><td>LLaMA 7B</td><td>LLaMA 13B</td></tr><tr><td>QAT</td><td>4</td><td>11.07</td><td>8.81</td><td>5.76</td><td>5.26</td></tr><tr><td>LoRA + OPTQ</td><td>4</td><td>12.09</td><td>8.91</td><td>7.13</td><td>5.31</td></tr><tr><td>PEQA (Ours)</td><td>4</td><td>11.38</td><td>8.84</td><td>5.84</td><td>5.30</td></tr><tr><td>QAT</td><td>3</td><td>12.37</td><td>9.60</td><td>6.14</td><td>5.59</td></tr><tr><td>LoRA+ OPTQ</td><td>3</td><td>21.93</td><td>11.22</td><td>19.47</td><td>7.33</td></tr><tr><td>PEQA (Ours)</td><td>3</td><td>12.54</td><td>9.36</td><td>6.19</td><td>5.54</td></tr></table>
91
+
92
+ Benefits of PEFT. By solely updating the quantization scales, PEQA substantially reduces the memory overhead associated with optimizer state, a feature consistent with other PEFT approaches. Notably, the utilization of quantization scales $s _ { 0 } + \Delta s$ allows PEQA to swiftly and effortlessly switch between task-specific parameters. This capability positions PEQA as ideally suited for deployment of quantized LLMs as a service, mirroring another key advantage of earlier PEFT methods. Note, however, that such a capability is not present in PEFT $^ +$ PTQ (i.e., the case where PTQ is applied after PEFT) due to the non-reversible quantizers, such as the rounding function.
93
+
94
+ Benefits of Quantization. Previous PEFT methods freeze the pre-trained weights $W _ { 0 }$ and utilize additional learnable parameters to reduce the memory usage of optimizer state. Similarly, PEQA freezes quantized pre-trained weights $\overline { { W } } _ { 0 }$ (which are the integer quantization values of $W _ { 0 }$ ) and fine-tunes quantization scales $s _ { 0 }$ . Since $\overline { { \boldsymbol { W } } } _ { 0 }$ is a $b$ -bit integer matrix, not only can PEQA reduce the optimizer states’ size but also the model size, leading to even greater efficiency in the PEFT scheme, as illustrated in Figure 2a. In addition, since $\widehat { W }$ is a $b$ -bit quantized matrix, PEQA can speed up token generation process at inference through dedicated kernels that accelerate the multiplication between a quantized weight matrix and a half-precision activation vector, as described by Frantar et al. [28], Lin et al. [47], and Park et al. [49]. It is worth noticing that employing PTQ before fine-tuning $( { \mathrm { P T Q } } \small { + } { \mathrm { P E F T } }$ ) [50] allows for memory-efficient fine-tuning and seamless task transition for the quantized LLM; however, $\mathrm { P T Q + P E F T }$ is not able to inherit from inference acceleration of quantization. As a result, PEQA can achieve both model compression in the process of fine-tuning and inference acceleration for fine-tuned models with marginal performance degradation compared to LoRA, one of the state-of-the-art PEFT techniques, as shown in Figure 2b.
95
+
96
+ The comparison of PEQA with other methods using the LLaMA 65B is summarized in Table 1.
97
+
98
+ # 4 Experiments
99
+
100
+ In this section, we empirically validate the effectiveness of our proposed PEQA method by examining its performance in both parameter-efficient fine-tuning (PEFT) and as a quantization method. We achieve this goal by using a series of benchmarks [52–57], datasets [51, 58, 59], and LLMs [4, 6, 60, 61] that have been publicly introduced. In Section 4.1, to empirically confirm the validity of fine-tuning only the quantization scale while freezing the integer matrix, we compare the perplexity of fine-tuned LLMs through quantization-aware training (QAT), PEFT $\left( + \mathrm { P T Q } \right)$ , and PEQA. In Section 4.2, to evaluate PEQA’s scalability and task-specific adaptation performance, we fine-tune and assess LLMs on the Wikitext2 [51] and PennTreeBank [58] datasets using PEQA and LoRA [21]. Section 4.3 is dedicated to showcasing PEQA’s performance-restoring capability through instruction-tuning on the Alpaca [59] dataset after round-to-nearest (RTN) quantization over the full-precision original model.
101
+
102
+ To assess PEQA’s performance as a PEFT method, we contrast PEQA with LoRA, which is currently recognized as one of the leading PEFT methods. As discussed in 3.1, we employ a baseline case that merges OPTQ [28], the state-of-the-art weight-only post-training quantization (PTQ) method for LLMs, with LoRA in order to evaluate PEQA’s quantization capabilities. In the context of LoRA, QV4 signifies the application of query and value layer weights with a LoRA rank of 4, while QKVO16 indicates the application of query, key, value, and output projection layer weights with a LoRA rank of 16. For PEQA, we utilize round-to-nearest (RTN) for the initialization method of quantized LLM.
103
+
104
+ Table 3: To show scalability of PEQA, the perplexity (PPL) on Wikitext2 and PennTreeBank (PTB) was compared with LoRA and PEQA. In this comparison, only the weights were quantized into 3-bit and 4-bit per-channel without group size. LoRA configuration is set to QV4. A lower PPL value indicates better performance.
105
+
106
+ <table><tr><td>Method</td><td>W Bits</td><td>GPT-Neo 2.7B</td><td>GPT-J 6B</td><td>LLaMA 7B</td><td>LLaMA 13B</td><td>LLaMA 30B</td><td>LLaMA 65B</td></tr><tr><td colspan="8">Wikitext2</td></tr><tr><td>LoRA</td><td>16</td><td>10.63</td><td>8.50</td><td>5.53</td><td>5.06</td><td>4.06</td><td>3.82</td></tr><tr><td>LoRA+OPTQ</td><td>4</td><td>12.09</td><td>8.91</td><td>7.13</td><td>5.31</td><td>4.39</td><td>4.10</td></tr><tr><td>PEQA (Ours)</td><td>4</td><td>11.38</td><td>8.84</td><td>5.84</td><td>5.30</td><td>4.36</td><td>4.02</td></tr><tr><td>LoRA+OPTQ</td><td>3</td><td>21.93</td><td>11.22</td><td>19.47</td><td>7.33</td><td>5.94</td><td>5.32</td></tr><tr><td>PEQA (Ours)</td><td>3</td><td>12.54</td><td>9.36</td><td>6.19</td><td>5.54</td><td>4.58</td><td>4.27</td></tr><tr><td colspan="8">PTB</td></tr><tr><td>LoRA</td><td>16</td><td>15.92</td><td>12.92</td><td>9.14</td><td>8.52</td><td>7.21</td><td>7.11</td></tr><tr><td>LoRA+OPTQ</td><td>4</td><td>18.83</td><td>13.46</td><td>11.22</td><td>8.83</td><td>7.55</td><td>7.46</td></tr><tr><td>PEQA (Ours)</td><td>4</td><td>16.55</td><td>13.30</td><td>9.69</td><td>8.64</td><td>7.68</td><td>7.36</td></tr></table>
107
+
108
+ # 4.1 Comparing Quantization Capabilities: PEQA vs. QAT vs. PEFT+PTQ
109
+
110
+ Table 2 presents the perplexity when various quantized LLMs are fine-tuned using QAT, PEFT $\left( + \mathrm { P T Q } \right)$ , and PEQA. To validate our approach, PEQA, which solely fine-tunes the quantization scale as outlined in Eq. 2 while simultaneously maintaining the integer matrix in a frozen state, we use QAT as an upper bound and PEFT $+$ PTQ as a lower bound. Note that QAT, unlike PEQA, updates all parameters including pre-trained weights as well as quantization scales. Table 2 reveals the competitive performance of PEQA compared to QAT. Furthermore, our observations indicate that PEQA consistently outperforms the combination of LoRA and OPTQ for any selected model, regardless of whether a 3-bit or 4-bit setting is employed. Such superior performance can be attributed to PEQA’s method of fine-tuning quantized LLMs, which minimizes the final task loss on the full training data, a capability that OPTQ lacks. Detailed settings are in Appendix B.
111
+
112
+ Diving deeper into the comparison between QAT and PEQA, it is important to note that QAT minimizes the final task loss computed from a weight-only quantized model, as described in Eq. 1, with respect to both $W _ { 0 }$ and $s _ { 0 }$ . Note that QAT includes all pre-trained weights for training, resulting in the practical model size limitation of LLMs under investigation being capped at 13B in our experiments. Despite the fact that QAT also updates $W _ { 0 }$ in Eq. 1, which is one of the most simple and straightforward approach though, we observe that the performance gap between QAT and PEQA narrows when the 4-bit association is introduced, especially as the size of LLMs increases. Impressively, PEQA can even outperform QAT in a 3-bit setting, a notably low-bit setting that challenges OPTQ in terms of quantizing LLMs. These findings suggest that the approach of PEQA, solely updating quantization scales while freezing the integer quantization values of pre-trained weights, can achieve performance comparable to that of QAT.
113
+
114
+ # 4.2 Task-specific Adaptation with Wikitext2 and PennTreeBank Datasets
115
+
116
+ Task-specific Adaptation and Scalability. We evaluate the task-specific adaptation performance and scalability of PEQA by employing GPT-Neo, GPT-J, and LLaMA models (up to 65B) on the Wikitext2 [51] and PennTreeBank (PTB) [58] datasets. The adaptation performance of PEQA is compared with LoRA, with its configuration set to QV4. As depicted in Table 3, we note a gradual convergence of PEQA’s perplexity to that of full-precision LoRA, with only marginal PPL degradation as the model size expands. Thus, Table 3 demonstrates that PEQA, compared to a prominent PEFT technique that utilizes full-precision pre-trained language model (PLM), can maintain a competitive perplexity level in LLMs while concurrently reducing DRAM usage through low-bit quantized weights. Notably, for a 3-bit quantization, PEQA experiences less performance degradation as the model size decreases due to extreme low-bit quantization compared to the combined LoRA and OPTQ. To further elucidate our findings, we have provided figures illustrating the results of 3-bit and 4-bit PEQA in the Appendix D. The comprehensive results indicate that for the deployment stage, PEQA allows models with larger parameters to operate under DRAM usage constraints, outperforming full-precision PEFT methods. For instance, under a restricted DRAM footprint, large LLaMA models can be explored using PEQA, while full-precision LoRA permits only smaller LLaMA models. Additional results with OPT [4], ranging from 1.3B to 66B models are included in the Appendix E. The detailed experimental settings are also included in the Appendix C.
117
+
118
+ Table 4: Number of learnable parameters and model size of GPT-Neo, GPT-J and LLaMAs. PEQA configuration is set to 4-bit or 3-bit channel-wise quantization.
119
+
120
+ <table><tr><td></td><td>Method</td><td>GPT-Neo 2.7B</td><td>GPT-J 6B</td><td>LLaMA 7B</td><td>LLaMA 13B</td><td>LLaMA 30B</td><td>LLaMA 65B</td></tr><tr><td>#of</td><td>LoRA (QV4)</td><td>1.31</td><td>1.84</td><td>2.10</td><td>3.28</td><td>6.39</td><td>10.49</td></tr><tr><td>Learnable</td><td>LoRA (QKV016)</td><td>5.24</td><td>7.34</td><td>8.39</td><td>13.11</td><td>25.56</td><td>41.94</td></tr><tr><td>Param. (M)</td><td>PEQA (Ours)</td><td>0.74</td><td>1.03</td><td>1.36</td><td>2.13</td><td>4.15</td><td>6.80</td></tr><tr><td>Model</td><td>LoRA (QV4)</td><td>5.30</td><td>12.10</td><td>13.48</td><td>26.03</td><td>65.06</td><td>130.57</td></tr><tr><td>Size</td><td>PEQA (Ours, 4-bit)</td><td>1.53</td><td>3.65</td><td>3.77</td><td>7.01</td><td>16.92</td><td>33.45</td></tr><tr><td>(GB)</td><td>PEQA (Ours, 3-bit)</td><td>1.21</td><td>2.94</td><td>2.96</td><td>5.42</td><td>12.90</td><td>25.35</td></tr></table>
121
+
122
+ Table 5: Multi-scale (grouping) performance with PEQA-tuned LLaMA 7B and 13B on Wikitext2 where $g$ indicates the group size [49]. The perplexity consistently increases as PEQA take on more learnable parameters.
123
+
124
+ <table><tr><td>Model</td><td>W Bits</td><td>Channel-Wise</td><td>g256</td><td>g128</td><td>g64</td></tr><tr><td>LLaMA 7B</td><td>4</td><td>5.84</td><td>5.69</td><td>5.66</td><td>5.64</td></tr><tr><td></td><td>3</td><td>6.19</td><td>5.96</td><td>5.91</td><td>5.89</td></tr><tr><td>LLaMA13B</td><td>4</td><td>5.30</td><td>5.18</td><td>5.16</td><td>5.16</td></tr><tr><td></td><td>3</td><td>5.54</td><td>5.40</td><td>5.37</td><td>5.34</td></tr></table>
125
+
126
+ Model Size and Number of Learnable Parameters. In an effort to estimate the DRAM usage necessitated by PEQA and LoRA during training and deployment, we outline the number of learnable parameters (for training) and the model size (expressed in gigabytes, GB, for deployment) in Table 4. As demonstrated in Table 4, PEQA involves fewer learnable parameters than LoRA when a quantization scale is assigned to each channel of pre-trained weights. For instance, PEQA has approximately 1.54 times fewer learnable parameters for LLaMA models than LoRA (QV4). In addition to having fewer learnable parameters, PEQA, through low-bit weight quantization, can also reduce the model size, which captures a huge amount of the DRAM footprint in fine-tuning LLMs. Remarkably, when fine-tuning LLaMA 30B using PEQA with 4-bit precision, the resulting model size is significantly smaller than that obtained by adapting 13B through LoRA, and slightly larger than the model adapted from LLaMA 7B using LoRA. Additionally, a comparison of the memory peak during training between PEQA and LoRA is provided in Appendix L.
127
+
128
+ Group-wise Quantization. Group-wise per-channel quantization [49], where weight groups in channels share quantization parameters, maintains accuracy at lower bits. In Table 5, we present that the performance incrementally improves as more learnable parameters are incorporated into PEQA. In particular, for Table 5, we examine various group sizes (denoted by $g$ ) when quantizing the weights [49, 62]. Through relatively straightforward grouping (employed to regulate the number of learnable parameters for PEQA), the perplexity incrementally decreases as more learnable parameters are utilized. Detailed settings are in Appendix G.
129
+
130
+ Table 6: Common-sense reasoning and in-context learning performance of parameter-efficient instruction-tuned LLaMAs [6] using Alpaca datasets. LoRA configuration is set to QKVO16. Quantization precision of PEQA is set to 4-bit per-channel without group size. Note that ARC-C, ARC-E and OBQA stands for ARC-Challenge, ARC-Easy, and OpenBookQA respectively.
131
+
132
+ <table><tr><td>Method</td><td># Params</td><td>Model Size (GB)</td><td>PIQA</td><td>HellaSwag</td><td>ARC-C</td><td>ARC-E</td><td>OBQA</td><td>Average</td></tr><tr><td colspan="9">Zero-Shot</td></tr><tr><td rowspan="3">LLaMA</td><td>7B</td><td>13.5GB</td><td>77.3</td><td>73.0</td><td>41.4</td><td>52.5</td><td>42.4</td><td>57.3</td></tr><tr><td>13B</td><td>26.1GB</td><td>79.1</td><td>76.2</td><td>44.5</td><td>59.9</td><td>42.2</td><td>60.4</td></tr><tr><td>30B</td><td>65.1GB</td><td>80.1</td><td>79.2</td><td>45.5</td><td>58.9</td><td>42.0</td><td>61.1</td></tr><tr><td rowspan="3">+LoRA</td><td>7B</td><td>13.5GB</td><td>78.6</td><td>73.3</td><td>43.7</td><td>55.8</td><td>43.0</td><td>58.9(+1.6)</td></tr><tr><td>13B</td><td>26.1GB</td><td>79.6</td><td>76.7</td><td>46.3</td><td>62.0</td><td>43.2</td><td>61.5(+1.1)</td></tr><tr><td>30B</td><td>65.1GB</td><td>81.8</td><td>80.3</td><td>48.2</td><td>61.6</td><td>42.8</td><td>62.9(+1.8)</td></tr><tr><td rowspan="3">+ PEQA</td><td>7B</td><td>3.8GB</td><td>77.9</td><td>71.4</td><td>42.4</td><td>57.2</td><td>42.0</td><td>58.2(+0.9)</td></tr><tr><td>13B</td><td>7.0GB</td><td>78.9</td><td>74.0</td><td>46.4</td><td>62.5</td><td>42.8</td><td>60.9(+0.5)</td></tr><tr><td>30B</td><td>16.9GB</td><td>80.3</td><td>78.4</td><td>49.8</td><td>63.3</td><td>42.8</td><td>62.9(+1.8)</td></tr><tr><td colspan="9">Five-Shot</td></tr><tr><td rowspan="3">LLaMA</td><td>7B</td><td>13.5GB</td><td>79.4</td><td>75.3</td><td>45.6</td><td>65.8</td><td>44.0</td><td>62.0</td></tr><tr><td>13B</td><td>26.1GB</td><td>80.0</td><td>78.4</td><td>50.4</td><td>70.8</td><td>47.2</td><td>65.4</td></tr><tr><td>30B</td><td>65.1GB</td><td>82.5</td><td>82.2</td><td>56.2</td><td>74.9</td><td>47.0</td><td>68.6</td></tr><tr><td rowspan="3">+LoRA</td><td>7B</td><td>13.5GB</td><td>79.9</td><td>75.2</td><td>46.4</td><td>66.5</td><td>47.2</td><td>63.0(+1.0)</td></tr><tr><td>13B</td><td>26.1GB</td><td>81.1</td><td>78.8</td><td>53.5</td><td>72.4</td><td>47.0</td><td>66.6(+1.1)</td></tr><tr><td>30B</td><td>65.1GB</td><td>84.1</td><td>83.3</td><td>59.5</td><td>79.2</td><td>50.6</td><td>71.4(+2.8)</td></tr><tr><td rowspan="3">+ PEQA</td><td>7B</td><td>3.8GB</td><td>78.9</td><td>73.2</td><td>45.1</td><td>65.4</td><td>44.0</td><td>61.3(-0.7)</td></tr><tr><td>13B</td><td>7.0GB</td><td>80.7</td><td>76.0</td><td>50.9</td><td>71.6</td><td>48.0</td><td>65.5(+0.1)</td></tr><tr><td>30B</td><td>16.9GB</td><td>82.7</td><td>80.2</td><td>56.8</td><td>75.5</td><td>47.6</td><td>68.6(+0.0)</td></tr></table>
133
+
134
+ # 4.3 Instruction-tuning with the Alpaca Dataset
135
+
136
+ Although inference cost and training efficiency are crucial, the methods of PEFT and quantization have not been extensively explored. While LoRA and PEQA have been evaluated on adaptation performance for task-specific purposes as discussed in Section 4.2, it has not been widely corroborated that fine-tuning via PEFT can retain the performance for unseen tasks. Thus, given that RTN quantization results in a non-negligible performance degradation in LLMs, it is important to assess how much the performance of low-bit quantized LLMs is degraded on comprehensive tasks. To address these concerns, we conduct comprehensive experiments, benchmarking our techniques on prevalent instruction-following datasets and assessing the response quality of PEQA-tuned LLMs. Furthermore, to determine if PEQA can regain the performance of full-precision LLMs, we employ RTN quantization in conjunction with PEQA instruction-tuning across LLaMAs.
137
+
138
+ Experimental Settings. We train LLaMAs [6, 7] in various sizes on the Alpaca dataset [59], which is one of the popular instruction-following datasets generated from outputs of InstructGPT [11]. Then, we test the models on other downstream tasks such as common-sense reasoning tasks [52–55] and massive multitask language understanding (MMLU) [56]. Due to limited time and resources, we could not conduct an exhaustive search over hyper-parameters such as the learning rate or epoch. Instead, we followed the training recipe from Taori et al. [59]. The LoRA configuration is set to QKVO16. Detailed settings can be found in Appendix H.
139
+
140
+ Common-Sense Reasoning. We conducted an experiment on five tasks [52–55] to assess whether the performance of common-sense reasoning and in-context learning can be sustained even after instruction-tuning LLMs on the Alpaca dataset via LoRA or PEQA. As depicted in Table 6, the results show that LLMs fine-tuned with LoRA or PEQA maintain a consistent trend in common-sense reasoning tasks. Furthermore, since PEQA’s performance aligns closely with that of full-precision adaptation, this consistency is observed even when the model size has been reduced through low-bit weight quantization. We utilized the evaluation code from Eleuther AI’s lm-evaluation-harness [63].
141
+
142
+ Table 7: Massive Multitask Language Understanding (MMLU) benchmark performance of PEQAtuned LLaMAs using Alpaca datasets. Five-shot accuracy is reported for the MMLU. Quantization precision of PEQA is set to 4-bit. When we quantize LLaMA [6] into 4-bit precision using the RTN method, no group size is applied. For LLaMA2 [7], a group size of 256 is used with the RTN method. Note that RTN stands for round-to-nearest in the table.
143
+
144
+ <table><tr><td></td><td># Params</td><td>Model Size</td><td>Humanities</td><td>STEM</td><td>Social Sciences</td><td>Other</td><td>Average</td></tr><tr><td>LLaMA [6]</td><td>7B</td><td>13.5GB</td><td>32.6</td><td>29.6</td><td>38.0</td><td>37.9</td><td>34.4</td></tr><tr><td></td><td>13B</td><td>26.1GB</td><td>42.8</td><td>36.1</td><td>53.3</td><td>53.2</td><td>46.1</td></tr><tr><td></td><td>30B</td><td>65.1GB</td><td>54.6</td><td>46.5</td><td>66.1</td><td>63.4</td><td>57.4</td></tr><tr><td>+RTN</td><td>7B</td><td>3.8GB</td><td>28.4</td><td>25.6</td><td>26.9</td><td>31.8</td><td>28.3</td></tr><tr><td>(w/o group size)</td><td>13B</td><td>7.0GB</td><td>30.5</td><td>27.2</td><td>35.5</td><td>38.8</td><td>32.8</td></tr><tr><td></td><td>30B</td><td>16.9GB</td><td>39.6</td><td>34.0</td><td>46.1</td><td>49.7</td><td>42.1</td></tr><tr><td>+ PEQA</td><td>7B</td><td>3.8GB</td><td>35.7</td><td>30.9</td><td>38.2</td><td>40.0</td><td>35.8</td></tr><tr><td></td><td>13B</td><td>7.0GB</td><td>42.8</td><td>37.7</td><td>53.6</td><td>49.0</td><td>45.0</td></tr><tr><td></td><td>30B</td><td>16.9GB</td><td>51.1</td><td>44.1</td><td>62.4</td><td>60.7</td><td>54.3</td></tr><tr><td>LLaMA2[7]</td><td>7B</td><td>13.5GB</td><td>43.3</td><td>37.0</td><td>51.8</td><td>52.4</td><td>45.9</td></tr><tr><td></td><td>13B</td><td>26.0GB</td><td>54.4</td><td>44.2</td><td>63.4</td><td>60.8</td><td>55.7</td></tr><tr><td></td><td>70B</td><td>138.0GB</td><td>65.2</td><td>57.9</td><td>80.3</td><td>74.7</td><td>69.1</td></tr><tr><td>+RTN</td><td>7B</td><td>3.8GB</td><td>39.5</td><td>35.5</td><td>49.3</td><td>49.9</td><td>43.2</td></tr><tr><td>(g256)</td><td>13B</td><td>7.0GB</td><td>50.2</td><td>42.6</td><td>61.3</td><td>59.7</td><td>53.2</td></tr><tr><td></td><td>70B</td><td>35.3GB</td><td>63.7</td><td>55.9</td><td>78.4</td><td>71.6</td><td>67.0</td></tr><tr><td>+ PEQA</td><td>7B</td><td>3.8GB</td><td>52.0</td><td>38.4</td><td>54.1</td><td>52.0</td><td>48.1</td></tr><tr><td></td><td>13B</td><td>7.0GB</td><td>60.5</td><td>45.0</td><td>63.3</td><td>57.0</td><td>55.3</td></tr><tr><td></td><td>70B</td><td>35.3GB</td><td>73.9</td><td>55.3</td><td>77.8</td><td>68.2</td><td>67.5</td></tr></table>
145
+
146
+ Massive Multitask Language Understanding. To assess whether the performance of PEQAtuned models can be restored to the levels of full-precision model’s performance, starting from RTN performance, we test our models on the MMLU benchmark containing 57 multiple-choice problems across various domains and levels of knowledge [56]. In this experiment, we utilize the RTN results as a baseline to determine the extent of degradation on quantized LLM. As shown in Table 7, instruction-tuning with PEQA boosts the performance of RTN quantized models. This observation supports our claim that our approach enables LLMs to regain their few-shot in-context learning and understanding capabilities, even though they are significantly smaller than their original model size through quantization. Unfortunately, it seems that the PEQA-tuning does not achieve the best performance in fine-tuning larger models. This might be because PEQA-tuning did not been sufficiently explored different epochs or learning rates. Nonetheless, the observation that the performance of the quantized LLaMAs is restored through PEQA-tuning using an instructionfollowing dataset highlights the potential to further enhance the accuracy of PTQ methods.
147
+
148
+ # 5 Conclusion
149
+
150
+ Fine-tuning aligns large language models (LLMs) with specific purposes. To maintain the comprehensive capabilities of LLMs while effectively aligning them, we introduce PEQA, a method that seamlessly combines the advantages of parameter-efficient fine-tuning (PEFT) and quantization in LLMs. PEQA not only reduces DRAM consumption during fine-tuning but also accelerates inference latency for deployment by retaining weights in a low-bit quantized format. Through rigorous testing across various datasets and LLMs, we have found that PEQA can match the performance of fullprecision baselines in task-specific adaptations, even with a significant reduction in model size. When combined with instruction-tuning, PEQA’s performance demonstrates its ability to both preserve and enhance comprehensive knowledge after the inherent compromises of quantization, recovering the performance of original model by simply updating the quantization scales of the quantized LLM.
151
+
152
+ # References
153
+
154
+ [1] 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. volume 33, pages 1877–1901, 2020.
155
+
156
+ [2] Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. Palm: Scaling language modeling with pathways, 2022.
157
+
158
+ [3] Alex Andonian, Quentin Anthony, Stella Biderman, Sid Black, Preetham Gali, Leo Gao, Eric Hallahan, Josh Levy-Kramer, Connor Leahy, Lucas Nestler, Kip Parker, Michael Pieler, Shivanshu Purohit, Tri Songz, Wang Phil, and Samuel Weinbach. GPT-NeoX: Large Scale Autoregressive Language Modeling in PyTorch, 8 2021. URL https://www.github.com/ eleutherai/gpt-neox.
159
+
160
+ [4] 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, 2022.
161
+
162
+ [5] OpenAI. Gpt-4 technical report, 2023.
163
+
164
+ [6] Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. Llama: Open and efficient foundation language models, 2023.
165
+
166
+ [7] Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023.
167
+
168
+ [8] Nisan Stiennon, Long Ouyang, Jeffrey Wu, Daniel Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul F Christiano. Learning to summarize with human feedback. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 3008–3021. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper_files/paper/2020/file/ 1f89885d556929e98d3ef9b86448f951-Paper.pdf.
169
+
170
+ [9] Luciano Floridi and Massimo Chiriatti. Gpt-3: Its nature, scope, limits, and consequences. Minds Mach., 30(4):681–694, dec 2020. ISSN 0924-6495. doi: 10.1007/s11023-020-09548-1. URL https://doi.org/10.1007/s11023-020-09548-1.
171
+
172
+ [10] Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. Rethinking the role of demonstrations: What makes in-context learning work? In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 11048–11064, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics. URL https://aclanthology.org/2022.emnlp-main.759.
173
+
174
+ [11] Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35:27730–27744, 2022.
175
+
176
+ [12] Yuntao Bai, Saurav Kadavath, Sandipan Kundu, Amanda Askell, Jackson Kernion, Andy Jones, Anna Chen, Anna Goldie, Azalia Mirhoseini, Cameron McKinnon, et al. Constitutional ai: Harmlessness from ai feedback. arXiv preprint arXiv:2212.08073, 2022.
177
+
178
+ [13] Jason Wei, Maarten Bosma, Vincent Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V Le. Finetuned language models are zero-shot learners. In International Conference on Learning Representations, 2022. URL https://openreview. net/forum?id=gEZrGCozdqR.
179
+
180
+ [14] Victor Sanh, Albert Webson, Colin Raffel, Stephen Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Arun Raja, Manan Dey, M Saiful Bari, Canwen Xu, Urmish Thakker, Shanya Sharma Sharma, Eliza Szczechla, Taewoon Kim, Gunjan Chhablani, Nihal Nayak, Debajyoti Datta, Jonathan Chang, Mike Tian-Jian Jiang, Han Wang, Matteo Manica, Sheng Shen, Zheng Xin Yong, Harshit Pandey, Rachel Bawden, Thomas Wang, Trishala Neeraj, Jos Rozen, Abheesht Sharma, Andrea Santilli, Thibault Fevry, Jason Alan Fries, Ryan Teehan, Teven Le Scao, Stella Biderman, Leo Gao, Thomas Wolf, and Alexander M Rush. Multitask prompted training enables zero-shot task generalization. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\underset { . } { = }$ 9Vrb9D0WI4.
181
+
182
+ [15] Thomas Scialom, Tuhin Chakrabarty, and Smaranda Muresan. Fine-tuned language models are continual learners. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 6107–6122, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics. URL https://aclanthology.org/2022. emnlp-main.410.
183
+
184
+ [16] Tianbao Xie, Chen Henry Wu, Peng Shi, Ruiqi Zhong, Torsten Scholak, Michihiro Yasunaga, Chien-Sheng Wu, Ming Zhong, Pengcheng Yin, Sida I Wang, et al. Unifiedskg: Unifying and multi-tasking structured knowledge grounding with text-to-text language models. arXiv preprint arXiv:2201.05966, 2022.
185
+
186
+ [17] Yi Tay, Jason Wei, Hyung Won Chung, Vinh Q Tran, David R So, Siamak Shakeri, Xavier Garcia, Huaixiu Steven Zheng, Jinfeng Rao, Aakanksha Chowdhery, et al. Transcending scaling laws with $0 . 1 \%$ extra compute. arXiv preprint arXiv:2210.11399, 2022.
187
+
188
+ [18] William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. J. Mach. Learn. Res., 23(1), jan 2022. ISSN 1532-4435.
189
+
190
+ [19] Xiao Liu, Yanan Zheng, Zhengxiao Du, Ming Ding, Yujie Qian, Zhilin Yang, and Jie Tang. Gpt understands, too, 2021.
191
+
192
+ [20] Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for NLP. In Kamalika Chaudhuri and Ruslan Salakhutdinov, editors, Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pages 2790–2799. PMLR, 09–15 Jun 2019. URL https://proceedings.mlr. press/v97/houlsby19a.html.
193
+
194
+ [21] Edward J Hu, yelong shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. LoRA: Low-rank adaptation of large language models. In International Conference on Learning Representations, 2022. URL https://openreview. net/forum?id $\equiv$ nZeVKeeFYf9.
195
+
196
+ [22] Sangil Jung, Changyong Son, Seohyung Lee, Jinwoo Son, Jae-Joon Han, Youngjun Kwak, Sung Ju Hwang, and Changkyu Choi. Learning to quantize deep networks by optimizing quantization intervals with task loss. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 4350–4359, 2019.
197
+
198
+ [23] Steven K. Esser, Jeffrey L. McKinstry, Deepika Bablani, Rathinakumar Appuswamy, and Dharmendra S. Modha. Learned step size quantization. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id=rkgO66VKDS.
199
+
200
+ [24] Xiandong Zhao, Ying Wang, Xuyi Cai, Cheng Liu, and Lei Zhang. Linear symmetric quantization of neural networks for low-precision integer hardware. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id $\underset { . } { = }$ H1lBj2VFPS.
201
+
202
+ [25] Jung Hyun Lee, Jihun Yun, Sung Ju Hwang, and Eunho Yang. Cluster-promoting quantization with bit-drop for minimizing network quantization loss, 2021.
203
+
204
+ [26] Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. Llm. int8 (): 8-bit matrix multiplication for transformers at scale. arXiv preprint arXiv:2208.07339, 2022.
205
+
206
+ [27] Zhewei Yao, Reza Yazdani Aminabadi, Minjia Zhang, Xiaoxia Wu, Conglong Li, and Yuxiong He. Zeroquant: Efficient and affordable post-training quantization for large-scale transformers. arXiv preprint arXiv:2206.01861, 2022.
207
+
208
+ [28] Elias Frantar, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. OPTQ: Accurate quantization for generative pre-trained transformers. In The Eleventh International Conference on Learning Representations, 2023. URL https://openreview.net/forum?id=tcbBPnfwxS.
209
+
210
+ [29] Guangxuan Xiao, Ji Lin, Mickael Seznec, Julien Demouth, and Song Han. Smoothquant: Accurate and efficient post-training quantization for large language models. arXiv preprint arXiv:2211.10438, 2022.
211
+
212
+ [30] Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, et al. Training compute-optimal large language models. arXiv preprint arXiv:2203.15556, 2022.
213
+
214
+ [31] Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. Toolformer: Language models can teach themselves to use tools. arXiv preprint arXiv:2302.04761, 2023.
215
+
216
+ [32] Reiichiro Nakano, Jacob Hilton, Suchir Balaji, Jeff Wu, Long Ouyang, Christina Kim, Christopher Hesse, Shantanu Jain, Vineet Kosaraju, William Saunders, Xu Jiang, Karl Cobbe, Tyna Eloundou, Gretchen Krueger, Kevin Button, Matthew Knight, Benjamin Chess, and John Schulman. Webgpt: Browser-assisted question-answering with human feedback. CoRR, abs/2112.09332, 2021. URL https://arxiv.org/abs/2112.09332.
217
+
218
+ [33] 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. CoRR, abs/2212.10560, 2022. doi: 10.48550/arXiv.2212.10560. URL https: //doi.org/10.48550/arXiv.2212.10560.
219
+
220
+ [34] Wei-Lin Chiang, Zhuohan Li, Zi Lin, Ying Sheng, Zhanghao Wu, Hao Zhang, Lianmin Zheng, Siyuan Zhuang, Yonghao Zhuang, Joseph E. Gonzalez, Ion Stoica, and Eric P. Xing. Vicuna: An open-source chatbot impressing gpt-4 with $9 0 \% *$ chatgpt quality, March 2023. URL https://lmsys.org/blog/2023-03-30-vicuna/.
221
+
222
+ [35] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
223
+
224
+ [36] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
225
+
226
+ [37] Timo Schick and Hinrich Schütze. Exploiting cloze questions for few shot text classification and natural language inference. arXiv preprint arXiv:2001.07676, 2020.
227
+
228
+ [38] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. 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), pages 4582–4597, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.353. URL https://aclanthology.org/2021.acl-long.353.
229
+
230
+ [39] Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 3045–3059, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.emnlp-main.243. URL https://aclanthology.org/2021.emnlp-main.243.
231
+
232
+ [40] Junxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Towards a unified view of parameter-efficient transfer learning. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\underset { . } { = }$ 0RDcd5Axok.
233
+
234
+ [41] Yuning Mao, Lambert Mathias, Rui Hou, Amjad Almahairi, Hao Ma, Jiawei Han, Scott Yih, and Madian Khabsa. UniPELT: A unified framework for parameter-efficient language model tuning. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 6253–6264, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long.433. URL https://aclanthology.org/2022.acl-long.433.
235
+
236
+ [42] Minseop Park, Jaeseong You, Markus Nagel, and Simyung Chang. Quadapter: Adapter for GPT-2 quantization. In Yoav Goldberg, Zornitsa Kozareva, and Yue Zhang, editors, Findings of the Association for Computational Linguistics: EMNLP 2022, Abu Dhabi, United Arab Emirates, December 7-11, 2022, pages 2510–2517. Association for Computational Linguistics, 2022. URL https://aclanthology.org/2022.findings-emnlp.185.
237
+
238
+ [43] Se Jung Kwon, Jeonghoon Kim, Jeongin Bae, Kang Min Yoo, Jin-Hwa Kim, Baeseong Park, Byeongwook Kim, Jung-Woo Ha, Nako Sung, and Dongsoo Lee. Alphatuning: Quantization-aware parameter-efficient adaptation of large-scale pre-trained language models. In Yoav Goldberg, Zornitsa Kozareva, and Yue Zhang, editors, Findings of the Association for Computational Linguistics: EMNLP 2022, Abu Dhabi, United Arab Emirates, December 7-11, 2022, pages 3288–3305. Association for Computational Linguistics, 2022. URL https://aclanthology.org/2022.findings-emnlp.240.
239
+
240
+ [44] Jung Hyun Lee, Jeonghoon Kim, Se Jung Kwon, and Dongsoo Lee. FlexRound: Learnable rounding based on element-wise division for post-training quantization. In Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 18913–18939. PMLR, 23–29 Jul 2023. URL https://proceedings.mlr.press/v202/lee23h.html.
241
+
242
+ [45] Jung Hwan Heo, Jeonghoon Kim, Beomseok Kwon, Byeongwook Kim, Se Jung Kwon, and Dongsoo Lee. Rethinking channel dimensions to isolate outliers for low-bit weight quantization of large language models. arXiv preprint arXiv:2309.15531, 2023.
243
+
244
+ [46] Sourab Mangrulkar, Sylvain Gugger, Lysandre Debut, Younes Belkada, and Sayak Paul. Peft: State-of-the-art parameter-efficient fine-tuning methods. https://github.com/ huggingface/peft, 2022.
245
+
246
+ [47] Ji Lin, Jiaming Tang, Haotian Tang, Shang Yang, Xingyu Dang, and Song Han. Awq: Activation-aware weight quantization for llm compression and acceleration. arXiv preprint arXiv:2306.00978, 2023.
247
+
248
+ [48] Guangxuan Xiao, Ji Lin, Mickael Seznec, Hao Wu, Julien Demouth, and Song Han. SmoothQuant: Accurate and efficient post-training quantization for large language models. In Proceedings of the 40th International Conference on Machine Learning, 2023.
249
+
250
+ [49] Gunho Park, Baeseong Park, Minsub Kim, Sungjae Lee, Jeonghoon Kim, Beomseok Kwon, Se Jung Kwon, Byeongwook Kim, Youngjoo Lee, and Dongsoo Lee. Lut-gemm: Quantized matrix multiplication based on luts for efficient inference in large-scale generative language models, 2023.
251
+
252
+ [50] Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer. Qlora: Efficient finetuning of quantized llms. arXiv preprint arXiv:2305.14314, 2023.
253
+
254
+ [51] Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models, 2016.
255
+
256
+ [52] Peter Clark, Isaac Cowhey, Oren Etzioni, Tushar Khot, Ashish Sabharwal, Carissa Schoenick, and Oyvind Tafjord. Think you have solved question answering? try arc, the ai2 reasoning challenge. arXiv preprint arXiv:1803.05457, 2018.
257
+
258
+ [53] Yonatan Bisk, Rowan Zellers, Jianfeng Gao, Yejin Choi, et al. Piqa: Reasoning about physical commonsense in natural language. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pages 7432–7439, 2020.
259
+
260
+ [54] Rowan Zellers, Ari Holtzman, Yonatan Bisk, Ali Farhadi, and Yejin Choi. Hellaswag: Can a machine really finish your sentence? In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, 2019.
261
+
262
+ [55] Todor Mihaylov, Peter Clark, Tushar Khot, and Ashish Sabharwal. Can a suit of armor conduct electricity? a new dataset for open book question answering. In EMNLP, 2018.
263
+
264
+ [56] Dan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Song, and Jacob Steinhardt. Measuring massive multitask language understanding. arXiv preprint arXiv:2009.03300, 2020.
265
+
266
+ [57] Swaroop Mishra, Daniel Khashabi, Chitta Baral, and Hannaneh Hajishirzi. Cross-task generalization via natural language crowdsourcing instructions. In ACL, 2022.
267
+
268
+ [58] Mitchell P. Marcus, Beatrice Santorini, and Mary Ann Marcinkiewicz. Building a large annotated corpus of English: The Penn Treebank. Computational Linguistics, 19(2):313–330, 1993. URL https://www.aclweb.org/anthology/J93-2004.
269
+
270
+ [59] 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.
271
+
272
+ [60] Sid Black, Leo Gao, Phil Wang, Connor Leahy, and Stella Biderman. GPT-Neo: Large Scale Autoregressive Language Modeling with Mesh-Tensorflow, March 2021. URL https: //doi.org/10.5281/zenodo.5297715. If you use this software, please cite it using these metadata.
273
+
274
+ [61] Renrui Zhang, Jiaming Han, Aojun Zhou, Xiangfei Hu, Shilin Yan, Pan Lu, Hongsheng Li, Peng Gao, and Yu Qiao. Llama-adapter: Efficient fine-tuning of language models with zero-init attention. arXiv preprint arXiv:2303.16199, 2023.
275
+
276
+ [62] Dan Alistarh, Demjan Grubic, Jerry Li, Ryota Tomioka, and Milan Vojnovic. QSGD: communication-efficient SGD via gradient quantization and encoding. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett, editors, Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pages 1709–1720, 2017. URL https://proceedings.neurips.cc/paper/2017/ hash/6c340f25839e6acdc73414517203f5f0-Abstract.html.
277
+
278
+ [63] 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.
279
+
280
+ [64] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019. URL https://openreview.net/forum?id $\ c =$ Bkg6RiCqY7.
281
+
282
+ [65] Jeff Rasley, Samyam Rajbhandari, Olatunji Ruwase, and Yuxiong He. Deepspeed: System optimizations enable training deep learning models with over 100 billion parameters. In Rajesh Gupta, Yan Liu, Jiliang Tang, and B. Aditya Prakash, editors, KDD ’20: The 26th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, Virtual Event, CA, USA, August 23-27, 2020, pages 3505–3506. ACM, 2020. doi: 10.1145/3394486.3406703. URL https://doi.org/10.1145/3394486.3406703.
283
+
284
+ [66] Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander Rush. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 38–45, Online, October 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-demos.6. URL https://aclanthology.org/2020.emnlp-demos.6.
285
+
286
+ # A Common Experimental Settings
287
+
288
+ For the common experimental settings, AdamW [64] optimizer and linear-decaying learning rate scheduler were used. We use Deepspeed repository [65] 2 for FP16 and BF16 training. Additionally, we utilize Huggingface repository $[ \dot { 6 } 6 ] ^ { 3 }$ for training, evaluation code and dataset.
289
+
290
+ # B Experimental Settings of Section 4.1
291
+
292
+ We compare the perplexity when weights are quantized and adapted by quantization-aware training (QAT), LoRA with post-training quantization (PTQ), and PEQA, using the Wikitext2 dataset in Section 4.1. The LoRA configuration is set to QV4. For PTQ method, we utilize OPTQ [28] 4 which is state-of-the-art low-bit weight-only PTQ method. We set the model’s maximum sequence length to 1024. Batch size and epoch for all experiments are set to 128 and 15 respectively. The learning rates for the experiments of Table 2 are displayed in Table 8. Learning rates for LoRA and PEQA are shown in Appendix C.
293
+
294
+ Table 8: Learning rates of QAT in Table 2.
295
+
296
+ <table><tr><td>Method</td><td>W Bits</td><td>GPT-Neo 2.7B</td><td>GPT-J 6B</td><td>LLaMA 7B</td><td>LLaMA 13B</td></tr><tr><td>QAT</td><td>4</td><td>4e-5</td><td>5e-6</td><td>1e-5</td><td>3e-5</td></tr><tr><td>QAT</td><td>3</td><td>6e-5</td><td>1e-5</td><td>2e-5</td><td>1e-5</td></tr></table>
297
+
298
+ # C Experimental settings of Table 3
299
+
300
+ In Section 4.2, Table 3 show the scalability and task-specific adaptation performance of PEQA by comparing with LoRA and $\mathrm { L o R A * O P T Q }$ on Wikitext2 [51] and PennTreeBank (PTB) [58] datasets. Detailed experimental settings are as follows. LoRA configuration is set to QV4. For PTQ method, we utilize OPTQ [28] which is state-of-the-art low-bit weight-only PTQ method. We set input sequence length after tokenization (block size) to 1024 for under 65B models. For LLaMA 65B, input sequence length after tokenization is set to 768 due to memory issue. Batch size and epoch for all experiments are set to 128 and 15 respectively. Learning rates for Table 3 experiments are shown in Table 9.
301
+
302
+ Table 9: Learning rate of LoRA and PEQA in Table 3 on Wikitext2 and PTB datasets.
303
+
304
+ <table><tr><td>Method</td><td>W Bits</td><td>GPT-Neo 2.7B</td><td>GPT-J 6B</td><td>LLaMA 7B</td><td>LLaMA 13B</td><td>LLaMA 30B</td><td>LLaMA 65B</td></tr><tr><td colspan="8">Wikitext2</td></tr><tr><td>LoRA</td><td>16</td><td>5e-4</td><td>6e-4</td><td>1e-4</td><td>1e-4</td><td>2e-4</td><td>4e-5</td></tr><tr><td>PEQA (Ours)</td><td>4</td><td>5e-5</td><td>6e-6</td><td>6e-6</td><td>1e-5</td><td>1e-5</td><td>1e-5</td></tr><tr><td>PEQA (Ours)</td><td>3</td><td>6e-5</td><td>5e-5</td><td>2e-5</td><td>6e-5</td><td>3e-5</td><td>3e-5</td></tr><tr><td colspan="8">PTB</td></tr><tr><td>LoRA</td><td>16</td><td>2e-3</td><td>1e-3</td><td>8e-4</td><td>5e-4</td><td>4e-4</td><td>6e-4</td></tr><tr><td>PEQA (Ours)</td><td>4</td><td>3e-4</td><td>5e-5</td><td>5e-5</td><td>5e-5</td><td>3e-5</td><td>6e-5</td></tr></table>
305
+
306
+ # D The Perplexity of 3-bit and 4-bit PEQA on Wikitext2 Dataset
307
+
308
+ Figure 3 illustrates the results of 3-bit and 4-bit PEQA’s next token prediction performance on the Wikitext2 dataset. As shown in Figure 3, 3-bit performance of PEQA shows lower perplexity than 3-bit post-training quantized LoRA. The results from the 3-bit PEQA show that PEQA allows for continuity in model size options under DRAM usage constraints.
309
+
310
+ ![](images/306f8a7e99b5229e68617861b164a7779025b9c708acc33b7052c1df52278a1e.jpg)
311
+ Figure 3: The perplexity over model size of 3/4-bit performance of PEQA and LoRA $. +$ OPTQ
312
+
313
+ # E OPT Models Adapted with PEQA and LoRA on Wikitext2 Dataset
314
+
315
+ Table 10 shows the perplexity of OPT[4] models adapted with PEQA and LoRA on the Wikitext2 dataset. The perplexity gap between LoRA and PEQA becomes smaller as the model size increases.
316
+
317
+ Table 10: The perplexity (PPL) on Wikitext2 for OPT 1.3B to 66B. In this comparison, only the weights were quantized into 4-bit. A lower PPL value indicates better performance.
318
+
319
+ <table><tr><td>Method</td><td>W Bits</td><td>OPT 1.3B</td><td>OPT 2.7B</td><td>OPT 6.7B</td><td>OPT13B</td><td>OPT 30B</td><td>OPT 66B</td></tr><tr><td>LoRA(QV4)</td><td>16</td><td>11.58</td><td>10.25</td><td>8.96</td><td>8.44</td><td>7.93</td><td>7.64</td></tr><tr><td>PEQA(Ours)</td><td>4</td><td>12.40</td><td>10.78</td><td>9.34</td><td>8.74</td><td>8.11</td><td>7.86</td></tr></table>
320
+
321
+ # F LoRA Configuration Comparison on Wikitext2 Dataset
322
+
323
+ As shown in Table 11, the LoRA target module configuration of QV4 and QKVO16 has not much effect on perplexity on Wikitext2 experimental results. Table 11 shows equal tendency as mentioned in [21]. We utilize QV4 configuration for Section 4.2 and QKVO16 configuration for Section 4.3 respectively.
324
+
325
+ Table 11: The perplexity (PPL) on Wikitext2 was compared with LoRA QV4 and QKVO16. A lower PPL value indicates better performance.
326
+
327
+ <table><tr><td>Method</td><td>#Bits</td><td>GPT-Neo 2.7B</td><td>GPT-J 6B</td><td>LLaMA 7B</td><td>LLaMA 13B</td><td>LLaMA 30B</td><td>LLaMA 65B</td></tr><tr><td>LoRA(QV4)</td><td>16</td><td>10.63</td><td>8.50</td><td>5.53</td><td>5.06</td><td>4.06</td><td>3.82</td></tr><tr><td>LoRA(QKVO16)</td><td>16</td><td>10.67</td><td>8.50</td><td>5.50</td><td>5.06</td><td>4.06</td><td>3.81</td></tr></table>
328
+
329
+ # G Experimental Settings of Multi-scale Performance
330
+
331
+ In Section 4.2, Table 5 shows the perplexity of PEQA with grouping learnable parameters. We set model maximum sequence length to 1024. Batch size and epoch for all experiments are set to 128 and 15 respectively. Learning rates for experiments are shown in Table 12.
332
+
333
+ Table 12: Learning rate for Table 5.
334
+
335
+ <table><tr><td>Model</td><td>W Bits</td><td>g-1</td><td>g256</td><td>g128</td><td>g64</td></tr><tr><td>LLaMA 13B</td><td>4</td><td>1e-5</td><td>4e-5</td><td>4e-5</td><td>3e-5</td></tr><tr><td></td><td>3</td><td>6e-5</td><td>9e-5</td><td>9e-5</td><td>5e-5</td></tr><tr><td>LLaMA 7B</td><td>4</td><td>6e-6</td><td>2e-5</td><td>2e-5</td><td>1e-5</td></tr><tr><td></td><td>3</td><td>2e-5</td><td>6e-5</td><td>4e-5</td><td>7e-5</td></tr></table>
336
+
337
+ # H Experimental Settings of Section 4.3
338
+
339
+ In Section 4.3, we use the Alpaca dataset [59] for instruction-tuning. We set learning rate, epoch, and quantization group size as in Table 13. The batch size is set to 128 for all experiments in this subsection. As mentioned in Section 4.3, due to limited time and resources, we couldn’t conduct an exhaustive search over hyper-parameters such as learning rate or epoch. We believe that there are hyper-parameters that can perform better. For LLaMA 1 series (LLaMA 7, 13, and 30B), we truncate the prompt to the length of 2024 since their maximum sequence length is 2024 when evaluating the massive multitask lanugage understanding (MMLU) benchmark. Thus, for LLaMA2-70B, we set the tokenizer max length to 1024 on fine-tuning due to the resource limit. Otherwise, we use default max length of tokenizer5 on training. For the evaluation, we use default tokenizer setting. For every experiment in this section, the configuration of PEQA is set to 4-bit RTN quantization.
340
+
341
+ Table 13: The learning rate, epoch, quantization group size [49] for experiments on Section 4.3. the weights were quantized into 4-bit.
342
+
343
+ <table><tr><td>Hyper-parameter</td><td>LLaMA7B</td><td>LLaMA 13B</td><td>LLaMA 30B</td><td>LLaMA2 7B</td><td>LLaMA2 13B</td><td>LLaMA2 70B</td></tr><tr><td>Epoch</td><td>3</td><td>3</td><td>5</td><td>3</td><td>3</td><td>5</td></tr><tr><td>Learning rate</td><td>2e-5</td><td>2e-5</td><td>5e-6</td><td>5e-6</td><td>5e-6</td><td>5e-6</td></tr><tr><td>Group size</td><td>Per-channel</td><td>Per-channel</td><td>Per-channel</td><td>256</td><td>256</td><td>256</td></tr></table>
344
+
345
+ # I LLaMA 7B and 13B on Natural Instruction
346
+
347
+ To evaluate the instruction-following ability of instruct-tuned models, we test them on another instruction-following dataset, Natural Instruction (NI) [57]. Different from the Alpaca dataset, instructions of NI were collected by humans for existing 61 NLP tasks. For simplicity, we utilize evaluation splits consisting of 12 subtasks and restrict the maximum number of instances for each task to 200. At test time, the model should generate proper output for the given input with instruction for the target unseen task. As shown in Table 14, we find LLaMAs trained with PEQA show consistently better zero-shot task generalization performance (ROUGE-L) in NI for all parameter sizes compared to those from LoRA.
348
+
349
+ Table 14: Natural Instruction benchmark performance of parameter-efficient instruction-tuned LLaMAs using Alpaca datasets. Zero-shot performance (ROUGE-L) is reported for the NI. LoRA configuration is set to QKVO16. Quantization precisions of LoRA w/ OPTQ and PEQA are set to 4-bit.
350
+
351
+ <table><tr><td># Params</td><td>LLaMA</td><td>+LoRA</td><td>+LoRA w/OPTQ</td><td>+PEQA</td></tr><tr><td>7B</td><td>9.4</td><td>24.4</td><td>25.0</td><td>27.1</td></tr><tr><td>13B</td><td>8.9</td><td>31.3</td><td>29.2</td><td>34.1</td></tr></table>
352
+
353
+ # J Comparison with AlphaTuning
354
+
355
+ When diving deeper into quantization scales, learnable parameters for both PEQA and AlphaTuning, it’s worth noting that PEQA’s adherence to uniform quantization means there’s only one shared quantization scale for integer weight. Conversely, AlphaTuning’s non-uniform approach means that for a $b$ -bit quantization, there are $b$ individual quantization scales for each weight matrix. Despite having multiple scales, AlphaTuning only fine-tunes one, leaving the rest static. As such, the number of trainable parameters are identical and AlphaTuning seems to offer a larger potential for a well-fitted model, but it can be easily seen that $b - 1$ rest static scales introduced in AlphaTuning have limited usability, and thus the method may be prone to overfitting as evident through empirical results.
356
+
357
+ In Table 15, we conducted training on GPT-Neo and OPT 1.3B using the Wikitext2 dataset. Interestingly, PEQA, drawing from its methodological advantages, consistently demonstrates superior performance to AlphaTuning by at least $0 . 7 \mathrm { p p l }$ on the Wikitext2 dataset. Both AlphaTuning and PEQA used channel-wise trainable parameters. Batch size of AlphaTuning is set to 32.
358
+
359
+ Table 15: The perplexity (PPL) of AlphaTuning and PEQA on Wikitext2 with OPT and GPT-Neo 1.3B. The lower PPL, the better.
360
+
361
+ <table><tr><td>Method</td><td>#Bits</td><td>OPT 1.3B</td><td>GPT-Neo 1.3B</td></tr><tr><td>AlphaTuning</td><td>4</td><td>13.15</td><td>15.03</td></tr><tr><td>PEQA (Ours)</td><td>4</td><td>12.40</td><td>14.22</td></tr><tr><td>AlphaTuning</td><td>3</td><td>14.00</td><td>17.25</td></tr><tr><td>PEQA (Ours)</td><td>3</td><td>13.40</td><td>15.16</td></tr></table>
362
+
363
+ Table 16: Learning rate of AlphaTuning in Table 15.
364
+
365
+ <table><tr><td>Method</td><td>W Bits</td><td>OPT 1.3B</td><td>GPT-Neo 1.3B</td></tr><tr><td>AlphaTuning</td><td>4</td><td>1e-4</td><td>5e-4</td></tr><tr><td>AlphaTuning</td><td>3</td><td>1e-4</td><td>1e-3</td></tr></table>
366
+
367
+ # K Choice of Updating Quantization Scales or Zero-Points
368
+
369
+ Uniform quantization can represent both asymmetric and symmetric quantizations, hence it’s not always necessary to mandate the use of zero-points. This is why adopting a strategy of only learning the scale factor serves as a fundamental and scalable baseline. We opted for this approach to clearly establish its advantages. To determine the efficacy of learning only the scaling factors, we have incorporated additional experiments. By referring to the table below, it’s evident that merely optimizing zero-points does not yield effective learning outcomes. Moreover, simultaneously optimizing both zero-points and quantization scales does not present any significant improvement in accuracy either.
370
+
371
+ Table 17: Perplexity (PPL) of PEQA on the Wikitext2 dataset for LLaMA 7B and LLaMA 13B with weights quantized into 4-bit.
372
+
373
+ <table><tr><td>Method</td><td>Zero-points only</td><td>Quantization scales only (PEQA)</td><td>Both zero-points and quantization scales</td></tr><tr><td>LLaMA 7B</td><td>11.56</td><td>5.84</td><td>5.86</td></tr><tr><td>LLaMA 13B</td><td>9.83</td><td>5.30</td><td>5.34</td></tr></table>
374
+
375
+ # L Memory Peak on Training
376
+
377
+ The memory consumption is not solely dictated by the model size but is also influenced by various other factors6. Our approach with PEQA inherently offers memory advantages during fine-tuning by striving to minimize both the model size and the number of training parameters. To provide a clear understanding of these benefits, we conducted tests using a single NVIDIA A100-80GB GPU and the causal language modeling code from the HuggingFace repository7. Both LoRA and PEQA fine-tuned the LLaMA-7B on the Wikitext2 dataset with a batch size of 2 without gradient accumulation. Our findings indicated that while LoRA peaked at a memory usage of 59GB during optimization, PEQA used just 43GB. Remarkably, this disparity (16GB, 7B) escalates as the model size increases; for instance, a 65B full-precision model under LoRA occupies 130GB, whereas PEQA remarkably uses just 33GB. Additionally, LoRA encountered Out-Of-Memory (OOM) issues at a batch size of 4, whereas PEQA, due to its efficiency, continued training seamlessly.
md/dev/2nJdh_C-UWe/2nJdh_C-UWe.md ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Towards Effective and Interpretable Human-AI Collaboration in MOBA Games
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 MOBA games, e.g., Dota2 and Honor of Kings, have been actively used as the
11
+ 2 testbed for the recent AI research on games, and various AI systems have been
12
+ 3 developed at the human level so far. However, these AI systems merely focus on
13
+ 4 how to compete with humans, less exploring how to collaborate with humans. To
14
+ 5 this end, this paper makes the first attempt to investigate human-AI collaboration in
15
+ 6 MOBA games. In this paper, we propose to enable humans and agents to collaborate
16
+ 7 through explicit communications by designing an efficient and interpretable Meta
17
+ 8 Command Communication-based framework, dubbed MCC, for accomplishing
18
+ 9 effective human-AI collaboration in MOBA games. The MCC framework consists
19
+ 10 of two pivotal modules: 1) an interpretable communication protocol, i.e., the
20
+ 11 Meta-Command, to bridge the communication gap between humans and agents;
21
+ 12 2) a meta-command value estimation model, i.e., the Meta-Command Selector,
22
+ 13 to select a valuable meta-command for each agent to achieve effective human-AI
23
+ 14 collaboration. Experimental results in Honor of Kings demonstrate that MCC
24
+ 15 agents can collaborate reasonably well with human teammates and even generalize
25
+ 16 to collaborate with different levels and numbers of human teammates. Videos are
26
+ 17 available at https://sites.google.com/view/mcc-demo.
27
+
28
+ # 18 1 Introduction
29
+
30
+ 19 Games, as the microcosm of real-world problems, have been widely used as testbeds to evaluate
31
+ 20 the performance of Artificial Intelligence (AI) techniques for decades. Recently, many researchers
32
+ 21 focus on developing various human-level AI systems for complex games, such as board games like
33
+ 22 Go [27, 28], First-Person Shooting (FPS) games like ViZDoom [14], Real-Time Strategy (RTS)
34
+ 23 games like StarCraft 2 [34], and Multi-player Online Battle Arena (MOBA) games like Dota 2 [22].
35
+ 24 However, these AI systems focus merely on how to compete instead of collaborating with humans,
36
+ 25 leaving Human-AI Collaboration (HAC) in complex environments still to be investigated.
37
+ 26 In this paper, we study the HAC problem in complex MOBA games, which is characterized by multi
38
+ 27 agent cooperation and competition mechanisms, long time horizons, enormous state-action spaces
39
+ 28 $( \bar { 1 0 } ^ { 2 0 0 0 0 } )$ , and imperfect information [22, 26, 38]. HAC requires the agent to collaborate reasonably
40
+ 29 with various human teammates. One straightforward approach is to improve the generalization of
41
+ 30 agents, that is, to collaborate with an enough diverse population of teammates during training. There
42
+ 31 are some Population-Based Training (PBT) based algorithms and learning systems [1, 2, 10, 11,
43
+ 32 31, 41] proposed to improve the generalization of agents in video games by constructing a diverse
44
+ 33 population of agents in different ways. However, this approach requires a vast amount of diverse data
45
+ 34 and massive computing resources, posing a big computational obstacle for complex MOBA games.
46
+ 35 Human team success in MOBA games requires not only subtle individual micro-operations but also
47
+ 36 excellent communications and collaborations among teammates on macro-strategies, i.e., long-term
48
+ 37 intentions [8, 37]. Consequently, we focus on enabling humans and agents to collaborate through
49
+ 38 explicit communications and propose an efficient and interpretable Meta-Command Communication
50
+ 39 based human-AI collaboration framework, dubbed MCC, to solve the HAC problem in MOBA
51
+ 40 games. First, we design an interpretable communication protocol, i.e., the Meta-Command, as a
52
+ 41 general representation of macro-strategies to bridge the communication gap between agents and
53
+ 42 humans. Both macro-strategies sent by humans and messages outputted by agents can be converted
54
+ 43 into unified meta-commands (see Figure 1). Second, following Gao et al. [8], we construct a
55
+ 44 hierarchical model that includes the command encoding network (macro-strategy layer) and the
56
+ 45 meta-command conditioned action network (micro-action layer), used for agents to generate and
57
+ 46 execute meta-commands, respectively. Third, we propose a meta-command value estimation model,
58
+ 47 i.e., the Meta-Command Selector, to select the optimal meta-command for each agent to execute.
59
+ 48 The training process of the MCC framework consists of three phases. We first train the command
60
+ 49 encoding network to learn the distribution of meta-commands sent from humans. Afterward, we
61
+ 50 train the meta-command conditioned action network to ensure that the agent has the near-human
62
+ 51 completion rate for meta-commands. Finally, we train the meta-command selector to ensure that the
63
+ 52 agent can select a valuable meta-command to achieve effective collaboration. We train and evaluate
64
+ 53 the agent in Honor of Kings 5v5 mode with a full hero pool (over 100 heroes). Experimental results
65
+ 54 demonstrate the effectiveness of the MCC framework. In general, our contributions are as follows:
66
+
67
+ ![](images/a47d3c45884a2e38bf746cefd3d4fd4bb0b9d7d11daa81a3d4c35ac30fb17b41.jpg)
68
+ Figure 1: MOBA game-related introduction. (a) Key elements of MOBA games such as Dota 2, Honor of Kings, etc. Players observe from the state of the environment, make micro-operations and macro-strategies decisions, and collaborate through explicit messages (e.g.,text and signals). (b) Example of collaboration via meta-commands. The Come And Kill The Dragon is more valuable for humans A and B and agent $_ \mathrm { D }$ t o collaborate, while the Clean Up Top-Lane Minions is more valuable for human C and agent E to collaborate.
69
+
70
+ • To the best of our knowledge, we are the first to investigate the HAC problem in MOBA games. We propose an efficient and interpretable Meta-Command Communication-based framework dubbed MCC to achieve effective human-AI collaboration in MOBA games.
71
+
72
+ • We design an interpretable communication protocol to bridge the communication gap between humans and agents. In addition, we propose a meta-command value estimation model to select a valuable meta-command for each agent to achieve effective human-AI collaboration.
73
+
74
+ • We introduce the training process of the MCC framework in a typical MOBA game Honor of Kings and evaluate it in practical human-AI game tests. Experimental results show that MCC agents can reasonably collaborate with different levels and numbers of human teammates.
75
+
76
+ # 64 2 Related Work
77
+
78
+ # 2.1 MOBA Games AI Research
79
+
80
+ 66 MOBA games, such as Dota 2 and Honor of Kings, have attracted much attention from AI researchers
81
+ 67 due to their multi-agent cooperative and competitive mechanics, long time horizons, partial observa
82
+ 68 tion, and enormous state-action spaces [22, 38]. Recently, OpenAI et al. [22] introduced an AI system
83
+ 69 named OpenAI-Five that defeated professional players in Dota 2 5v5 mode under the condition of
84
+ 70 limited heroes. Ye et al. [38, 39, 40] proposed another learning system named WuKong that can
85
+ 71 surpass top e-sport players in Honor of Kings with a full hero pool. Further, Wu [37] and Gao et
86
+ 72 al. [8] proposed learning systems that enable the agent to learn human strategies to achieve policy
87
+ 73 diversity. However, these AI systems can only defeat human players but cannot collaborate well due
88
+ 74 to the communication gap between agents and humans, see Table 1. In most real-world scenarios, the
89
+ 75 excellent collaboration between humans and agents may make more sense than the competition.
90
+
91
+ PBT is considered one way to solve the HAC problem [4]. Most PBT-based methods are devoted to training an agent which can be compatible with unseen partners by maintaining a population of agents with diverse behaviors in different ways [1, 2, 10, 11, 31, 41][6, 19, 20, 30]. These methods have been validated on both objective and subjective metrics in video games Overcooked and Capture the Flag and card game Hanabi. However, the main difference between these games and MOBA games is that these games do not provide explicit communication mechanics for collaboration on macrostrategies between agents and humans. Besides, MOBA AI agents usually need to learn billions of network parameters to cope with the enormous state-action spaces $( 1 0 ^ { 2 0 0 0 0 } )$ [38], which constitutes a prohibitive computational burden for learning. As a more realistic topic of HAC, human-robot interaction in manufacturing also attracts much attention [13, 17, 25]. However, these studies are mainly limited to collaboration between a robot and a human through one-way communication, i.e., humans give robots orders. Therefore, there is still a large room to study RL with the participation of humans. This work can be a stepping stone for broader real-world applications.
92
+
93
+ # 2.3 Multi-Agent Communication
94
+
95
+ Communication is often used in Multi-Agent Reinforcement Learning (MARL) to improve interagent collaboration. Most communication-based MARL methods are mainly focused on exploring communication protocols between multiple agents with an end-to-end RL framework [5, 7, 9, 23, 29, 32, 36]. Jiang and Lu [12] and Kim et al. [15] proposed to model the value of multi-agent communication for effective collaboration. Unfortunately, these methods all model communications in a latent space without considering human-AI interactions, making it less interpretable to humans. Instead, we focus on enabling humans and agents to collaborate through explicit communications.
96
+
97
+ # 3 Human-AI Collaboration
98
+
99
+ We consider an interpretable communicative human-AI collaboration task, which can be extended from Partially Observable Markov Decision Process (POMDP) and formulated as a tuple $< N , H , { \bf S } , { \bf A } ^ { N } , { \bf A } ^ { H } , { \bf O } , { \bf M } , r , P , \gamma >$ , where $N$ and $H$ represent the numbers of agents and humans, respectively. S is the space of global states. $\mathbf { A } ^ { N } = \{ A _ { i } ^ { N } \} _ { i = 1 , \dots , N }$ and $\mathbf { A } ^ { H } = \{ A _ { i } ^ { \breve { H } } \} _ { i = 1 , \dots , H }$ denote the spaces of actions of $N$ agents and $H$ humans, respectively. $\mathbf { O } = \{ O _ { i } \} _ { i = 1 , \dots , N + H }$ denotes the space of observations of $N$ agents and $H$ humans. $\mathbf { M }$ represents the space of interpretable messages, that is, the Meta-Commands in the MCC framework. $P : \mathbf { S } \times \bar { \mathbf { A } } ^ { N } \times \mathbf { A } ^ { H } \vec { \mathbf { \Lambda } } \vec { \mathbf { \Lambda } } \vec { \mathbf { \Lambda } } $ and $r : \mathbf { S } \times \mathbf { A } ^ { N } \times \mathbf { A } ^ { H } \to \mathbb { R }$ denote the shared state transition probability function and reward function of $N$ agents, respectively. Note that, $r$ includes both individual reward and team reward. $\gamma \in [ 0 , 1 )$ denotes the discount factor. For each agent $i$ in state $s _ { t } \in \mathbf { S }$ , it receives an observation $o _ { t } ^ { i } \in O _ { i }$ and a selected message $c _ { t } ^ { i } \in \mathbf { M }$ , and then outputs an action $a _ { t } ^ { i } = \pi _ { \theta } ( o _ { t } ^ { i } , c _ { t } ^ { i } ) \in A _ { i } ^ { N }$ and a new message $m _ { t + 1 } ^ { i } = \pi _ { \phi } \bar { ( } o _ { t } ^ { i } ) \bar { \ } \in \bf { M }$ , where $\pi _ { \theta }$ and $\pi _ { \phi }$ are action network and message encoding network, respectively. A message selector $c _ { t } ^ { i } = \pi _ { \omega } ( o _ { t } ^ { i } , C _ { t } )$ is introduced to receive a message set $C _ { t } = \{ m _ { t } ^ { i } \} _ { i = 1 , \dots , N + H } \subset \mathbf { M }$ from all agents and humans and select the optimal one to execute.
100
+
101
+ We divide the HAC problem in MOBA games into the Human-to-AI (H2A) and the AI-to-Human (A2H) scenarios. The H2A Scenario: Humans send macro-strategies as messages to agent teammates, and agents combine them with their own messages to select the optimal one based on their own message selector to execute, achieving effective collaboration with humans. The A2H Scenario: Agents send messages as macro-strategies to human teammates, and humans combine them with their own macro-strategies to select the optimal one based on their own value systems to execute, achieving effective collaboration with agents. The goal of both tasks is that agents and humans communicate macro-strategies with pre-defined communication protocols, and then select valuable macro-strategies for effective collaboration to win the game.
102
+
103
+ # 4 Meta-Command Communication-Based Framework
104
+
105
+ 123 In this section, we present the proposed MCC framework in detail. We first briefly describe three key
106
+ 124 stages of the MCC framework (see Section 4.1). Then we introduce the two pivotal modules in the
107
+ 125 MCC framework: 1) an interpretable communication protocol, i.e., the Meta-Command, as a general
108
+ 126 representation of macro-strategies to bridge the communication gap between agents and humans (see
109
+ 127 Section 4.2); 2) a meta-command value estimation model, i.e., the Meta-Command Selector, to select
110
+ 128 a valuable meta-command for each agent to achieve effective HAC in MOBA games(see Section 4.3).
111
+
112
+ ![](images/c89c4ffb7d8cc5140248e1fc8c06e64f011a5a4fb8897abe7e8a4618c1bf202a.jpg)
113
+ Figure 2: The temporal process of the MCC framework. For each communication step $t$ and $T$ ), MCC first (I) converts messages from humans and agents into meta-commands, then (II) selects the optimal meta-command for each agent to execute, and (III) finally predicts a sequence of actions for each agent to perform. The selected meta-command is retained and executed for $_ n$ time steps. This process is repeated until the end of a game.
114
+
115
+ # 4.1 Overview
116
+
117
+ 0 The flow of the MCC framework can be divided into three stages: the meta-command conversion stage,
118
+ the meta-command communication stage, and the human-AI collaboration stage, as plotted in Figure 2.
119
+ 2 At the Meta-Command Conversion Stage, the MCC framework converts the macro-strategies sent
120
+ 33 by humans and the messages outputted by the command encoding network of agents into unified
121
+ 34 meta-commands and then broadcasts them to all agents and humans. At the Meta-Command
122
+ 35 Communication Stage, the MCC framework uses the meta-command selector to estimate the values
123
+ 36 of all received meta-commands and select the optimal one for each agent to execute. Note that
124
+ 37 humans also select the optimal meta-command based on their value systems. At the Human-AI
125
+ 38 Collaboration Stage, the MCC framework adopts the meta-command conditioned action network to
126
+ 39 predict a sequence of actions for each agent to perform based on its selected meta-command. For
127
+ 40 each game, humans and agents have to collaborate multiple times, that is, they need to perform the
128
+ above three stages multiple times to win the game.
129
+
130
+ # 142 4.2 Meta-Command
131
+
132
+ 143 In MOBA games, we propose that a macro-strategy consists of three components: where to go, what
133
+ 144 to do, and how long. For example, a macro-strategy can be Come And Kill The Dragon, which
134
+ 145 consists of Come To The Dragon (where to go), Attack The Dragon (what to do), and Until The
135
+ 146 Dragon Is Killed (how long). Thus, we propose a general representation of macro-strategies, i.e.,
136
+ 147 the Meta-Command, as an interpretable communication protocol to bridge the communication gap
137
+ 148 between agents and humans.
138
+ 149 Meta-Command Definition. We formulate the Meta-Command as a tuple $< L , E , T ^ { m c } >$ , as shown
139
+ 150 in Figure 1(b), where $L$ is the Location to go, $E$ is the Event to do after reaching $L$ , and $T ^ { m c }$ is the
140
+ 151 Time Limit for executing the meta-command. Among them, $L$ is the key to the meta-command, which
141
+ 152 contains the intention of the macro-strategy. $E$ can be thought of as human micro-operation, which is
142
+ 153 implemented through a pre-trained micro-action network $\pi _ { \theta }$ in the MCC framework. $T ^ { m c }$ can be set
143
+ 154 to how long it normally takes a human to complete a macro-strategy in MOBA games, usually 20
144
+ 155 seconds corresponds to $80 \%$ completion rate for meta-commands, see Appendix A.12.1.
145
+ 156 Meta-Command Conversion. To realize interpretable human-AI communication, we convert the
146
+ 157 explicit messages from humans and the implicit messages from agents into unified meta-commands.
147
+ 158 To achieve the former, a hand-crafted command converter function $f ^ { c c }$ is used to generate $L$ of meta
148
+ 159 commands by extracting the location from explicit messages, such as text and signals, sent by humans.
149
+ 160 To achieve the latter, we use a Command Encoding Network (CEN) $\pi _ { \phi } ( m | o )$ to generate $L$ of meta
150
+ 161 commands. The CEN is trained via supervised learning (SL) with the goal of learning the distribution
151
+ 162 of meta-commands sent from humans, as shown in Figure 3(a)(I). The training dataset $\{ < o , m > \}$
152
+ 163 is obtained by extracting the observation $o$ and its corresponding meta-command $m$ from expert data.
153
+ 164 After converting all messages into unified meta-commands, the MCC framework broadcasts them to
154
+ 165 all agents and humans. Then, agents and humans receive an identical meta-command candidate set.
155
+ 166 Meta-Command Execution. After receiving a meta-command candidate set, agents can se
156
+ 167 lect one meta-command from it to execute. We adopt a Meta-Command Conditioned Ac
157
+ 168 tion Network (MCCAN) $\pi _ { \boldsymbol { \theta } } ( a | o , m )$ for agents to perform actions based on the selected meta
158
+ 169 command, as shown in Figure 3(a)(II). The MCCAN is trained via goal-conditioned RL with
159
+ 170 the goal of achieving a near-human completion rate for the meta-commands generated by the
160
+ 171 pre-trained CEN while ensuring that the win rate is not reduced. We adopt an intrinsic reward
161
+ 172 $\begin{array} { r } { \dot { r } _ { t } ^ { i n t } ( s _ { t } , m _ { t } , s _ { t + 1 } ) = \left| f ^ { c e } ( s _ { t } ) - \check { m } _ { t } \right| - \left| f ^ { c e } ( s _ { t + 1 } ) - m _ { t } \right| } \end{array}$ to guide the process of executing the meta
162
+ 173 command $m _ { t }$ , where $f ^ { c e }$ is a hand-crafted command extraction function. We train the MCCAN
163
+ 174 with the objective of maximizing the expectation over extrinsic and intrinsic discounted total re
164
+ 175 wards $\begin{array} { r } { G _ { t } = \mathbb { E } _ { s \sim d _ { \pi _ { \theta } } , a \sim \pi _ { \theta } } \left[ \sum _ { i = 0 } ^ { \infty } \gamma ^ { i } r _ { t + i } + \alpha \sum _ { j = 0 } ^ { T ^ { m c } } \gamma ^ { j } r _ { t + j } ^ { i n t } \right] , } \end{array}$ , where $\alpha$ is a trade-off parameter and
165
+ 176 $\begin{array} { r } { d _ { \pi } ( s ) = \operatorname* { l i m } _ { t \infty } P ( s _ { t } = \bar { s } \mid s _ { 0 } , \pi ) } \end{array}$ is the probability when following $\pi$ for $t$ steps from $s _ { 0 }$ .
166
+ 177 After training the CEN and MCCAN, we can achieve HAC by simply setting an agent to randomly
167
+ 178 select a meta-command derived from humans to execute. However, such collaboration is non
168
+ 179 intelligent and can even be a disaster for game victory because agents have no mechanism to
169
+ 180 model the values of meta-commands and cannot choose the optimal meta-command to execute.
170
+ 181 While humans usually choose the optimal one based on their value systems for achieving effective
171
+ 182 collaboration to win the game. Thus, we further propose a meta-command value estimation model to
172
+ 183 select a valuable meta-command for each agent, as described in the following subsection.
173
+
174
+ ![](images/11ef9ab63482191eb45580c4a980f761f010eb2b27918be64211bd35b8a522df.jpg)
175
+ Figure 3: The training process and model structure of MCC. (a) The training process is divided into three phases: we first (I) train the CEN via supervised learning (SL), then (II) train the MCCAN via goal-conditioned RL, and finally (III) train the CS via RL. Among them, the dashed box represents the frozen model. (b) The detailed CS model structure, including CNN feature extraction, gating mechanism, target attention module, etc.
176
+
177
+ # 184 4.3 Meta-Command Selector
178
+
179
+ 185 In real-world MOBA games, the same macro-strategy often has different values for different humans
180
+ 186 in different situations. For example, a macro-strategy can be Come And Kill The Dragon, as shown in
181
+ 187 Figure 1(b). It is more valuable for humans A and B to collaborate. While another macro-strategy can
182
+ 188 be Clean Up Top-Lane Minions, which is more valuable for human C rather than humans A and B.
183
+ 189 Therefore, it is important to select the most valuable meta-command from the received meta-command
184
+ 190 candidate set $C$ to achieve effective human-AI collaboration. We propose a meta-command value
185
+ 191 estimation model, i.e., the Meta-Command Selector (CS) $\pi _ { \omega } ( o , C )$ , to estimate the values of all
186
+ 192 current meta-commands and select the most valuable one for each agent to execute.
187
+
188
+ 193 CS Optimization Objective. Typically, the execution of a meta-command involves reaching location
189
+ 194 $L$ and doing event $E$ , of which the latter is more important to the value of the meta-command.
190
+ 195 For example, for the meta-command Come And Kill The Dragon, if Kill The Dragon event cannot
191
+ 196 be done within $T ^ { m c }$ time steps, then it is pointless to Come To The Dragon. Thus, the long-term
192
+ reward 197 steps b198 $R ^ { m c }$ for executinracting with a mete en manent: ds withi, where $T ^ { m c }$ $\begin{array} { r } { R _ { t } ^ { m c } = \sum _ { i = 0 } ^ { T ^ { L } } r _ { t + i } + \beta \sum _ { j = T ^ { L } } ^ { T ^ { m c } } r _ { t + j } } \end{array}$ $T ^ { L } < T ^ { m c }$ is the time for reaching $L$ $\beta > 1$ is a trade-off parameter. Note that the reward function $r$
193
+
194
+ 200 includes both individual rewards and team rewards. The optimization objective of CS is to select
195
+ 201 the optimal meta-command $m _ { t } ^ { * } = \pi _ { \omega } ( o _ { t } , C _ { t } )$ for each agent to maximize the expected discounted
196
+ 202 meta-command execution return Gmct = Es∼dπ ,m∼πω,a∼πθ $\begin{array} { r } { G _ { t } ^ { m c } = \mathbb { E } _ { s \sim d _ { \pi _ { \theta } } , m \sim \pi _ { \omega } , a \sim \pi _ { \theta } } \left[ \sum _ { i = 0 } ^ { \infty } \gamma _ { m c } ^ { i } R _ { t + i \cdot T ^ { m c } } ^ { m c } \right] } \end{array}$ , where $o _ { t } \in \mathbf { O }$ ,
197
+ 203 $C _ { t }$ is the meta-command candidate set in state $s _ { t }$ , and $\gamma _ { m c } \in [ 0 , 1 )$ is the discount factor.
198
+ 204 CS Training Process. We construct a self-play training environment for CS where agents can send
199
+ 205 messages to each other. Specifically, three tricks in Figure 3(a)(III) are adopted to increase the
200
+ 206 sample efficiency while ensuring efficient exploration. First, each sent meta-command $m$ is sampled
201
+ 207 with the argmax rule from the results predicted by the pre-trained CEN. Second, each agent sends
202
+ 208 its meta-command with a probability $p$ every $T ^ { m c }$ time steps. Finally, each agent selects the final
203
+ 209 meta-command $c$ sampled with the softmax rule from its CS output results and hands it over to the
204
+ 210 pre-trained MCCAN for execution. We use the multi-head value mechanism [38] to model the value
205
+ 211 of the meta-command execution, and the corresponding value loss can be formulated as:
206
+
207
+ $$
208
+ L ^ { V } ( \omega ) = \mathbb { E } _ { S , C } \left[ \sum _ { h e a d _ { k } } \| G _ { k } ^ { m c } - V _ { \omega } ^ { k } ( S , C ) \| _ { 2 } \right] ,
209
+ $$
210
+
211
+ 212 where 213 $V _ { \omega } ^ { k } ( S , C )$ is the value of the $k$ -th head. For DQN-based methods [21, 33, 35], the $Q$ loss is:
212
+
213
+ $$
214
+ L ^ { Q } ( \omega ) = \mathbb { E } _ { S , C , M } \left[ \Vert G _ { t o t a l } - Q _ { \omega } ^ { k } ( S , C , M ) \Vert _ { 2 } \right] , G _ { t o t a l } = \sum _ { h e a d _ { k } } w _ { k } G _ { k } ^ { m c } ,
215
+ $$
216
+
217
+ where $w _ { k }$ is the weight of the $k$ -th head and $G _ { k } ^ { m c }$ is the Temporal Difference (TD) estimated value error $R _ { k } ^ { m c } + \gamma _ { m c } V _ { \omega } ^ { k } ( S ^ { \prime } , C ^ { \prime } ) - V _ { \omega } ^ { k } ( S , C )$ .
218
+
219
+ CS Model Structure. We design a general network structure for CS towards MOBA games, as shown in Figure 3(b). In MOBA games, the meta-commands corresponding to adjacent regions usually have similar values. Thus, we divide the meta-commands in the map into grids, a common location description for MOBA games, and use the shared Convolutional Neural Network (CNN) to extract region-related information from the meta-commands to improve the generalization of CS to adjacent meta-commands. Besides, we use the gating mechanism [18] to fuse the map embedding of all received meta-commands and the state embedding of the observation information. Finally, to directly construct the relationship between the observation information and each meta-command, we introduce a target attention module, where the query is the fused embedding $h$ and the key is the map embedding $m ^ { \prime }$ of each meta-command. The fused embedding $h$ is used as the input into the subsequent Q network $Q ( h , m ^ { \prime } )$ and $\mathrm { v }$ network $V ( h )$ network of CS. In this way, the Q network can also be easily converted to the policy network $\pi ( \boldsymbol { m } | \boldsymbol { h } , \boldsymbol { m } ^ { \prime } )$ . Thus, the CS model structure can be easily applied to most popular RL algorithms, such as PPO [24], DQN [21], etc.
220
+
221
+ # 5 Experiments
222
+
223
+ We evaluate the proposed MCC framework in Honor of Kings, one of the most popular MOBA games worldwide, which has been actively used as the testbed for recent game AI research [8, 37–40]. We conduct all experiments in Honor of Kings 5v5 mode with a full hero pool (over 100 heroes), except ablation studies with a 20 hero pool for exploring the influence of different model components more sufficiently and efficiently.
224
+
225
+ # 5.1 Experimental Setup
226
+
227
+ # 5.1.1 Training Setup 1
228
+
229
+ Due to the complexity of MOBA games and limited resources, instead of training jointly, we train the CEN, MCCAN, and CS sequentially. For all model training, the location $L$ of meta-commands in the map is divided into 144 grids. The time limit $T ^ { m c }$ for the meta-command execution is set to 20s.
230
+
231
+ CEN Training Settings. We train the CEN via SL until it converges for 26 hours using 8 NVIDIA P40 GPUs. The batch size of each GPU is set to 512. Adam[16] is adopted as the optimizer with an initial learning rate of 0.0001.
232
+
233
+ MCCAN Training Settings. We train the MCCAN by finetuning a pre-trained micro-action network [38], the state-of-the-art (SOTA) model in Honor of Kings, which is conditioned on the meta-command sampled from the pre-trained CEN. The MCCAN is trained until it converges for 48
234
+
235
+ ![](images/03a0d2fabc9647984c0c8f2039d13c7fd0c145ace28ab51b5984238876d58c56.jpg)
236
+ Figure 4: Communication environments in the experiment. The orange arrows indicate sending metacommands, and the blue arrows indicate receiving meta-commands. The dashed line denotes sending metacommands with probability $p$ .
237
+
238
+ ![](images/687ec50018143f5fcc38b1e11bc5431b5a3e117f130b9cc3e456aa4ac3fccbbe.jpg)
239
+ Figure 5: AI performance in the testing environments. (a) and (b) show the win rate maps of different agents who play against each other. (c) shows the final Elo scores of these agents.
240
+
241
+ 247 hours using a physical computer cluster with 63,000 CPUs and 560 NVIDIA V100 GPUs. The batch
242
+ 248 size of each GPU is set to 256.
243
+
244
+ CS Training Settings. We train the CS via self-play until it converges for 24 hours using a physical computer cluster with 70,000 CPUs and 680 NVIDIA V100 GPUs. The batch size of each GPU is set to 256. The parameter $\beta$ is set to 2. Each agent sends a meta-command with a probability $p$ of 0.8 and an interval $T ^ { m c }$ of 20s, as shown in Figure 4(a).
245
+
246
+ # 5.1.2 Evaluating Setup
247
+
248
+ Our primary concern is whether the agents trained with the MCC framework, briefly called the MCC agents, can collaborate with humans well. However, evaluating agents with humans is expensive, which is not conducive to model selection and iteration. Therefore, we built two agent-only testing environments: Test I and Test II, for the model selection and iteration process, as shown in Figure 4(b). We also evaluate the MCC agents in practical human-AI game tests to examine the performance of collaborating with humans, as shown in Figure 4(c).
249
+
250
+ Compared Agents. We compare the MCC agent with three different types of agents: the MC-Base agent (agent only executes its own meta-command without communication), the MC-Rand agent (agent randomly selects a meta-command to execute), and the MC-Rule agent (agent selects the nearest meta-command to execute). We adopt the MC-Base agent-only team as the opponent for all tests. Note that the MC-Base agent-only team has the ability of the SOTA and is more stable than the human-only team. Results are reported over five random seeds.
251
+
252
+ Agent-Only Environmental Settings. Test I is the most complex environment where all agent teammates can send and receive meta-commands simultaneously with an interval of 20s. Test I is used to evaluate the agents’ performance under extremely complex situations as well as in ablation studies. Test $\mathrm { I I }$ is a simple environment to simulate practical game scenarios, where at most one human sends his macro-strategy at a time step. Thus, in Test II, only one agent is randomly selected to send its meta-command with an interval of 20s, and the other agents only receive meta-commands.
253
+
254
+ Human-AI Game Testing Settings. We had different types of agents team up with different levels and numbers of humans, including 15 strong humans $( \tan 1 \% )$ and 15 average humans $( \mathrm { t o p } 3 0 \% )$ ), in m $A I + n$ Human mode, where $m + n = 5$ . For fair comparisons, each tester was not told the type of agent teammates. To eliminate the effects of collaboration between agents, we prohibit agents from receiving meta-commands from their agent teammates, and the agent can only receive meta-commands from humans. In each game test, humans can send the converted meta-commands whenever they think their macro-strategies are important. To make the agent behave like humans (at most one human sends his macro-strategy at a time step), we restrict agents from sending their meta-commands. We randomly choose a human teammate and use his observation and all agents’ meta-commands as the CS input and select the final output of CS to send with an interval of 20s.
255
+
256
+ # 5.2 Results in Agent-Only Environment
257
+
258
+ # 5.2.1 AI Performance
259
+
260
+ The Kullback-Leibler (KL) divergence of the meta-command distribution between the CEN and humans decreased from 4.96 to 0.44 as training converges. The MCCAN is trained with the parameter $\alpha$ equal to 16. The win rate of the trained agent against the SOTA agent [8, 38] is close to $50 \%$ . The average completion rates of the trained agent and humans for meta-commands are $82 \%$ and $80 \%$ , respectively. Notably, we can train an agent with a higher completion rate by increasing $\alpha$ , but this will significantly reduce the win rate because the meta-command executed is not necessarily optimal and may result in the death of agents. We put the detailed experimental results of the CEN and MCCAN in the Appendix A.10.1 and A.10.2 due to space limitations.
261
+
262
+ Figure 5(a) and (b) show the win rates of four types of agents who play against each other for 600 matches in Test I and Test II, respectively. We see that the MCC agent achieves the highest win rate against all the other agents in both testing environments, indicating that the CS can select a valuable meta-command for each agent to collaborate, and such reasonable collaboration is conducive to winning the game. The MC-Rand and MC-Rule agents are worse than the MC-Base agent, confirming that agents executing low-value meta-commands can hurt performance. Notably, we find that the win rates of the MCC agent in Test I and Test II are close, suggesting that the MCC agent can generalize to different numbers of meta-commands. Figure 5(c) demonstrates the final Elo scores [3] of these agents. It clearly shows the effectiveness of CS in agent-only collaboration scenarios.
263
+
264
+ # 5.2.2 Ablation Studies
265
+
266
+ We further investigate the influence of different components, including CNN feature extraction with the gating mechanism (w/o CNN-GM), target attention module (w/o TA), and PPO optimization algorithm (MCC-PPO), on the performance of CS. We conduct ablation studies in Test I with a 20 hero pool. In practical games, meta-commands
267
+
268
+ ![](images/a93f018c6e2b88df6ca939c1302af4814d6cd1836f9bf57043fac763bee3f8d5.jpg)
269
+ Figure 6: Results of ablation studies. (a) The training curves of different CS ablation versions. (b) The converged WR-RR results of different CS ablation versions. The shadow indicates the standard deviation.
270
+
271
+ with adjacent regions often have similar intentions and values. Thus the response rate of the agent to adjacent meta-commands should be as close as possible. Besides, the higher the agent’s response rate to meta-commands, the more collaborative behaviors of the agent, thus we expect the response rate of CS as high as possible. Generally, we expect the Response Rate (RR) of CS as high as possible while ensuring that the Win Rate (WR) is not reduced.
272
+
273
+ 321 Figure 6(a) demonstrates the WR of different CS ablation versions during the training process, and
274
+ 322 Figure 6(b) shows the converged WR-RR results. We see that after ablating the TA module, the WR
275
+ 323 and RR of CS are greatly reduced, indicating that the TA module can improve the accuracy of CS
276
+ 324 to meta-commands. Besides, after ablating the CNN-GM module, the RR of CS is most affected,
277
+ 325 which is reduced by $20 \%$ . It indicates that without the CNN-GM module, the value estimation of CS
278
+ 326 to adjacent meta-commands is not accurate enough, resulting in missing some actual high valuable
279
+ 327 meta-commands. We notice that the MCC and MCC-PPO in both metrics are close, confirming the
280
+ 328 versatility of the CS model structure.
281
+
282
+ Table 1: The WR of different human-AI teams against MC-Base agents in $4 A I + I$ Human mode.
283
+
284
+ <table><tr><td rowspan="2">Teammate</td><td colspan="3">Type of Agent</td></tr><tr><td>MC-Base</td><td>MC-Rand</td><td>MCC</td></tr><tr><td>Average Human</td><td>23%</td><td>5%</td><td>37%</td></tr><tr><td>Strong Human</td><td>42%</td><td>28%</td><td>54%</td></tr></table>
285
+
286
+ Table 2: The RR of humans and agents to teammates.
287
+
288
+ <table><tr><td>Sender\Receiver</td><td>Average Human</td><td>Strong Human</td><td>MCC</td></tr><tr><td>MC-Rand</td><td>41.07%</td><td>35.69%</td><td>34.03%</td></tr><tr><td>Average Human</td><td>72.34%</td><td>-</td><td>61.17%</td></tr><tr><td>Strong Human</td><td>-</td><td>74.91%</td><td>73.05%</td></tr><tr><td>MCC</td><td>73.43%</td><td>78.50%</td><td>-</td></tr></table>
289
+
290
+ ![](images/11037341ffae27d4daf7386e092e7780793b1cee69cdcaba5a981953a5997e08.jpg)
291
+ Average Rank of Strong Human
292
+
293
+ ![](images/ba5c6725660d0430fbb713315f508d10f2caf23f2a77b611c01cf7ae7b4b0d9a.jpg)
294
+ Figure 7: Case study on the value estimation of CS.
295
+
296
+ # 29 5.3 Results in Human-AI Game Test
297
+
298
+ Due to space limitations, we only show the objective results in $4 A I + I$ Human mode. Other modes results and the subjective preference results of testers can be found in the Appendix A.10.3 and A.11. Table 1 shows the WR of different human-AI teams who play against the MC-Base agent-only team. We see that the MCC agent significantly outperforms other agents, regardless of whether they pair with a strong or average human. To explain why humans have a higher WR when paired with the MCC agents, we count the RR of agents to the meta-commands sent from human teammates (H2A scenarios) and the RR of humans to the meta-commands sent from agent teammates (A2H scenarios), respectively, as shown in Table 2. In H2A scenarios, the RRs of the MCC agents to average humans and strong humans are $6 1 . 1 7 \%$ and $7 3 . 0 5 \%$ , respectively, indicating that the MCC agents are more willing to respond to valuable meta-commands sent from strong humans. We also notice that the RR of the MCC agents to strong humans $( 7 3 . 0 5 \% )$ is very close to the RR of strong humans themselves $( 7 4 . 9 1 \% )$ , suggesting that the CS is close to the value system of strong humans. In A2H scenarios, the RRs of average humans and strong humans to the MCC agents are $7 3 . 4 3 \%$ and $78 . 5 \%$ , respectively, which is significantly higher than that of MC-Rand agents $( 4 1 . 0 7 \%$ and $3 5 . 6 9 \%$ ), indicating that the meta-commands sent from the MCC agents are more valuable and reasonable to humans. Note that the RR of the MCC agents to the MC-Rand agents is $3 4 . 0 3 \%$ , which is close to that of strong humans $( 3 5 . 6 9 \% )$ , once again confirming that the CS is close to the value system of strong humans.
299
+
300
+ We also visualize the comparison of CS and strong human value systems on a game scene with three meta-commands existing, as shown in Figure 7. We see that the CS selects the meta-command B for the two heroes in the red dashed box to collaborate, selects the meta-command C for the two heroes in the purple dashed box to collaborate, and selects the meta-command A for the remaining hero to execute alone. The CS selection results are consistent with the ranking results of strong humans, confirming the effectiveness of CS and the interpretability of the collaboration behavior between MCC agents and humans.
301
+
302
+ # 6 Conclusion
303
+
304
+ In this paper, we proposed an efficient and interpretable Meta-Command Communication-based framework, dubbed MCC, to achieve effective human-AI collaboration in MOBA games. To bridge the communication gap between humans and agents, we designed an interpretable communication protocol, i.e., the Meta-Command, to convert the explicit messages from humans and the implicit messages from agents into unified meta-commands. To achieve effective collaboration, we constructed a meta-command value estimation model, i.e., the Meta-Command Selector, to select a valuable meta-command for each agent to execute. Finally, we introduced the training process of the MCC framework and conducted practical human-AI game tests in the typical MOBA game Honor of Kings. The experimental results show that the MCC agents can collaborate reasonably with human teammates and even generalize to collaborate with different levels and numbers of human teammates. We expect this work can be a foundation for future HAC research in complex environments.
305
+
306
+ 366 References
307
+ 367 [1] Lupu Andrei, Cui Brandon, Hu Hengyuan, and Foerster Jakob N. Trajectory diversity for
308
+ 368 zero-shot coordination. 139:7204–7213, 2021.
309
+ 369 [2] Micah Carroll, Rohin Shah, Mark K Ho, Tom Griffiths, Sanjit Seshia, Pieter Abbeel, and Anca
310
+ 370 Dragan. On the utility of learning about humans for human-ai coordination. Advances in Neural
311
+ 371 Information Processing Systems, 32, 2019.
312
+ 372 [3] Rémi Coulom. Whole-history rating: A bayesian rating system for players of time-varying
313
+ 373 strength. In Proceedings of the International Conference on Computers and Games, pages
314
+ 374 113–124, 2008.
315
+ 375 [4] Allan Dafoe, Edward Hughes, Yoram Bachrach, Tantum Collins, Kevin R McKee, Joel Z
316
+ 376 Leibo, Kate Larson, and Thore Graepel. Open problems in cooperative ai. arXiv preprint
317
+ 377 arXiv:2012.08630, 2020.
318
+ 378 [5] Abhishek Das, Théophile Gervet, Joshua Romoff, Dhruv Batra, Devi Parikh, Mike Rabbat, and
319
+ 379 Joelle Pineau. Tarmac: Targeted multi-agent communication. In Proceedings of the International
320
+ 380 Conference on Machine Learning, pages 1538–1546, 2019.
321
+ 381 [6] Yuqing Du, Stas Tiomkin, Emre Kiciman, Daniel Polani, Pieter Abbeel, and Anca Dragan. Ave:
322
+ 382 Assistance via empowerment. Advances in Neural Information Processing Systems, 33:4560–4571,
323
+ 383 2020.
324
+ 384 [7] Jakob Foerster, Ioannis Alexandros Assael, Nando De Freitas, and Shimon Whiteson. Learning
325
+ 385 to communicate with deep multi-agent reinforcement learning. Advances in Neural Information
326
+ 386 Processing Systems, 29, 2016.
327
+ 387 [8] Yiming Gao, Bei Shi, Xueying Du, Liang Wang, Guangwei Chen, Zhenjie Lian, Fuhao Qiu,
328
+ 388 Guoan Han, Weixuan Wang, Deheng Ye, et al. Learning diverse policies in moba games via
329
+ 389 macro-goals. Advances in Neural Information Processing Systems, 34, 2021.
330
+ 390 [9] Mohammad Ghavamzadeh and Sridhar Mahadevan. Learning to communicate and act using
331
+ 391 hierarchical reinforcement learning. Computer Science Department Faculty Publication Series,
332
+ 392 page 172, 2004.
333
+ 393 [10] Hengyuan Hu, Adam Lerer, Alex Peysakhovich, and Jakob Foerster. “other-play” for zero
334
+ 394 shot coordination. In Proceedings of the International Conference on Machine Learning, pages
335
+ 395 4399–4410, 2020.
336
+ 396 [11] Max Jaderberg, Wojciech M Czarnecki, Iain Dunning, Luke Marris, Guy Lever, Antonio Garcia
337
+ 397 Castaneda, Charles Beattie, Neil C Rabinowitz, Ari S Morcos, Avraham Ruderman, et al. Human
338
+ 398 level performance in 3D multiplayer games with population-based reinforcement learning. Science,
339
+ 399 364(6443):859–865, 2019.
340
+ 400 [12] Jiechuan Jiang and Zongqing Lu. Learning attentional communication for multi-agent coopera
341
+ 401 tion. Advances in Neural Information Processing Systems, 31, 2018.
342
+ 402 [13] Uri Kartoun, Helman Stern, and Yael Edan. A human-robot collaborative reinforcement learning
343
+ 403 algorithm. Journal of Intelligent & Robotic Systems, 60(2):217–239, 2010.
344
+ 404 [14] Michał Kempka, Marek Wydmuch, Grzegorz Runc, Jakub Toczek, and Wojciech Jaskowski. ´
345
+ 405 Vizdoom: A doom-based ai research platform for visual reinforcement learning. In 2016 IEEE
346
+ 406 Conference on Computational Intelligence and Games, pages 1–8, 2016.
347
+ 407 [15] Daewoo Kim, Sangwoo Moon, David Hostallero, Wan Ju Kang, Taeyoung Lee, Kyunghwan
348
+ 408 Son, and Yung Yi. Learning to schedule communication in multi-agent reinforcement learning.
349
+ 409 arXiv preprint arXiv:1902.01554, 2019.
350
+ 410 [16] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint
351
+ 411 arXiv:1412.6980, 2014.
352
+
353
+ [17] Quan Liu, Zhihao Liu, Wenjun Xu, Quan Tang, Zude Zhou, and Duc Truong Pham. Humanrobot collaboration in disassembly for sustainable manufacturing. International Journal of Production Research, 57(12):4027–4044, 2019.
354
+ [18] Hanxiao Liu, Zihang Dai, David So, and Quoc V Le. Pay attention to mlps. Advances in Neural Information Processing Systems, 34:9204–9215, 2021.
355
+ [19] Kevin R McKee, Xuechunzi Bai, and Susan T Fiske. Warmth and competence in human-agent cooperation. arXiv preprint arXiv:2201.13448, 2022.
356
+ [20] Kevin R McKee, Joel Z Leibo, Charlie Beattie, and Richard Everett. Quantifying the effects of environment and population diversity in multi-agent reinforcement learning. Autonomous Agents and Multi-Agent Systems, 36(1):1–16, 2022.
357
+ [21] Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A. Rusu, Joel Veness, Marc G. Bellemare, Alex Graves, Martin A. Riedmiller, Andreas Fidjeland, Georg Ostrovski, Stig Petersen, Charles Beattie, Amir Sadik, Ioannis Antonoglou, Helen King, Dharshan Kumaran, Daan Wierstra, Shane Legg, and Demis Hassabis. Human-level control through deep reinforcement learning. Nature, 518(7540):529–533, 2015.
358
+ [22] OpenAI, Christopher Berner, Greg Brockman, Brooke Chan, Vicki Cheung, Przemysław D˛ebiak, Christy Dennison, David Farhi, Quirin Fischer, Shariq Hashme, Chris Hesse, Rafal Józefowicz, Scott Gray, Catherine Olsson, Jakub Pachocki, Michael Petrov, Henrique Pondé de Oliveira Pinto, Jonathan Raiman, Tim Salimans, Jeremy Schlatter, Jonas Schneider, Szymon Sidor, Ilya Sutskever, Jie Tang, Filip Wolski, and Susan Zhang. Dota 2 with large scale deep reinforcement learning. arXiv preprint arXiv:1912.06680, 2019.
359
+ [23] Peng Peng, Ying Wen, Yaodong Yang, Quan Yuan, Zhenkun Tang, Haitao Long, and Jun Wang. Multiagent bidirectionally-coordinated nets: Emergence of human-level coordination in learning to play starcraft combat games. arXiv preprint arXiv:1703.10069, 2017.
360
+ [24] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
361
+ [25] Ali Shafti, Jonas Tjomsland, William Dudley, and A Aldo Faisal. Real-world human-robot collaborative reinforcement learning. In 2020 IEEE/RSJ International Conference on Intelligent Robots and Systems, pages 11161–11166, 2020.
362
+ [26] Victor do Nascimento Silva and Luiz Chaimowicz. Moba: A new arena for game ai. arXiv preprint arXiv:1705.10443, 2017.
363
+ [27] 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.
364
+ [28] David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas Baker, Matthew Lai, Adrian Bolton, et al. Mastering the game of Go without human knowledge. Nature, 550(7676):354–359, 2017.
365
+ [29] Amanpreet Singh, Tushar Jain, and Sainbayar Sukhbaatar. Learning when to communicate at scale in multi-agent cooperative and competitive tasks. arXiv preprint arXiv:1812.09755, 2018.
366
+ [30] Ho Chit Siu, Jaime Peña, Edenna Chen, Yutai Zhou, Victor Lopez, Kyle Palko, Kimberlee Chang, and Ross Allen. Evaluation of human-ai teams for learned and rule-based agents in hanabi. Advances in Neural Information Processing Systems, 34:16183–16195, 2021.
367
+ [31] DJ Strouse, Kevin McKee, Matt Botvinick, Edward Hughes, and Richard Everett. Collaborating with humans without human data. Advances in Neural Information Processing Systems, 34, 2021.
368
+ [32] Sainbayar Sukhbaatar, Rob Fergus, et al. Learning multi-agent communication with backpropagation. Advances in Neural Information Processing Systems, 29, 2016.
369
+ [33] Hado Van Hasselt, Arthur Guez, and David Silver. Deep reinforcement learning with double q-learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 30, 2016.
370
+ [34] Oriol Vinyals, Igor Babuschkin, Wojciech M Czarnecki, Michaël 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.
371
+ [35] Ziyu Wang, Tom Schaul, Matteo Hessel, Hado Hasselt, Marc Lanctot, and Nando Freitas. Dueling network architectures for deep reinforcement learning. In Proceedings of the International Conference on Machine Learning, pages 1995–2003, 2016.
372
+ [36] Rundong Wang, Xu He, Runsheng Yu, Wei Qiu, Bo An, and Zinovi Rabinovich. Learning efficient multi-agent communication: An information bottleneck approach. In Proceedings of the International Conference on Machine Learning, pages 9908–9918, 2020.
373
+ [37] Bin Wu. Hierarchical macro strategy model for moba game ai. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 1206–1213, 2019.
374
+ [38] Deheng Ye, Guibin Chen, Wen Zhang, Sheng Chen, Bo Yuan, Bo Liu, Jia Chen, Zhao Liu, Fuhao Qiu, Hongsheng Yu, et al. Towards playing full moba games with deep reinforcement learning. Advances in Neural Information Processing Systems, 33:621–632, 2020.
375
+ [39] Deheng Ye, Guibin Chen, Peilin Zhao, Fuhao Qiu, Bo Yuan, Wen Zhang, Sheng Chen, Mingfei Sun, Xiaoqian Li, Siqin Li, et al. Supervised learning achieves human-level performance in moba games: A case study of honor of kings. IEEE Transactions on Neural Networks and Learning Systems, 2020.
376
+ [40] Deheng Ye, Zhao Liu, Mingfei Sun, Bei Shi, Peilin Zhao, Hao Wu, Hongsheng Yu, Shaojie Yang, Xipeng Wu, Qingwei Guo, et al. Mastering complex control in moba games with deep reinforcement learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 6672–6679, 2020.
377
+ [41] Rui Zhao, Jinming Song, Haifeng Hu, Yang Gao, Yi Wu, Zhongqian Sun, and Wei Yang. Maximum entropy population based training for zero-shot human-ai coordination. arXiv preprint arXiv:2112.11701, 2021.
378
+
379
+ # Checklist
380
+
381
+ 1. For all authors...
382
+
383
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See the abstract and the contributions in Section 1.
384
+ (b) Did you describe the limitations of your work? [Yes] For margin reasons, we will discuss limitations here. We have currently only verified the effectiveness of the MCC framework in MOBA games, and we will explore in more types of complex games, such as First-Person Shooting (FPS) and Massively Multiplayer Online (MMO) in the future.
385
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] The purpose of our method is only for academic research based on game environments, e.g., investigating the MOBA game-playing problems. Like AlphaGo or AlphaStar, the potential negative societal impacts of our work will be limited to the development of gaming AI applications. However, our research will contribute to the research community, the game industry, and the e-sports community.
386
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
387
+
388
+ 2. If you are including theoretical results...
389
+
390
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
391
+
392
+ 3. If you ran experiments...
393
+
394
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [No] The code and the data are proprietary.
395
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See the full experimental setup in Section 5.1.1 and Appendix.
396
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] All results are reported over five random seeds (see Section 5.1.2). For the convenience of presentation, the median is shown in AI Performance, while detailed error bars are presented in Ablation Studies. Due to the high cost of Human-AI Game Test, we only used the median model for testing.
397
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See the resources in Section 5.1.1.
398
+
399
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
400
+
401
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
402
+ (b) Did you mention the license of the assets? [Yes]
403
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
404
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] Honor of Kings is a released and recognized "testbed" for MOBA-game-playing problems [40, 39, 38, 8, 37]. We contact the relevant author and obtain authorization from the game provider.
405
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] See Appendix. All data in this paper is gamerelated and has nothing to do with identity information.
406
+
407
+ 5. If you used crowdsourcing or conducted research with human subjects...
408
+
409
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [Yes] See Appendix. In the Human-AI Game Test, all participants have more than three years of experience in Honor of Kings and are familiar with all the information in the game. Before the test, we also inform the participants of the detailed test instructions, and the participants voluntarily choose whether to participate in the test. We have detailed ethics descriptions in Appendix A.9. As stated in Section A.9.2, participants were given instructions before testing. As mentioned in point 5 (Line 87-88), participants’ game statistics will be only used for academic research, and participants can choose whether to participate or not.
410
+
411
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [Yes] We had performed a process similar to IRB before the test was conducted in this paper. The institution and all participants have approved our research. First, we analyze the risks of these experiments to the participants. The risks mainly include the leakage of identity information and the time cost. Then, a series of measures are implemented to prevent these risks in Appendix A.9.2. We make a risk statement for participants and sign an identity information confidentiality agreement. We only use information related to the game state in our research without identity information. In addition, special equipment and accounts are provided to the participants to prevent leakage of equipment and account information during the test. The identity information of all participants is not disclosed to the public.
412
+
413
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [Yes] In the Human-AI Game Test, participants can get 5 dollars for each match, and each match is about 10 to 20 minutes.